Résolu Problème de Overlay
-
Bonjour a tous en faites j’ai créer un mod pour un serveur , l’item en question est le UnclaimFinder je l’ai recréer mais il ne fonction pas voila les class merci de me soutenir et bon courage
le Client Proxy
public class ClientProxy extends CommonProxy { public static int tesrRenderID; public void registerRenders() { RenderingRegistry.registerEntityRenderingHandler(EntityDynamite.class, new RenderSnowball(ItemMod.ItemDynamite)); RenderingRegistry.registerEntityRenderingHandler(CustomEnderPreal.class, new RenderSnowball(ItemMod.CoolEnderPreal)); tesrRenderID = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityIronCreate.class, new TileEntityIronCreatespecialRenderer()); } public void registerOverlay() { MinecraftForge.EVENT_BUS.register(new OverlayUnclaimFinder()); } public EntityPlayer getplayer() { return Minecraft.getMinecraft().thePlayer; } } ``` le CommonProxy ```java public class CommonProxy { boolean server; public static final boolean DEV = false; public void preInit(FMLPreInitializationEvent event) { if(event.getSide().equals(Side.SERVER)) { this.server = true; } if(event.getSide().equals(Side.CLIENT)) { FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); } } public void init(FMLInitializationEvent event) { IridiumCore.proxy.registerOverlay(); } private void registerEvents() { } public void postInit(FMLPostInitializationEvent event) { } public void registerOverlay() {} private static Iterator list(ClassLoader CL) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException { Class CL_class = CL.getClass(); while(CL_class != ClassLoader.class) { CL_class = CL_class.getSuperclass(); } Field ClassLoader_classes_field = CL_class.getDeclaredField("classes"); ClassLoader_classes_field.setAccessible(true); Vector classes = (Vector)ClassLoader_classes_field.get(CL); return classes.iterator(); } public void registerRenders() { } }
la classe du Overlay
public class OverlayUnclaimFinder extends Gui { Minecraft mc ; private String show; final ResourceLocation bg = new ResourceLocation(References.MOD_ID , "textures/overlay/UnclaimFinder.png"); FontRenderer fontRender; RenderItem itemRenderer = new RenderItem(); public OverlayUnclaimFinder() { this.mc = Minecraft.getMinecraft(); this.show = "0%"; this.fontRender = this.mc.fontRenderer; } @SubscribeEvent(priority = EventPriority.NORMAL) public void onRender(RenderGameOverlayEvent.Post event) { if(event.type != RenderGameOverlayEvent.ElementType.HOTBAR) { return; } if((this.mc.thePlayer.getHeldItem() != null) && ((this.mc.thePlayer.getHeldItem().getItem() instanceof ItemUnclaimFinder)) && (this.mc.theWorld.isRemote)) { this.mc.renderEngine.bindTexture(this.bg); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(2896); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); DisplayHelper.drawTexturedQuadFit(5.0D, 5.0D, 32.0D, 32.0D, 0.0D); int amountTiles = this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0, this.mc.thePlayer.chunkCoordZ + 0).chunkTileEntityMap.values().size(); amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0, this.mc.thePlayer.chunkCoordZ + 1).chunkTileEntityMap.values().size(); amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 0, this.mc.thePlayer.chunkCoordZ - 1).chunkTileEntityMap.values().size(); amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + 1, this.mc.thePlayer.chunkCoordZ).chunkTileEntityMap.values().size(); amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX - 1, this.mc.thePlayer.chunkCoordZ).chunkTileEntityMap.values().size(); if(this.mc.thePlayer.getHeldItem().getItemDamage() >= 1) { int[] y = {-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2}; int[] x = {-2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2}; for(int i = 0; i < y.length; i++) { amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x*, this.mc.thePlayer.chunkCoordZ + y*).chunkTileEntityMap.values().size(); } } if(this.mc.thePlayer.getHeldItem().getItemDamage() >= 2) { int[] y = {-3, -2, -1, 0, 1, 2, 0, 3, -3, 3, -3, 3, -3, 3, -3, 3, -3, -2, -1, 0, 1, 2, 3}; int[] x = {-3, -3, -3, -3, -3, -3, -5, -2, -1, -1, 0, 0, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 3}; for(int i = 0; i < y.length; i++) { amountTiles = amountTiles + this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x*, this.mc.thePlayer.chunkCoordZ + y*).chunkTileEntityMap.values().size(); } } if(this.mc.thePlayer.getHeldItem().getItemDamage() >= 3) { int tileAmmount = 0; int items = 0; int chests = 0; int moddedChests = 0; for(int x = -3; x < 3; x++) { for(int z = -3; z < 3; z++) { Map tileMap = this.mc.theWorld.getChunkFromChunkCoords(this.mc.thePlayer.chunkCoordX + x, this.mc.thePlayer.chunkCoordZ + z).chunkTileEntityMap; Iterator entries = tileMap.entrySet().iterator(); while(entries.hasNext()) { Map.Entry e = (Map.Entry)entries.next(); TileEntity te = (TileEntity)e.getValue(); if(te != null) { if(te.getClass().toString().contains("net.minecraft.tileentity.TileEntityChest")) { chests++; } else if((te.getClass().toString().contains("Chest")) || (te.getClass().toString().contains("chest"))) { moddedChests++; } } } } } ItemStack stackChest = new ItemStack(Blocks.chest); ItemStack stackModdedChests = new ItemStack(BlockMod.GemMachine); GL11.glPushMatrix(); GL11.glEnable(2929); GL11.glScaled(1.5D, 1.5D, 1.5D); this.itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, stackChest, 30, 5); this.itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, stackModdedChests, 50, 5); GL11.glDisable(2929); GL11.glDisable(2896); GL11.glPopMatrix(); int xChests = 53; int xModdedChests = 83; if(chests > 100) { chests = 100; } if(moddedChests > 100) { moddedChests = 100; } String showChests = chests + "%"; String showModdedChests = moddedChests + "%"; if(chests > 9) { xChests -= 3; } if(moddedChests > 9) { xModdedChests -= 3; } this.fontRender.drawStringWithShadow(showChests, xChests, 37, -1); this.fontRender.drawStringWithShadow(showModdedChests, xModdedChests, 37, -1); } if(amountTiles > 100) { amountTiles = 100; } this.show = (amountTiles + "%"); int x = 0; if(amountTiles > 9) { x = 12; } else { x = 15; } this.fontRender.drawStringWithShadow(this.show, x, 37, -1); } } }
la classe du Item
public class ItemUnclaimFinder extends Item { private String[] type = { "UnclaimFinder", "UnclaimFinder_Orange", "UnclaimFinder_Red", "UnclaimFinder_Precise" }; private IIcon[] iconArray; public ItemUnclaimFinder() { setMaxStackSize(1); setUnlocalizedName("unclaimfinder"); } public void registerIcons(IIconRegister iconregister) { this.iconArray = new IIcon[this.type.length]; for (int i = 0; i < this.type.length; i++) { this.iconArray* = iconregister.registerIcon(References.MOD_ID + ":" + this.type*); } } @SideOnly(Side.CLIENT) public void getSubItems(Item Item, CreativeTabs creativeTabs, List list) { for (int metadata = 0; metadata < this.type.length; metadata++) { list.add(new ItemStack(Item, 1, metadata)); } } @SideOnly(Side.CLIENT) public IIcon getIconFromDamage(int metadata) { return (metadata < this.type.length) && (metadata >= 0) ? this.iconArray[metadata] : this.iconArray[0]; } }
la classe du DisplayHelper
public class DisplayHelper { public static Minecraft mc ; public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) { drawTexturedModalRect(par1, par2, z, par3, par4, par5, par6, 0.00390625F, 0.00390625F); } public static void drawTexturedModalRect(int par1, int par2, float z, int par3, int par4, int par5, int par6, float f, float f1) { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(par1 + 0, par2 + par6, z, (par3 + 0) * f, (par4 + par6) * f1); tessellator.addVertexWithUV(par1 + par5, par2 + par6, z, (par3 + par5) * f, (par4 + par6) * f1); tessellator.addVertexWithUV(par1 + par5, par2 + 0, z, (par3 + par5) * f, (par4 + 0) * f1); tessellator.addVertexWithUV(par1 + 0, par2 + 0, z, (par3 + 0) * f, (par4 + 0) * f1); tessellator.draw(); } public static void renderEntity(int x, int y, int scale, float rotX, float rotY, EntityLivingBase entity, boolean nametag) { GL11.glEnable(2903); GL11.glPushMatrix(); GL11.glTranslatef(x, y, 50.0F); GL11.glScalef(-scale, scale, scale); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-(float)Math.atan(rotY / 40.0F) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = ((float)Math.atan(rotX / 40.0F) * 20.0F); entity.rotationYaw = ((float)Math.atan(rotX / 40.0F) * 40.0F); entity.rotationPitch = (-(float)Math.atan(rotY / 40.0F) * 20.0F); entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GL11.glPopMatrix(); GL11.glDisable(32826); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(3553); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel) { Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV(x + 0.0D, y + height, zLevel, 0.0D, 1.0D); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1.0D, 1.0D); tessellator.addVertexWithUV(x + width, y + 0.0D, zLevel, 1.0D, 0.0D); tessellator.addVertexWithUV(x + 0.0D, y + 0.0D, zLevel, 0.0D, 0.0D); tessellator.draw(); } public static void renderFloatingText(String text, float x, float y, float z, int color) { RenderManager renderManager = RenderManager.instance; FontRenderer fontRenderer = mc.fontRenderer; float scale = 0.027F; GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); GL11.glPushMatrix(); GL11.glTranslatef(x + 0.0F, y + 2.3F, z); GL11.glNormal3f(0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F); GL11.glScalef(-scale, -scale, scale); GL11.glDisable(2896); GL11.glDepthMask(false); GL11.glDisable(2929); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); Tessellator tessellator = Tessellator.instance; int yOffset = 0; GL11.glDisable(3553); tessellator.startDrawingQuads(); int stringMiddle = fontRenderer.getStringWidth(text) / 2; tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.5F); tessellator.addVertex(-stringMiddle - 1, -1 + yOffset, 0.0D); tessellator.addVertex(-stringMiddle - 1, 8 + yOffset, 0.0D); tessellator.addVertex(stringMiddle + 1, 8 + yOffset, 0.0D); tessellator.addVertex(stringMiddle + 1, -1 + yOffset, 0.0D); tessellator.draw(); GL11.glEnable(3553); GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5F); fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color); GL11.glEnable(2929); GL11.glDepthMask(true); fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, color); GL11.glEnable(2896); GL11.glDisable(3042); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glPopMatrix(); } }
Merci pour tous les gens qui aurons le temps de regarder le message et excuser moi pour l’écriture
merci infiniment -
c’est qui marche pas ? l’affichage ou la detection des TE ?
Unclaim finder -> PlayerTickEvent > check if player.getHelpItem == unclaim finder > for x/y/z World#getTileEntity(x, y, z) > if tileEntity instance TileEntityChest
-
Bonjour et Bonsoir et merci de ton attention, et mon problème est quand je tien l’item en question en main j’ai rien pas de overlay ni rien c’est comme un Item vierge
Merci a tous les gens qui orant le temps de lire et de répondre
Cordialement Ishal
PS : désoler pour les fautes orthographe
C’est bon j’ai la solution c’est juste il faute mettre le proxy.init(event); dans la classe principal
Merci pour le Temps que vous avez consacre a lire le topic merci tout les monde
-
Ce message a été supprimé !