Advertisement
Ghaz-ranka

Untitled

May 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. if (hasShovelHead && hasToolHandle){
  2. Sponge.getServer().getBroadcastChannel().send(Text.of("hasShovelHead and hasToolHandle"));
  3.  
  4. int quantity = 0;
  5. for (Inventory slot : player.getInventory().query(shovelHead).slots()) {
  6. ItemStack stack = slot.peek().get();
  7. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Stone Shovelhead")){
  8. quantity += stack.getQuantity();
  9. }
  10. }
  11. int quantity2 = 0;
  12. for (Inventory slot : player.getInventory().query(ItemTypes.STICK).slots()) {
  13. ItemStack stack = slot.peek().get();
  14. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Tool Handle")){
  15. quantity2 += stack.getQuantity();
  16. }
  17. }
  18. if (quantity < 1) {
  19. player.sendMessage(Text.of("ლ(ಠ益ಠლ)"));
  20. return;
  21. }
  22. if (quantity2 < 1) {
  23. player.sendMessage(Text.of("ლ(ಠ益ಠლ)"));
  24. return;
  25. }
  26. if (quantity > 1 && quantity2 > 1) {
  27. for (Inventory slot : player.getInventory().query(shovelHead).slots()) {
  28. ItemStack stack = slot.peek().get();
  29. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Stone Shovelhead")){
  30. if (stack.getQuantity() >= quantity) {
  31. slot.poll(1);
  32. } else {
  33. quantity -= stack.getQuantity();
  34. slot.clear();
  35. }
  36. }
  37. }
  38. for (Inventory slot : player.getInventory().query(ItemTypes.STICK).slots()) {
  39. ItemStack stack = slot.peek().get();
  40. if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Tool Handle")){
  41. if (stack.getQuantity() >= quantity2) {
  42. slot.poll(1);
  43. } else {
  44. quantity2 -= stack.getQuantity();
  45. slot.clear();
  46. }
  47. }
  48. }
  49. Optional<ItemType> Stoneshovel_ = Sponge.getGame().getRegistry().getType(ItemType.class, "forgecraft:wootzshovel");
  50. ItemType StoneShovelType = Stoneshovel_.get();
  51. ItemStack stoneshovel = ItemStack.of(StoneShovelType, 1);
  52. stoneshovel.offer(Keys.DISPLAY_NAME, Text.of("Stone Shovel"));
  53. //List<Text> itemShovelLore = new ArrayList<Text>();
  54. //itemShovelLore.add(Text.of(TextColors.GOLD, "Crafting Requirements:"));
  55. //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Flat Stone"));
  56. //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Tool Handle"));
  57. //stoneshovel.offer(Keys.ITEM_LORE , itemShovelLore);
  58.  
  59. player.getInventory().offer(stoneshovel);
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement