12345678910111213141516171819202122232425262728293031 |
- package me.km.utils;
- import net.minecraft.entity.passive.EntityVillager;
- import net.minecraft.inventory.InventoryBasic;
- public class InventoryUtils
- {
- public static InventoryBasic getInventory(EntityVillager v)
- {
- EntityInventory real = new EntityInventory("Villager", 9, v);
- InventoryBasic old = v.getVillagerInventory();
- for(int i = 0; i < 9; i++)
- {
- real.setInventorySlotContents(i, old.getStackInSlot(i).copy());
- }
- return real;
- }
-
- public static void setInventory(EntityInventory inv)
- {
- if(inv.getEntity() instanceof EntityVillager)
- {
- EntityVillager v = (EntityVillager) inv.getEntity();
- InventoryBasic vInv = v.getVillagerInventory();
- for(int i = 0; i < 9; i++)
- {
- vInv.setInventorySlotContents(i, inv.getStackInSlot(i).copy());
- }
- }
- }
- }
|