Jump to content

Lua

Members
  • Posts

    191
  • Joined

  • Last visited

Everything posted by Lua

  1. Wait I thought you meant in game, like "You actually put something in the bag didnt you?" anyway heres the code: @Override public void openChest() { if(bagpack.hasTagCompound()) { readFromNBT(bagpack.getTagCompound());//Bag pack has some info for the inventory System.out.println("call3"); } else { bagpack.stackTagCompound = new NBTTagCompound(); System.out.println("call2"); } } @Override public void closeChest() { if(! bagpack.hasTagCompound()) { //Should never be reached, since done when opening the first time bagpack.setTagCompound(writeToNBT(new NBTTagCompound())); System.out.println("call"); } else {//We made changes to the inventory, save them System.out.println("call4"); writeToNBT(bagpack.getTagCompound()); }
  2. Yes I put some itemstacks in it and closed it
  3. Okay, after some more testing, it seems that it writes to nbt when opened to according to the console. And its trying to read the nbt but it looks like nothing is there. Also yeah bagpack is an instance of itemstack
  4. Yes I have @Override public void openChest() { if(bagpack.hasTagCompound()) { System.out.println("hastag");//never gets printed readFromNBT(bagpack.getTagCompound()); } } @Override public void closeChest() { if(! bagpack.hasTagCompound()) { System.out.println("writing without tag compound"); //Prints all the time, even after its set and it should be false bagpack.setTagCompound(new NBTTagCompound()); } NBTTagCompound tag = bagpack.getTagCompound(); writeToNBT(tag); } It seems that the tag never gets properly because it always seems to get set everytime and always goes through the if statement. But the hasCompound never gets printed
  5. this, its someting simple but you "give up" ... oh well one less mod on the market... I couldnt figure out what was wrong w/ my saving code and neither could anyone else it seemed
  6. wut
  7. I give up.
  8. As in, it didnt work, Im not sure why too
  9. bump :c
  10. Nope :C
  11. I have no idea, I know most people dont work like this, but can some one just give me the code? Ive tried to do myself but no avail
  12. @GotoLink Okay this is what i tried and it didnt work: @Override public void openChest() { NBTTagCompound compound = new NBTTagCompound(); ItemStack stack = ItemStack.loadItemStackFromNBT(compound); if(bagpack.hasTagCompound()) { System.out.println("hastag");//never gets printed //readFromNBT(bagpack.getTagCompound()); readFromNBT(stack.getTagCompound()); } } @Override public void closeChest() { NBTTagCompound compound = new NBTTagCompound(); ItemStack stack = ItemStack.loadItemStackFromNBT(compound); System.out.println("writing without tag compound"); //Prints all the time, even after its set and it should be false //bagpack.setTagCompound(new NBTTagCompound()); if(stack != null) { writeToNBT(stack.getTagCompound()); } }
  13. In the open and close chest methods? (They get called when opening and closing the container btw)
  14. Can I have an example?
  15. Anyone?
  16. Okay Im trying to save the items in container item based gui. This is what ive got so far but I cant seem to get it to work: ItemBagpackInventory(Ive written some comments on some bits which I think is the problem Container Bagpack: GuBagpack: package simplecamping; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.FMLClientHandler; public class GuiBagpack extends GuiContainer { public ItemBagpackInventory bagpack; public GuiBagpack(InventoryPlayer par1InventoryPlayer, ItemBagpackInventory bgInv) { super(new ContainerBagpack(par1InventoryPlayer, bgInv)); this.bagpack = bgInv; } /** * Draw the foreground layer for the GuiContainer (everything in front of the items) */ protected void drawGuiContainerForegroundLayer(int par1, int par2) { String s = this.bagpack.isInvNameLocalized() ? this.bagpack.getInvName() : I18n.func_135053_a(this.bagpack.getInvName()); this.fontRenderer.drawString(s, 8, 6, 4210752); this.fontRenderer.drawString(I18n.func_135053_a("container.inventory"), 8, this.ySize - 96 + 2, 4210752); } /** * Draw the background layer for the GuiContainer (everything behind the items) */ protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation(Strings.MOD_ID, "/textures/gui/bagpack.png")); int k = this.guiLeft; int l = this.guiTop; this.drawTexturedModalRect(k, l, 0, 0, 256, 256); } } GuiHandler:
  17. Okay, thanks for everything:D
  18. Okay I changed it to a new class and registered it and stuff but yeah its my texture what is messing it up, cant I have http://gyazo.com/4c72117aef825f9dbcaa98c2e1db6ce9 this because id like it to have a border
  19. is it my texture? http://gyazo.com/4c72117aef825f9dbcaa98c2e1db6ce9 Heres my code. but yeah I think I copied everything: private Timer timer; public void HealthBarRenderer() { Field[] fields = Minecraft.getMinecraft().getClass().getDeclaredFields(); for(Field field : fields) { if(field.getType().isAssignableFrom(Timer.class)) { field.setAccessible(true); try { timer = (Timer) field.get(Minecraft.getMinecraft()); } catch(IllegalArgumentException e) { e.printStackTrace(); } catch(IllegalAccessException e) { e.printStackTrace(); } } } } @ForgeSubscribe public void renderCavemanHealthBar(RenderLivingEvent.Specials.Pre event) { float interp = 1; EntityLivingBase e = event.entity; float healthLength = 5;//you can change the length of the health if you want float healthHeight = 2.0f;//and its height EntityPlayer p = Minecraft.getMinecraft().thePlayer; double diffX = e.prevPosX + interp * (e.posX - e.prevPosX) - (p.prevPosX + interp * (p.posX - p.prevPosX)); double diffY = e.prevPosY + interp * (e.posY - e.prevPosY) - (p.prevPosY + interp * (p.posY - p.prevPosY)); double diffZ = e.prevPosZ + interp * (e.posZ - e.prevPosZ) - (p.prevPosZ + interp * (p.posZ - p.prevPosZ)); GL11.glPushMatrix(); double height = event.entity.boundingBox.maxY - event.entity.boundingBox.minY + 0.5; GL11.glTranslated(diffX, diffY + height, diffZ); GL11.glRotated(- p.rotationYaw, 0, 1, 0); GL11.glScaled(- 1, 1, 1); Tessellator t = Tessellator.instance; FMLClientHandler.instance().getClient().renderEngine.func_110577_a(new ResourceLocation(Strings.MOD_ID, "/textures/gui/health_bar.png")); float currentHealth = e.getDataWatcher().func_111145_d(6); float maxHealth = e.func_110138_aP(); float sizeOfActiveHealth = healthLength * (currentHealth / maxHealth); GL11.glTranslated(- healthLength / 2f, 0, 0); t.startDrawingQuads(); t.setColorOpaque(0, 255, 0); t.addVertexWithUV(0, 0, 0, 0, 0); t.addVertexWithUV(sizeOfActiveHealth, 0, 0, 1, 0); t.addVertexWithUV(sizeOfActiveHealth, healthHeight, 0, 1, 1); t.addVertexWithUV(0, healthHeight, 0, 0, 1); t.draw(); float rest = healthLength - sizeOfActiveHealth; GL11.glTranslated(sizeOfActiveHealth, 0, 0); t.startDrawingQuads(); t.setColorOpaque(255, 0, 0); t.addVertexWithUV(0, 0, 0, 0, 0); t.addVertexWithUV(rest, 0, 0, 1, 0); t.addVertexWithUV(rest, healthHeight, 0, 1, 1); t.addVertexWithUV(0, healthHeight, 0, 0, 1); t.draw(); GL11.glPopMatrix(); }
  20. Like when he takes damage the other bar starts to happen
  21. http://gyazo.com/13704bfdbee6eac630adde08953337ce This is what happens
  22. Wut, I cant edit base classes...
  23. float interp = timer.renderPartialTicks; Got an npe at ^
  24. Wait isnt the problem in here public static void drawTexturedQuadFit(double x, double y, double width, double height, double zLevel) { caveman = caveman.getCaveman(); Tessellator tessellator = Tessellator.instance; if(caveman != null) { for(int i = 0; i < caveman.func_110138_aP(); i++) { if(caveman.func_110138_aP() > i) { tessellator.startDrawingQuads(); tessellator.setColorOpaque(0, 255, 0); tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0, 1); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1); tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1, 0); tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0); tessellator.setColorOpaque(0, 255, 0); tessellator.draw(); } else { tessellator.startDrawingQuads(); tessellator.setColorOpaque(255, 0, 0); tessellator.addVertexWithUV(x + 0, y + height, zLevel, 0, 1); tessellator.addVertexWithUV(x + width, y + height, zLevel, 1, 1); tessellator.addVertexWithUV(x + width, y + 0, zLevel, 1, 0); tessellator.addVertexWithUV(x + 0, y + 0, zLevel, 0, 0); tessellator.setColorOpaque(255, 0, 0); tessellator.draw(); } } } } Because before I added that it was working
×
×
  • Create New...

Important Information

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