Résolu Lampes redstone colorées, problème textures
-
Bonjour à tous,
J’essaye de créer des lampes de redstone colorées pour les ajouter sur mon serveur. Tout va bien, la lampe marche et fait de la lumière quand elle est alimentée, mais j’ai un problème de textures. Les textures ne fonctionnent pas de la même manière sous forge et je ne sais pas comment adapter le code.Voici la déclaration de mon bloc dans la class principale de mon mod:
redstoneLampBlueIdle = (new BlockRedstoneBlueLight(175, false)).setHardness(0.3F).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("redstoneBlueLight_lit").setTextureName("rm:redstonebluelight").setCreativeTab(CreativeTabs.tabRedstone); redstoneLampBlueActive = (new BlockRedstoneBlueLight(176, true)).setHardness(0.3F).setStepSound(Block.soundGlassFootstep).setUnlocalizedName("redstoneBlueLight").setTextureName("rm:redstonebluelight").setCreativeTab(CreativeTabs.tabRedstone);
Voici le code de ma lampe customisée:
package monMod; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.BlockRedstoneLight; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.world.World; public class BlockRedstoneBlueLight extends Block { /** Whether this lamp block is the powered version. */ private final boolean powered; public BlockRedstoneBlueLight(int par1, boolean par2) { super(par1, Material.redstoneLight); this.powered = par2; if (par2) { this.setLightValue(1.0F); } } /** * When this method is called, your block should register all the icons it needs with the given IconRegister. This * is the only chance you get to register icons. */ public void registerIcons(IconRegister par1IconRegister) { if (this.powered) { this.blockIcon = par1IconRegister.registerIcon("redstonebluelight"); } else { this.blockIcon = par1IconRegister.registerIcon("redstonebluelight_lit"); } } /** * Called whenever the block is added into the world. Args: world, x, y, z */ public void onBlockAdded(World par1World, int par2, int par3, int par4) { if (!par1World.isRemote) { if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4); } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlock(par2, par3, par4, ZexxionMod.redstoneLampBlueActive.blockID, 0, 2); } } } /** * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * their own) Args: x, y, z, neighbor blockID */ public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) { if (!par1World.isRemote) { if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4); } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlock(par2, par3, par4, ZexxionMod.redstoneLampBlueActive.blockID, 0, 2); } } } /** * Ticks the block if it's been scheduled */ public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) { if (!par1World.isRemote && this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) { par1World.setBlock(par2, par3, par4, ZexxionMod.redstoneLampBlueIdle.blockID, 0, 2); } } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return ZexxionMod.redstoneLampBlueIdle.blockID; } /** * only called by clickMiddleMouseButton , and passed to inventory.setCurrentItem (along with isCreative) */ public int idPicked(World par1World, int par2, int par3, int par4) { return ZexxionMod.redstoneLampBlueIdle.blockID; } }
Que dois-je changer pour qu’il m’affiche correctement la texture ?
Merci d’avance. -
Dans tes registers icons, c’est comme pour les getTextureName, soit “modID:nomdelatexture”.
Ensuite, tes textures sont bien dans assets/modID/textures/blocks ?
-
Non mais en fait c’est tout con, j’ai oublié le ModId:
Merci à toi, j’ai honte x). -
No soucis, les oublies tout bêtes ça arrive… Et ce sont elles qui nous font le plus réfléchir a savoir ce qu’il cloche xD.
PS : N’oublie pas de passé ton Message en résolu
-
Comment fait-on ? :$
EDIT: J’ai trouvé