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

523
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,242 +614,277 @@ function trade(tradepos, tradelane, reach) {
} }
} }
} }
if ( if (false)
e if (
.getPos() e
.toVector( .getPos()
PositionCommon.createPos( .toVector(
941.5 + tradelane, PositionCommon.createPos(
70, 941.5 + tradelane,
11852.5 - tradepos * 2 70,
11852.5 - tradepos * 2
)
) )
) .getMagnitude() < 1
.getMagnitude() < 1 ) {
) { if (e.getType() === "minecraft:villager") {
if (e.getType() === "minecraft:villager") { const uuid = e.getUUID();
const uuid = e.getUUID(); const epos = e.getPos();
const old_uuid = GlobalVars.getString("last_cleric"); player.lookAt(
if (old_uuid === uuid) { epos.x,
//skip epos.y + e.getEyeHeight(),
} else { epos.z
GlobalVars.putString("last_cleric", uuid); );
player.interactEntity(e, false); const old_uuid = GlobalVars.getString("last_cleric");
const ev = JsMacros.waitForEvent("OpenContainer"); if (old_uuid === uuid) {
ev.context.releaseLock(); //skip
Time.sleep(100); } else {
const inv = ev.event.inventory; GlobalVars.putString("last_cleric", uuid);
const trades = inv.getTrades(); player.interactEntity(e, false, true);
let found = false; const ev = JsMacros.waitForEvent("OpenContainer");
let index = 0; ev.context.releaseLock();
if (emerald < 256 || mode === "emerald") { let inv = Player.openInventory();
for (const tr in trades) { Time.sleep(200);
if ( //const inv = ev.event.inventory;
trades[tr].getInput()[0].getItemId() === const trades = inv.getTrades ? inv.getTrades() : [];
"minecraft:rotten_flesh" let found = false;
) { let index = 0;
if (trades[tr].isAvailable() === true) { if (emerald < 256 || mode === "emerald") {
if ( for (const tr in trades) {
trades[tr] if (
.getInput()[0] trades[tr].getInput()[0].getItemId() ===
.getCount() < 9 "minecraft:rotten_flesh"
) { ) {
if (flesh >= 16) { if (trades[tr].isAvailable() === true) {
found = true; if (
index = tr; trades[tr]
} .getInput()[0]
if (!trade_good_flesh) { .getCount() < 9
GlobalVars.putBoolean( ) {
"trade_good_flesh", if (flesh >= 16) {
true found = true;
); index = tr;
trade_good_flesh = true; }
if (!trade_good_flesh) {
GlobalVars.putBoolean(
"trade_good_flesh",
true
);
trade_good_flesh = true;
}
} else {
//Chat.log('flesh too expensive');
} }
} else { } else {
//Chat.log('flesh too expensive'); //Chat.log('flesh no stock');
} }
} else {
//Chat.log('flesh no stock');
} }
} }
} if (found === true) {
if (found === true) { const before1 = quantify(inv);
const before1 = quantify(inv); inv.selectTrade(index);
inv.selectTrade(index); for (
for (let i = 0; i < inv.getTotalSlots(); i++) { let i = 0;
if (inv.getLocation(i) === "output") { i < inv.getTotalSlots();
inv.quickAll(i); i++
) {
if (inv.getLocation(i) === "output") {
inv.quickAll(i);
}
} }
compareT(before1, quantify(inv));
} }
compareT(before1, quantify(inv)); found = false;
} }
found = false; if (mode === "redstone" && emerald >= 12) {
} for (const tr in trades) {
if (mode === "redstone" && emerald >= 12) { if (
for (const tr in trades) { trades[tr].getOutput().getItemId() ===
if ( "minecraft:redstone"
trades[tr].getOutput().getItemId() === ) {
"minecraft:redstone" if (trades[tr].isAvailable() === true) {
) { if (
if (trades[tr].isAvailable() === true) { trades[tr]
if ( .getInput()[0]
trades[tr] .getCount() < 3
.getInput()[0] ) {
.getCount() < 3 if (emerald >= 12) {
) { found = true;
if (emerald >= 12) { index = tr;
found = true; }
index = tr; } else {
//Chat.log('redstone too expensive');
} }
} else { } else {
//Chat.log('redstone too expensive'); //Chat.log('redstone no stock');
} }
} else {
//Chat.log('redstone no stock');
} }
} }
} if (found === true) {
if (found === true) { const before1 = quantify(inv);
const before1 = quantify(inv); inv.selectTrade(index);
inv.selectTrade(index); for (
for (let i = 0; i < inv.getTotalSlots(); i++) { let i = 0;
if (inv.getLocation(i) === "output") { i < inv.getTotalSlots();
inv.quickAll(i); i++
//Chat.log('** redstone traded'); ) {
if (inv.getLocation(i) === "output") {
inv.quickAll(i);
//Chat.log('** redstone traded');
}
} }
compareT(before1, quantify(inv));
} }
compareT(before1, quantify(inv)); found = false;
} }
found = false; if (mode === "experience_bottle" && emerald >= 16) {
} for (const tr in trades) {
if (mode === "experience_bottle" && emerald >= 16) { if (
for (const tr in trades) { trades[tr].getOutput().getItemId() ===
if ( "minecraft:experience_bottle"
trades[tr].getOutput().getItemId() === ) {
"minecraft:experience_bottle" if (trades[tr].isAvailable() === true) {
) { if (
if (trades[tr].isAvailable() === true) { trades[tr]
if ( .getInput()[0]
trades[tr] .getCount() <= 2
.getInput()[0] ) {
.getCount() <= 2 //maximum xp bottle price (3 == 1100)
) { if (emerald >= 12) {
//maximum xp bottle price (3 == 1100) found = true;
if (emerald >= 12) { index = tr;
found = true; }
index = tr; } else {
//Chat.log('xp too expensive');
} }
} else { } else {
//Chat.log('xp too expensive'); //Chat.log('xp no stock');
} }
} else {
//Chat.log('xp no stock');
} }
} }
} if (found === true) {
if (found === true) { const before1 = quantify(inv);
const before1 = quantify(inv); inv.selectTrade(index);
inv.selectTrade(index); for (
for (let i = 0; i < inv.getTotalSlots(); i++) { let i = 0;
if (inv.getLocation(i) === "output") { i < inv.getTotalSlots();
inv.quickAll(i); i++
//Chat.log('** redstone traded'); ) {
if (inv.getLocation(i) === "output") {
inv.quickAll(i);
//Chat.log('** redstone traded');
}
} }
compareT(before1, quantify(inv));
} }
compareT(before1, quantify(inv)); 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 ( trades[tr].getInput()[0].getItemId() ===
trades[tr].getInput()[0].getItemId() === "minecraft:glass_bottle"
"minecraft:glass_bottle" ) {
) { if (trades[tr].isAvailable() === true) {
if (trades[tr].isAvailable() === true) { if (
if ( trades[tr]
trades[tr] .getInput()[0]
.getInput()[0] .getCount() === 1
.getCount() === 1 ) {
) { if (bottle > 16) {
if (bottle > 16) { found = true;
found = true; index = tr;
index = tr; }
} if (!trade_good_bottle) {
if (!trade_good_bottle) { GlobalVars.putBoolean(
GlobalVars.putBoolean( "trade_good_bottle",
"trade_good_bottle", true
true );
); trade_good_bottle = true;
trade_good_bottle = true; }
} else {
//Chat.log('bottle too expensive');
} }
} else { } else {
//Chat.log('bottle too expensive'); //Chat.log('bottle no stock');
} }
} else {
//Chat.log('bottle no stock');
} }
} }
if (found === true) {
const before1 = quantify(inv);
inv.selectTrade(index);
for (
let i = 0;
i < inv.getTotalSlots();
i++
) {
if (inv.getLocation(i) === "output") {
inv.quickAll(i);
}
}
compareT(before1, quantify(inv));
}
} }
if (found === true) { if (inv && inv.close) {
const before1 = quantify(inv); const before = quantify(inv);
inv.selectTrade(index); globQuant = before;
for (let i = 0; i < inv.getTotalSlots(); i++) {
if (inv.getLocation(i) === "output") { inv.close();
inv.quickAll(i);
} if (!before["minecraft:experience_bottle"])
} before["minecraft:experience_bottle"] = 0;
compareT(before1, quantify(inv)); if (!before["minecraft:emerald"])
before["minecraft:emerald"] = 0;
if (!before["minecraft:glass_bottle"])
before["minecraft:glass_bottle"] = 0;
if (!before["minecraft:rotten_flesh"])
before["minecraft:rotten_flesh"] = 0;
if (!before["minecraft:redstone"])
before["minecraft:redstone"] = 0;
if (!before["minecraft:paper"])
before["minecraft:paper"] = 0;
if (!before["minecraft:glass"])
before["minecraft:glass"] = 0;
GlobalVars.putInt(
"glass",
before["minecraft:glass"]
);
glass = before["minecraft:glass"];
GlobalVars.putInt(
"paper",
before["minecraft:paper"]
);
paper = before["minecraft:paper"];
GlobalVars.putInt(
"emerald",
before["minecraft:emerald"]
);
emerald = before["minecraft:emerald"];
GlobalVars.putInt(
"redstone",
before["minecraft:redstone"]
);
redstone = before["minecraft:redstone"];
flesh = before["minecraft:rotten_flesh"];
xp = before["minecraft:experience_bottle"];
GlobalVars.putInt(
"bottle",
before["minecraft:glass_bottle"]
);
GlobalVars.putInt(
"flesh",
before["minecraft:rotten_flesh"]
);
GlobalVars.putInt(
"xp",
before["minecraft:experience_bottle"]
);
Time.sleep(100);
} }
} }
const before = quantify(inv);
globQuant = quantify(inv);
inv.close();
if (!before["minecraft:experience_bottle"])
before["minecraft:experience_bottle"] = 0;
if (!before["minecraft:emerald"])
before["minecraft:emerald"] = 0;
if (!before["minecraft:glass_bottle"])
before["minecraft:glass_bottle"] = 0;
if (!before["minecraft:rotten_flesh"])
before["minecraft:rotten_flesh"] = 0;
if (!before["minecraft:redstone"])
before["minecraft:redstone"] = 0;
if (!before["minecraft:paper"])
before["minecraft:paper"] = 0;
if (!before["minecraft:glass"])
before["minecraft:glass"] = 0;
GlobalVars.putInt("glass", before["minecraft:glass"]);
glass = before["minecraft:glass"];
GlobalVars.putInt("paper", before["minecraft:paper"]);
paper = before["minecraft:paper"];
GlobalVars.putInt(
"emerald",
before["minecraft:emerald"]
);
emerald = before["minecraft:emerald"];
GlobalVars.putInt(
"redstone",
before["minecraft:redstone"]
);
redstone = before["minecraft:redstone"];
flesh = before["minecraft:rotten_flesh"];
xp = before["minecraft:experience_bottle"];
GlobalVars.putInt(
"bottle",
before["minecraft:glass_bottle"]
);
GlobalVars.putInt(
"flesh",
before["minecraft:rotten_flesh"]
);
GlobalVars.putInt(
"xp",
before["minecraft:experience_bottle"]
);
Time.sleep(100);
} }
} }
}
} }
if (reach) { if (reach) {
@@ -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);
} put(940, 71, 11852, "glass");
if (glass > 88 && tradepos === 1 && tradelane === 0) {
if (mode === "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);
trade(trade_pos, tradelane, true); if ((trade_pos + 1) % 4 === 0) {
trade(trade_pos + 1, tradelane, false); trade(trade_pos, tradelane, true);
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);
//} //}