InventoryUtils.java 934 B

12345678910111213141516171819202122232425262728293031
  1. package me.km.utils;
  2. import net.minecraft.entity.passive.EntityVillager;
  3. import net.minecraft.inventory.InventoryBasic;
  4. public class InventoryUtils
  5. {
  6. public static InventoryBasic getInventory(EntityVillager v)
  7. {
  8. EntityInventory real = new EntityInventory("Villager", 9, v);
  9. InventoryBasic old = v.getVillagerInventory();
  10. for(int i = 0; i < 9; i++)
  11. {
  12. real.setInventorySlotContents(i, old.getStackInSlot(i).copy());
  13. }
  14. return real;
  15. }
  16. public static void setInventory(EntityInventory inv)
  17. {
  18. if(inv.getEntity() instanceof EntityVillager)
  19. {
  20. EntityVillager v = (EntityVillager) inv.getEntity();
  21. InventoryBasic vInv = v.getVillagerInventory();
  22. for(int i = 0; i < 9; i++)
  23. {
  24. vInv.setInventorySlotContents(i, inv.getStackInSlot(i).copy());
  25. }
  26. }
  27. }
  28. }