本文整理匯總了Java中net.minecraft.util.BlockPos.offset方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPos.offset方法的具體用法?Java BlockPos.offset怎麽用?Java BlockPos.offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.util.BlockPos
的用法示例。
在下文中一共展示了BlockPos.offset方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: func_180120_a
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
protected int func_180120_a(BlockPos p_180120_1_, EnumFacing p_180120_2_)
{
int i;
for (i = 0; i < 22; ++i)
{
BlockPos blockpos = p_180120_1_.offset(p_180120_2_, i);
if (!this.func_150857_a(this.world.getBlockState(blockpos).getBlock()) || this.world.getBlockState(blockpos.down()).getBlock() != Blocks.obsidian)
{
break;
}
}
Block block = this.world.getBlockState(p_180120_1_.offset(p_180120_2_, i)).getBlock();
return block == Blocks.obsidian ? i : 0;
}
示例2: shouldSideBeRendered
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
if (this.isDouble())
{
return super.shouldSideBeRendered(worldIn, pos, side);
}
else if (side != EnumFacing.UP && side != EnumFacing.DOWN && !super.shouldSideBeRendered(worldIn, pos, side))
{
return false;
}
else
{
BlockPos blockpos = pos.offset(side.getOpposite());
IBlockState iblockstate = worldIn.getBlockState(pos);
IBlockState iblockstate1 = worldIn.getBlockState(blockpos);
boolean flag = isSlab(iblockstate.getBlock()) && iblockstate.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP;
boolean flag1 = isSlab(iblockstate1.getBlock()) && iblockstate1.getValue(HALF) == BlockSlab.EnumBlockHalf.TOP;
return flag1 ? (side == EnumFacing.DOWN ? true : (side == EnumFacing.UP && super.shouldSideBeRendered(worldIn, pos, side) ? true : !isSlab(iblockstate.getBlock()) || !flag)) : (side == EnumFacing.UP ? true : (side == EnumFacing.DOWN && super.shouldSideBeRendered(worldIn, pos, side) ? true : !isSlab(iblockstate.getBlock()) || flag));
}
}
示例3: isConnectedTo
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public static boolean isConnectedTo(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing direction)
{
BlockPos blockpos = pos.offset(direction);
IBlockState iblockstate = worldIn.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (block == Blocks.tripwire_hook)
{
EnumFacing enumfacing = direction.getOpposite();
return iblockstate.getValue(BlockTripWireHook.FACING) == enumfacing;
}
else if (block == Blocks.tripwire)
{
boolean flag = ((Boolean)state.getValue(SUSPENDED)).booleanValue();
boolean flag1 = ((Boolean)iblockstate.getValue(SUSPENDED)).booleanValue();
return flag == flag1;
}
else
{
return false;
}
}
示例4: calculateInputStrength
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
int i = worldIn.getRedstonePower(blockpos, enumfacing);
if (i >= 15)
{
return i;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(blockpos);
return Math.max(i, iblockstate.getBlock() == Blocks.redstone_wire ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : 0);
}
}
示例5: onBlockHarvested
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.capabilities.isCreativeMode && state.getValue(PART) == BlockBed.EnumPartType.HEAD)
{
BlockPos blockpos = pos.offset(((EnumFacing)state.getValue(FACING)).getOpposite());
if (worldIn.getBlockState(blockpos).getBlock() == this)
{
worldIn.setBlockToAir(blockpos);
}
}
}
示例6: Size
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public Size(World worldIn, BlockPos p_i45694_2_, EnumFacing.Axis p_i45694_3_)
{
this.world = worldIn;
this.axis = p_i45694_3_;
if (p_i45694_3_ == EnumFacing.Axis.X)
{
this.field_150863_d = EnumFacing.EAST;
this.field_150866_c = EnumFacing.WEST;
}
else
{
this.field_150863_d = EnumFacing.NORTH;
this.field_150866_c = EnumFacing.SOUTH;
}
for (BlockPos blockpos = p_i45694_2_; p_i45694_2_.getY() > blockpos.getY() - 21 && p_i45694_2_.getY() > 0 && this.func_150857_a(worldIn.getBlockState(p_i45694_2_.down()).getBlock()); p_i45694_2_ = p_i45694_2_.down())
{
;
}
int i = this.func_180120_a(p_i45694_2_, this.field_150863_d) - 1;
if (i >= 0)
{
this.field_150861_f = p_i45694_2_.offset(this.field_150863_d, i);
this.field_150868_h = this.func_180120_a(this.field_150861_f, this.field_150866_c);
if (this.field_150868_h < 2 || this.field_150868_h > 21)
{
this.field_150861_f = null;
this.field_150868_h = 0;
}
}
if (this.field_150861_f != null)
{
this.field_150862_g = this.func_150858_a();
}
}
示例7: breakBlock
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
super.breakBlock(worldIn, pos, state);
EnumFacing enumfacing = ((EnumFacing)state.getValue(FACING)).getOpposite();
pos = pos.offset(enumfacing);
IBlockState iblockstate = worldIn.getBlockState(pos);
if ((iblockstate.getBlock() == Blocks.piston || iblockstate.getBlock() == Blocks.sticky_piston) && ((Boolean)iblockstate.getValue(BlockPistonBase.EXTENDED)).booleanValue())
{
iblockstate.getBlock().dropBlockAsItem(worldIn, pos, iblockstate, 0);
worldIn.setBlockToAir(pos);
}
}
示例8: onItemUse
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
BlockPos blockpos = flag ? pos : pos.offset(side);
if (!playerIn.canPlayerEdit(blockpos, side, stack))
{
return false;
}
else
{
Block block = worldIn.getBlockState(blockpos).getBlock();
if (!worldIn.canBlockBePlaced(block, blockpos, false, side, (Entity)null, stack))
{
return false;
}
else if (Blocks.redstone_wire.canPlaceBlockAt(worldIn, blockpos))
{
--stack.stackSize;
worldIn.setBlockState(blockpos, Blocks.redstone_wire.getDefaultState());
return true;
}
else
{
return false;
}
}
}
示例9: doMove
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private boolean doMove(World worldIn, BlockPos pos, EnumFacing direction, boolean extending)
{
if (!extending)
{
worldIn.setBlockToAir(pos.offset(direction));
}
BlockPistonStructureHelper blockpistonstructurehelper = new BlockPistonStructureHelper(worldIn, pos, direction, extending);
List<BlockPos> list = blockpistonstructurehelper.getBlocksToMove();
List<BlockPos> list1 = blockpistonstructurehelper.getBlocksToDestroy();
if (!blockpistonstructurehelper.canMove())
{
return false;
}
else
{
int i = list.size() + list1.size();
Block[] ablock = new Block[i];
EnumFacing enumfacing = extending ? direction : direction.getOpposite();
for (int j = list1.size() - 1; j >= 0; --j)
{
BlockPos blockpos = (BlockPos)list1.get(j);
Block block = worldIn.getBlockState(blockpos).getBlock();
block.dropBlockAsItem(worldIn, blockpos, worldIn.getBlockState(blockpos), 0);
worldIn.setBlockToAir(blockpos);
--i;
ablock[i] = block;
}
for (int k = list.size() - 1; k >= 0; --k)
{
BlockPos blockpos2 = (BlockPos)list.get(k);
IBlockState iblockstate = worldIn.getBlockState(blockpos2);
Block block1 = iblockstate.getBlock();
block1.getMetaFromState(iblockstate);
worldIn.setBlockToAir(blockpos2);
blockpos2 = blockpos2.offset(enumfacing);
worldIn.setBlockState(blockpos2, Blocks.piston_extension.getDefaultState().withProperty(FACING, direction), 4);
worldIn.setTileEntity(blockpos2, BlockPistonMoving.newTileEntity(iblockstate, direction, extending, false));
--i;
ablock[i] = block1;
}
BlockPos blockpos1 = pos.offset(direction);
if (extending)
{
BlockPistonExtension.EnumPistonType blockpistonextension$enumpistontype = this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT;
IBlockState iblockstate1 = Blocks.piston_head.getDefaultState().withProperty(BlockPistonExtension.FACING, direction).withProperty(BlockPistonExtension.TYPE, blockpistonextension$enumpistontype);
IBlockState iblockstate2 = Blocks.piston_extension.getDefaultState().withProperty(BlockPistonMoving.FACING, direction).withProperty(BlockPistonMoving.TYPE, this.isSticky ? BlockPistonExtension.EnumPistonType.STICKY : BlockPistonExtension.EnumPistonType.DEFAULT);
worldIn.setBlockState(blockpos1, iblockstate2, 4);
worldIn.setTileEntity(blockpos1, BlockPistonMoving.newTileEntity(iblockstate1, direction, true, false));
}
for (int l = list1.size() - 1; l >= 0; --l)
{
worldIn.notifyNeighborsOfStateChange((BlockPos)list1.get(l), ablock[i++]);
}
for (int i1 = list.size() - 1; i1 >= 0; --i1)
{
worldIn.notifyNeighborsOfStateChange((BlockPos)list.get(i1), ablock[i++]);
}
if (extending)
{
worldIn.notifyNeighborsOfStateChange(blockpos1, Blocks.piston_head);
worldIn.notifyNeighborsOfStateChange(pos, this);
}
return true;
}
}
示例10: getRawLight
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* gets the light level at the supplied position
*/
private int getRawLight(BlockPos pos, EnumSkyBlock lightType)
{
if (lightType == EnumSkyBlock.SKY && this.canSeeSky(pos))
{
return 15;
}
else
{
Block block = this.getBlockState(pos).getBlock();
int i = lightType == EnumSkyBlock.SKY ? 0 : block.getLightValue();
int j = block.getLightOpacity();
if (j >= 15 && block.getLightValue() > 0)
{
j = 1;
}
if (j < 1)
{
j = 1;
}
if (j >= 15)
{
return 0;
}
else if (i >= 14)
{
return i;
}
else
{
for (EnumFacing enumfacing : EnumFacing.values())
{
BlockPos blockpos = pos.offset(enumfacing);
int k = this.getLightFor(lightType, blockpos) - j;
if (k > i)
{
i = k;
}
if (i >= 14)
{
return i;
}
}
return i;
}
}
}
示例11: onItemUse
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
if (!block.isReplaceable(worldIn, pos))
{
pos = pos.offset(side);
}
if (stack.stackSize == 0)
{
return false;
}
else if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity)null, stack))
{
int i = this.getMetadata(stack.getMetadata());
IBlockState iblockstate1 = this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, i, playerIn);
if (worldIn.setBlockState(pos, iblockstate1, 3))
{
iblockstate1 = worldIn.getBlockState(pos);
if (iblockstate1.getBlock() == this.block)
{
setTileEntityNBT(worldIn, playerIn, pos, stack);
this.block.onBlockPlacedBy(worldIn, pos, iblockstate1, playerIn, stack);
}
worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.block.stepSound.getPlaceSound(), (this.block.stepSound.getVolume() + 1.0F) / 2.0F, this.block.stepSound.getFrequency() * 0.8F);
--stack.stackSize;
}
return true;
}
else
{
return false;
}
}
示例12: onItemUse
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (side == EnumFacing.DOWN)
{
return false;
}
else if (!worldIn.getBlockState(pos).getBlock().getMaterial().isSolid())
{
return false;
}
else
{
pos = pos.offset(side);
if (!playerIn.canPlayerEdit(pos, side, stack))
{
return false;
}
else if (!Blocks.standing_banner.canPlaceBlockAt(worldIn, pos))
{
return false;
}
else if (worldIn.isRemote)
{
return true;
}
else
{
if (side == EnumFacing.UP)
{
int i = MathHelper.floor_double((double)((playerIn.rotationYaw + 180.0F) * 16.0F / 360.0F) + 0.5D) & 15;
worldIn.setBlockState(pos, Blocks.standing_banner.getDefaultState().withProperty(BlockStandingSign.ROTATION, Integer.valueOf(i)), 3);
}
else
{
worldIn.setBlockState(pos, Blocks.wall_banner.getDefaultState().withProperty(BlockWallSign.FACING, side), 3);
}
--stack.stackSize;
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityBanner)
{
((TileEntityBanner)tileentity).setItemValues(stack);
}
return true;
}
}
}
示例13: onItemUse
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (side == EnumFacing.DOWN)
{
return false;
}
else
{
boolean flag = worldIn.getBlockState(pos).getBlock().isReplaceable(worldIn, pos);
BlockPos blockpos = flag ? pos : pos.offset(side);
if (!playerIn.canPlayerEdit(blockpos, side, stack))
{
return false;
}
else
{
BlockPos blockpos1 = blockpos.up();
boolean flag1 = !worldIn.isAirBlock(blockpos) && !worldIn.getBlockState(blockpos).getBlock().isReplaceable(worldIn, blockpos);
flag1 = flag1 | (!worldIn.isAirBlock(blockpos1) && !worldIn.getBlockState(blockpos1).getBlock().isReplaceable(worldIn, blockpos1));
if (flag1)
{
return false;
}
else
{
double d0 = (double)blockpos.getX();
double d1 = (double)blockpos.getY();
double d2 = (double)blockpos.getZ();
List<Entity> list = worldIn.getEntitiesWithinAABBExcludingEntity((Entity)null, AxisAlignedBB.fromBounds(d0, d1, d2, d0 + 1.0D, d1 + 2.0D, d2 + 1.0D));
if (list.size() > 0)
{
return false;
}
else
{
if (!worldIn.isRemote)
{
worldIn.setBlockToAir(blockpos);
worldIn.setBlockToAir(blockpos1);
EntityArmorStand entityarmorstand = new EntityArmorStand(worldIn, d0 + 0.5D, d1, d2 + 0.5D);
float f = (float)MathHelper.floor_float((MathHelper.wrapAngleTo180_float(playerIn.rotationYaw - 180.0F) + 22.5F) / 45.0F) * 45.0F;
entityarmorstand.setLocationAndAngles(d0 + 0.5D, d1, d2 + 0.5D, f, 0.0F);
this.applyRandomRotations(entityarmorstand, worldIn.rand);
NBTTagCompound nbttagcompound = stack.getTagCompound();
if (nbttagcompound != null && nbttagcompound.hasKey("EntityTag", 10))
{
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
entityarmorstand.writeToNBTOptional(nbttagcompound1);
nbttagcompound1.merge(nbttagcompound.getCompoundTag("EntityTag"));
entityarmorstand.readFromNBT(nbttagcompound1);
}
worldIn.spawnEntityInWorld(entityarmorstand);
}
--stack.stackSize;
return true;
}
}
}
}
}
示例14: onItemUse
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
/**
* Called when a Block is right-clicked with this Item
*/
public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
{
if (worldIn.isRemote)
{
return true;
}
else if (!playerIn.canPlayerEdit(pos.offset(side), side, stack))
{
return false;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(pos);
if (iblockstate.getBlock() == Blocks.mob_spawner)
{
TileEntity tileentity = worldIn.getTileEntity(pos);
if (tileentity instanceof TileEntityMobSpawner)
{
MobSpawnerBaseLogic mobspawnerbaselogic = ((TileEntityMobSpawner)tileentity).getSpawnerBaseLogic();
mobspawnerbaselogic.setEntityName(EntityList.getStringFromID(stack.getMetadata()));
tileentity.markDirty();
worldIn.markBlockForUpdate(pos);
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
return true;
}
}
pos = pos.offset(side);
double d0 = 0.0D;
if (side == EnumFacing.UP && iblockstate instanceof BlockFence)
{
d0 = 0.5D;
}
Entity entity = spawnCreature(worldIn, stack.getMetadata(), (double)pos.getX() + 0.5D, (double)pos.getY() + d0, (double)pos.getZ() + 0.5D);
if (entity != null)
{
if (entity instanceof EntityLivingBase && stack.hasDisplayName())
{
entity.setCustomNameTag(stack.getDisplayName());
}
if (!playerIn.capabilities.isCreativeMode)
{
--stack.stackSize;
}
}
return true;
}
}
示例15: canPlaceAt
import net.minecraft.util.BlockPos; //導入方法依賴的package包/類
private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing)
{
BlockPos blockpos = pos.offset(facing.getOpposite());
boolean flag = facing.getAxis().isHorizontal();
return flag && worldIn.isBlockNormalCube(blockpos, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos);
}