Jump to content

Casual Dutchman

Members
  • Posts

    98
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    (Nether)lands
  • Personal Text
    I can code, but not that good!

Casual Dutchman's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. fixed it by experimenting with the GuiInventory function and my function.
  2. Tried several setting. disable it before rendering. disable it before, enable it after enable it before. enable it before, disable it after It did not help.
  3. So this Gui is a bit more advanced. It has a representation of the clicked mob. There is one problem. When it gets night, the gui is very dark. When it it day, the gui is light, normal. *see below code for the gui file **see below package comp101.client.gui; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import comp101.client.SendPackage; import comp101.common.Core; import comp101.common.container.ContainerHireable; import comp101.common.entity.EntityHireable; public class GuiHireable extends GuiContainer{ private static final ResourceLocation tex = new ResourceLocation(Core.getModID(), "textures/gui/hireable.png"); EntityHireable hireable; boolean toggleRightVisible = false; boolean toggleLeftVisible = false; public GuiHireable(EntityPlayer player, EntityHireable entity) { super(new ContainerHireable(player, entity)); hireable = entity; this.ySize = 176; this.xSize = 196; } public void initGui() { int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.buttonList.clear(); this.buttonList.add(new InvisibleButton(0, k + 98, l + 71, 26, 18, "")); this.buttonList.add(new InvisibleButton(1, k + (xSize - 5), l + 13, 15, 60, "")); this.buttonList.add(new InvisibleButton(2, k - 5, l + 13, 15, 60, "")); this.buttonList.add(new InvisibleButton(3, k + -20, l + 23, 16, 18, "")); this.buttonList.add(new InvisibleButton(4, k + -20, l + 23 + 20, 16, 18, "")); super.initGui(); } @Override protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(tex); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k + 26, l + 18, 196, 0, 52, 70); func_74223_a(this.mc, guiLeft + 51, guiTop + 82, 30, (float)(width + 51) - this.width, (float)(guiTop + 75 - 50) - this.height); this.mc.getTextureManager().bindTexture(tex); this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); this.setRightSide(this.toggleRightVisible ? 100 : 5, this.toggleRightVisible ? (this.hireable.getBonusHealth() > 0 || this.hireable.getBonusDamage() > 0 ? (this.hireable.getBonusHealth() > 0 && this.hireable.getBonusDamage() > 0 ? 74 : 63) : 56) : 50); if(this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack) || this.hireable.HasUpgradeItem(Core.LittleOven)){ this.setLeftSide(27, 30); } if((this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack)) && this.hireable.HasUpgradeItem(Core.LittleOven)){ this.setLeftSide(27, 51); } if(this.hireable.HasUpgradeCount(1)){ if(this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack)){ this.drawTexturedModalRect(k - 20, l + 23, 154, 176, 16, 18); } if(this.hireable.HasUpgradeItem(Core.LittleOven) && (this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack))){ this.drawTexturedModalRect(k - 20, l + 23 + 20, 170, 176, 16, 18); } if(this.hireable.HasUpgradeItem(Core.LittleOven) && !(this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack))){ this.drawTexturedModalRect(k - 20, l + 23, 170, 176, 16, 18); } } for(int i = 0; i < hireable.getBonusUpgradeSlot(); i++){ this.drawTexturedModalRect(k + 125 + (i * 18), l + 71, 17, 93, 18, 18); } //text GL11.glDisable(GL11.GL_LIGHTING); String s = this.hireable.hasCustomNameTag() ? this.hireable.getCustomNameTag() : I18n.format("entity." + Core.getModID() + "." + hireable.getName() + ".name", new Object[0]); this.fontRendererObj.drawString(s + "'s " + I18n.format("entity.gui.stat", new Object[0]), (this.width / 2) - this.fontRendererObj.getStringWidth(s + " " + I18n.format("entity.gui.stat", new Object[0])) / 2, l + 6, 4210752); if(this.toggleRightVisible){ this.fontRendererObj.drawString(I18n.format("entity.gui.level", new Object[0]) + " = " + hireable.getLevel(), k + 198, l + 14 + 9, 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.health", new Object[0]) + " = " + hireable.getHealth(), k + 198, l + 14 + (9 * 2), 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.maxhealth", new Object[0]) + " = " + hireable.getMaxHealth(), k + 198, l + 14 + (9 * 3), 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.xp", new Object[0]) + " = " + hireable.getXP() + " / " + hireable.getXPtonextLevel(), k + 198, l + 14 + (9 * 4), 4210752); this.fontRendererObj.drawString(I18n.format("entity.gui.damage", new Object[0]) + " = " + hireable.getAttackDamage(), k + 198, l + 14 + (9 * 5), 4210752); if(this.hireable.getBonusHealth() > 0){ this.fontRendererObj.drawString(I18n.format("entity.gui.bonushealth", new Object[0]) + " +" + (hireable.getBonusHealth() * 2), k + 198, l + 14 + (9 * 6), 4210752); } if(this.hireable.getBonusDamage() > 0){ this.fontRendererObj.drawString(I18n.format("entity.gui.bonusdamage", new Object[0]) + " +" + hireable.getBonusDamage(), k + 198, l + 14 + (9 * (this.hireable.getBonusHealth() > 0 ? 7 : 6)), 4210752); } } } public void actionPerformed(GuiButton button) { if(button.id == 0){ this.mc.displayGuiScreen(new GuiPowerUp(hireable)); } if(button.id == 1 || button.id == 2){ if(this.toggleRightVisible == false){ this.toggleRightVisible = true; }else{ this.toggleRightVisible = false; } if(this.toggleLeftVisible == false){ this.toggleLeftVisible = true; }else{ this.toggleLeftVisible = false; } } if(button.id == 3){ Core.network.sendToServer(new SendPackage(5, hireable.getEntityId(), 1)); } if(button.id == 4){ Core.network.sendToServer(new SendPackage(5, hireable.getEntityId(), 2)); } } private void setRightSide(int sizex, int sizey) { int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; if(sizey > 80){ this.drawTexturedModalRect(k + xSize, l + 17, 154 - sizex, 176, sizex, 4); this.drawTexturedModalRect(k + xSize, l + 17 + 4, 154 - sizex, 180, sizex, 60); this.drawTexturedModalRect(k + xSize, l + 17 + 64, 154 - sizex, 180, sizex, sizey - 68); this.drawTexturedModalRect(k + xSize, l + 17 + (sizey - 4), 154 - sizex, 252, sizex, 4); }else{ this.drawTexturedModalRect(k + xSize, l + 17, 154 - sizex, 176, sizex, sizey - 4); this.drawTexturedModalRect(k + xSize, l + 17 + (sizey - 4), 154 - sizex, 252, sizex, 4); } } private void setLeftSide(int sizex, int sizey) { int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; if(sizey > 80){ this.drawTexturedModalRect(k - sizex, l + 17, 0, 176, sizex, 4); this.drawTexturedModalRect(k - sizex, l + 17 + 4, 0, 180, sizex, 60); this.drawTexturedModalRect(k - sizex, l + 17 + 64, 0, 180, sizex, sizey - 68); this.drawTexturedModalRect(k - sizex, l + 17 + (sizey - 4), 0, 252, sizex, 4); }else{ this.drawTexturedModalRect(k - sizex, l + 17, 0, 176, sizex, sizey - 4); this.drawTexturedModalRect(k - sizex, l + 17 + (sizey - 4), 0, 252, sizex, 4); } } public void func_74223_a(Minecraft par0Minecraft, int par1, int par2, int par3, float par4, float par5) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef((float)par1, (float)par2, 50.0F); GL11.glScalef((float)(-par3), (float)par3, (float)par3); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(10, 1.0F, 0.0F, 0.0F); //GL11.glRotatef((((float)(System.currentTimeMillis()%10000)) / 10000)*360, 0, 1, 0); float percent = (((float)(System.currentTimeMillis()%5000)) / 5000); if(percent < 0.75){ GL11.glRotatef(percent*180F/.75F-90F, 0, 1, 0); }else{ GL11.glRotatef(percent*180F/.25F-90F, 0, 1, 0); } GL11.glRotatef(0,0,1,0); RenderManager.instance.playerViewY = 180.0F; //hireable.renderShadow = false; RenderManager.instance.renderEntityWithPosYaw(new EntityHireable(Minecraft.getMinecraft().theWorld).setTextureInt(hireable.getTextureInt()).copyInventory(hireable), 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); //RenderManager.instance.renderEntityWithPosYaw(par0Minecraft.thePlayer, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); //GL11.glRotatef((((float)(System.currentTimeMillis()%10000)) / 10000)*360, 0, -1, 0); GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_COLOR_MATERIAL); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } public void updateScreen() { if(this.hireable.HasUpgradeItem(Core.BackPack) || this.hireable.HasUpgradeItem(Core.IronBackPack) || this.hireable.HasUpgradeItem(Core.DiamondBackPack)){ ((GuiButton)this.buttonList.get(3)).enabled = true; }else{ ((GuiButton)this.buttonList.get(3)).enabled = false; } if(this.hireable.HasUpgradeItem(Core.LittleOven)){ ((GuiButton)this.buttonList.get(4)).enabled = true; }else{ ((GuiButton)this.buttonList.get(4)).enabled = false; } super.updateScreen(); } public boolean doesGuiPauseGame() { return false; } }
  4. So I did this in the Entity class in the OnUpdate methode. But It still does not work and it still says it had a potentionel memory leak
  5. So it does not change a thing. for the way I does it. if(message.code == 10){ WorldServer worldserver = (WorldServer)ctx.getServerHandler().playerEntity.worldObj; EntityTracker track = worldserver.getEntityTracker(); Entity entity = ctx.getServerHandler().playerEntity.worldObj.getEntityByID(message.entityID); EntityHireable hire = (EntityHireable)entity; hire.Backpack = -1; track.func_151247_a(entity, Core.network.getPacketFrom(message)); } I this is text from the console: [19:43:28] [Client thread/ERROR] [FML]: Detected ongoing potential memory leak. 100 packets have leaked. Top offenders [19:43:28] [Client thread/ERROR] [FML]: comp101.channel : 100
  6. How can I use the EntityTracker? I'm now checking the change and it works. (checked by println()) What do I need to do when I call the sendToAll(Message)?
  7. I mean when I checked if the itemstack and then use network.sendToServer() to change the itemstack again but then use by server so the server will change the itemstack. Maybe I could also modify the Slot class, the OnSlotChanged methode. So it will send a package to the server.
  8. That is a bit of a problem. I have no clue on how to do that thing. Should I just check it and then send a package to the server telling the item is changed so the model can be changed on all clients. Would that work, gonna test it right away
  9. Can't you just create a different png with an animation of all colors. Like the portal or fire. And then use that picture as an overlay on the sword.
  10. So, i'm sending stuf through packages with the Message stuff. (followed your thread on that) But how do I tell the other clients that something has changed?
  11. Try to do it, but how do I check if an item is added to an itemstack or removed. Let me be more specific. When you right click, a gui will open. There is an slot that will need an item. When this item is placed in there, there will be something added to the model. This works fine, but when on a server, the added thing to the model does not show an other client. Ho do I check this?
  12. I have made a mob which you can give an item and then the model will change a bit. Everytime I log on to my world, that change is not shown on screen. I create a simple println() to show if the item is stored in it and it does. How can I make the World or Server render the change when starting the world.
  13. Okay I was working on some stuff and I thought let's get a player skin when renaming the mob to it. This is just the normal Biped model, so the skin server would be great. I went digging in the RenderPlayer class and found the bindTexture part. It guides me to AbstractClientPlayer via getLocationSkin() this is a dead end, because it gets a stored ResourceLocation, that is set using a methode in this class by another class. That class is neary impossible to get, because of all the func_123456_a methodes. When I look in the AbstractClientPlayer class, I can see it has a getDownloadImageSkin methode. This could be it. no. it returns a ThreadDownloadImageData. I could make a new IResourceManager, but that would not be the best idea. In the AbstractClientPlayer class, the constructor refers is an other class, called the SkinManager. this looks promising. But again, this is usng MinecraftProfileTexture, which is almost not useable by a simple modder, me! I had an idea, making a methode that will download the skin from an URL and then gettingthat image via a RecourceLocation. The only problem, I have no clue how to do that! Could anyone please help me with this?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.