Untitled
unknown
plain_text
3 years ago
4.2 kB
94
Indexable
// Map of wanted items and any enchantments they have /*wantedItems = { Material.ENCHANTED_BOOK: { "feather_falling" : 2 }, Material.GLASS : { }, Material.BOOKSHELF : { } };*/ //simple wanted items simpleItems = [ //"polished_andesite" "polished_diorite" //"white_wool" //"quartz_block" //"quartz_pillar" //"redstone" ]; fun tradeWithVillager(player, villager) { printOnly = false; afterBuy = 2; //0 = do nothing, 1 = drop, 2 = put in container player.interactWithEntity(villager); // We wait until we are no longer looking at the villager skipFail = 0; if(printOnly == true){ print("Sleep sleep.."); sleep(1500); } else{ while (true) { entity = player.getLookingAtEntity(); if (entity == null || entity.getId() != "villager") { if(player.getY() != 66){ print("!!! FAIL SAFE - STILL WRONG Y-LEVEL !!!"); skipFail++; } else{ break; } } sleep(50); } } // You may need to ajust this based on your setup sleep(1000); currentScreen = player.getCurrentScreen(); if (!currentScreen.instanceOf("MerchantScreen")) { return; } tradeList = currentScreen.getTradeList(); // print("Len of tradeList"); // print(len(tradeList)); if(skipFail < 11){ for (i = 0; i < len(tradeList); i++) { trade = tradeList.get(i); sellItem = trade.getSellItem(); if(printOnly == true){ print("I have sellitem..."); print(sellItem); print(sellItem.getId()); } else{ //sellItemEnchants = sellItem.getEnchantments(); foreach (material : simpleItems) { if (sellItem.getId() != material) { continue; } isMatch = true; // We trade until we can't // print("MaxUses: "); // print(trade.getMaxUses()); // print(trade.getUses()); print("Shopping time..."); print(player.getPos()); for (j = 0; trade.getUses() < trade.getMaxUses(); j++) { if (j > 30) { // You could maybe add a check to see if the player // still has the required items to do the trade print("Tried to trade too many times"); stop(); } print("Real $hopping time..."); currentScreen.tradeIndex(i); sleep(50); } sleep(50); if(afterBuy == 1){ player.dropAll(sellItem.getMaterial().asItemStack()); } } } } }else{ print("Skipping buying..."); print(skipFail); } if(printOnly == true){ print("Stopping script...."); stop(); } sleep(1200); player.closeScreen(); print("Looking for chest..."); chest = player.getLookingAtBlock(); while(true){ if(chest != null && chest.getId() == "trapped_chest") { print("Found chest"); break; } else{ print(chest); } sleep(50); chest = player.getLookingAtBlock(); } sleep(100); playerpos = new Pos(player.getX(), player.getY(), player.getZ()); player.interactBlock(playerpos, "down", chest.getPos(), false); sleep(50); if(afterBuy == 2){ foreach (material : simpleItems) { slotList = player.getAllSlotsFor(Material.of(material).asItemStack()); //print("Items are at slot..."); foreach(slot: slotList){ if(player.getTotalSlots() > slot && slot > 53){ player.shiftClickSlot(slot); } //print(slot); } } } //27 is first item in inventory (if single chest is opened) //54 is first hotbar //54 is first item in inventory with double chest /* if(player.getTotalSlots() > 80){ print("Dropping too much coins if.."); player.shiftClickSlot(56); //player.shiftClickSlot(76); //player.shiftClickSlot(77); }*/ /* for(x = 0; x < len(simpleItems); x++){ //print(27 + x); //player.shiftClickSlot(36 + x); //player.shiftClickSlot(28 + x); sleep(5); }*/ //player.closeScreen(); } print("Waiting.."); sleep(2500); print("Start"); while (true) { player = Player.get(); entity = player.getLookingAtEntity(); if (entity != null && entity.getId() == "villager") { print("Next round.."); tradeWithVillager(player, entity); } sleep(50); }
Editor is loading...