本文整理匯總了Java中net.minecraft.util.BlockPos.west方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.west方法的具體用法?Java BlockPos.west怎麽用?Java BlockPos.west使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.BlockPos
的用法示例。
在下文中一共展示了BlockPos.west方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
}
示例2: getGrowthChance
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
protected static float getGrowthChance(Block blockIn, World worldIn, BlockPos pos)
{
float f = 1.0F;
BlockPos blockpos = pos.down();
for (int i = -1; i <= 1; ++i)
{
for (int j = -1; j <= 1; ++j)
{
float f1 = 0.0F;
IBlockState iblockstate = worldIn.getBlockState(blockpos.add(i, 0, j));
if (iblockstate.getBlock() == Blocks.farmland)
{
f1 = 1.0F;
if (((Integer)iblockstate.getValue(BlockFarmland.MOISTURE)).intValue() > 0)
{
f1 = 3.0F;
}
}
if (i != 0 || j != 0)
{
f1 /= 4.0F;
}
f += f1;
}
}
BlockPos blockpos1 = pos.north();
BlockPos blockpos2 = pos.south();
BlockPos blockpos3 = pos.west();
BlockPos blockpos4 = pos.east();
boolean flag = blockIn == worldIn.getBlockState(blockpos3).getBlock() || blockIn == worldIn.getBlockState(blockpos4).getBlock();
boolean flag1 = blockIn == worldIn.getBlockState(blockpos1).getBlock() || blockIn == worldIn.getBlockState(blockpos2).getBlock();
if (flag && flag1)
{
f /= 2.0F;
}
else
{
boolean flag2 = blockIn == worldIn.getBlockState(blockpos3.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.north()).getBlock() || blockIn == worldIn.getBlockState(blockpos4.south()).getBlock() || blockIn == worldIn.getBlockState(blockpos3.south()).getBlock();
if (flag2)
{
f /= 2.0F;
}
}
return f;
}
示例3: onBlockPlacedBy
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
state = state.withProperty(FACING, enumfacing);
BlockPos blockpos = pos.north();
BlockPos blockpos1 = pos.south();
BlockPos blockpos2 = pos.west();
BlockPos blockpos3 = pos.east();
boolean flag = this == worldIn.getBlockState(blockpos).getBlock();
boolean flag1 = this == worldIn.getBlockState(blockpos1).getBlock();
boolean flag2 = this == worldIn.getBlockState(blockpos2).getBlock();
boolean flag3 = this == worldIn.getBlockState(blockpos3).getBlock();
if (!flag && !flag1 && !flag2 && !flag3)
{
worldIn.setBlockState(pos, state, 3);
}
else if (enumfacing.getAxis() != EnumFacing.Axis.X || !flag && !flag1)
{
if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
{
if (flag2)
{
worldIn.setBlockState(blockpos2, state, 3);
}
else
{
worldIn.setBlockState(blockpos3, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
}
else
{
if (flag)
{
worldIn.setBlockState(blockpos, state, 3);
}
else
{
worldIn.setBlockState(blockpos1, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
if (stack.hasDisplayName())
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest)
{
((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
}
}
}
示例4: canPlaceBlockAt
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
int i = 0;
BlockPos blockpos = pos.west();
BlockPos blockpos1 = pos.east();
BlockPos blockpos2 = pos.north();
BlockPos blockpos3 = pos.south();
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos1).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos1))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos2).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos2))
{
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos3).getBlock() == this)
{
if (this.isDoubleChest(worldIn, blockpos3))
{
return false;
}
++i;
}
return i <= 1;
}
示例5: onBlockPlacedBy
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called by ItemBlocks after a block is set in the world, to allow
* post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer,
ItemStack stack) {
EnumFacing enumfacing = EnumFacing
.getHorizontal(MathHelper.floor_double((double) (placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3)
.getOpposite();
state = state.withProperty(FACING, enumfacing);
BlockPos blockpos = pos.north();
BlockPos blockpos1 = pos.south();
BlockPos blockpos2 = pos.west();
BlockPos blockpos3 = pos.east();
boolean flag = this == worldIn.getBlockState(blockpos).getBlock();
boolean flag1 = this == worldIn.getBlockState(blockpos1).getBlock();
boolean flag2 = this == worldIn.getBlockState(blockpos2).getBlock();
boolean flag3 = this == worldIn.getBlockState(blockpos3).getBlock();
if (!flag && !flag1 && !flag2 && !flag3) {
worldIn.setBlockState(pos, state, 3);
} else if (enumfacing.getAxis() != EnumFacing.Axis.X || !flag && !flag1) {
if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3)) {
if (flag2) {
worldIn.setBlockState(blockpos2, state, 3);
} else {
worldIn.setBlockState(blockpos3, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
} else {
if (flag) {
worldIn.setBlockState(blockpos, state, 3);
} else {
worldIn.setBlockState(blockpos1, state, 3);
}
worldIn.setBlockState(pos, state, 3);
}
if (stack.hasDisplayName()) {
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityChest) {
((TileEntityChest) tileentity).setCustomName(stack.getDisplayName());
}
}
}
示例6: canPlaceBlockAt
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean canPlaceBlockAt(World worldIn, BlockPos pos) {
int i = 0;
BlockPos blockpos = pos.west();
BlockPos blockpos1 = pos.east();
BlockPos blockpos2 = pos.north();
BlockPos blockpos3 = pos.south();
if (worldIn.getBlockState(blockpos).getBlock() == this) {
if (this.isDoubleChest(worldIn, blockpos)) {
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos1).getBlock() == this) {
if (this.isDoubleChest(worldIn, blockpos1)) {
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos2).getBlock() == this) {
if (this.isDoubleChest(worldIn, blockpos2)) {
return false;
}
++i;
}
if (worldIn.getBlockState(blockpos3).getBlock() == this) {
if (this.isDoubleChest(worldIn, blockpos3)) {
return false;
}
++i;
}
return i <= 1;
}