C’est bon j’ai une solution plus ou moins optimiser:
| |
| [font=Courier New**public boolean **]onBlockDestroyed(ItemStack stack, World world, IBlockState block, BlockPos pos, EntityLivingBase living) |
| { |
| **if**(living **instanceof **EntityPlayer && !world.**isRemote**) |
| { |
| **for**(**int **x1 = -2; x1 < 3; x1++) |
| { |
| **for**(**int **y1 = -2; y1 < 3; y1++) |
| { |
| **for**(**int **z1 = -2; z1 < 3; z1++) |
| { |
| **int **x = pos.getX(); |
| **int **y = pos.getY(); |
| **int **z = pos.getZ(); |
| |
| TileEntity te = **new **TileEntity() {}; |
| |
| BlockPos pos1 = **new **BlockPos(x + x1, y + y1, z + z1); |
| **if**(world.getBlockState(pos1).getBlockHardness(world, pos1) >= 0) { |
| world.getBlockState(pos1).getBlock().harvestBlock(world, (EntityPlayer)living, pos1, block, te,stack); |
| world.setBlockToAir(pos1); |
| } |
| |
| **int **exp = world.getBlockState(pos).getBlock().getExpDrop(world.getBlockState(pos), world, pos1, 0); |
| **if**(exp > 0) { |
| EntityXPOrb expOrb = **new **EntityXPOrb(world, x, y, z, exp); |
| world.spawnEntityInWorld(expOrb); |
| } |
| } |
| } |
| } |
| } |
| **return super**.onBlockDestroyed(stack, world, block, pos, living); |
| } |
| [font=Courier New |
| ```] |
| |
| La méthode n'était pas appelé car il y avait int x, int y, int z à la ligne 1\. Il fallait aussi créer une tile entity. |
| Merci à BrokenSwing, son code m'a grandement aidé et aux autres bien sûr! :) Et désolé à Plaigon de ne pas avoir été appréciable. :'( |