Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (hasShovelHead && hasToolHandle){
- Sponge.getServer().getBroadcastChannel().send(Text.of("hasShovelHead and hasToolHandle"));
- int quantity = 0;
- for (Inventory slot : player.getInventory().query(shovelHead).slots()) {
- ItemStack stack = slot.peek().get();
- if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Stone Shovelhead")){
- quantity += stack.getQuantity();
- }
- }
- int quantity2 = 0;
- for (Inventory slot : player.getInventory().query(ItemTypes.STICK).slots()) {
- ItemStack stack = slot.peek().get();
- if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Tool Handle")){
- quantity2 += stack.getQuantity();
- }
- }
- if (quantity < 1) {
- player.sendMessage(Text.of("ლ(ಠ益ಠლ)"));
- return;
- }
- if (quantity2 < 1) {
- player.sendMessage(Text.of("ლ(ಠ益ಠლ)"));
- return;
- }
- if (quantity > 1 && quantity2 > 1) {
- for (Inventory slot : player.getInventory().query(shovelHead).slots()) {
- ItemStack stack = slot.peek().get();
- if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Stone Shovelhead")){
- if (stack.getQuantity() >= quantity) {
- slot.poll(1);
- } else {
- quantity -= stack.getQuantity();
- slot.clear();
- }
- }
- }
- for (Inventory slot : player.getInventory().query(ItemTypes.STICK).slots()) {
- ItemStack stack = slot.peek().get();
- if (stack.get(Keys.DISPLAY_NAME).orElse(Text.EMPTY).toPlain().equals("Tool Handle")){
- if (stack.getQuantity() >= quantity2) {
- slot.poll(1);
- } else {
- quantity2 -= stack.getQuantity();
- slot.clear();
- }
- }
- }
- Optional<ItemType> Stoneshovel_ = Sponge.getGame().getRegistry().getType(ItemType.class, "forgecraft:wootzshovel");
- ItemType StoneShovelType = Stoneshovel_.get();
- ItemStack stoneshovel = ItemStack.of(StoneShovelType, 1);
- stoneshovel.offer(Keys.DISPLAY_NAME, Text.of("Stone Shovel"));
- //List<Text> itemShovelLore = new ArrayList<Text>();
- //itemShovelLore.add(Text.of(TextColors.GOLD, "Crafting Requirements:"));
- //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Flat Stone"));
- //itemShovelLore.add(Text.of(TextColors.GOLD, "1 Tool Handle"));
- //stoneshovel.offer(Keys.ITEM_LORE , itemShovelLore);
- player.getInventory().offer(stoneshovel);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement