Comment crée un arbre 1.8.9
-
Désolé j’avait oublié de précisé l’erreur “The method setBlock(int, int, int, Block) is undefined for the type world”.
Désolé d’avoir oublié de préciser l’erreur.
Cordialement ,
lexmad13009 -
En 1.8 World#setBlock, devient World#setBlockState
Du coup fais plutôt un world.setBlockState(new BlockPos(position.getX(), position.getY() + i, position.getZ()), BlockMod.test.getDefaultState());, pour le premier. -
Merci mais sa me met une erreur “The constructeur BlockPos(int, int, int, iBlockState) is undefined”
sinon j’ai essayer sa “world.setBlockState(position.getX(), position.getY() + i, position.getZ(), BlockMod.test.getDefaultState(), flags);” mais à la place de flags je sais pas quoi mettre -
J’avais oublié une parenthèse, j’ai édité mon message. T’aurais pu le deviner tout de même ^^’
-
Merci et j’avais pas remarqué
-
En flag met 2 ou 3. (2 = update vers le client, 3 = update serveur et client).
-
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