Auto void trading
cxnub
kotlin
a year ago
2.5 kB
18
Indexable
import * from Minecraft; //simple wanted items simpleItems = [ "quartz_block" ]; outOfEmeralds = false; fun tradeWithVillager(player, villager) { player.interactWithEntity(villager); // wait until barrel found to avoid // villager locking out the trade barrel = findBarrel(player); sleep(200); // make the trade currentScreen = player.getCurrentScreen(); if (currentScreen.getName() != "Merchant") { return; } tradeList = currentScreen.getTradeList(); NumberOfTrades = len(tradeList); // loop through all trades for (i=0; i < NumberOfTrades; i++) { trade = tradeList.get(i); tradeItem = trade.getSellItem(); // loop through all wanted items foreach (item : simpleItems) { // if the trade is for the wanted item if (tradeItem.getId() == item) { print("Found trade for " + item); sleep(100); uses = trade.getUses(); maxUses = trade.getMaxUses(); print("Trading"); // trade until the trade is used up for (j=0; j < maxUses; j++) { sleep(100); currentScreen.tradeIndex(i); uses = trade.getUses(); // check if player ran out of emeralds if (uses == 0 && j > 0) { outOfEmeralds = true; print("Out of emeralds, refilling..."); break; } } // drop the items dropTradedItem(player, tradeItem); } } } // close the screen player.closeScreen(); // open the barrel player.interactBlock(barrel.getPos(), "down"); // refill if out of emeralds if (outOfEmeralds) { // get all emeralds from barrel for (i=0; i < 27; i++) { sleep(100); player.shiftClickSlot(i); print("Refilled " + (i + 1).toString() + " stacks of emeralds"); } outOfEmeralds = false; } } fun findVillager(player) { // wait for player to look at villager villager = player.getLookingAtEntity(); while (villager == null || villager.getId() != "villager") { sleep(100); villager = player.getLookingAtEntity(); } print("Villager found"); return villager; } fun findBarrel(player) { // wait for player to look at barrel barrel = player.getLookingAtBlock(); while (barrel.getId() != "barrel") { sleep(100); barrel = player.getLookingAtBlock(); } print("Barrel found"); return barrel; } fun dropTradedItem(player, item) { player.dropAllExact(item); } player = Player.get(); while (true) { villager = findVillager(player); tradeWithVillager(player, villager); sleep(1000); }
Editor is loading...
Leave a Comment