Résolu Problème de texture
-
Bonjour, j’essaye actuellement de créer un bloc qui fonctionnerai comme le bloc de canne à sucre. J’ai donc récupéré le code existant de la canne à sucre. Mais lors du lancement du jeu j’ai quelques erreurs :
[19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=3 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=15 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=2 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=1 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=0 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=11 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=12 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=13 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=14 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=10 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=9 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=8 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=7 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=6 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=5 not found [19:03:23] [Client thread/ERROR] [FML]: Model definition for location scmod:bamboo_plant#age=4 not found
Je pense que ça vient des différentes state qui varient en fonction de l’age mais je ne vois pas comment régler ce problème…
Merci d’avance pour vos réponses.
-
Envoie ton code pour voir
-
Comme je l’ai dit, c’est principalement le code du BlockReed existant dans le jeu, j’ai juste modifié quelques trucs.
package fr.scrollcraft.scmod.block; import java.util.Iterator; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumWorldBlockLayer; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BambooPlant extends Block implements net.minecraftforge.common.IPlantable { public static final PropertyInteger AGE = PropertyInteger.create("age", 0, 15); private static final String __OBFID = "CL_00000300"; public BambooPlant() { super(Material.plants); this.setDefaultState(this.blockState.getBaseState().withProperty(AGE, Integer.valueOf(0))); float f = 0.375F; this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 1.0F, 0.5F + f); this.setTickRandomly(true); this.setUnlocalizedName("bamboo_plant"); this.setHardness(0.0F); this.setStepSound(soundTypeGrass); this.setCreativeTab(CreativeTabs.tabBlock); this.disableStats(); } public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if (worldIn.getBlockState(pos.down()).getBlock() == Blocks.reeds || this.checkForDrop(worldIn, pos, state)) { if (worldIn.isAirBlock(pos.up())) { int i; for (i = 1; worldIn.getBlockState(pos.down(i)).getBlock() == this; ++i) { ; } if (i < 3) { int j = ((Integer)state.getValue(AGE)).intValue(); if (j == 15) { worldIn.setBlockState(pos.up(), this.getDefaultState()); worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(0)), 4); } else { worldIn.setBlockState(pos, state.withProperty(AGE, Integer.valueOf(j + 1)), 4); } } } } } public boolean canPlaceBlockAt(World worldIn, BlockPos pos) { Block block = worldIn.getBlockState(pos.down()).getBlock(); if (block.canSustainPlant(worldIn, pos.down(), EnumFacing.UP, this)) return true; if (block == this) { return true; } else if (block != Blocks.grass && block != Blocks.dirt && block != Blocks.sand) { return false; } else { Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator(); EnumFacing enumfacing; if (!iterator.hasNext()) { return false; } enumfacing = (EnumFacing)iterator.next(); return true; } } /** * Called when a neighboring block changes. */ public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { this.checkForDrop(worldIn, pos, state); } protected final boolean checkForDrop(World worldIn, BlockPos p_176353_2_, IBlockState state) { if (this.canBlockStay(worldIn, p_176353_2_)) { return true; } else { this.dropBlockAsItem(worldIn, p_176353_2_, state, 0); worldIn.setBlockToAir(p_176353_2_); return false; } } public boolean canBlockStay(World worldIn, BlockPos pos) { return this.canPlaceBlockAt(worldIn, pos); } public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) { return null; } /** * Get the Item that this Block should drop when harvested. * * @param fortune the level of the Fortune enchantment on the player's tool */ public Item getItemDropped(IBlockState state, Random rand, int fortune) { return Items.reeds; } public boolean isOpaqueCube() { return false; } public boolean isFullCube() { return false; } @SideOnly(Side.CLIENT) public Item getItem(World worldIn, BlockPos pos) { return Items.reeds; } @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) { return worldIn.getBiomeGenForCoords(pos).getGrassColorAtPos(pos); } /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(AGE, Integer.valueOf(meta)); } @SideOnly(Side.CLIENT) public EnumWorldBlockLayer getBlockLayer() { return EnumWorldBlockLayer.CUTOUT; } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((Integer)state.getValue(AGE)).intValue(); } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] {AGE}); } @Override public net.minecraftforge.common.EnumPlantType getPlantType(IBlockAccess world, BlockPos pos) { return net.minecraftforge.common.EnumPlantType.Beach; } @Override public IBlockState getPlant(IBlockAccess world, BlockPos pos) { return this.getDefaultState(); }
-
Envoi les blockstate surtout.
-
Déjà, enlève le OBFID_, il ne sert à rien ^^
Et le bug vient des fichiers de models qui ne sont pas trouvés, donne nous le code où tu enregistres les textures.
PS: Je n’ai pas vu ton message SCAREX.
-
Le blockstate :
{ "variants": { "normal": { "model": "scmod:bamboo_plant" } } }
L’enregistrement des textures :
proxy.registerBlockTexture(bambooPlant, "bamboo_plant");
Je précise que j’utilise forge depuis 1 semaine donc il se peut que l’erreur soit très conne…
-
dans les variantes, il me semble qu’il faut mettre chaque métadata.
-
Une idée du nom qu’elles devraient avoir ?
J’ai testé avec age=0 , age=1, etc… à la place de “normal”, j’ai également testé avec 0, 1, 2, etc…
Aucun ne marche pour le moment…
-
{ "variants": { "age=0": { "model": "scmod:bamboo_plant" }, "age=1": { "model": "scmod:bamboo_plant" }, "age=2": { "model": "scmod:bamboo_plant" } } }
Pourtant c’est bien comme ça qu’il faut faire.
-
J’ai réessayé comme ça :
{ "variants": { "age=0": { "model": "scmod:bamboo_plant" }, "age=1": { "model": "scmod:bamboo_plant" }, "age=2": { "model": "scmod:bamboo_plant" } "age=3": { "model": "scmod:bamboo_plant" } "age=4": { "model": "scmod:bamboo_plant" } "age=5": { "model": "scmod:bamboo_plant" } "age=6": { "model": "scmod:bamboo_plant" } "age=7": { "model": "scmod:bamboo_plant" } "age=8": { "model": "scmod:bamboo_plant" } "age=9": { "model": "scmod:bamboo_plant" } "age=10": { "model": "scmod:bamboo_plant" } "age=11": { "model": "scmod:bamboo_plant" } "age=12": { "model": "scmod:bamboo_plant" } "age=13": { "model": "scmod:bamboo_plant" } "age=14": { "model": "scmod:bamboo_plant" } "age=15": { "model": "scmod:bamboo_plant" } } }
La texture ne s’affiche toujours pas et j’ai quelques erreurs dans la console :
(Désolé pour le pastebin, mais le forum m’empêchait de poster un message trop long.)
-
Ton json est erroné. Il manque pleins de virgule. Toutes les lignes devrait en avoir une sauf la dernière.
http://jsonlint.com/ -
En effet, merci.
Tout marche bien maintenant, merci à vous !