本文整理汇总了Java中net.minecraft.world.World.destroyBlock方法的典型用法代码示例。如果您正苦于以下问题:Java World.destroyBlock方法的具体用法?Java World.destroyBlock怎么用?Java World.destroyBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.world.World
的用法示例。
在下文中一共展示了World.destroyBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateTask
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTask()
{
super.updateTask();
this.field_179500_c.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.field_179500_c.getVerticalFaceSpeed());
if (this.getIsAboveDestination())
{
World world = this.field_179500_c.worldObj;
BlockPos blockpos = this.destinationBlock.up();
IBlockState iblockstate = world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (this.field_179499_e && block instanceof BlockCarrot && ((Integer)iblockstate.getValue(BlockCarrot.AGE)).intValue() == 7)
{
world.setBlockState(blockpos, Blocks.air.getDefaultState(), 2);
world.destroyBlock(blockpos, true);
this.field_179500_c.createEatingParticles();
}
this.field_179499_e = false;
this.runDelay = 10;
}
}
示例2: neighborChanged
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
if(pos.offset(EnumFacing.DOWN).equals(fromPos)&&
!worldIn.getBlockState(fromPos).isSideSolid(worldIn, fromPos, EnumFacing.UP)){
worldIn.destroyBlock(pos, true);
return;
}
if(state.getValue(TYPE)==EnumKilnTypes.ACTIVE){
if(pos.offset(EnumFacing.UP).equals(fromPos)){
IBlockState fromState=worldIn.getBlockState(fromPos);
if(fromState.getBlock()==Blocks.FIRE)
return;
((TilePotteryKiln)worldIn.getTileEntity(pos)).isValid=false;
}
((TilePotteryKiln)worldIn.getTileEntity(pos)).isValid=false;
}
}
示例3: onBlockHarvested
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player) {
if(worldIn.getBlockState(pos.down()).getBlock() instanceof HereticCauldron)
{
worldIn.getBlockState(pos.down()).getBlock().onBlockHarvested(worldIn, pos.down(), worldIn.getBlockState(pos.down()), player);
worldIn.destroyBlock(pos.down(), !player.isCreative());
}
}
示例4: neighborChanged
import net.minecraft.world.World; //导入方法依赖的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, BlockPos p_189540_5_)
{
if (!this.canBlockStay(worldIn, pos))
{
worldIn.destroyBlock(pos, true);
}
}
示例5: neighborChanged
import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn) {
if(!worldIn.isRemote) {
if(!worldIn.getBlockState(pos.down()).isOpaqueCube())
{
worldIn.destroyBlock(pos,false);
}
}
super.neighborChanged(state, worldIn, pos, blockIn);
}
示例6: checkAndDropBlock
import net.minecraft.world.World; //导入方法依赖的package包/类
protected final void checkAndDropBlock(World world, BlockPos pos, IBlockState state) {
boolean drop = world.getBlockState(pos.down()).getBlock() != this && !world.getBlockState(pos.down()).isNormalCube();
if (drop && !world.isRemote) {
world.destroyBlock(pos, true);
breakBlock(world, pos, state);
}
}
示例7: onEntityCollidedWithBlock
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Called When an Entity Collided with the Block
*/
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);
if (entityIn instanceof EntityBoat)
{
worldIn.destroyBlock(new BlockPos(pos), true);
}
}
示例8: updateTask
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTask()
{
--this.field_179463_b;
if (this.field_179463_b <= 0)
{
World world = this.silverfish.worldObj;
Random random = this.silverfish.getRNG();
BlockPos blockpos = new BlockPos(this.silverfish);
for (int i = 0; i <= 5 && i >= -5; i = i <= 0 ? 1 - i : 0 - i)
{
for (int j = 0; j <= 10 && j >= -10; j = j <= 0 ? 1 - j : 0 - j)
{
for (int k = 0; k <= 10 && k >= -10; k = k <= 0 ? 1 - k : 0 - k)
{
BlockPos blockpos1 = blockpos.add(j, i, k);
IBlockState iblockstate = world.getBlockState(blockpos1);
if (iblockstate.getBlock() == Blocks.monster_egg)
{
if (world.getGameRules().getBoolean("mobGriefing"))
{
world.destroyBlock(blockpos1, true);
}
else
{
world.setBlockState(blockpos1, ((BlockSilverfish.EnumType)iblockstate.getValue(BlockSilverfish.VARIANT)).getModelBlock(), 3);
}
if (random.nextBoolean())
{
return;
}
}
}
}
}
}
}
示例9: updateTick
import net.minecraft.world.World; //导入方法依赖的package包/类
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!this.canSurviveAt(worldIn, pos))
{
worldIn.destroyBlock(pos, true);
}
}
示例10: onNeighborBlockChange
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (!this.canBlockStay(worldIn, pos))
{
worldIn.destroyBlock(pos, true);
}
}
示例11: neighborChanged
import net.minecraft.world.World; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
if (!this.canPlaceBlockAt(worldIn, pos)) worldIn.destroyBlock(pos, false);
}
示例12: tryPlaceFluid
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Tries to place a fluid in the world in block form.
* Makes a fluid emptying sound when successful.
* Checks if water-like fluids should vaporize like in the nether.
*
* Modeled after {@link net.minecraft.item.ItemBucket#tryPlaceContainedLiquid(EntityPlayer, World, BlockPos)}
*
* @param player Player who places the fluid. May be null for blocks like dispensers.
* @param worldIn World to place the fluid in
* @param fluidStack The fluidStack to place.
* @param pos The position in the world to place the fluid block
* @return true if successful
*/
public static boolean tryPlaceFluid(@Nullable EntityPlayer player, World worldIn, FluidStack fluidStack, BlockPos pos)
{
if (worldIn == null || fluidStack == null || pos == null)
{
return false;
}
Fluid fluid = fluidStack.getFluid();
if (fluid == null || !fluid.canBePlacedInWorld())
{
return false;
}
// check that we can place the fluid at the destination
IBlockState destBlockState = worldIn.getBlockState(pos);
Material destMaterial = destBlockState.getMaterial();
boolean isDestNonSolid = !destMaterial.isSolid();
boolean isDestReplaceable = destBlockState.getBlock().isReplaceable(worldIn, pos);
if (!worldIn.isAirBlock(pos) && !isDestNonSolid && !isDestReplaceable)
{
return false; // Non-air, solid, unreplacable block. We can't put fluid here.
}
if (worldIn.provider.doesWaterVaporize() && fluid.doesVaporize(fluidStack))
{
fluid.vaporize(player, worldIn, pos, fluidStack);
}
else
{
if (!worldIn.isRemote && (isDestNonSolid || isDestReplaceable) && !destMaterial.isLiquid())
{
worldIn.destroyBlock(pos, true);
}
SoundEvent soundevent = fluid.getEmptySound(fluidStack);
worldIn.playSound(player, pos, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
IBlockState fluidBlockState = fluid.getBlock().getDefaultState();
worldIn.setBlockState(pos, fluidBlockState, 11);
}
return true;
}
示例13: tryPlaceContainedLiquid
import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean tryPlaceContainedLiquid(@Nullable EntityPlayer player, World worldIn, BlockPos posIn)
{
if (this.containedBlock == Blocks.AIR)
{
return false;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(posIn);
Material material = iblockstate.getMaterial();
boolean flag = !material.isSolid();
boolean flag1 = iblockstate.getBlock().isReplaceable(worldIn, posIn);
if (!worldIn.isAirBlock(posIn) && !flag && !flag1)
{
return false;
}
else
{
if (worldIn.provider.doesWaterVaporize() && this.containedBlock == Blocks.FLOWING_WATER)
{
int l = posIn.getX();
int i = posIn.getY();
int j = posIn.getZ();
worldIn.playSound(player, posIn, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
for (int k = 0; k < 8; ++k)
{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, (double)l + Math.random(), (double)i + Math.random(), (double)j + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
}
}
else
{
if (!worldIn.isRemote && (flag || flag1) && !material.isLiquid())
{
worldIn.destroyBlock(posIn, true);
}
SoundEvent soundevent = this.containedBlock == Blocks.FLOWING_LAVA ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
worldIn.playSound(player, posIn, soundevent, SoundCategory.BLOCKS, 1.0F, 1.0F);
worldIn.setBlockState(posIn, this.containedBlock.getDefaultState(), 11);
}
return true;
}
}
}
示例14: onBlockHarvested
import net.minecraft.world.World; //导入方法依赖的package包/类
public void onBlockHarvested(World worldIn, BlockPos pos, IBlockState state, EntityPlayer player)
{
if (state.getValue(HALF) == BlockDoublePlant.EnumBlockHalf.UPPER)
{
if (worldIn.getBlockState(pos.down()).getBlock() == this)
{
if (!player.capabilities.isCreativeMode)
{
IBlockState iblockstate = worldIn.getBlockState(pos.down());
BlockDoublePlant.EnumPlantType blockdoubleplant$enumplanttype = (BlockDoublePlant.EnumPlantType)iblockstate.getValue(VARIANT);
if (blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.FERN && blockdoubleplant$enumplanttype != BlockDoublePlant.EnumPlantType.GRASS)
{
worldIn.destroyBlock(pos.down(), true);
}
else if (!worldIn.isRemote)
{
if (player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
{
this.onHarvest(worldIn, pos, iblockstate, player);
worldIn.setBlockToAir(pos.down());
}
else
{
worldIn.destroyBlock(pos.down(), true);
}
}
else
{
worldIn.setBlockToAir(pos.down());
}
}
else
{
worldIn.setBlockToAir(pos.down());
}
}
}
else if (player.capabilities.isCreativeMode && worldIn.getBlockState(pos.up()).getBlock() == this)
{
worldIn.setBlockState(pos.up(), Blocks.air.getDefaultState(), 2);
}
super.onBlockHarvested(worldIn, pos, state, player);
}
示例15: updateTask
import net.minecraft.world.World; //导入方法依赖的package包/类
/**
* Updates the task
*/
public void updateTask()
{
super.updateTask();
this.theVillager.getLookHelper().setLookPosition((double)this.destinationBlock.getX() + 0.5D, (double)(this.destinationBlock.getY() + 1), (double)this.destinationBlock.getZ() + 0.5D, 10.0F, (float)this.theVillager.getVerticalFaceSpeed());
if (this.getIsAboveDestination())
{
World world = this.theVillager.world;
BlockPos blockpos = this.destinationBlock.up();
IBlockState iblockstate = world.getBlockState(blockpos);
Block block = iblockstate.getBlock();
if (this.currentTask == 0 && block instanceof BlockCrops && ((BlockCrops)block).isMaxAge(iblockstate))
{
world.destroyBlock(blockpos, true);
}
else if (this.currentTask == 1 && iblockstate.getMaterial() == Material.AIR)
{
InventoryBasic inventorybasic = this.theVillager.getVillagerInventory();
for (int i = 0; i < inventorybasic.getSizeInventory(); ++i)
{
ItemStack itemstack = inventorybasic.getStackInSlot(i);
boolean flag = false;
if (!itemstack.func_190926_b())
{
if (itemstack.getItem() == Items.WHEAT_SEEDS)
{
world.setBlockState(blockpos, Blocks.WHEAT.getDefaultState(), 3);
flag = true;
}
else if (itemstack.getItem() == Items.POTATO)
{
world.setBlockState(blockpos, Blocks.POTATOES.getDefaultState(), 3);
flag = true;
}
else if (itemstack.getItem() == Items.CARROT)
{
world.setBlockState(blockpos, Blocks.CARROTS.getDefaultState(), 3);
flag = true;
}
else if (itemstack.getItem() == Items.BEETROOT_SEEDS)
{
world.setBlockState(blockpos, Blocks.BEETROOTS.getDefaultState(), 3);
flag = true;
}
}
if (flag)
{
itemstack.func_190918_g(1);
if (itemstack.func_190926_b())
{
inventorybasic.setInventorySlotContents(i, ItemStack.field_190927_a);
}
break;
}
}
}
this.currentTask = -1;
this.runDelay = 10;
}
}