Sunconure111

Untitled

Apr 21st, 2020
386
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /**
  2. * @param entity the entity to check
  3. * @param poppet the poppet variant to find
  4. * @return false always, poppets are not currently in the mod
  5. */
  6. public static boolean hasPoppet(EntityPlayer entity, Item poppet) {
  7. World world = entity.getEntityWorld();
  8. ExtendedWorld ext = ExtendedWorld.get(world);
  9.  
  10. for (int i = 0; i < entity.inventory.getSizeInventory(); i++) {
  11. ItemStack stack = entity.inventory.getStackInSlot(i);
  12. if (stack.getItem() == poppet) {
  13. String uuid = stack.getTagCompound().getString("boundId");
  14. if(entity.getUniqueID().toString().equals(uuid)) {
  15. if (stack.getItemDamage() == 0)
  16. stack.damageItem(2, entity);
  17. else stack.damageItem(1, entity);
  18. return true;
  19. }
  20. }
  21. }
  22.  
  23. for (NBTTagCompound poppetShelves : ext.storedPoppetShelves) {
  24. BlockPos pos = BlockPos.fromLong(poppetShelves.getLong("position"));
  25. if (world.getTileEntity(pos) instanceof TileEntityPoppetShelf) {
  26. TileEntityPoppetShelf te = (TileEntityPoppetShelf) world.getTileEntity(pos);
  27. if (te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
  28. IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
  29. for (int slot = 0; slot < handler.getSlots(); slot++) {
  30. ItemStack itemStack = handler.getStackInSlot(slot);
  31. if (itemStack.getItem() == poppet) {
  32. String uuid = itemStack.getTagCompound().getString("boundId");
  33. if(entity.getUniqueID().toString().equals(uuid)) {
  34. te.damageSlot(entity, slot);
  35. return true;
  36. }
  37. }
  38. }
  39. }
  40. }
  41. }
  42. return false;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment