This commit is contained in:
sebseb7
2023-04-08 06:58:18 +02:00
parent b5c7a6943a
commit f9007c0eae

137
craft.js
View File

@@ -413,10 +413,10 @@ function trade(tradepos, tradelane, reach) {
//mode = 'experience_bottle'; //mode = 'experience_bottle';
//GlobalVars.putString('trade_item','emerald'); //GlobalVars.putString('trade_item','emerald');
//mode = 'emerald'; //mode = 'emerald';
//GlobalVars.putString('trade_item','glass'); GlobalVars.putString("trade_item", "glass");
//mode = 'glass'; mode = "glass";
GlobalVars.putString("trade_item", "redstone"); //GlobalVars.putString("trade_item", "redstone");
mode = "redstone"; //mode = "redstone";
if ( if (
!( !(
@@ -454,17 +454,25 @@ function trade(tradepos, tradelane, reach) {
) { ) {
if (e.getType() === "minecraft:villager") { if (e.getType() === "minecraft:villager") {
const uuid = e.getUUID(); const uuid = e.getUUID();
const epos = e.getPos();
player.lookAt(
epos.x,
epos.y + e.getEyeHeight(),
epos.z
);
const old_uuid = GlobalVars.getString("last_lib"); const old_uuid = GlobalVars.getString("last_lib");
if (old_uuid === uuid) { if (old_uuid === uuid) {
//skip //skip
} else { } else {
GlobalVars.putString("last_lib", uuid); GlobalVars.putString("last_lib", uuid);
player.interactEntity(e, false); player.interactEntity(e, false, true);
const ev = JsMacros.waitForEvent("OpenContainer"); const ev = JsMacros.waitForEvent("OpenContainer");
ev.context.releaseLock(); ev.context.releaseLock();
let inv = Player.openInventory();
Time.sleep(200); Time.sleep(200);
const inv = ev.event.inventory;
const trades = inv ? inv.getTrades() : []; //const inv = ev.event.inventory;
const trades = inv.getTrades();
let found = false; let found = false;
let index = 0; let index = 0;
for (const tr in trades) { for (const tr in trades) {
@@ -552,11 +560,13 @@ function trade(tradepos, tradelane, reach) {
inv.quickAll(i); inv.quickAll(i);
} }
} }
compareT(before1, quantify(inv)); const after = quantify(inv);
compareT(before1, after);
globQuant = after;
} }
if (!globQuant) globQuant = quantify(inv);
const before = globQuant;
const before = quantify(inv);
globQuant = quantify(inv);
inv.close(); inv.close();
if (!before["minecraft:emerald"]) if (!before["minecraft:emerald"])
before["minecraft:emerald"] = 0; before["minecraft:emerald"] = 0;
@@ -604,6 +614,7 @@ function trade(tradepos, tradelane, reach) {
} }
} }
} }
if (false)
if ( if (
e e
.getPos() .getPos()
@@ -618,17 +629,24 @@ function trade(tradepos, tradelane, reach) {
) { ) {
if (e.getType() === "minecraft:villager") { if (e.getType() === "minecraft:villager") {
const uuid = e.getUUID(); const uuid = e.getUUID();
const epos = e.getPos();
player.lookAt(
epos.x,
epos.y + e.getEyeHeight(),
epos.z
);
const old_uuid = GlobalVars.getString("last_cleric"); const old_uuid = GlobalVars.getString("last_cleric");
if (old_uuid === uuid) { if (old_uuid === uuid) {
//skip //skip
} else { } else {
GlobalVars.putString("last_cleric", uuid); GlobalVars.putString("last_cleric", uuid);
player.interactEntity(e, false); player.interactEntity(e, false, true);
const ev = JsMacros.waitForEvent("OpenContainer"); const ev = JsMacros.waitForEvent("OpenContainer");
ev.context.releaseLock(); ev.context.releaseLock();
Time.sleep(100); let inv = Player.openInventory();
const inv = ev.event.inventory; Time.sleep(200);
const trades = inv.getTrades(); //const inv = ev.event.inventory;
const trades = inv.getTrades ? inv.getTrades() : [];
let found = false; let found = false;
let index = 0; let index = 0;
if (emerald < 256 || mode === "emerald") { if (emerald < 256 || mode === "emerald") {
@@ -665,7 +683,11 @@ function trade(tradepos, tradelane, reach) {
if (found === true) { if (found === true) {
const before1 = quantify(inv); const before1 = quantify(inv);
inv.selectTrade(index); inv.selectTrade(index);
for (let i = 0; i < inv.getTotalSlots(); i++) { for (
let i = 0;
i < inv.getTotalSlots();
i++
) {
if (inv.getLocation(i) === "output") { if (inv.getLocation(i) === "output") {
inv.quickAll(i); inv.quickAll(i);
} }
@@ -701,7 +723,11 @@ function trade(tradepos, tradelane, reach) {
if (found === true) { if (found === true) {
const before1 = quantify(inv); const before1 = quantify(inv);
inv.selectTrade(index); inv.selectTrade(index);
for (let i = 0; i < inv.getTotalSlots(); i++) { for (
let i = 0;
i < inv.getTotalSlots();
i++
) {
if (inv.getLocation(i) === "output") { if (inv.getLocation(i) === "output") {
inv.quickAll(i); inv.quickAll(i);
//Chat.log('** redstone traded'); //Chat.log('** redstone traded');
@@ -739,7 +765,11 @@ function trade(tradepos, tradelane, reach) {
if (found === true) { if (found === true) {
const before1 = quantify(inv); const before1 = quantify(inv);
inv.selectTrade(index); inv.selectTrade(index);
for (let i = 0; i < inv.getTotalSlots(); i++) { for (
let i = 0;
i < inv.getTotalSlots();
i++
) {
if (inv.getLocation(i) === "output") { if (inv.getLocation(i) === "output") {
inv.quickAll(i); inv.quickAll(i);
//Chat.log('** redstone traded'); //Chat.log('** redstone traded');
@@ -749,6 +779,7 @@ function trade(tradepos, tradelane, reach) {
} }
found = false; found = false;
} }
e;
if (emerald < 256 || mode === "emerald") { if (emerald < 256 || mode === "emerald") {
for (const tr in trades) { for (const tr in trades) {
if ( if (
@@ -783,7 +814,11 @@ function trade(tradepos, tradelane, reach) {
if (found === true) { if (found === true) {
const before1 = quantify(inv); const before1 = quantify(inv);
inv.selectTrade(index); inv.selectTrade(index);
for (let i = 0; i < inv.getTotalSlots(); i++) { for (
let i = 0;
i < inv.getTotalSlots();
i++
) {
if (inv.getLocation(i) === "output") { if (inv.getLocation(i) === "output") {
inv.quickAll(i); inv.quickAll(i);
} }
@@ -791,9 +826,12 @@ function trade(tradepos, tradelane, reach) {
compareT(before1, quantify(inv)); compareT(before1, quantify(inv));
} }
} }
if (inv && inv.close) {
const before = quantify(inv); const before = quantify(inv);
globQuant = quantify(inv); globQuant = before;
inv.close(); inv.close();
if (!before["minecraft:experience_bottle"]) if (!before["minecraft:experience_bottle"])
before["minecraft:experience_bottle"] = 0; before["minecraft:experience_bottle"] = 0;
if (!before["minecraft:emerald"]) if (!before["minecraft:emerald"])
@@ -808,9 +846,15 @@ function trade(tradepos, tradelane, reach) {
before["minecraft:paper"] = 0; before["minecraft:paper"] = 0;
if (!before["minecraft:glass"]) if (!before["minecraft:glass"])
before["minecraft:glass"] = 0; before["minecraft:glass"] = 0;
GlobalVars.putInt("glass", before["minecraft:glass"]); GlobalVars.putInt(
"glass",
before["minecraft:glass"]
);
glass = before["minecraft:glass"]; glass = before["minecraft:glass"];
GlobalVars.putInt("paper", before["minecraft:paper"]); GlobalVars.putInt(
"paper",
before["minecraft:paper"]
);
paper = before["minecraft:paper"]; paper = before["minecraft:paper"];
GlobalVars.putInt( GlobalVars.putInt(
"emerald", "emerald",
@@ -841,6 +885,7 @@ function trade(tradepos, tradelane, reach) {
} }
} }
} }
}
if (reach) { if (reach) {
if (mode === "emerald") { if (mode === "emerald") {
@@ -881,7 +926,7 @@ function trade(tradepos, tradelane, reach) {
if (xp > 88 && tradepos === 1 && tradelane === 0) { if (xp > 88 && tradepos === 1 && tradelane === 0) {
put(940, 71, 11852, "experience_bottle"); put(940, 71, 11852, "experience_bottle");
} }
if (paper < 64 && trade_good_paper) { if (paper < 32 && trade_good_paper) {
//Chat.log('should take paper'); //Chat.log('should take paper');
takeStacks( takeStacks(
938, 938,
@@ -901,21 +946,23 @@ function trade(tradepos, tradelane, reach) {
globQuant = quantify(inv); globQuant = quantify(inv);
inv.close(); inv.close();
} }
if (bottle < 128 && trade_good_bottle) { //if (bottle < 32 && trade_good_bottle) {
if (glass >= 3) { if (mode === "glass" && tradepos === 1 && tradelane === 0) {
craft( //craft(
938 + tradelane, // 938 + tradelane,
72, // 72,
11851 - tradepos * 2, // 11851 - tradepos * 2,
"glass_bottle" // "glass_bottle"
); //);
} //GlobalVars.putInt("glass", 0);
}
if (glass > 88 && tradepos === 1 && tradelane === 0) {
if (mode === "glass") {
put(940, 71, 11852, "glass"); put(940, 71, 11852, "glass");
} }
} //}
// if (glass > 0 && tradepos === 1) {
// if (mode === "glass") {
// put(940, 71, 11852, "glass");
// }
// }
if (flesh < 128 && trade_good_flesh) { if (flesh < 128 && trade_good_flesh) {
//Chat.log('should take flesh'); //Chat.log('should take flesh');
//takeStacks(946,74,11849,'minecraft:rotten_flesh',3); //takeStacks(946,74,11849,'minecraft:rotten_flesh',3);
@@ -1360,18 +1407,10 @@ if (pdetect === false) {
player.interactBlock(-708, 71, -2222, 4, false); player.interactBlock(-708, 71, -2222, 4, false);
} }
} }
if (
player
.getPos()
.toVector(PositionCommon.createPos(-1211.5, 184, 3650.6))
.getMagnitude() < 1.5
) {
farm = "brew";
//brew(-1210,185,3650);
}
if ( if (
player.getZ() > 11800 && player.getZ() > 11800 &&
player.getZ() < 11852 && player.getZ() < 11853 &&
player.getY() >= 69 && player.getY() >= 69 &&
player.getY() < 71 && player.getY() < 71 &&
player.getX() > 938 && player.getX() > 938 &&
@@ -1400,7 +1439,7 @@ if (pdetect === false) {
diff < 0.4 && diff < 0.4 &&
(last_trade_pos !== trade_pos || last_tradelane !== tradelane) (last_trade_pos !== trade_pos || last_tradelane !== tradelane)
) { ) {
//Chat.log(trade_pos+' '+diff); //Chat.log(trade_pos);
GlobalVars.putInt("last_trade_pos", trade_pos); GlobalVars.putInt("last_trade_pos", trade_pos);
GlobalVars.putInt("last_tradelane", tradelane); GlobalVars.putInt("last_tradelane", tradelane);
@@ -1408,8 +1447,14 @@ if (pdetect === false) {
//}else{ //}else{
// GlobalVars.putBoolean('trade_lock',true); // GlobalVars.putBoolean('trade_lock',true);
GlobalVars.putInt("trade_pos", trade_pos); GlobalVars.putInt("trade_pos", trade_pos);
if ((trade_pos + 1) % 4 === 0) {
trade(trade_pos, tradelane, true); trade(trade_pos, tradelane, true);
trade(trade_pos + 1, tradelane, false); trade(trade_pos + 1, tradelane, false);
} else {
trade(trade_pos + 1, tradelane, false);
trade(trade_pos, tradelane, true);
}
//trade(trade_pos+1,false); //trade(trade_pos+1,false);
// GlobalVars.putBoolean('trade_lock',false); // GlobalVars.putBoolean('trade_lock',false);
//} //}