Créer un buisson récoltable
-
Ps: Il y a quelques “EmotionBlocks.strawberryBush” qui persiste dans le code, malheureusement je ne peu pas le modifier il faudra donc le remplacer manuellement par “MainRegistry.strawberryBush” ou le nom de votre classe principale.
Ps2: Désolé pour toutes les fautes avec bloque et bloques, j’ai plus souvent l’habitude de l’écrire en anglais x)
-
Bloque = verbe bloquer.
bloc = le bloc, celui que tu devrais normalement utiliser x)
Je faisais aussi l’erreur il y a un ou deux ans. -
J’attendrais pas de l’apprendre ^^ Je l’abandonne et puis c’est tout, j’écrirais block maintenant

-
Petit correction à la fonction onBlockHarvested qui doit plus ressembler à ça :
public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) { if (this == MODID.strawberryBush) { spawnAsEntity(world, pos, new ItemStack(Item.getItemFromBlock(MODID.strawberrySimple), 1)); //Ici spécifier le bloc spawnAsEntity(world, pos, new ItemStack(MODID.strawberry, 1 + RANDOM.nextInt(2))); //Drop d'item } }A rajouter aussi la fonction getItemDropped de la classe “Block” par Minecraft :
public Item getItemDropped(IBlockState state, Random rand, int fortune) { if (this == MODID.strawberryBush) { return null; } return Item.getItemFromBlock(this); } -
Si l’on est en 1.7.10 le code change ??
-
Oui, les blockstate n’existaient pas en 1.7 donc le code est différent.
-
Tu pourrais en faire un tuto robin ??
Envoyé de mon 4016X en utilisant Tapatalk
-
Non, je ne ferai plus de tutoriel 1.7. Je me concentre maintenant sur la 1.8 et bientôt 1.9.
-
Le tuto marche en 1.7.10 ou pas ?
Merci !
clement. -
Voilà j’ai voulu le mettre en 1.7.10 tous fonction sauf quand je fait le clique droit dessus sa remais bien le block en mode sans orange mais sa me drop rien
package fr.darkvince.ultrav2.Fruit; import java.util.Random; import fr.darkvince.ultrav2.Main; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.material.Material; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class BlockOrange extends BlockBush { public BlockOrange() { super(Material.plants); this.setStepSound(soundTypeGrass); this.setTickRandomly(true); this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } public boolean canPlaceBlockAt(World world, int x, int y, int z) { return super.canPlaceBlockAt(world, x, y, z) && world.getBlock(x, y - 1, z).canSustainPlant(world, x, y - 1, x, ForgeDirection.UP, this); } protected boolean canPlaceBlockOn(Block ground) { return ground == Blocks.grass || ground == Blocks.dirt || ground == Blocks.farmland; } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { if (this == Main.BlockOrangeBush) { world.setBlock(x, y, z , Main.BlockOrange); dropBerry(world, x, y, x); } return null == null; } protected void dropBerry(World world, int x, int y, int z) { if (this == Main.BlockOrange || this == Main.BlockOrangeBush) { dropBlockAsItem(world, x, y, z, new ItemStack(Main.Orange, 1)); } } protected void makeBerry(World world, int x, int y, int z) { if (this == Main.BlockOrange) { world.setBlock(x, y, z, Main.BlockOrangeBush); } } public void onBlockHarvested(World world,int x, int y, int z, int p_149681_5_, EntityPlayer player) { if (this == Main.BlockOrangeBush) { dropBlockAsItem(world, x, y, z, new ItemStack(Main.BlockOrange, 1)); dropBlockAsItem(world, x, y, z, new ItemStack(Main.Orange, 1)); dropBlockAsItem(world, x, y, z, new ItemStack(Main.BlockOrangeBush, 0)); } } public void updateTick(World world, int x, int y, int z, Random rand) { super.updateTick(world, x, y, z, rand); int i = 1; if (i < 20) { if (rand.nextInt((int)(5.0F) + 1) == 0) { if (this == Main.BlockOrange) { makeBerry(world, x, y, z); } } } } }Désolé mais les espace s’enleve a chaque fois

