Problème Invetory + Item comme une map
-
-
Essaie de changer les valeurs du glScalef dans handleRenderType(…)
Ensuite tu ajusteras sa position dans le slot de l’inventaire du joueur, avec le glTranslatef -
Bon, je suis un peux nul je crois, car j’ai pris les même valeur que MapItemRenderer voici mon code :
[font=Courier Newpackage ]fr.ph1823.MyLife.Item%(#cc7832)[; ] import net.minecraft.client.Minecraft%(#cc7832)[; ]import net.minecraft.client.gui.FontRenderer%(#cc7832)[; ]import net.minecraft.client.gui.MapItemRenderer%(#cc7832)[; ]import net.minecraft.client.renderer.Tessellator%(#cc7832)[; ]import net.minecraft.client.renderer.entity.RenderItem%(#cc7832)[; ]import net.minecraft.client.renderer.texture.DynamicTexture%(#cc7832)[; ]import net.minecraft.client.renderer.texture.TextureManager%(#cc7832)[; ]import net.minecraft.item.ItemMap%(#cc7832)[; ]import net.minecraft.item.ItemStack%(#cc7832)[; ]import net.minecraft.nbt.NBTTagCompound%(#cc7832)[; ]import net.minecraft.nbt.NBTTagList%(#cc7832)[; ]import net.minecraft.nbt.NBTTagString%(#cc7832)[; ]import net.minecraft.util.ResourceLocation%(#cc7832)[; ]import net.minecraft.world.storage.MapData%(#cc7832)[; ]import net.minecraftforge.client.IItemRenderer%(#cc7832)[; ]import org.lwjgl.opengl.GL11%(#cc7832)[; ] %(#629755)[*/** *]%(#629755)[* * Created by ph1823 - Minecraft on 28/03/2016. *]%(#629755)[* */ *]public class IdentityTechneRender implements IItemRenderer { protected Identity model%(#cc7832)[; ] private static RenderItem *renderItem *= new RenderItem()%(#cc7832)[; ] private static DynamicTexture *dyn*%(#cc7832)[; ] private static TextureManager *manager *= Minecraft.*getMinecraft*().getTextureManager()%(#cc7832)[; ] protected static ResourceLocation *texture *= new ResourceLocation("plants:textures/items/card.png")%(#cc7832)[; ] public IdentityTechneRender() { %(#808080)[// this.getDynamicTextureLocation() ]%(#808080)[ //model = new Identity(); ] *dyn *= new DynamicTexture(64,64)%(#cc7832)[; ] %(#808080)[// this.field_148241_e = this.field_148243_c.getTextureData(); ] *texture *= *manager*.getDynamicTextureLocation("plants:textures/items/card.png", *dyn*)%(#cc7832)[; ] } %(#bbb529)[@Override ] public boolean handleRenderType(ItemStack item, ItemRenderType type) { %(#808080)[// Get icon index for the texture ] String text= "texte par default"%(#cc7832)[; ] NBTTagCompound nbt = item.getTagCompound()%(#cc7832)[; ] if (nbt != null) { NBTTagCompound disp = nbt.getCompoundTag("display")%(#cc7832)[; ] if (disp != null) { NBTTagList lore = disp.getTagList("Lore", 8)%(#cc7832)[; ] if (lore != null) { %(#808080)[// text = lore.getStringTagAt(0); ] } } } *manager*.bindTexture(*texture*)%(#cc7832)[; ] %(#808080)[//net.minecraft.util.IIcon icon = item.getIconIndex(); ]%(#808080)[// Use vanilla code to render the icon in a 16x16 square of inventory slot ]%(#808080)[ // renderItem.renderIcon(0, 0, icon, 16, 16); ] %(#808080)[ // ]%(#808080)[// Set drawing mode (see first tutorial link above). ]%(#808080)[ /* GL11.glBegin(GL11.GL_QUADS); ]%(#808080)[// Set semi-transparent black color ]%(#808080)[ GL11.glColor4f(0F, 0F, 0F, 0.5F); ] %(#808080)[// Draw a 8x8 square ]%(#808080)[ GL11.glVertex3d(0, 0, 0); ]%(#808080)[ GL11.glVertex3d(0, 8, 0); ]%(#808080)[ GL11.glVertex3d(8, 8, 0); ]%(#808080)[ GL11.glVertex3d(8, 0, 0);*/ ] %(#808080)[// GL11.glEnd(); ] byte b0 = 0%(#cc7832)[; ] byte b1 = 0%(#cc7832)[; ] Tessellator tessellator = Tessellator.*instance*%(#cc7832)[; ] float f = 0.0F%(#cc7832)[; ]%(#808080)[// Set drawing mode. Tessellator should support most drawing modes. ]%(#808080)[ // tessellator.startDrawing(GL11.GL_QUADS); ]%(#808080)[// Set semi-transparent black color ] tessellator.startDrawingQuads()%(#cc7832)[; ] tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 0.0D, 1.0D)%(#cc7832)[; ] tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 1.0D, 1.0D)%(#cc7832)[; ] tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 1.0D, 0.0D)%(#cc7832)[; ] tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 0.0D, 0.0D)%(#cc7832)[; ] tessellator.draw()%(#cc7832)[; ] FontRenderer fontRenderer = Minecraft.*getMinecraft*().fontRenderer%(#cc7832)[; ] GL11.*glEnable*(GL11.*GL_ALPHA_TEST*)%(#cc7832)[; ] GL11.*glDisable*(GL11.*GL_BLEND*)%(#cc7832)[; ] %(#808080)[// Enable texturing, because Minecraft text font is actually a texture ]%(#808080)[ //GL11.glEnable(GL11.GL_TEXTURE_2D); ]%(#808080)[// Get our text value ] %(#808080)[// Draw our text at (1, 1) with white color ] fontRenderer.drawStringWithShadow(text, 1, 1, 0xFFFFFF)%(#cc7832)[; ] %(#808080)[// MapItemRenderer ]%(#808080)[//ItemMap ] GL11.*glPushMatrix*()%(#cc7832)[; ] %(#808080)[//GL11.glTranslatef((float)b0 + (float)mapcoord.centerX / 2.0F + 64.0F, (float)b1 + (float)mapcoord.centerZ / 2.0F + 64.0F, -0.02F); ]%(#808080)[ //GL11.glRotatef((float)(mapcoord.iconRotation * 360) / 16.0F, 0.0F, 0.0F, 1.0F); ] GL11.*glScalef*(4.0F, 4.0F, 3.0F)%(#cc7832)[; ] GL11.*glTranslatef*(-0.125F, 0.125F, 0.0F)%(#cc7832)[; ] GL11.*glPopMatrix*()%(#cc7832)[; ] switch(type) { case *FIRST_PERSON_MAP*: %(#cc7832)[return true; ] default: %(#cc7832)[return false; ] } %(#808080)[// return false; ] } %(#bbb529)[@Override ] public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { switch(type) { case *FIRST_PERSON_MAP*: %(#cc7832)[return true; ] default: %(#cc7832)[return false; ] } } %(#bbb529)[@Override ] public void renderItem(ItemRenderType type, ItemStack item, Object… data) { switch(type) { case *FIRST_PERSON_MAP*: { } default: %(#cc7832)[break; ] } } }
Merci de vos réponse.
-
Problème résolu du coup ?
-
Ha mince, en mettant ce message j’avais crue mettre bien exprimé, justement non, cela fait la même chose que avec l’ancien code, et le même bug que dans l’image Comment pourais-je faire ?
-
Essaie de recopier une fonction pour dessiner, la tesselation est compliquée et elle fait souvent n’importe quoi
-
Bonjoours, recopier quelle fonction? Une fonction de MapItemRender? Merci de votre aide.
-
Le problème vient bien de là ?
tessellator.startDrawingQuads(); tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 0.0D, 1.0D); tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 128) - f), -0.009999999776482582D, 1.0D, 1.0D); tessellator.addVertexWithUV((double)((float)(b0 + 128) - f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 1.0D, 0.0D); tessellator.addVertexWithUV((double)((float)(b0 + 0) + f), (double)((float)(b1 + 0) + f), -0.009999999776482582D, 0.0D, 0.0D); tessellator.draw();
Pour tester mets en commentaire par exemple