Comment crée un arbre 1.8.9
-
Bonjour je voudrait sa voir comment fair que si on à des int x y z comment on peut le regrouper en position
-
En BlockPos ? C’est une mauvaise idée pour la mémoire mais sinon tu peux faire new BlockPos(x, y, z)
-
Est que qu’elle qu’un peut me donner un exemple car je n’y arrive pas et ne comprend pas
-
Un exemple de quoi ?
-
Pour faire un arbre et le généré
-
J’ai réussi à avoir un résultat plus ou moins convenable en copiant les classes de minecraft et du tutoriel :
public class TreeGenerator implements IWorldGenerator { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (world.provider.getDimensionId() == 0) { int x = chunkX * 16; int z = chunkZ * 16; int x1 = x + random.nextInt(16); int y1 = random.nextInt(128); int z1 = z + random.nextInt(16); for (int i = 0; i < 100; i++) { (new TreeStructure(true)).generate(world, random, new BlockPos(x1, y1, z1)); } } } }public class TreeStructure extends WorldGenAbstractTree { private final int minTreeHeight; private final boolean vinesGrow; private final int metaWood; private final int metaLeaves; private static final String __OBFID = "CL_00000438"; public TreeStructure(boolean p_i2027_1_) { this(p_i2027_1_, 4, 0, 0, false); } public TreeStructure(boolean p_i2028_1_, int p_i2028_2_, int p_i2028_3_, int p_i2028_4_, boolean p_i2028_5_) { super(p_i2028_1_); this.minTreeHeight = p_i2028_2_; this.metaWood = p_i2028_3_; this.metaLeaves = p_i2028_4_; this.vinesGrow = p_i2028_5_; } public boolean generate(World worldIn, Random p_180709_2_, BlockPos p_180709_3_) { int i = p_180709_2_.nextInt(3) + this.minTreeHeight; boolean flag = true; if (p_180709_3_.getY() >= 1 && p_180709_3_.getY() + i + 1 <= 256) { byte b0; int l; for (int j = p_180709_3_.getY(); j <= p_180709_3_.getY() + 1 + i; ++j) { b0 = 1; if (j == p_180709_3_.getY()) { b0 = 0; } if (j >= p_180709_3_.getY() + 1 + i - 2) { b0 = 2; } for (int k = p_180709_3_.getX() - b0; k <= p_180709_3_.getX() + b0 && flag; ++k) { for (l = p_180709_3_.getZ() - b0; l <= p_180709_3_.getZ() + b0 && flag; ++l) { if (j >= 0 && j < 256) { if (!this.isReplaceable(worldIn, new BlockPos(k, j, l))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { BlockPos down = p_180709_3_.down(); Block block1 = worldIn.getBlockState(down).getBlock(); boolean isSoil = block1.canSustainPlant(worldIn, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling) Blocks.sapling); if (isSoil && p_180709_3_.getY() < 256 - i - 1) { block1.onPlantGrow(worldIn, down, p_180709_3_); b0 = 3; byte b1 = 0; int i1; int j1; int k1; int l1; BlockPos blockpos1; for (l = p_180709_3_.getY() - b0 + i; l <= p_180709_3_.getY() + i; ++l) { i1 = l - (p_180709_3_.getY() + i); j1 = b1 + 1 - i1 / 2; for (k1 = p_180709_3_.getX() - j1; k1 <= p_180709_3_.getX() + j1; ++k1) { l1 = k1 - p_180709_3_.getX(); for (int i2 = p_180709_3_.getZ() - j1; i2 <= p_180709_3_.getZ() + j1; ++i2) { int j2 = i2 - p_180709_3_.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || p_180709_2_.nextInt(2) != 0 && i1 != 0) { blockpos1 = new BlockPos(k1, l, i2); Block block = worldIn.getBlockState(blockpos1).getBlock(); if (block.isAir(worldIn, blockpos1) || block.isLeaves(worldIn, blockpos1) || block.getMaterial() == Material.vine) { this.func_175905_a(worldIn, blockpos1, Blocks.gold_block, this.metaLeaves); } } } } } for (l = 0; l < i; ++l) { BlockPos upN = p_180709_3_.up(l); Block block2 = worldIn.getBlockState(upN).getBlock(); if (block2.isAir(worldIn, upN) || block2.isLeaves(worldIn, upN) || block2.getMaterial() == Material.vine) { this.func_175905_a(worldIn, p_180709_3_.up(l), Blocks.diamond_block, this.metaWood); if (this.vinesGrow && l > 0) { if (p_180709_2_.nextInt(3) > 0 && worldIn.isAirBlock(p_180709_3_.add(-1, l, 0))) { this.func_175905_a(worldIn, p_180709_3_.add(-1, l, 0), Blocks.vine, BlockVine.EAST_FLAG); } if (p_180709_2_.nextInt(3) > 0 && worldIn.isAirBlock(p_180709_3_.add(1, l, 0))) { this.func_175905_a(worldIn, p_180709_3_.add(1, l, 0), Blocks.vine, BlockVine.WEST_FLAG); } if (p_180709_2_.nextInt(3) > 0 && worldIn.isAirBlock(p_180709_3_.add(0, l, -1))) { this.func_175905_a(worldIn, p_180709_3_.add(0, l, -1), Blocks.vine, BlockVine.SOUTH_FLAG); } if (p_180709_2_.nextInt(3) > 0 && worldIn.isAirBlock(p_180709_3_.add(0, l, 1))) { this.func_175905_a(worldIn, p_180709_3_.add(0, l, 1), Blocks.vine, BlockVine.NORTH_FLAG); } } } } if (this.vinesGrow) { for (l = p_180709_3_.getY() - 3 + i; l <= p_180709_3_.getY() + i; ++l) { i1 = l - (p_180709_3_.getY() + i); j1 = 2 - i1 / 2; for (k1 = p_180709_3_.getX() - j1; k1 <= p_180709_3_.getX() + j1; ++k1) { for (l1 = p_180709_3_.getZ() - j1; l1 <= p_180709_3_.getZ() + j1; ++l1) { BlockPos blockpos3 = new BlockPos(k1, l, l1); if (worldIn.getBlockState(blockpos3).getBlock().isLeaves(worldIn, blockpos3)) { BlockPos blockpos4 = blockpos3.west(); blockpos1 = blockpos3.east(); BlockPos blockpos5 = blockpos3.north(); BlockPos blockpos2 = blockpos3.south(); if (p_180709_2_.nextInt(4) == 0 && worldIn.getBlockState(blockpos4).getBlock().isAir(worldIn, blockpos4)) { this.func_175923_a(worldIn, blockpos4, BlockVine.EAST_FLAG); } if (p_180709_2_.nextInt(4) == 0 && worldIn.getBlockState(blockpos1).getBlock().isAir(worldIn, blockpos1)) { this.func_175923_a(worldIn, blockpos1, BlockVine.WEST_FLAG); } if (p_180709_2_.nextInt(4) == 0 && worldIn.getBlockState(blockpos5).getBlock().isAir(worldIn, blockpos5)) { this.func_175923_a(worldIn, blockpos5, BlockVine.SOUTH_FLAG); } if (p_180709_2_.nextInt(4) == 0 && worldIn.getBlockState(blockpos2).getBlock().isAir(worldIn, blockpos2)) { this.func_175923_a(worldIn, blockpos2, BlockVine.NORTH_FLAG); } } } } } if (p_180709_2_.nextInt(5) == 0 && i > 5) { for (l = 0; l < 2; ++l) { for (i1 = 0; i1 < 4; ++i1) { if (p_180709_2_.nextInt(4 - l) == 0) { j1 = p_180709_2_.nextInt(3); EnumFacing enumfacing = EnumFacing.getHorizontal(i1).getOpposite(); this.func_175905_a(worldIn, p_180709_3_.add(enumfacing.getFrontOffsetX(), i - 5 + l, enumfacing.getFrontOffsetZ()), Blocks.cocoa, j1 << 2 | EnumFacing.getHorizontal(i1).getHorizontalIndex()); } } } } } return true; } else { return false; } } } else { return false; } } private void func_175923_a(World worldIn, BlockPos p_175923_2_, int p_175923_3_) { this.func_175905_a(worldIn, p_175923_2_, Blocks.vine, p_175923_3_); int j = 4; for (p_175923_2_ = p_175923_2_.down(); worldIn.getBlockState(p_175923_2_).getBlock().isAir(worldIn, p_175923_2_) && j > 0; –j) { this.func_175905_a(worldIn, p_175923_2_, Blocks.vine, p_175923_3_); p_175923_2_ = p_175923_2_.down(); } } } -
Aux niveaux du “public class TreeGenerator implements IWorldGenerator” c’est pas plutot “public class TreeGenerator implements WorldGenerator”
car moi sa me fait une erreur “IWorldGenerator cannot be resolved to a type” -
Essaie d’importer car chez moi ça existe, c’est la classe qui est enregistrée dans le GameRegistry
-
Non cbon c’est juste que la libréries forgesrc était plus la mais je les récup___Juste un dernier problème il me demande de créer la mathode “func_175905_a” et les flag “EAST_FLAG” ect me font ce porblème “EAST_FLAGcannot be resolved or is not a field”
-
les noms sont peut être différents selon les mappings, est-ce que tu veux que je trouves les noms ?
-
Oui et merci si tu les trouve
-
Il me faut le numéro de tes mappings
-
C’est la Stable 22 normalement

-
Les logiciels ne trouvent pas donc soit tu ne la vois pas, soit le code a changé depuis la 1.8
-
Je sais pas :(___J’ai vue que dans le code source de l’arbre il créer plus que 1 fonction a la fin sa vient pas des la ?
-
hein ? Au pire tout le code que j’ai pris vient de minecraft donc tu l’as
PS : attention aux doubles posts
-
Oui mais comment je fait pour changer le Block car sinnon c’est le oak
-
Tu remplaces tous les Blocks.oak… par ta buche, de même pour les feuilles
-
il y en as pas regarde le class
package net.minecraft.world.gen.feature; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockCocoa; import net.minecraft.block.BlockLeaves; import net.minecraft.block.BlockOldLeaf; import net.minecraft.block.BlockOldLog; import net.minecraft.block.BlockPlanks; import net.minecraft.block.BlockVine; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.state.IBlockState; import net.minecraft.init.Blocks; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; public class WorldGenTrees extends WorldGenAbstractTree { private static final IBlockState field_181653_a = Blocks.log.getDefaultState().withProperty(BlockOldLog.VARIANT, BlockPlanks.EnumType.OAK); private static final IBlockState field_181654_b = Blocks.leaves.getDefaultState().withProperty(BlockOldLeaf.VARIANT, BlockPlanks.EnumType.OAK).withProperty(BlockLeaves.CHECK_DECAY, Boolean.valueOf(false)); /** The minimum height of a generated tree. */ private final int minTreeHeight; /** True if this tree should grow Vines. */ private final boolean vinesGrow; /** The metadata value of the wood to use in tree generation. */ private final IBlockState metaWood; /** The metadata value of the leaves to use in tree generation. */ private final IBlockState metaLeaves; public WorldGenTrees(boolean p_i2027_1_) { this(p_i2027_1_, 4, field_181653_a, field_181654_b, false); } public WorldGenTrees(boolean p_i46446_1_, int p_i46446_2_, IBlockState p_i46446_3_, IBlockState p_i46446_4_, boolean p_i46446_5_) { super(p_i46446_1_); this.minTreeHeight = p_i46446_2_; this.metaWood = p_i46446_3_; this.metaLeaves = p_i46446_4_; this.vinesGrow = p_i46446_5_; } public boolean generate(World worldIn, Random rand, BlockPos position) { int i = rand.nextInt(3) + this.minTreeHeight; boolean flag = true; if (position.getY() >= 1 && position.getY() + i + 1 <= 256) { for (int j = position.getY(); j <= position.getY() + 1 + i; ++j) { int k = 1; if (j == position.getY()) { k = 0; } if (j >= position.getY() + 1 + i - 2) { k = 2; } BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); for (int l = position.getX() - k; l <= position.getX() + k && flag; ++l) { for (int i1 = position.getZ() - k; i1 <= position.getZ() + k && flag; ++i1) { if (j >= 0 && j < 256) { if (!this.isReplaceable(worldIn,blockpos$mutableblockpos.set(l, j, i1))) { flag = false; } } else { flag = false; } } } } if (!flag) { return false; } else { BlockPos down = position.down(); Block block1 = worldIn.getBlockState(down).getBlock(); boolean isSoil = block1.canSustainPlant(worldIn, down, net.minecraft.util.EnumFacing.UP, (net.minecraft.block.BlockSapling)Blocks.sapling); if (isSoil && position.getY() < 256 - i - 1) { block1.onPlantGrow(worldIn, down, position); int k2 = 3; int l2 = 0; for (int i3 = position.getY() - k2 + i; i3 <= position.getY() + i; ++i3) { int i4 = i3 - (position.getY() + i); int j1 = l2 + 1 - i4 / 2; for (int k1 = position.getX() - j1; k1 <= position.getX() + j1; ++k1) { int l1 = k1 - position.getX(); for (int i2 = position.getZ() - j1; i2 <= position.getZ() + j1; ++i2) { int j2 = i2 - position.getZ(); if (Math.abs(l1) != j1 || Math.abs(j2) != j1 || rand.nextInt(2) != 0 && i4 != 0) { BlockPos blockpos = new BlockPos(k1, i3, i2); Block block = worldIn.getBlockState(blockpos).getBlock(); if (block.isAir(worldIn, blockpos) || block.isLeaves(worldIn, blockpos) || block.getMaterial() == Material.vine) { this.setBlockAndNotifyAdequately(worldIn, blockpos, this.metaLeaves); } } } } } for (int j3 = 0; j3 < i; ++j3) { BlockPos upN = position.up(j3); Block block2 = worldIn.getBlockState(upN).getBlock(); if (block2.isAir(worldIn, upN) || block2.isLeaves(worldIn, upN) || block2.getMaterial() == Material.vine) { this.setBlockAndNotifyAdequately(worldIn, position.up(j3), this.metaWood); if (this.vinesGrow && j3 > 0) { if (rand.nextInt(3) > 0 && worldIn.isAirBlock(position.add(-1, j3, 0))) { this.func_181651_a(worldIn, position.add(-1, j3, 0), BlockVine.EAST); } if (rand.nextInt(3) > 0 && worldIn.isAirBlock(position.add(1, j3, 0))) { this.func_181651_a(worldIn, position.add(1, j3, 0), BlockVine.WEST); } if (rand.nextInt(3) > 0 && worldIn.isAirBlock(position.add(0, j3, -1))) { this.func_181651_a(worldIn, position.add(0, j3, -1), BlockVine.SOUTH); } if (rand.nextInt(3) > 0 && worldIn.isAirBlock(position.add(0, j3, 1))) { this.func_181651_a(worldIn, position.add(0, j3, 1), BlockVine.NORTH); } } } } if (this.vinesGrow) { for (int k3 = position.getY() - 3 + i; k3 <= position.getY() + i; ++k3) { int j4 = k3 - (position.getY() + i); int k4 = 2 - j4 / 2; BlockPos.MutableBlockPos blockpos$mutableblockpos1 = new BlockPos.MutableBlockPos(); for (int l4 = position.getX() - k4; l4 <= position.getX() + k4; ++l4) { for (int i5 = position.getZ() - k4; i5 <= position.getZ() + k4; ++i5) { blockpos$mutableblockpos1.set(l4, k3, i5); if (worldIn.getBlockState(blockpos$mutableblockpos1).getBlock().isLeaves(worldIn,blockpos$mutableblockpos1)) { BlockPos blockpos2 = blockpos$mutableblockpos1.west(); BlockPos blockpos3 = blockpos$mutableblockpos1.east(); BlockPos blockpos4 = blockpos$mutableblockpos1.north(); BlockPos blockpos1 = blockpos$mutableblockpos1.south(); if (rand.nextInt(4) == 0 && worldIn.getBlockState(blockpos2).getBlock().isAir(worldIn,blockpos2)) { this.func_181650_b(worldIn, blockpos2, BlockVine.EAST); } if (rand.nextInt(4) == 0 && worldIn.getBlockState(blockpos3).getBlock().isAir(worldIn,blockpos3)) { this.func_181650_b(worldIn, blockpos3, BlockVine.WEST); } if (rand.nextInt(4) == 0 && worldIn.getBlockState(blockpos4).getBlock().isAir(worldIn,blockpos4)) { this.func_181650_b(worldIn, blockpos4, BlockVine.SOUTH); } if (rand.nextInt(4) == 0 && worldIn.getBlockState(blockpos1).getBlock().isAir(worldIn,blockpos1)) { this.func_181650_b(worldIn, blockpos1, BlockVine.NORTH); } } } } } if (rand.nextInt(5) == 0 && i > 5) { for (int l3 = 0; l3 < 2; ++l3) { for (EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL) { if (rand.nextInt(4 - l3) == 0) { EnumFacing enumfacing1 = enumfacing.getOpposite(); this.func_181652_a(worldIn, rand.nextInt(3), position.add(enumfacing1.getFrontOffsetX(), i - 5 + l3, enumfacing1.getFrontOffsetZ()), enumfacing); } } } } } return true; } else { return false; } } } else { return false; } } private void func_181652_a(World p_181652_1_, int p_181652_2_, BlockPos p_181652_3_, EnumFacing p_181652_4_) { this.setBlockAndNotifyAdequately(p_181652_1_, p_181652_3_, Blocks.cocoa.getDefaultState().withProperty(BlockCocoa.AGE, Integer.valueOf(p_181652_2_)).withProperty(BlockCocoa.FACING, p_181652_4_)); } private void func_181651_a(World p_181651_1_, BlockPos p_181651_2_, PropertyBool p_181651_3_) { this.setBlockAndNotifyAdequately(p_181651_1_, p_181651_2_, Blocks.vine.getDefaultState().withProperty(p_181651_3_, Boolean.valueOf(true))); } private void func_181650_b(World p_181650_1_, BlockPos p_181650_2_, PropertyBool p_181650_3_) { this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); int i = 4; for (p_181650_2_ = p_181650_2_.down(); p_181650_1_.getBlockState(p_181650_2_).getBlock().isAir(p_181650_1_,p_181650_2_) && i > 0; –i) { this.func_181651_a(p_181650_1_, p_181650_2_, p_181650_3_); p_181650_2_ = p_181650_2_.down(); } } } -
Ah oui, il faut modifier un peu le code car Minecraft place la sapling et ensuite fait pousser l’arbre donc soit tu adaptes le code soit tu récupères celui utilisé dans le tuto
Bonjour ! Vous semblez intéressé par cette conversation, mais vous n’avez pas encore de compte.
Marre de refaire défiler les mêmes messages ? Créez un compte pour retrouver votre position, recevoir des notifications des nouvelles réponses, sauvegarder vos favoris et voter pour les messages que vous appréciez.
Grâce à votre participation, ce message peut devenir encore meilleur 💗
S'inscrire Se connecter