Java Code Examples for net.minecraft.world.World#canMineBlock()
The following examples show how to use
net.minecraft.world.World#canMineBlock() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemEntityEgg.java From Et-Futurum with The Unlicense | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (world.isRemote) return stack; else { MovingObjectPosition movingobjectposition = getMovingObjectPositionFromPlayer(world, player, true); if (movingobjectposition == null) return stack; else { if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { int i = movingobjectposition.blockX; int j = movingobjectposition.blockY; int k = movingobjectposition.blockZ; if (!world.canMineBlock(player, i, j, k)) return stack; if (!player.canPlayerEdit(i, j, k, movingobjectposition.sideHit, stack)) return stack; if (world.getBlock(i, j, k) instanceof BlockLiquid) { Entity entity = spawnEntity(world, stack.getItemDamage(), i, j, k); if (entity != null) { if (entity instanceof EntityLivingBase && stack.hasDisplayName()) ((EntityLiving) entity).setCustomNameTag(stack.getDisplayName()); if (!player.capabilities.isCreativeMode) stack.stackSize--; } } } return stack; } } }
Example 2
Source File: ItemMorphShovel.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
@Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) { if(EnchantmentHelper.getEnchantmentLevel(DarkEnchantments.impact.effectId, stack) <= 0) return super.onBlockDestroyed(stack, world, block, x, y, z, player); if(!player.worldObj.isRemote) { int meta = world.getBlockMetadata(x, y, z); if(ForgeHooks.isToolEffective(stack, block, meta)) { for(int aa = -1; aa <= 1; ++aa) { for(int bb = -1; bb <= 1; ++bb) { int xx = 0; int yy = 0; int zz = 0; if(this.side <= 1) { xx = aa; zz = bb; } else if(this.side <= 3) { xx = aa; yy = bb; } else { zz = aa; yy = bb; } if(!(player instanceof EntityPlayer) || world.canMineBlock((EntityPlayer)player, x + xx, y + yy, z + zz)) { Block bl = world.getBlock(x + xx, y + yy, z + zz); meta = world.getBlockMetadata(x + xx, y + yy, z + zz); if(bl.getBlockHardness(world, x + xx, y + yy, z + zz) >= 0.0F && ForgeHooks.isToolEffective(stack, bl, meta)) { stack.damageItem(1, player); BlockUtils.harvestBlock(world, (EntityPlayer)player, x + xx, y + yy, z + zz, true, 2); } } } } } else return super.onBlockDestroyed(stack, world, block, x, y, z, player); } return super.onBlockDestroyed(stack, world, block, x, y, z, player); }
Example 3
Source File: ItemMorphPickaxe.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
@Override public boolean onBlockDestroyed(ItemStack stack, World world, Block block, int x, int y, int z, EntityLivingBase player) { if(EnchantmentHelper.getEnchantmentLevel(DarkEnchantments.impact.effectId, stack) <= 0) return super.onBlockDestroyed(stack, world, block, x, y, z, player); if(!player.worldObj.isRemote) { int meta = world.getBlockMetadata(x, y, z); if(ForgeHooks.isToolEffective(stack, block, meta)) { for(int aa = -1; aa <= 1; ++aa) { for(int bb = -1; bb <= 1; ++bb) { int xx = 0; int yy = 0; int zz = 0; if(this.side <= 1) { xx = aa; zz = bb; } else if(this.side <= 3) { xx = aa; yy = bb; } else { zz = aa; yy = bb; } if(!(player instanceof EntityPlayer) || world.canMineBlock((EntityPlayer)player, x + xx, y + yy, z + zz)) { Block bl = world.getBlock(x + xx, y + yy, z + zz); meta = world.getBlockMetadata(x + xx, y + yy, z + zz); if(bl.getBlockHardness(world, x + xx, y + yy, z + zz) >= 0.0F && ForgeHooks.isToolEffective(stack, bl, meta)) { stack.damageItem(1, player); BlockUtils.harvestBlock(world, (EntityPlayer)player, x + xx, y + yy, z + zz, true, 2); } } } } } else return super.onBlockDestroyed(stack, world, block, x, y, z, player); } return super.onBlockDestroyed(stack, world, block, x, y, z, player); }