Résolu Bug TileEntity
-
Quand je pose mon bloc en 3D je le vois parfait avant le plante :
package fr.altiscraft.altiscraft.common; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityPoubelle extends TileEntity { private byte direction; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.direction = compound.getByte("Direction"); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setByte("Direction", this.direction); } public byte getDirection() { return direction; } public void setDirection(byte direction) { this.direction = direction; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); } }
package fr.altiscraft.altiscraft.proxy; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.model.ModelBiped; import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.InputEvent.KeyInputEvent; import fr.altiscraft.altiscraft.common.EntityMobBenjaminLoison; import fr.altiscraft.altiscraft.common.GuiCustomMainMenu; import fr.altiscraft.altiscraft.common.RenderMobBenjaminLoison; import fr.altiscraft.altiscraft.common.TileEntityATM; import fr.altiscraft.altiscraft.common.TileEntityCoco; import fr.altiscraft.altiscraft.common.TileEntityLampadaire; import fr.altiscraft.altiscraft.common.TileEntityPoubelle; import fr.altiscraft.altiscraft.common.TileEntityVLampadaire; public class ClientProxy extends CommonProxy { // private static final Block Block = Blocks.bedrock; Minecraft mc = Minecraft.getMinecraft(); public static int tesrRenderId; @Override public void registerRender() { FMLCommonHandler.instance().bus().register(this); System.out.println("Méthode côté client"); RenderingRegistry.registerEntityRenderingHandler( EntityMobBenjaminLoison.class, new RenderMobBenjaminLoison( new ModelBiped())); ClientRegistry.registerKeyBinding(toucheinv); ClientRegistry.registerKeyBinding(touchecarte); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityATM.class, new TileEntityATMSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoco.class, new TileEntityCocoSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer( TileEntityLampadaire.class, new TileEntityLampadaireSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer( TileEntityVLampadaire.class, new TileEntityVLampadaireSpecialRenderer()); ClientRegistry.bindTileEntitySpecialRenderer( TileEntityPoubelle.class, new TileEntityPoubelleSpecialRenderer()); tesrRenderId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); } private static KeyBinding toucheinv = new KeyBinding( "Inventaire d'AltisCraft.fr", 21, "AltisCraft.fr"); private static KeyBinding touchecarte = new KeyBinding("Carte", 21, "AltisCraft.fr"); // @SubscribeEvent // @SideOnly(Side.CLIENT) // public void onTick(TickEvent.ClientTickEvent event) { Minecraft mc = FMLClientHandler.instance().getClient(); GuiScreen currentScreen = mc.currentScreen; if (mc.currentScreen != null && mc.currentScreen.getClass().equals(GuiMainMenu.class)) { mc.displayGuiScreen(new GuiCustomMainMenu()); } } @SubscribeEvent public void onEvent(KeyInputEvent event) { if (toucheinv.isPressed()) { toucheInvTyped(); } else if (touchecarte.isPressed()) { toucheCarteTyped(); } } private void toucheInvTyped() { Minecraft.getMinecraft().thePlayer .sendChatMessage((new StringBuilder()).append("/inventaire") .toString()); Minecraft.getMinecraft(); } private void toucheCarteTyped() { } // setblock : theWorld.setBlock(0, 1, 0, Block, 1, 2);} public static ResourceLocation getLocationSkin(String Skin) { return new ResourceLocation("skins/" + StringUtils.stripControlCodes(Skin)); } }
package fr.altiscraft.altiscraft.proxy; 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 cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import fr.altiscraft.altiscraft.common.ModAltisCraft; public class TESRInventoryRenderer implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { if (block == ModAltisCraft.BlocATM) { GL11.glPushMatrix(); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager() .bindTexture(TileEntityATMSpecialRenderer.texture); TileEntityATMSpecialRenderer.model.renderAll(); GL11.glPopMatrix(); } else if (block == ModAltisCraft.BlocVLampadaire) { GL11.glPushMatrix(); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager() .bindTexture(TileEntityVLampadaireSpecialRenderer.texturev); TileEntityVLampadaireSpecialRenderer.modelv.renderAll(); GL11.glPopMatrix(); } else if (block == ModAltisCraft.BlocCoco) { GL11.glPushMatrix(); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager() .bindTexture(TileEntityCocoSpecialRenderer.textures); TileEntityCocoSpecialRenderer.models.renderAll(); GL11.glPopMatrix(); } else if (block == ModAltisCraft.BlocPoubelle) { GL11.glPushMatrix(); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager() .bindTexture(TileEntityPoubelleSpecialRenderer.texturem); TileEntityPoubelleSpecialRenderer.modelm.renderAll(); GL11.glPopMatrix(); } else if (block == ModAltisCraft.BlocLampadaire) { GL11.glPushMatrix(); GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager() .bindTexture(TileEntityLampadaireSpecialRenderer.texturesb); TileEntityLampadaireSpecialRenderer.modelsb.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 int getRenderId() { return ClientProxy.tesrRenderId; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } }
package fr.altiscraft.altiscraft.proxy; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import fr.altiscraft.altiscraft.client.ModelBlockPoubelle; import fr.altiscraft.altiscraft.common.ModAltisCraft; import fr.altiscraft.altiscraft.common.TileEntityPoubelle; public class TileEntityPoubelleSpecialRenderer extends TileEntitySpecialRenderer{ public static ModelBlockPoubelle modelm = new ModelBlockPoubelle(); public static ResourceLocation texturem = new ResourceLocation(ModAltisCraft.MODID, "textures/models/blocks/ModelBlockPoubelle.png"); public TileEntityPoubelleSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityPoubelleAt((TileEntityPoubelle) tile, x, y, z, partialRenderTick); } private void renderTileEntityPoubelleAt(TileEntityPoubelle 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(texturem); modelm.renderAll(); GL11.glPopMatrix(); } }
Voilà merci si quelqu’un peut m’aider
-
@‘Benjamin Loison’:
Quand je pose mon bloc en 3D je le vois parfait avant le plante :
:huh:
En français ? -
Je pose ma “poubelle”, je vois alors pendant un instant qu’elle est dans la bonne direction, bien modélisé, etc… Mais après ça crash… http://pastebin.com/mPKbyAD6
-
Ton tile entity n’est pas enregistré.
-
A oui c’est encore ça fait chier merci beaucoup