Diverses Questions
-
Le problème que tu as est sur le rendu dans l’inventaire, lorsque le rendu dans l’inventaire est fait l’objet tile est null, il faut donc prévoir le coup. Ou alors séparer le rendu dans le monde et celui dans l’inventaire.
Ce n’est pas du tout par la fonction onNeighborChange qu’il faut passer.
-
Tu peux m’aider ou pas ? Je t’avoues ne pas avoir tout saisis ^^
-
Envoie la classe de ton TESR en entier.
-
VOila:
package com.harrypotter.sosoh.client.render.blocks; import org.lwjgl.opengl.GL11; import com.harrypotter.sosoh.client.model.blocks.ModelChaudron; import com.harrypotter.sosoh.common.ModHarryPotter; import com.harrypotter.sosoh.common.blocks.TileEntityChaudron; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntityChaudronSpecialRenderer extends TileEntitySpecialRenderer { public static ModelChaudron model = new ModelChaudron(); public static ResourceLocation texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png");; public TileEntityChaudronSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityChaudronAt((TileEntityChaudron)tile, x, y, z, partialRenderTick); } private void renderTileEntityChaudronAt(TileEntityChaudron tile, double x, double y, double z, float partialRenderTick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); this.bindTexture(texture); model.renderAll(); GL11.glPopMatrix(); } }et
package com.harrypotter.sosoh.client.render.blocks; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; import com.harrypotter.sosoh.common.ModHarryPotter; import com.harrypotter.sosoh.proxy.ClientProxy; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class BlockChaudronTechneRender implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { if(block == ModHarryPotter.blockChaudron && metadata == 0) { GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(TileEntityChaudronSpecialRenderer.texture); TileEntityChaudronSpecialRenderer.model.renderAll(); GL11.glPopMatrix(); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return ClientProxy.blockChaudronRenderId; } } -
Avec cette méthode tu ne devrait pas avoir de NPE avec le rendu dans l’inventaire, c’est étrange. Actuellement le rendu fonctionne où non ?
-
Oui il fonctionne
-
Et quand tu utilise l’autre code que tu as mit à la première page (lui :
if (tile.getContenu().equalsIgnoreCase("vide") { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); } else { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); }) ça crash ?
Je trouve ça étrange, il n’y a pas de raison pour que cela crash pourtant … -
Tu as pas une idee de comment je pourrais faire ?
-
Heu … ? tu n’as pas répondu à ma question x)
Car ce que tu es en train de faire c’est exactement comme ça que je l’aurai fait. Et kevin_68 l’a fait dans son mod spotlight, ça fonctionne très bien.
-
J’ai cru que c’était rhétorique car tu as dis “Je trouve ça étrange […]”. x) Le code je le juste avant d’appliquer la texture ?
EDIT:
Je l’ai mis ici:private void renderTileEntityChaudronAt(TileEntityChaudron tile, double x, double y, double z, float partialRenderTick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); if (tile.getContenu().equalsIgnoreCase("vide")) { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); } else { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); } this.bindTexture(texture); model.renderAll(); GL11.glPopMatrix(); }Et ça crash:
[23:05:10] [main/INFO] [GradleStart]: Extra: []
[23:06:42] [Server thread/INFO]: Stopping server
[23:06:42] [Server thread/INFO]: Saving players
[23:06:42] [Server thread/INFO]: Saving worlds
[23:06:42] [Server thread/INFO]: Saving chunks for level ‘Nouveau monde’/Overworld
[23:06:42] [Server thread/INFO]: Saving chunks for level ‘Nouveau monde’/Nether
[23:06:42] [Server thread/INFO]: Saving chunks for level ‘Nouveau monde’/The End
[23:06:42] [Server thread/INFO] [FML]: Unloading dimension 0
[23:06:42] [Server thread/INFO] [FML]: Unloading dimension -1
[23:06:42] [Server thread/INFO] [FML]: Unloading dimension 1
[23:06:42] [Server thread/INFO] [FML]: Applying holder lookups
[23:06:42] [Server thread/INFO] [FML]: Holder lookups applied
[23:06:43] [Client thread/FATAL]: Reported exception thrown!
net.minecraft.util.ReportedException: Rendering Block Entity
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(TileEntityRendererDispatcher.java:148) ~[TileEntityRendererDispatcher.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntity(TileEntityRendererDispatcher.java:126) ~[TileEntityRendererDispatcher.class:?]
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:539) ~[RenderGlobal.class:?]
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300) ~[EntityRenderer.class:?]
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1091) ~[EntityRenderer.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056) ~[Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:951) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_71]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.7.0_71]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.7.0_71]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?]
at GradleStart.main(GradleStart.java:45) [start/:?]
Caused by: java.lang.NullPointerException
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityChaudronAt(TileEntityChaudronSpecialRenderer.java:36) ~[TileEntityChaudronSpecialRenderer.class:?]
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityAt(TileEntityChaudronSpecialRenderer.java:27) ~[TileEntityChaudronSpecialRenderer.class:?]
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(TileEntityRendererDispatcher.java:141) ~[TileEntityRendererDispatcher.class:?]
… 15 more
[23:06:43] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ----
// Quite honestly, I wouldn’t worry myself about that.Time: 18/02/15 23:06
Description: Rendering Block Entityjava.lang.NullPointerException: Rendering Block Entity
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityChaudronAt(TileEntityChaudronSpecialRenderer.java:36)
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityAt(TileEntityChaudronSpecialRenderer.java:27)
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(TileEntityRendererDispatcher.java:141)
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntity(TileEntityRendererDispatcher.java:126)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:539)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1091)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1056)
at net.minecraft.client.Minecraft.run(Minecraft.java:951)
at net.minecraft.client.main.Main.main(Main.java:164)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78)
at GradleStart.main(GradleStart.java:45)A detailed walkthrough of the error, its code path and all known details is as follows:
– Head –
Stacktrace:
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityChaudronAt(TileEntityChaudronSpecialRenderer.java:36)
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.renderTileEntityAt(TileEntityChaudronSpecialRenderer.java:27)– Block Entity Details –
Details:
Name: ModHarryPotter.MODID:BlockChaudron // com.harrypotter.sosoh.common.blocks.TileEntityChaudron
Block type: ID #165 (tile.chaudron // com.harrypotter.sosoh.common.blocks.BlockChaudron)
Block data value: 0 / 0x0 / 0b0000
Block location: World: (-138,4,1356), Chunk: (at 6,0,12 in -9,84; contains blocks -144,0,1344 to -129,255,1359), Region: (-1,2; contains chunks -32,64 to -1,95, blocks -512,0,1024 to -1,255,1535)
Actual block type: ID #165 (tile.chaudron // com.harrypotter.sosoh.common.blocks.BlockChaudron)
Actual block data value: 0 / 0x0 / 0b0000
Stacktrace:
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntityAt(TileEntityRendererDispatcher.java:141)
at net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher.renderTileEntity(TileEntityRendererDispatcher.java:126)
at net.minecraft.client.renderer.RenderGlobal.renderEntities(RenderGlobal.java:539)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1300) -
Au pire, mets une valeur par défaut et regarde ce que ça donne, normalement il ne devrais plus y avoir de NPE.
-
Valeur ou ?
-
@‘sosoh’:
Valeur ou ?
public RessourceLocation texture = new RessourceLocation(MODID, “textures…”);
-
at com.harrypotter.sosoh.client.render.blocks.TileEntityChaudronSpecialRenderer.ren derTileEntityChaudronAt(TileEntityChaudronSpecialRenderer.java:36) ~[TileEntityChaudronSpecialRenderer.class:?]
Tu as quoi à la ligne 36 ? -
Désolé, de repondre que maintenant, j’étais occupé, à la ligne 36 j’ai:
if (tile.getContenu().equalsIgnoreCase("vide")) { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); } else { this.texture = new ResourceLocation(ModHarryPotter.MODID, "textures/models/blocks/model_block_chaudron.png"); } -
Le contenu est null. Fait comme ça :
if (tile.getContenu() != null && tile.getContenu().equalsIgnoreCase(“vide”)) {ou :
if (“vide”.equalsIgnoreCase(tile.getContenu())) {