Rendu complexe de bloc via TESR
-
@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
-
Dans ce cas je ne sais pas.
-
bon bha pas grave
-
J’ai un problème avec la boite de collision ce qui permet de faire des choses pas cool…
-
Bloc sur deux bloc de haut ? Déjà traité dans la parti support, un bloc ne peut pas avoir une collision supérieur à la taille d’un bloc, il faire que lorsqu’on place le bloc, un deuxième se pose, et que lorsqu’on le détruit, l’autre se détruit avec. Cf : le lampadaire et la parasol de Nanotech mod city.
-
J’ai un probleme quand je charge le monde
craft Crash Report –-- // Uh... Did I do that? Time: 03/03/14 21:38 Description: Exception in server tick loop java.lang.OutOfMemoryError: Java heap space at java.util.Arrays.copyOf(Unknown Source) at java.util.ArrayList.grow(Unknown Source) at java.util.ArrayList.ensureExplicitCapacity(Unknown Source) at java.util.ArrayList.ensureCapacityInternal(Unknown Source) at java.util.ArrayList.add(Unknown Source) at net.minecraft.util.AABBPool.getAABB(AABBPool.java:51) at net.minecraft.block.Block.getCollisionBoundingBoxFromPool(Block.java:602) at net.minecraft.block.Block.addCollisionBoxesToList(Block.java:568) at net.minecraft.world.World.getCollidingBoundingBoxes(World.java:1684) at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:187) at net.minecraft.server.management.ServerConfigurationManager.createPlayerForUser(ServerConfigurationManager.java:389) at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:91) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:691) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:587) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:129) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:484) at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.6.4 Operating System: Windows 7 (amd64) version 6.1 Java Version: 1.7.0_51, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 10989104 bytes (10 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 13845150 (775328400 bytes; 739 MB) allocated, 13845150 (775328400 bytes; 739 MB) used Suspicious classes: FML and Forge are installed IntCache: cache: 0, tcache: 0, allocated: 23, tallocated: 41 FML: MCP v8.11 FML v6.4.45.953 Minecraft Forge 9.11.1.953 4 mods loaded, 4 mods active mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available FML{6.4.45.953} [Forge Mod Loader] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Forge{9.11.1.953} [Minecraft Forge] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available UltimateUniverseMod{1.0.0} [Ultimate Universe Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available Profiler Position: N/A (disabled) Vec3 Pool Size: 915 (51240 bytes; 0 MB) allocated, 915 (51240 bytes; 0 MB) used Player Count: 0 / 8; [] Type: Integrated Server (map_client.txt) Is Modded: Definitely; Client brand changed to 'fml,forge' ```</init>
-
On pourrait voir les classes que tu as utilisées?
-
classe principale
@EventHandler public void PreInit(FMLPreInitializationEvent event) { // Blocks PanneauSolaireBasique = new BasicSolarPanel(2000).setHardness(1.0F).setResistance(5.0F).setStepSound(Block.soundStoneFootstep) .setUnlocalizedName("BasicSolarPanel").setTextureName("universe:basicsolarpanel"); GameRegistry.registerBlock(PanneauSolaireBasique, "PanneausolaireBasique"); } @EventHandler public void Init(FMLInitializationEvent event) { //Registry GameRegistry.registerTileEntity(TileEntitySolarPanelBasic.class, "TileEntityBasicSolarPanel"); proxy.registerTileEntityRender(); }
Techne du panneau solaire
// Date: 03/03/2014 20:39:16 // Template version 1.1 // Java generated by Techne // Keep in mind that you still need to fill in some blanks // - ZeuX package Universe.common; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelSolarPanel extends ModelBase { //fields ModelRenderer reference_taille_block; ModelRenderer Shape1; ModelRenderer Shape2; ModelRenderer Shape3; ModelRenderer Shape4; ModelRenderer Shape5; ModelRenderer Shape6; ModelRenderer Shape7; public ModelSolarPanel () { textureWidth = 64; textureHeight = 32; reference_taille_block = new ModelRenderer(this, 0, 0); reference_taille_block.addBox(0F, 0F, 0F, 1, 16, 1); reference_taille_block.setRotationPoint(-10F, 8F, 0F); reference_taille_block.setTextureSize(64, 32); reference_taille_block.mirror = true; Shape1 = new ModelRenderer(this, 0, 0); Shape1.addBox(0F, 0F, 0F, 6, 10, 6); Shape1.setRotationPoint(-3F, 14F, -3F); Shape1.setTextureSize(64, 32); Shape1.mirror = true; Shape2 = new ModelRenderer(this, 0, 0); Shape2.addBox(0F, 0F, 0F, 10, 8, 4); Shape2.setRotationPoint(-5F, 16F, -2F); Shape2.setTextureSize(64, 32); Shape2.mirror = true; Shape3 = new ModelRenderer(this, 0, 0); Shape3.addBox(0F, 0F, 0F, 16, 5, 2); Shape3.setRotationPoint(-8F, 19F, -1F); Shape3.setTextureSize(64, 32); Shape3.mirror = true; Shape4 = new ModelRenderer(this, 0, 0); Shape4.addBox(0F, 0F, 0F, 14, 6, 3); Shape4.setRotationPoint(-7F, 18F, -1.5F); Shape4.setTextureSize(64, 32); Shape4.mirror = true; Shape5 = new ModelRenderer(this, 0, 0); Shape5.addBox(0F, 0F, 0F, 4, 1, 4); Shape5.setRotationPoint(-2F, 23F, -7F); Shape5.setTextureSize(64, 32); Shape5.mirror = true; Shape6 = new ModelRenderer(this, 0, 0); Shape6.addBox(0F, 0F, 0F, 1, 4, 4); Shape6.setRotationPoint(-2F, 19F, -7F); Shape6.setTextureSize(64, 32); Shape6.mirror = true; Shape5 = new ModelRenderer(this, 0, 0); Shape5.addBox(0F, 0F, 0F, 4, 1, 4); Shape5.setRotationPoint(-2F, 19F, -7F); Shape5.setTextureSize(64, 32); Shape5.mirror = true; Shape6 = new ModelRenderer(this, 0, 0); Shape6.addBox(0F, 0F, 0F, 1, 4, 4); Shape6.setRotationPoint(1F, 20F, -7F); Shape6.setTextureSize(64, 32); Shape6.mirror = true; Shape7 = new ModelRenderer(this, 0, 0); Shape7.addBox(0F, 0F, 0F, 4, 3, 1); Shape7.setRotationPoint(-2F, 16F, -4F); Shape7.setTextureSize(64, 32); Shape7.mirror = true; } public void render(float f) { Shape1.render(f); Shape2.render(f); Shape3.render(f); Shape4.render(f); Shape5.render(f); Shape6.render(f); Shape5.render(f); Shape6.render(f); Shape7.render(f); } }
Tile entity du panneau solaire
package Universe.common; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; public class TileEntitySolarPanelBasic extends TileEntity { public String visiteur[] = new String[]{"visiteur0", "visiteur1", "visiteur2", "visiteur3", "visiteur4"}; public void readFromNBT(NBTTagCompound nbtTag) { super.readFromNBT(nbtTag); for(int i = 0; i < 5; i++) { visiteur* = nbtTag.getString("visiteur" + i); } } public void writeToNBT(NBTTagCompound nbtTag) { super.writeToNBT(nbtTag); for(int i = 0; i < 5; i++) { nbtTag.setString("visiteur" + i, visiteur*); } } }
Tile entity Special renderer
package Universe.common; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntityRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntitySolarPanelBasicSpecialRender extends TileEntitySpecialRenderer implements IInventoryRenderer { @Override public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) { // TODO Auto-generated method stub } @Override public void renderInventory(double x, double y, double z) { this.renderTileEntitySolarPanelBasicAt(null, x, y, z, 0.0F); } public void renderTileEntitySolarPanelBasicAt(TileEntitySolarPanelBasic te, double x, double y, double z, float tick) { this.renderTileEntitySolarPanelBasicAt((TileEntitySolarPanelBasic)te, x, y, z, 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(); } private final BasicSolarPanel model = new BasicSolarPanel(0); public static final ResourceLocation textureLocation = new ResourceLocation("modtutoriel", "textures/blocks/modelTutoriel.png"); public TileEntitySolarPanelBasicSpecialRender() { this.setTileEntityRenderer(TileEntityRenderer.instance); } }
Tesri inventory renderer
package Universe.common; 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 { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { // TODO Auto-generated method stub } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { // TODO Auto-generated method stub return false; } @Override public boolean shouldRender3DInInventory() { // TODO Auto-generated method stub return false; } @Override public int getRenderId() { // TODO Auto-generated method stub return 0; } }
Je crois que c’est tout
-
Déjà ta classe TESRInventoryRenderer est incomplète.
Et ton problème vient du bloc, et tu n’as pas envoyé la classe du bloc. -
classe du bloc :
package Universe.common; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.Icon; import net.minecraft.world.World; public class BasicSolarPanel extends BlockContainer { public BasicSolarPanel(int id) { super(id, Material.rock); this.setCreativeTab(CreativeTabs.tabBlock); } @Override public TileEntity createNewTileEntity(World world) { // TODO Auto-generated method stub return null; } @Override public TileEntity createTileEntity(World world, int metadata) { { return new TileEntitySolarPanelBasic(); } } public boolean renderAsNormalBlock() { return false; } public boolean isOpaqueCube() { return false; } @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.renderInventoryTESRId; } }