本文整理匯總了Java中net.minecraft.util.BlockPos.up方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.up方法的具體用法?Java BlockPos.up怎麽用?Java BlockPos.up使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.BlockPos
的用法示例。
在下文中一共展示了BlockPos.up方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldMoveTo
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Return true to set given position as destination
*/
protected boolean shouldMoveTo(World worldIn, BlockPos pos)
{
Block block = worldIn.getBlockState(pos).getBlock();
if (block == Blocks.farmland)
{
pos = pos.up();
IBlockState iblockstate = worldIn.getBlockState(pos);
block = iblockstate.getBlock();
if (block instanceof BlockCrops && ((Integer)iblockstate.getValue(BlockCrops.AGE)).intValue() == 7 && this.field_179503_e && (this.field_179501_f == 0 || this.field_179501_f < 0))
{
this.field_179501_f = 0;
return true;
}
if (block == Blocks.air && this.hasFarmItem && (this.field_179501_f == 1 || this.field_179501_f < 0))
{
this.field_179501_f = 1;
return true;
}
}
return false;
}
示例2: func_175934_c
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private void func_175934_c(World worldIn, BlockPos p_175934_2_)
{
for (int i = 2; i >= -3; --i)
{
BlockPos blockpos = p_175934_2_.up(i);
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block == Blocks.grass || block == Blocks.dirt)
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, field_181635_g);
break;
}
if (block.getMaterial() != Material.air && i < 0)
{
break;
}
}
}
示例3: placeDoor
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public static void placeDoor(World worldIn, BlockPos pos, EnumFacing facing, Block door)
{
BlockPos blockpos = pos.offset(facing.rotateY());
BlockPos blockpos1 = pos.offset(facing.rotateYCCW());
int i = (worldIn.getBlockState(blockpos1).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos1.up()).getBlock().isNormalCube() ? 1 : 0);
int j = (worldIn.getBlockState(blockpos).getBlock().isNormalCube() ? 1 : 0) + (worldIn.getBlockState(blockpos.up()).getBlock().isNormalCube() ? 1 : 0);
boolean flag = worldIn.getBlockState(blockpos1).getBlock() == door || worldIn.getBlockState(blockpos1.up()).getBlock() == door;
boolean flag1 = worldIn.getBlockState(blockpos).getBlock() == door || worldIn.getBlockState(blockpos.up()).getBlock() == door;
boolean flag2 = false;
if (flag && !flag1 || j > i)
{
flag2 = true;
}
BlockPos blockpos2 = pos.up();
IBlockState iblockstate = door.getDefaultState().withProperty(BlockDoor.FACING, facing).withProperty(BlockDoor.HINGE, flag2 ? BlockDoor.EnumHingePosition.RIGHT : BlockDoor.EnumHingePosition.LEFT);
worldIn.setBlockState(pos, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.LOWER), 2);
worldIn.setBlockState(blockpos2, iblockstate.withProperty(BlockDoor.HALF, BlockDoor.EnumDoorHalf.UPPER), 2);
worldIn.notifyNeighborsOfStateChange(pos, door);
worldIn.notifyNeighborsOfStateChange(blockpos2, door);
}
示例4: generate
import net.minecraft.util.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;
}
示例5: findRailAt
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private BlockRailBase.Rail findRailAt(BlockPos pos)
{
IBlockState iblockstate = this.world.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate))
{
return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
}
else
{
BlockPos lvt_2_1_ = pos.up();
iblockstate = this.world.getBlockState(lvt_2_1_);
if (BlockRailBase.isRailBlock(iblockstate))
{
return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
}
else
{
lvt_2_1_ = pos.down();
iblockstate = this.world.getBlockState(lvt_2_1_);
return BlockRailBase.isRailBlock(iblockstate) ? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
}
}
}
示例6: findRailAt
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private BlockRailBase.Rail findRailAt(BlockPos pos) {
IBlockState iblockstate = this.world.getBlockState(pos);
if (BlockRailBase.isRailBlock(iblockstate)) {
return BlockRailBase.this.new Rail(this.world, pos, iblockstate);
} else {
BlockPos lvt_2_1_ = pos.up();
iblockstate = this.world.getBlockState(lvt_2_1_);
if (BlockRailBase.isRailBlock(iblockstate)) {
return BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate);
} else {
lvt_2_1_ = pos.down();
iblockstate = this.world.getBlockState(lvt_2_1_);
return BlockRailBase.isRailBlock(iblockstate)
? BlockRailBase.this.new Rail(this.world, lvt_2_1_, iblockstate) : null;
}
}
}
示例7: clearCurrentPositionBlocksUpwards
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Deletes all continuous blocks from selected position upwards. Stops at hitting air.
*/
protected void clearCurrentPositionBlocksUpwards(World worldIn, int x, int y, int z, StructureBoundingBox structurebb)
{
BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));
if (structurebb.isVecInside(blockpos))
{
while (!worldIn.isAirBlock(blockpos) && blockpos.getY() < 255)
{
worldIn.setBlockState(blockpos, Blocks.air.getDefaultState(), 2);
blockpos = blockpos.up();
}
}
}
示例8: shouldBeExtended
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private boolean shouldBeExtended(World worldIn, BlockPos pos, EnumFacing facing)
{
for (EnumFacing enumfacing : EnumFacing.values())
{
if (enumfacing != facing && worldIn.isSidePowered(pos.offset(enumfacing), enumfacing))
{
return true;
}
}
if (worldIn.isSidePowered(pos, EnumFacing.DOWN))
{
return true;
}
else
{
BlockPos blockpos = pos.up();
for (EnumFacing enumfacing1 : EnumFacing.values())
{
if (enumfacing1 != EnumFacing.DOWN && worldIn.isSidePowered(blockpos.offset(enumfacing1), enumfacing1))
{
return true;
}
}
return false;
}
}
示例9: onItemRightClick
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(worldIn, playerIn, true);
if (movingobjectposition == null)
{
return itemStackIn;
}
else
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
BlockPos blockpos = movingobjectposition.getBlockPos();
if (!worldIn.isBlockModifiable(playerIn, blockpos))
{
return itemStackIn;
}
if (!playerIn.canPlayerEdit(blockpos.offset(movingobjectposition.sideHit), movingobjectposition.sideHit, itemStackIn))
{
return itemStackIn;
}
BlockPos blockpos1 = blockpos.up();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock().getMaterial() == Material.water && ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.isAirBlock(blockpos1))
{
worldIn.setBlockState(blockpos1, Blocks.waterlily.getDefaultState());
if (!playerIn.capabilities.isCreativeMode)
{
--itemStackIn.stackSize;
}
playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
}
}
return itemStackIn;
}
}
示例10: generate
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 0)
{
position = position.down();
}
Block block1 = worldIn.getBlockState(position).getBlock();
if (block1 == Blocks.dirt || block1 == Blocks.grass)
{
position = position.up();
this.setBlockAndNotifyAdequately(worldIn, position, this.woodMetadata);
for (int i = position.getY(); i <= position.getY() + 2; ++i)
{
int j = i - position.getY();
int k = 2 - j;
for (int l = position.getX() - k; l <= position.getX() + k; ++l)
{
int i1 = l - position.getX();
for (int j1 = position.getZ() - k; j1 <= position.getZ() + k; ++j1)
{
int k1 = j1 - position.getZ();
if (Math.abs(i1) != k || Math.abs(k1) != k || rand.nextInt(2) != 0)
{
BlockPos blockpos = new BlockPos(l, i, j1);
if (!worldIn.getBlockState(blockpos).getBlock().isFullBlock())
{
this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
}
}
}
}
}
}
return true;
}
示例11: generateLeafNodeList
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Generates a list of leaf nodes for the tree, to be populated by generateLeaves.
*/
void generateLeafNodeList()
{
this.height = (int)((double)this.heightLimit * this.heightAttenuation);
if (this.height >= this.heightLimit)
{
this.height = this.heightLimit - 1;
}
int i = (int)(1.382D + Math.pow(this.leafDensity * (double)this.heightLimit / 13.0D, 2.0D));
if (i < 1)
{
i = 1;
}
int j = this.basePos.getY() + this.height;
int k = this.heightLimit - this.leafDistanceLimit;
this.field_175948_j = Lists.<WorldGenBigTree.FoliageCoordinates>newArrayList();
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(this.basePos.up(k), j));
for (; k >= 0; --k)
{
float f = this.layerSize(k);
if (f >= 0.0F)
{
for (int l = 0; l < i; ++l)
{
double d0 = this.scaleWidth * (double)f * ((double)this.rand.nextFloat() + 0.328D);
double d1 = (double)(this.rand.nextFloat() * 2.0F) * Math.PI;
double d2 = d0 * Math.sin(d1) + 0.5D;
double d3 = d0 * Math.cos(d1) + 0.5D;
BlockPos blockpos = this.basePos.add(d2, (double)(k - 1), d3);
BlockPos blockpos1 = blockpos.up(this.leafDistanceLimit);
if (this.checkBlockLine(blockpos, blockpos1) == -1)
{
int i1 = this.basePos.getX() - blockpos.getX();
int j1 = this.basePos.getZ() - blockpos.getZ();
double d4 = (double)blockpos.getY() - Math.sqrt((double)(i1 * i1 + j1 * j1)) * this.branchSlope;
int k1 = d4 > (double)j ? j : (int)d4;
BlockPos blockpos2 = new BlockPos(this.basePos.getX(), k1, this.basePos.getZ());
if (this.checkBlockLine(blockpos2, blockpos) == -1)
{
this.field_175948_j.add(new WorldGenBigTree.FoliageCoordinates(blockpos, blockpos2.getY()));
}
}
}
}
}
}
示例12: generate
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean generate(World worldIn, Random rand, BlockPos position)
{
Block block;
while (((block = worldIn.getBlockState(position).getBlock()).getMaterial() == Material.air || block.getMaterial() == Material.leaves) && position.getY() > 1)
{
position = position.down();
}
if (position.getY() < 1)
{
return false;
}
else
{
position = position.up();
for (int i = 0; i < 4; ++i)
{
BlockPos blockpos = position.add(rand.nextInt(4) - rand.nextInt(4), rand.nextInt(3) - rand.nextInt(3), rand.nextInt(4) - rand.nextInt(4));
if (worldIn.isAirBlock(blockpos) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos.down()))
{
worldIn.setBlockState(blockpos, Blocks.chest.getDefaultState(), 2);
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityChest)
{
WeightedRandomChestContent.generateChestContents(rand, this.chestItems, (TileEntityChest)tileentity, this.itemsToGenerateInBonusChest);
}
BlockPos blockpos1 = blockpos.east();
BlockPos blockpos2 = blockpos.west();
BlockPos blockpos3 = blockpos.north();
BlockPos blockpos4 = blockpos.south();
if (worldIn.isAirBlock(blockpos2) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos2.down()))
{
worldIn.setBlockState(blockpos2, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos1) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos1.down()))
{
worldIn.setBlockState(blockpos1, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos3) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos3.down()))
{
worldIn.setBlockState(blockpos3, Blocks.torch.getDefaultState(), 2);
}
if (worldIn.isAirBlock(blockpos4) && World.doesBlockHaveSolidTopSurface(worldIn, blockpos4.down()))
{
worldIn.setBlockState(blockpos4, Blocks.torch.getDefaultState(), 2);
}
return true;
}
}
return false;
}
}
示例13: onNeighborBlockChange
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (state.getValue(HALF) == BlockDoor.EnumDoorHalf.UPPER)
{
BlockPos blockpos = pos.down();
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() != this)
{
worldIn.setBlockToAir(pos);
}
else if (neighborBlock != this)
{
this.onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
}
}
else
{
boolean flag1 = false;
BlockPos blockpos1 = pos.up();
IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);
if (iblockstate1.getBlock() != this)
{
worldIn.setBlockToAir(pos);
flag1 = true;
}
if (!World.doesBlockHaveSolidTopSurface(worldIn, pos.down()))
{
worldIn.setBlockToAir(pos);
flag1 = true;
if (iblockstate1.getBlock() == this)
{
worldIn.setBlockToAir(blockpos1);
}
}
if (flag1)
{
if (!worldIn.isRemote)
{
this.dropBlockAsItem(worldIn, pos, state, 0);
}
}
else
{
boolean flag = worldIn.isBlockPowered(pos) || worldIn.isBlockPowered(blockpos1);
if ((flag || neighborBlock.canProvidePower()) && neighborBlock != this && flag != ((Boolean)iblockstate1.getValue(POWERED)).booleanValue())
{
worldIn.setBlockState(blockpos1, iblockstate1.withProperty(POWERED, Boolean.valueOf(flag)), 2);
if (flag != ((Boolean)state.getValue(OPEN)).booleanValue())
{
worldIn.setBlockState(pos, state.withProperty(OPEN, Boolean.valueOf(flag)), 2);
worldIn.markBlockRangeForRenderUpdate(pos, pos);
worldIn.playAuxSFXAtEntity((EntityPlayer)null, flag ? 1003 : 1006, pos, 0);
}
}
}
}
}
示例14: updateAITasks
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
protected void updateAITasks()
{
super.updateAITasks();
BlockPos blockpos = new BlockPos(this);
BlockPos blockpos1 = blockpos.up();
if (this.getIsBatHanging())
{
if (!this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
{
this.setIsBatHanging(false);
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
}
else
{
if (this.rand.nextInt(200) == 0)
{
this.rotationYawHead = (float)this.rand.nextInt(360);
}
if (this.worldObj.getClosestPlayerToEntity(this, 4.0D) != null)
{
this.setIsBatHanging(false);
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1015, blockpos, 0);
}
}
}
else
{
if (this.spawnPosition != null && (!this.worldObj.isAirBlock(this.spawnPosition) || this.spawnPosition.getY() < 1))
{
this.spawnPosition = null;
}
if (this.spawnPosition == null || this.rand.nextInt(30) == 0 || this.spawnPosition.distanceSq((double)((int)this.posX), (double)((int)this.posY), (double)((int)this.posZ)) < 4.0D)
{
this.spawnPosition = new BlockPos((int)this.posX + this.rand.nextInt(7) - this.rand.nextInt(7), (int)this.posY + this.rand.nextInt(6) - 2, (int)this.posZ + this.rand.nextInt(7) - this.rand.nextInt(7));
}
double d0 = (double)this.spawnPosition.getX() + 0.5D - this.posX;
double d1 = (double)this.spawnPosition.getY() + 0.1D - this.posY;
double d2 = (double)this.spawnPosition.getZ() + 0.5D - this.posZ;
this.motionX += (Math.signum(d0) * 0.5D - this.motionX) * 0.10000000149011612D;
this.motionY += (Math.signum(d1) * 0.699999988079071D - this.motionY) * 0.10000000149011612D;
this.motionZ += (Math.signum(d2) * 0.5D - this.motionZ) * 0.10000000149011612D;
float f = (float)(MathHelper.func_181159_b(this.motionZ, this.motionX) * 180.0D / Math.PI) - 90.0F;
float f1 = MathHelper.wrapAngleTo180_float(f - this.rotationYaw);
this.moveForward = 0.5F;
this.rotationYaw += f1;
if (this.rand.nextInt(100) == 0 && this.worldObj.getBlockState(blockpos1).getBlock().isNormalCube())
{
this.setIsBatHanging(true);
}
}
}
示例15: grow
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public void grow(World worldIn, Random rand, BlockPos pos, IBlockState state)
{
BlockPos blockpos = pos.up();
for (int i = 0; i < 128; ++i)
{
BlockPos blockpos1 = blockpos;
int j = 0;
while (true)
{
if (j >= i / 16)
{
if (worldIn.getBlockState(blockpos1).getBlock().blockMaterial == Material.air)
{
if (rand.nextInt(8) == 0)
{
BlockFlower.EnumFlowerType blockflower$enumflowertype = worldIn.getBiomeGenForCoords(blockpos1).pickRandomFlower(rand, blockpos1);
BlockFlower blockflower = blockflower$enumflowertype.getBlockType().getBlock();
IBlockState iblockstate = blockflower.getDefaultState().withProperty(blockflower.getTypeProperty(), blockflower$enumflowertype);
if (blockflower.canBlockStay(worldIn, blockpos1, iblockstate))
{
worldIn.setBlockState(blockpos1, iblockstate, 3);
}
}
else
{
IBlockState iblockstate1 = Blocks.tallgrass.getDefaultState().withProperty(BlockTallGrass.TYPE, BlockTallGrass.EnumType.GRASS);
if (Blocks.tallgrass.canBlockStay(worldIn, blockpos1, iblockstate1))
{
worldIn.setBlockState(blockpos1, iblockstate1, 3);
}
}
}
break;
}
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (worldIn.getBlockState(blockpos1.down()).getBlock() != Blocks.grass || worldIn.getBlockState(blockpos1).getBlock().isNormalCube())
{
break;
}
++j;
}
}
}