Rendu complexe de bloc via TESR
-
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()); } } -
Et dans ta classe principale tu as bien proxy.registerRenderers(); ?
-
proxy.registerRenderers();
proxy.registerTileEntityRender(); -
Ha, je sais ce qu’il manque :
TESRInventoryRenderer.blockByTESR.put(new TESRIndex(ClassePrincipale.nomDuBloc, metadata), new TonTileEntitySpecialRender());
À mettre dans registerTileEntityRender(). -
proxy.registerTileEntityRender(TESRInventoryRenderer.blockByTESR.put(new TESRIndex(MineralherbMain.coppermineral, metadata), new TileEntityCopperSpecialRender()));erreur a registerTileEntityRender: The method registerTileEntityRender() in the type CommonProxy is not applicable for the arguments (IInventoryRenderer)
à MineralherbMain.coppermineral: Cannot make a static reference to the non-static field MineralherbMain.coppermineral
et à metadata: metadata cannot be resolved to a variable
-
…
@Override public void registerTileEntityRender() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCopper.class, new TileEntityCopperSpecialRender()); }Devient
@Override public void registerTileEntityRender() { ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCopper.class, new TileEntityCopperSpecialRender()); TESRInventoryRenderer.blockByTESR.put(new TESRIndex(MineralherbMain.coppermineral, 0), new TileEntityCopperSpecialRender()); }Et metadata, tu le remplace par le metadata du bloc, donc 0 je suppose.
-
cela ne fait rien le rendu ne se fait toujours pas
