Résolu Propriétés pour couper des arbres
-
world.getBlockState(testPos).getBlock().getMetaFromState(world.getBlockState(testPos))
-
Super, ça fonctionne, mon item est donc complètement terminé : Voilà à quoi ça ressemble :
Dans la classe de mon item, il y a ceci :
[size=x-small**public**] **[color=#7f0055boolean]** onBlockDestroyed(ItemStack [color=#6a3e3estack], World [color=#6a3e3eworldIn], Block [color=#6a3e3eblockIn], BlockPos [color=#6a3e3epos], EntityLivingBase [color=#6a3e3eplayerIn]) { **[color=#7f0055 if]**([color=#6a3e3eworldIn].getBlockState([color=#6a3e3epos].up(7)).getBlock().isWood([color=#6a3e3eworldIn], [color=#6a3e3epos].up(7))) { **[color=#7f0055 if]**([color=#6a3e3eplayerIn] **[color=#7f0055instanceof]** EntityPlayer && ![color=#6a3e3eworldIn].[color=#0000c0isRemote]) { } **[color=#7f0055 return]** **[color=#7f0055super]**.onBlockDestroyed([color=#6a3e3estack], [color=#6a3e3eworldIn], [color=#6a3e3eblockIn], [color=#6a3e3epos], [color=#6a3e3eplayerIn]); } **[color=#7f0055 for]** (**[color=#7f0055int]** [color=#6a3e3ei] = 0 ; [color=#6a3e3ei] < 7; [color=#6a3e3ei]++) { BlockPos [color=#6a3e3etestPos] = [color=#6a3e3epos].up([color=#6a3e3ei]); **[color=#7f0055 if]** ([color=#6a3e3eworldIn].getBlockState([color=#6a3e3etestPos]).getBlock().isWood([color=#6a3e3eworldIn], [color=#6a3e3etestPos])) { [color=#6a3e3e stack].damageItem(1, [color=#6a3e3eplayerIn]); **[color=#7f0055 if]** (![color=#6a3e3eworldIn].[color=#0000c0isRemote] && [color=#6a3e3eworldIn].getGameRules().getBoolean([color=#2a00ff"doTileDrops"])) { **[color=#7f0055 float]** [color=#6a3e3ef] = 0.7F; **[color=#7f0055 double]** [color=#6a3e3ed0] = (**[color=#7f0055double]**)([color=#6a3e3eworldIn].[color=#0000c0rand].nextFloat() * [color=#6a3e3ef]) + (**[color=#7f0055double]**)(1.0F - [color=#6a3e3ef]) * 0.5D; **[color=#7f0055 double]** [color=#6a3e3ed1] = (**[color=#7f0055double]**)([color=#6a3e3eworldIn].[color=#0000c0rand].nextFloat() * [color=#6a3e3ef]) + (**[color=#7f0055double]**)(1.0F - [color=#6a3e3ef]) * 0.5D; **[color=#7f0055 double]** [color=#6a3e3ed2] = (**[color=#7f0055double]**)([color=#6a3e3eworldIn].[color=#0000c0rand].nextFloat() * [color=#6a3e3ef]) + (**[color=#7f0055double]**)(1.0F - [color=#6a3e3ef]) * 0.5D; EntityItem [color=#6a3e3eentityItem] = **[color=#7f0055new]** EntityItem([color=#6a3e3eworldIn], (**[color=#7f0055double]**)[color=#6a3e3etestPos].getX() + [color=#6a3e3ed0], (**[color=#7f0055double]**)[color=#6a3e3etestPos].getY() + [color=#6a3e3ed1], (**[color=#7f0055double]**)[color=#6a3e3etestPos].getZ() + [color=#6a3e3ed2], **[color=#7f0055new]** ItemStack(Item.*getItemFromBlock*([color=#6a3e3eblockIn]), 1,[color=#6a3e3e worldIn].getBlockState([color=#6a3e3etestPos]).getBlock().getMetaFromState([color=#6a3e3eworldIn].getBlockState([color=#6a3e3etestPos])))); [color=#6a3e3e entityItem].setDefaultPickupDelay(); [color=#6a3e3e worldIn].spawnEntityInWorld([color=#6a3e3eentityItem]); } [color=#6a3e3e worldIn].setBlockToAir([color=#6a3e3etestPos]); } **[color=#7f0055 else]** { **[color=#7f0055 return]** **[color=#7f0055super]**.onBlockDestroyed([color=#6a3e3estack], [color=#6a3e3eworldIn], [color=#6a3e3eblockIn], [color=#6a3e3epos], [color=#6a3e3eplayerIn]); } } **[color=#7f0055 return]** **[color=#7f0055super]**.onBlockDestroyed([color=#6a3e3estack], [color=#6a3e3eworldIn], [color=#6a3e3eblockIn], [color=#6a3e3epos], [color=#6a3e3eplayerIn]); }
Dans ma classe event, il y a ceci :
@SubscribeEvent **[color=#7f0055public]** **[color=#7f0055void]** breakBlock(BlockEvent.BreakEvent [color=#6a3e3eevent]) { **[color=#7f0055 if]** ([color=#6a3e3eevent].[color=#0000c0world].getBlockState([color=#6a3e3eevent].[color=#0000c0pos].up(7)).getBlock().isWood([color=#6a3e3eevent].[color=#0000c0world], [color=#6a3e3eevent].[color=#0000c0pos])) { [color=#6a3e3e event].setCanceled(**[color=#7f0055true]**); [color=#6a3e3e event].getPlayer().addChatMessage(**[color=#7f0055new]** ChatComponentText([color=#2a00ff"Cet arbre est trop grand pour pouvoir être coupé"])); } }
Je met la balise en résolu : )