Jump to content

Nichie

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Nichie's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Hi, all! What i have?: I have new custom inventory. At this inventory i have custom slot for backpack. If i put backpack into this slot, appear new slots. What i need?: If i put backpack into custom slot and put some items into new backpack slots it need to be save for this backpack. So, if i remove backpack from slot, backpack slots save for backpack. if i put backpack, backpack slots appear and items, which saved for this backpack, appear into backpack slots. How i realized it?: I realized it in my BackpackSlot (Custom slot in my inventory). I do it with NBT. private ItemStack lastItem; private int lastType; public void onSlotChanged() { ItemStack is = this.invEx.getBackpack(); int type = this.invEx.bagTypeInv; if(is != null && is.getItem() instanceof ItemBackpack) { lastItem = this.invEx.getBackpack(); lastType = this.invEx.bagTypeInv; this.invEx.bagTypeInv = ((ItemBackpack)this.getStack().getItem()).bagTypeItem; if(type != 3) { this.readSlots(is, type * 6); } else { this.readSlots(is, type * 5); } } else { if(lastType != 3) { this.writeSlots(lastItem, lastType * 6); } else { this.writeSlots(lastItem, lastType * 5); } this.invEx.bagTypeInv = 0; } } public void readSlots(ItemStack item, int slotsToClear) { int slotsCount = 3 + slotsToClear); if(item.stackTagCompound != null) { NBTTagList nbttaglist = item.stackTagCompound.getTagList("Items1", 10); for (int i = 0; i <= nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound1 = (NBTTagCompound)nbttaglist.getCompoundTagAt(i); byte b0 = nbttagcompound1.getByte("Slot"); if (b0 >= 3 && b0 < slotsCount) { this.invEx.invslots[b0] = ItemStack.loadItemStackFromNBT(nbttagcompound1); } } } } public static boolean isDo = false; public void writeSlots(ItemStack item, int slotsToClear) { int slotsCount = 3 + slotsToClear; if(!isDo) { if(item != null) { item.stackTagCompound = new NBTTagCompound(); NBTTagList nbttaglist = new NBTTagList(); for(int i = 3; i < slotsCount; ++i) { if (this.invEx.invslots[i] != null) { NBTTagCompound nbttagcompound1 = new NBTTagCompound(); nbttagcompound1.setByte("Slot", (byte)i); this.invEx.invslots[i].writeToNBT(nbttagcompound1); nbttaglist.appendTag(nbttagcompound1); } this.invEx.setInventorySlotContents(i, (ItemStack)null); } item.stackTagCompound.setTag("Items1", nbttaglist); } isDo = true; } } Boolean 'isDo' automaticaly set to false into TickHandler. If it was not, then the first recorded items, and then instead of them null. What do it code?: This code should work, but it is packed with bugs. For example, I can put on a backpack will preserve things for him, then put on another click on an empty slot and somehow pull out the things that have been preserved for the first out of the void. They are, as it were left on the server. Or, I can take a completely empty backpack, and there will be things that have been stored for a completely different backpack that I've been deleted. So, how i can realize/fix that?
  2. Mod must be on version 1.6.4. (It will be updated to 1.7.2, but now it must be on 1.6.4) I know, what need to send packets. But how to do this on version 1.6.4?
  3. Hi all! I created new Inventory, which open if i press 'I'. Inventory have one new slot. If in this slot put the backpack, his should be rendered behind the player back. I use RenderPlayerAPI, because mod must be compatibility with Smart Moving. But if i put backpack into the slot on server. It will be visible only for me. Render method: public void renderModel(EntityLivingBase entityLiving, float f1, float f2, float f3, float f4, float f5, float f6) { super.renderModel(entityLiving, f1, f2, f3, f4, f5, f6); EntityPlayer player = (EntityPlayer)entityLiving; InventoryEx inv = PlayerExtended.get(player).inventory; if (inv.bagtype == 1) { this.mc.getTextureManager().bindTexture(small_t); super.renderPlayerAPI.getModelBipedMainField().bipedBody.postRender(0.0625F); this.small.render(0.0625F); } } 'bagtype' - type of backpack. Automatically changes to 1, if he is in the slot. I registry Render into ClientProxy. RenderPlayerAPI.register(NichieInfo.ID, RenderBackpackOnPlayer.class); How to fix this?
×
×
  • Create New...

Important Information

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