本文整理汇总了Java中net.minecraft.init.Blocks.piston方法的典型用法代码示例。如果您正苦于以下问题:Java Blocks.piston方法的具体用法?Java Blocks.piston怎么用?Java Blocks.piston使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.init.Blocks
的用法示例。
在下文中一共展示了Blocks.piston方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockHarvested
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (player.capabilities.isCreativeMode)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
if (enumfacing != null)
{
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
Block block = worldIn.getBlockState(blockpos).getBlock();
if (block == Blocks.piston || block == Blocks.sticky_piston)
{
worldIn.setBlockToAir(blockpos);
}
}
}
super.onBlockHarvested(worldIn, pos, state, player);
}
示例2: onNeighborBlockChange
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() != Blocks.piston && iblockstate.getBlock() != Blocks.sticky_piston)
{
worldIn.setBlockToAir(pos);
}
else
{
iblockstate.getBlock().onNeighborBlockChange(worldIn, blockpos, iblockstate, neighborBlock);
}
}
示例3: setBlockBoundsBasedOnState
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
{
TileEntityPiston tileentitypiston = this.getTileEntity(worldIn, pos);
if (tileentitypiston != null)
{
IBlockState iblockstate = tileentitypiston.getPistonState();
Block block = iblockstate.getBlock();
if (block == this || block.getMaterial() == Material.air)
{
return;
}
float f = tileentitypiston.getProgress(0.0F);
if (tileentitypiston.isExtending())
{
f = 1.0F - f;
}
block.setBlockBoundsBasedOnState(worldIn, pos);
if (block == Blocks.piston || block == Blocks.sticky_piston)
{
f = 0.0F;
}
EnumFacing enumfacing = tileentitypiston.getFacing();
this.minX = block.getBlockBoundsMinX() - (double)((float)enumfacing.getFrontOffsetX() * f);
this.minY = block.getBlockBoundsMinY() - (double)((float)enumfacing.getFrontOffsetY() * f);
this.minZ = block.getBlockBoundsMinZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
this.maxX = block.getBlockBoundsMaxX() - (double)((float)enumfacing.getFrontOffsetX() * f);
this.maxY = block.getBlockBoundsMaxY() - (double)((float)enumfacing.getFrontOffsetY() * f);
this.maxZ = block.getBlockBoundsMaxZ() - (double)((float)enumfacing.getFrontOffsetZ() * f);
}
}
示例4: breakBlock
import net.minecraft.init.Blocks; //导入方法依赖的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);
}
}
示例5: breakWeapon
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
private void breakWeapon(World world, ItemStack stack, Entity entity)
{
if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
{
this.setCooldown(stack, 40);
return;
}
EntityPlayer player = (EntityPlayer) entity;
player.renderBrokenItemStack(stack);
player.destroyCurrentEquippedItem(); // Breaking
stack.stackSize = 0;
EntityItem piston = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.piston));
piston.delayBeforeCanPickup = 10;
if (player.captureDrops) { player.capturedDrops.add(piston); }
else { world.spawnEntityInWorld(piston); }
EntityItem hook = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.tripwire_hook));
hook.delayBeforeCanPickup = 10;
if (player.captureDrops) { player.capturedDrops.add(hook); }
else { world.spawnEntityInWorld(hook); }
world.playSoundAtEntity(player, "random.break", 1.0F, 1.5F);
}
示例6: canPush
import net.minecraft.init.Blocks; //导入方法依赖的package包/类
public static boolean canPush(Block blockIn, World worldIn, BlockPos pos, EnumFacing direction, boolean allowDestroy)
{
if (blockIn == Blocks.obsidian)
{
return false;
}
else if (!worldIn.getWorldBorder().contains(pos))
{
return false;
}
else if (pos.getY() >= 0 && (direction != EnumFacing.DOWN || pos.getY() != 0))
{
if (pos.getY() <= worldIn.getHeight() - 1 && (direction != EnumFacing.UP || pos.getY() != worldIn.getHeight() - 1))
{
if (blockIn != Blocks.piston && blockIn != Blocks.sticky_piston)
{
if (blockIn.getBlockHardness(worldIn, pos) == -1.0F)
{
return false;
}
if (blockIn.getMobilityFlag() == 2)
{
return false;
}
if (blockIn.getMobilityFlag() == 1)
{
if (!allowDestroy)
{
return false;
}
return true;
}
}
else if (((Boolean)worldIn.getBlockState(pos).getValue(EXTENDED)).booleanValue())
{
return false;
}
return !(blockIn instanceof ITileEntityProvider);
}
else
{
return false;
}
}
else
{
return false;
}
}