Jump to content

Casual Dutchman

Members
  • Posts

    98
  • Joined

  • Last visited

Everything posted by Casual Dutchman

  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?
  14. I'm sorry, I'm just being stupid. The item was a New Item instead of a New ItemBackPack That is the reason. next time I will double check every option before posting here. gawd, I feel dumb!
  15. I did not say that, I was just saying that you don't need it, it is usefull to see if the methode corresponds to the methode called by the extended class. With or without the @Override annotation, it does not work and I hace copied the methode over and over again from various other classes. Here is the Item class: nothing strange, no errors, registered just like other items. I just have no clue package mefa.Items; import java.util.List; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ItemBackpack extends Item{ public ItemBackpack() { super(); this.setMaxStackSize(1); } @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } }
  16. Java.util.List This is also used by the first set of code from my previous post. This is not the problem.
  17. I'm sorry? Minecraft will get the methode as an overwritten methode. In the ItemStack class the methode is called int the getToolTip mothode. It will then get the addinformation methode from the item in the itemstack. if the custom item does not have this methode, it will use the empty methode in the Item class. btw, it did not work? I have no clue why not? look at the first and the second methode! the first one will display the information and de second not! //nothing fancy here, no override, no sideonly, nothing public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { String info = EnumChatFormatting.DARK_GRAY + "A very effective melee weapon"; String info2 = EnumChatFormatting.DARK_GRAY + "Shift-Right-Click a door to instantly smash it"; par3List.add(info); par3List.add(info2); } //Works great @Override //<= just this! public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } //does not display!
  18. I created a custom Irecipe that adds a tier upon a succesfull recipe. But then comes the problem. Now I created a the AddInformation(things) methode to display more information. It just does not display. public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if(par1ItemStack.hasTagCompound()){ NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound().getCompoundTag("backpack"); if(nbttagcompound != null){ if(nbttagcompound.hasKey("tier")){ int tier = nbttagcompound.getInteger("tier"); String sayTier = "Tier " + tier; par3List.add(sayTier); } } } String info = "info"; par3List.add(info); } the wierd part is, "info" is not even displayed!
  19. I created a Item that will use custom itemstack's nbt tag lists. (same as Dyeable Leather armor) The only thing is, I will not use it to change color. I want it so that is you place in item A, the main item, All Items B increase the tier. The only problem is, it does not even create a new item in the crafting table; Just nothing. This is the register code: GameRegistry.addRecipe(new RecipeIncreaseTier()); Here is my Item Code: public boolean hasTier(ItemStack par1ItemStack) { return (!par1ItemStack.hasTagCompound() ? false : (!par1ItemStack.getTagCompound().hasKey("display", 10) ? false : par1ItemStack.getTagCompound().getCompoundTag("display").hasKey("tier", 3))); } public int getTier(ItemStack par1ItemStack) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { return 1; } else { NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); return nbttagcompound1 == null ? 1 : (nbttagcompound1.hasKey("tier", 3) ? nbttagcompound1.getInteger("tier") : 1); } } public void setTier(ItemStack par1ItemStack, int par2) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); if (nbttagcompound == null) { nbttagcompound = new NBTTagCompound(); par1ItemStack.setTagCompound(nbttagcompound); } NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); if (!nbttagcompound.hasKey("display", 10)) { nbttagcompound.setTag("display", nbttagcompound1); } nbttagcompound1.setInteger("tier", par2); } public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { String info = ""; NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("display"); info = "Tier " + (nbttagcompound1 == null ? 1 : (nbttagcompound1.hasKey("tier", 3) ? nbttagcompound1.getInteger("tier") : 1)); par3List.add(info); } } Here is the IRecipe Code: @Override public boolean matches(InventoryCrafting par1InventoryCrafting, World var2) { ItemStack itemstack = null; ArrayList arraylist = new ArrayList(); for (int i = 0; i < par1InventoryCrafting.getSizeInventory(); ++i) { ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(i); if (itemstack1 != null) { if (itemstack1.getItem() instanceof ItemBackpack) { if (itemstack1.getItem() != Core.BackPack || itemstack != null) { return false; } itemstack = itemstack1; } else { if (itemstack1.getItem() != Items.diamond) { return false; } arraylist.add(itemstack1); } } } return itemstack != null && !arraylist.isEmpty(); } @Override public ItemStack getCraftingResult(InventoryCrafting par1InventoryCrafting) { ItemStack itemstack = null; int Int = 0; int[] aint = new int[3]; int i = 0; int j = 0; ItemBackpack backpack = null; int k; int l; float f; float f1; int l1; for (k = 0; k < par1InventoryCrafting.getSizeInventory(); ++k) { ItemStack itemstack1 = par1InventoryCrafting.getStackInSlot(k); if (itemstack1 != null) { if (itemstack1.getItem() instanceof ItemBackpack) { backpack = (ItemBackpack)itemstack1.getItem(); if (itemstack1.getItem() != Core.BackPack || itemstack != null) { return null; } itemstack = itemstack1.copy(); itemstack.stackSize = 1; if (backpack.hasTier(itemstack1)) { l = backpack.getTier(itemstack); Int = l; ++j; } } else { if (itemstack1.getItem() != Items.diamond) { return null; } Int = Int + 1; ++j; } } } if (backpack == null) { return null; } else { l1 = Int + j; backpack.setTier(itemstack, l1); return itemstack; } } @Override public int getRecipeSize() { return 10; } @Override public ItemStack getRecipeOutput() { return null; } }
  20. It is not that difficult. btw, it is the only easy way to get it done! this is my getArmorModel methode: @Override @SideOnly(Side.CLIENT) public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { ModelBiped armorModel = null; if(itemStack != null) { if(itemStack.getItem() instanceof ItemBackpack) { int type = ((ItemArmor)itemStack.getItem()).armorType; if(type == 1){ armorModel = Core.proxy.getArmorModel(0); } } if(armorModel != null){ armorModel.bipedBody.showModel = armorSlot == 1; armorModel.bipedRightArm.showModel = armorSlot == 1; armorModel.bipedLeftArm.showModel = armorSlot == 1; armorModel.isSneak = entityLiving.isSneaking(); armorModel.isRiding = entityLiving.isRiding(); armorModel.isChild = entityLiving.isChild(); return armorModel; } } return null; } You can see it uses some less stuff then the methode in the RenderBiped class. There is only one item used here, the chestplate. The tutorial looks very difficult, but it is really easy to understand.
  21. http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571595-1-7-2-how-to-code-custom-3d-armor-models-3d
  22. It's a shame the shouldrenderpass can only be up to 4 ties and the armor uses all the 4 passes. It there a way to get more passes for this methode?
×
×
  • Create New...

Important Information

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