Rendu complexe de bloc via TESR
-
J’ai un nullPointerException au moment de lancer le jeu, juste après avoir fait les rendus de l’inventaire. J’ai pourtant suivi à la lettre le tuto :huh:
J’ai mis mon crash report en pièce jointe.
-
Envoi tes class TESRInventoryRenderer, ClientProxy, Mod_FearZ.
-
voila mon client proxy
(je ne peut mettre qu’une seul pièce jointe par message. j’envoie les deux autres à la suite)___
Mon mod_FearZ___
et mon TESEInventoryRender -
N’envoie pas tes class en pièce joint, met ton code dans des balises [java][/java] sans les *.
-
Ok, désolé.
Mod_FearZ.java
package _fearZ.mod; import org.lwjgl.util.glu.Registry; import net.minecraft.block.Block; import net.minecraft.block.BlockChest; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import _fearZ.mod.common.CommonProxy; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.Mod.PreInit; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; @Mod(modid = "fearz", name = "FearZ", version = "1.0.0") @NetworkMod(clientSideRequired = true, serverSideRequired = true) public class Mod_FearZ { @Instance("FearZMod") public static Mod_FearZ modInstance; @SidedProxy(clientSide="_fearZ.mod.client.ClientProxy", serverSide="_fearZ.mod.common.CommonProxy") public static CommonProxy proxy; /**blocks*/ public static Block armoirePh; /**Items*/ /**Creative Tabs*/ public static final CreativeTabs onglet = new OngletCreatif(CreativeTabs.getNextID(), "FearZ"); @EventHandler public void PreInit(FMLPreInitializationEvent event) { /**Blocks*/ Block armoirePh = new BlockPharmacie (1800).setBlockUnbreakable().setHardness(10000f).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("ArmoirePharmacie"); GameRegistry.registerBlock(armoirePh, "armoirePh"); } @EventHandler public void Init(FMLInitializationEvent event) { /**Mobs*/ /**Render*/ proxy.registerRender(); proxy.registerTileEntityRender(); /**NetWork*/ /**Recipes*/ /**TileEntityRegistry*/ GameRegistry.registerTileEntity(TileEntityArmoirePh.class, "pharmacie"); } @EventHandler public void PostInit(FMLPostInitializationEvent event) { /**Integration avec les autres mods*/ } }ClientProxy.java
package _fearZ.mod.client; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import _fearZ.mod.Mod_FearZ; import _fearZ.mod.TileEntityArmoirePh; import _fearZ.mod.client.TESRInventoryRenderer.TESRIndex; import _fearZ.mod.common.CommonProxy; public class ClientProxy extends CommonProxy { public static int renderInventoryTESRId; @Override public void registerRender() { renderInventoryTESRId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); } @Override public void registerTileEntityRender() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmoirePh.class, new TileEntityArmoirePhSpecialRender()); TESRInventoryRenderer.blockByTESR.put(new TESRIndex(Mod_FearZ.armoirePh, 0), new TileEntityArmoirePhSpecialRender()); } }TESRInventoryRenderer
package _fearZ.mod.client; import java.util.HashMap; import _fearZ.mod.IInventoryRenderer; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class TESRInventoryRenderer implements ISimpleBlockRenderingHandler { public static class TESRIndex { Block block; int metadata; public TESRIndex (Block block, int metadata) { this.block = block; this.metadata = metadata; } @Override public int hashCode() { return block.hashCode() + metadata; } @Override public boolean equals(Object o) { if (!(o instanceof TESRIndex)) { return false; } TESRIndex tesr = (TESRIndex)o; return tesr.block == block && tesr.metadata == metadata; } } public static HashMap <tesrindex, iinventoryrenderer="">blockByTESR = new HashMap <tesrindex, iinventoryrenderer="">(); @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { TESRIndex index = new TESRIndex(block, metadata); if(blockByTESR.containsKey(index)) { blockByTESR.get(index).renderInventory(-0.5, -0.5, -0.5); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return true; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { return ClientProxy.renderInventoryTESRId; } } ```</tesrindex,></tesrindex,> -
Change ton implementation :
public class TESRInventoryRenderer implements ISimpleBlockRenderingHandlerpar
public class TESRInventoryRenderer extends TileEntitySpecialRenderer implements IInventoryRendererEDIT: J’ai rien dis
-
Je me disais aussi qu’avec le nombre d’erreurs qu’il m’affichait en faisant ça, ça marcherais pas. ^^
-
/**blocks*/ public static Block armoirePh; […] @EventHandler public void PreInit(FMLPreInitializationEvent event) { /**Blocks*/ /*Block*/ armoirePh = new BlockPharmacie (1800).setBlockUnbreakable().setHardness(10000f).setStepSound(Block.soundMetalFootstep).setUnlocalizedName("ArmoirePharmacie"); GameRegistry.registerBlock(armoirePh, "armoirePh"); }Ici tu as déclaré dans ta classe une variable du type Block nommé armoirePh. Plus bas, dans la méthode preInit, tu as créer une variable local nommé armoirePh et tu l’a initialisé.
Donc la variable de la classe reste null, d’où ton nullPointerException.
Il faut donc que tu enlève le Block que j’ai mit en commentaire. -
Merci, ça marche nickel. Je n’avais en effet pas du tout fais attention à ça

-
bonjour a tous
j’ai le meme probleme, a savoir un bloc fait sous techne qui ne s’affiche pas, je suppose que j’ai un probleme de rendu/texture, ça fait plusieurs tuto que je fais avec le meme résultat. En fait le bloc existe mais il est transparent !
-
Sans tes class, on ne peut pas savoir d’où vient le problème.
-
Bonjour, j’ai encore un problème sur mon animation, serait-il possible de faire des animation de type translation plutot que des rotations ?
-
Pour les questions concernant les animations, merci de poster dans ce poste :
http://www.minecraftforgefrance.fr/showthread.php?tid=375Et oui, c’est possible, il te suffit de faire une méthode dans ton modèle qui ne rend que le morceaux que tu veux déplacer :
public void renderMorceauxVoulu(float f) { nomDuMorceau.render(f); }et tu retire le morceau de la méthode render(float f)
Ensuite dans ton tile entity spécial render, tu refais un Gl11.pull();, tu rends ce morceau, et tu le déplace avec Gl11.translatef(x, y, z); et tu refais un Gl11.push();
-
je n’est pas bien compris comment faire pour le rendu dans l’inventaire
-
Mets juste :
@Override public void renderInventory(double x, double y, double z) { this.renderTileEntitySculptureAt(null, x, y, z, 0.0F); }Et c’est bon, il va faire la même chose que pour le rendu sur le monde.
-
@Override public void renderInventory(double x, double y, double z) { // TODO Auto-generated method stub this.renderTileEntityCopperAt(null, x, y, z, 0.0F); }dans TileEntityCopperSpecialRender
mais cela ne fait rien -
Le rendu sur le monde se fait bien ? Si non, tu as un problème dans la méthode renderTileEntityCopperAt.
Si oui, tu as loupé quelque chose au niveau du TESRInventoryRenderer. -
TESRInventoryRenderer:
package Mineralherb; import java.util.HashMap; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import Mineralherb.client.IInventoryRenderer; public class TESRInventoryRenderer implements ISimpleBlockRenderingHandler { public static class TESRIndex { Block block; int metadata; public TESRIndex(Block block, int metadata) { this.block = block; this.metadata = metadata; } @Override public int hashCode() { return block.hashCode() + metadata; } @Override public boolean equals(Object o) { if(!(o instanceof TESRIndex)) return false; TESRIndex tesr = (TESRIndex)o; return tesr.block == block && tesr.metadata == metadata; } } public static HashMap <tesrindex, iinventoryrenderer="">blockByTESR = new HashMap<tesrindex, iinventoryrenderer="">(); public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return true; } public boolean shouldRender3DInInventory() { return true; } public int getRenderId() { return ClientProxy.renderInventoryTESRId; } @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { // TODO Auto-generated method stub } }TileEntityCopperSpecialRender:
package Mineralherb; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import Mineralherb.Blocks.ModelCoppermineral; import Mineralherb.Blocks.TileEntityCopper; import Mineralherb.client.IInventoryRenderer; public class TileEntityCopperSpecialRender extends TileEntitySpecialRenderer implements IInventoryRenderer { private final ModelCoppermineral model = new ModelCoppermineral(); public static final ResourceLocation textureLocation = new ResourceLocation("mineralherb", "textures/blocks/coppermineral.png"); public TileEntityCopperSpecialRender() { this.setTileEntityRenderer(TileEntityRenderer.instance); } public void renderTileEntityCopperAt(TileEntityCopper te, double x, double y, double z, float tick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5F, y + 1.5F, z + 0.5F); this.bindTexture(textureLocation); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); this.model.render(0.0625F); GL11.glPopMatrix(); } @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float tick) { // TODO Auto-generated method stub this.renderTileEntityCopperAt((TileEntityCopper)te, x, y, z, tick); } @Override public void renderInventory(double x, double y, double z) { // TODO Auto-generated method stub this.renderTileEntityCopperAt(null, x, y, z, 0.0F); } } ```</tesrindex,></tesrindex,> -
Je voudrais corriger la boite de collision de mon rendu TESR, j’ai cherché mais franchement je ne voit pas vraiment de quel méthode cela peut venir…
Il s’affiche bien mais vu que c’est un gros rendu, on peut traverser le block… Qui n’est pas du tout pratique.
@isador34 Ta bien rajouté “public int getRenderType()” dans la class de ton block ?
-
oui:
@SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.renderInventoryTESRId; }mon clientproxy:
package Mineralherb; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; import Mineralherb.Blocks.TileEntityCopper; public class ClientProxy extends CommonProxy{ public static int renderInventoryTESRId; @Override public void registerRenderers(){ //Ici les futurs registrys renderInventoryTESRId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); } @Override public void registerTileEntityRender() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCopper.class, new TileEntityCopperSpecialRender()); } }
