當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockPos類代碼示例

本文整理匯總了Java中net.minecraft.util.math.BlockPos的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos類的具體用法?Java BlockPos怎麽用?Java BlockPos使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BlockPos類屬於net.minecraft.util.math包,在下文中一共展示了BlockPos類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findItemOnGroundOrInChest

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
@Override
public boolean findItemOnGroundOrInChest(Predicate<ItemStack> matcher, int maxAmount, String message, String... parameters) {
    List<BlockPos> meeCreepChests = findMeeCreepChests(worker.getSearchBox());
    if (meeCreepChests.isEmpty()) {
        if (!findItemOnGround(worker.getSearchBox(), matcher, this::pickup)) {
            if (!findInventoryContainingMost(worker.getSearchBox(), matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
                showMessage(message, parameters);
                return false;
            }
        }
    } else {
        if (!findInventoryContainingMost(meeCreepChests, matcher, p -> fetchFromInventory(p, matcher, maxAmount))) {
            showMessage(message, parameters);
            return false;
        }
    }
    return true;
}
 
開發者ID:McJty,項目名稱:MeeCreeps,代碼行數:19,代碼來源:WorkerHelper.java

示例2: getItem

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
public ItemStack getItem(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntityFlowerPot tileentityflowerpot = this.getTileEntity(worldIn, pos);

    if (tileentityflowerpot != null)
    {
        ItemStack itemstack = tileentityflowerpot.getFlowerItemStack();

        if (itemstack != null)
        {
            return itemstack;
        }
    }

    return new ItemStack(Items.FLOWER_POT);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:17,代碼來源:BlockFlowerPot.java

示例3: neighborChanged

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    EnumFacing.Axis enumfacing$axis = (EnumFacing.Axis)state.getValue(AXIS);

    if (enumfacing$axis == EnumFacing.Axis.X)
    {
        BlockPortal.Size blockportal$size = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.X);

        if (!blockportal$size.isValid() || blockportal$size.portalBlockCount < blockportal$size.width * blockportal$size.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
    else if (enumfacing$axis == EnumFacing.Axis.Z)
    {
        BlockPortal.Size blockportal$size1 = new BlockPortal.Size(worldIn, pos, EnumFacing.Axis.Z);

        if (!blockportal$size1.isValid() || blockportal$size1.portalBlockCount < blockportal$size1.width * blockportal$size1.height)
        {
            worldIn.setBlockState(pos, Blocks.AIR.getDefaultState());
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:29,代碼來源:BlockPortal.java

示例4: getPossibleCreatures

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
public List<Biome.SpawnListEntry> getPossibleCreatures(EnumCreatureType creatureType, BlockPos pos) {
	if (pos==null) return ImmutableList.of();
	
	if (creatureType == EnumCreatureType.MONSTER) {
           //if (this.genNetherBridge.isInsideStructure(pos)) {
           //    return this.genNetherBridge.getSpawnList();
           //}

           if (this.genNetherBridge.isPositionInStructure(this.world, pos) && this.world.getBlockState(pos.down()).getBlock() == Blocks.NETHER_BRICK) {
               return this.genNetherBridge.getSpawnList();
           }
           
           return Biomes.HELL.getSpawnableList(EnumCreatureType.MONSTER); //TODO: Replace with actual-biome lists.
	}
	return ImmutableList.of();

	//Biome biome = this.world.getBiome(pos);
	//return biome.getSpawnableList(creatureType);
}
 
開發者ID:elytra,項目名稱:ThermionicsWorld,代碼行數:20,代碼來源:ChunkProviderNeo.java

示例5: moveMinecartOnRail

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
/**
 * Moved to allow overrides.
 * This code handles minecart movement and speed capping when on a rail.
 */
public void moveMinecartOnRail(BlockPos pos)
{
    double mX = this.motionX;
    double mZ = this.motionZ;

    if (this.isBeingRidden())
    {
        mX *= 0.75D;
        mZ *= 0.75D;
    }

    double max = this.getMaxSpeed();
    mX = MathHelper.clamp_double(mX, -max, max);
    mZ = MathHelper.clamp_double(mZ, -max, max);
    this.moveEntity(mX, 0.0D, mZ);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:EntityMinecart.java

示例6: dispense

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playEvent(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
            {
                tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:26,代碼來源:BlockDispenser.java

示例7: updateTick

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
@Override
   public void updateTick(World world, BlockPos pos, IBlockState state, Random rand) {
	
	if (this.getAge(state) >= getMaxAge())
		return;
	
	int friends = 0;
	
	Iterable<BlockPos> getBox = BlockPos.getAllInBox(pos.add(-4, 0, -4), pos.add(4, 0, 4));
	Iterator it = getBox.iterator();
	while (it.hasNext()) {
		BlockPos looppos = (BlockPos)it.next();
		Block loopblock = world.getBlockState(looppos).getBlock();
		if (loopblock != null && !world.isAirBlock(looppos) && loopblock == UCBlocks.cropWafflonia) {
			if (!world.isRemote)
				friends++;
		}
	}
	if ((friends != 0 && friends % 4 != 0) || friends == 0)
		return;
	
	super.updateTick(world, pos, state, rand);
}
 
開發者ID:bafomdad,項目名稱:uniquecrops,代碼行數:24,代碼來源:Wafflonia.java

示例8: generate

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
    for (; position.getY() < 128; position = position.up())
    {
        if (worldIn.isAirBlock(position))
        {
            for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL.facings())
            {
                if (Blocks.VINE.canPlaceBlockOnSide(worldIn, position, enumfacing))
                {
                    IBlockState iblockstate = Blocks.VINE.getDefaultState().withProperty(BlockVine.NORTH, Boolean.valueOf(enumfacing == EnumFacing.NORTH)).withProperty(BlockVine.EAST, Boolean.valueOf(enumfacing == EnumFacing.EAST)).withProperty(BlockVine.SOUTH, Boolean.valueOf(enumfacing == EnumFacing.SOUTH)).withProperty(BlockVine.WEST, Boolean.valueOf(enumfacing == EnumFacing.WEST));
                    worldIn.setBlockState(position, iblockstate, 2);
                    break;
                }
            }
        }
        else
        {
            position = position.add(rand.nextInt(4) - rand.nextInt(4), 0, rand.nextInt(4) - rand.nextInt(4));
        }
    }

    return true;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:WorldGenVines.java

示例9: xDominant

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
private List<BlockPos> xDominant(BlockPos start, BlockPos end) {
    int x = start.getX();
    int y = start.getY();
    int z = start.getZ();
    
    int yd = ay - (ax >> 1);
    int zd = az - (ax >> 1);
    
    List<BlockPos> posLt = new ArrayList<>();
    do {
        posLt.add(new BlockPos(x, y, z));
        if(yd >= 0) {
            y += sy;
            yd -= ax;
        }
        if(zd >= 0) {
            z += sz;
            zd -= ax;                    
        }
        x += sx;
        yd += ay;
        zd += az;
    } while(x != end.getX());
    return posLt;
}
 
開發者ID:JustinSDK,項目名稱:craftsman,代碼行數:26,代碼來源:LinePts.java

示例10: computeEnergyCost

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
private int computeEnergyCost(EntityPlayer player, int blockDim, BlockPos pos)
  {
  	// check fuel type
  	if (UniversalRemoteConfiguration.fuel.fuelType.equals(UniversalRemoteConfiguration.FuelType.Energy.toString()) &&
  			UniversalRemoteConfiguration.fuel.energy.energyCapacity > 0)
{

	if (player.dimension == blockDim) {

		return Math.min(UniversalRemoteConfiguration.fuel.energy.energyCostMax, (int)(Math.sqrt(player.getDistanceSq(pos)) * UniversalRemoteConfiguration.fuel.energy.energyCostPerBlock));

	} else {

		return UniversalRemoteConfiguration.fuel.energy.energyCostMax;

	}

} else {
	return 0;
}
  }
 
開發者ID:orbwoi,項目名稱:UniversalRemote,代碼行數:22,代碼來源:ItemUniversalRemote.java

示例11: generateTree

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
@Override
public boolean generateTree(World worldIn, Random rand, BlockPos pos) {
	filler.leaf = leaf;
	// Check light levels
	if(worldIn.getLight(pos)<7){
		return false;
	}
	// Check height of trunk
	int h = rand.nextInt(heightVar) + height;
	for(int y = 0; y<h; y++){
		if(!checkBlockAt(worldIn,pos.add(0,h,0))){
			return false;
		}
	}
	// Place central trunk
	for(int y = 0; y<h; y++){
		fill(worldIn, pos.add(0, y, 0));
	}
	filler.fillLeaves(worldIn, pos.add(0,h-1,0), rand);
	
	return false;
}
 
開發者ID:trigg,項目名稱:Firma,代碼行數:23,代碼來源:TreeGeneric.java

示例12: onBlockActivated

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityEnchantmentTable)
        {
            playerIn.displayGui((TileEntityEnchantmentTable)tileentity);
        }

        return true;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:19,代碼來源:BlockEnchantmentTable.java

示例13: growLeavesLayerStrict

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
/**
 * grow leaves in a circle with the outsides being within the circle
 */
protected void growLeavesLayerStrict(World worldIn, BlockPos layerCenter, int width)
{
    int i = width * width;

    for (int j = -width; j <= width + 1; ++j)
    {
        for (int k = -width; k <= width + 1; ++k)
        {
            int l = j - 1;
            int i1 = k - 1;

            if (j * j + k * k <= i || l * l + i1 * i1 <= i || j * j + i1 * i1 <= i || l * l + k * k <= i)
            {
                BlockPos blockpos = layerCenter.add(j, 0, k);
                IBlockState state = worldIn.getBlockState(blockpos);

                if (state.getBlock().isAir(state, worldIn, blockpos) || state.getBlock().isLeaves(state, worldIn, blockpos))
                {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:WorldGenHugeTrees.java

示例14: neighborChanged

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
	BlockPos I = pos.add(-1, 0, -1);
	BlockPos F = pos.add(1, 1, 1);
	for (BlockPos blockPos : BlockPos.getAllInBox(I, F)) {
		Block block = worldIn.getBlockState(blockPos).getBlock();
		if (block != this && block != Blocks.WATER && block != Blocks.FLOWING_WATER) {
			checkAndDropBlock(worldIn, pos, state);
			break;
		}
	}
	if (!canBlockStay(worldIn, pos, state) || !canSustainBush(worldIn.getBlockState(pos.down()))) {
		checkAndDropBlock(worldIn, pos, state);
	}
}
 
開發者ID:Um-Mitternacht,項目名稱:Bewitchment,代碼行數:16,代碼來源:CropKelp.java

示例15: onNeighborChange

import net.minecraft.util.math.BlockPos; //導入依賴的package包/類
@Override
public void onNeighborChange(IBlockAccess world, BlockPos pos, BlockPos neighbor)
{
	super.onNeighborChange(world, pos, neighbor);
	if (world instanceof World)
	{
		World w = (World) world;
		if (this.canFall(w, world.getBlockState(pos), pos, neighbor))
		{
			w.setBlockState(pos, ExPBlocks.soil.getDefaultState().withProperty(DIRT_CLASS, world.getBlockState(pos).getValue(DIRT_CLASS)));
		}
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:ExPetrum,代碼行數:14,代碼來源:BlockFarmland.java


注:本文中的net.minecraft.util.math.BlockPos類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。