hohserg

Untitled

Sep 22nd, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.99 KB | None | 0 0
  1. package org.cifrazia.entity;
  2.  
  3. import net.minecraft.item.ItemStack;
  4. import net.minecraft.util.NonNullList;
  5. import noppes.npcs.entity.EntityNPCInterface;
  6. import org.apache.commons.lang3.tuple.Pair;
  7. import org.cifrazia.stat.npc.NpcCapability;
  8. import org.cifrazia.stat.npc.NpcCapabilityProvider;
  9.  
  10. import java.util.List;
  11. import java.util.stream.Collectors;
  12.  
  13. public class EntityDeadNPCWrapper implements IEntityLootable {
  14.     private NpcCapability capability;
  15.     private int invHeight;
  16.     private EntityNPCInterface npc;
  17.  
  18.     private List<ItemStack> resultDrops;
  19.  
  20.     public EntityDeadNPCWrapper(EntityNPCInterface npc) {
  21.         this.npc = npc;
  22.         capability = npc.getCapability(NpcCapabilityProvider.NPC_CAP, null);
  23.  
  24.         resultDrops = capability.drops
  25.                 .stream()
  26.                 .filter(p -> {
  27.                     float v = npc.world.rand.nextFloat();
  28.                     return p.getRight() > v;
  29.                 })
  30.                 .map(Pair::getLeft)
  31.                 .collect(Collectors.toList());
  32.  
  33.         invHeight = (int) Math.ceil(((float)resultDrops.size())/9);
  34.  
  35.         System.out.println(invHeight);//1
  36.         System.out.println(resultDrops);//apple
  37.     }
  38.  
  39.     @Override
  40.     public int getLootableInventorySize() {
  41.         return invHeight * 9;
  42.     }
  43.  
  44.     @Override
  45.     public NonNullList<ItemStack> getInventory() {
  46.         return NonNullList.from(ItemStack.EMPTY, resultDrops.toArray(new ItemStack[0]));
  47.     }
  48.  
  49.     @Override
  50.     public String getRenderName() {
  51.         return npc.getName();
  52.     }
  53.  
  54.     @Override
  55.     public float getWidth() {
  56.         return npc.width;
  57.     }
  58.  
  59.     @Override
  60.     public float getHeight() {
  61.         return npc.height;
  62.     }
  63.  
  64.     @Override
  65.     public int getInventoryWidth() {
  66.         return 9;
  67.     }
  68.  
  69.     @Override
  70.     public int getInventoryHeight() {
  71.         return invHeight;
  72.     }
  73.  
  74.     @Override
  75.     public int getTicksToCorpseDeath() {
  76.         return npc.stats.respawnTime * 1000 / 2;
  77.     }
  78. }
Advertisement
Add Comment
Please, Sign In to add comment