-
Notifications
You must be signed in to change notification settings - Fork 15
ClientScript
ClientScript is a feature of EssentialClient what allows you to write scripts for the client directly into Minecraft. It extends Arucas which is an interpreted language, with very similar syntax to Java using Java as it's host language, Arucas, has the core functionality of a programming language and ClientScript adds all the Minecraft functions.
The main purpose of this feature is to make automating the player easier without having to use any external programs or macros, and without having to create a whole mod for simple tasks.
You must have EssentialClient installed, then after you have booted the
game, you can navigate to the Essential Client Menu (to get to this menu you must join a world and press ESC
). Once
you have opened this menu there will be an option to open your Script file (in the bottom right), this will open a prompt
asking you what program to open the file with, open it with any text editor (Visual Studio Code has syntax highlighting support). You can also
change the current Script file that you open, and run by changing the clientScriptFilename
in the Client Rules Menu.
ClientScripts are stored in .minecraft/config/EssentialClient/Scripts
.
In game, you can navigate to controls and bind Client Script
to a keybind. Once you press this key in game the script
will execute, if the script fails it will notify you in game, and will give you an error of why it failed making debugging
convenient.
There are 6 variable types that this language supports:
Double
- This stores floating point numbers, can store integers too
String
- This stores any text
Boolean
- This stores either a true or false
Functions
- This can store a function as a variable
Null
- This just means that there is no value
List
- This can store a list of any other values that the language supports
+
- Adds 2 numbers together, or concatenates 2 strings
-
- Subtracts 1 number from another
*
- Multiplies 2 numbers together
/
- Divides ` number from another
^
- Exponent of one number to another
++
- Increments the value by 1
--
- Decrements the value by 1
//
- Used to comment
/* */
- Used for multiline comments
and
or &&
- This is the logical AND
or
or ||
- This is the logical OR
not
or !
- This is the logical NOT
- This is used for initialising any variables, this is not required for initialising variables, think of it as a notation
- Examples:
var number = 0;
var string = "foo";
- This is used for defining functions, or for defining lambdas
- Example:
fun foo(bar) { print(bar); }
fun () { print("this is a lambda"); }
- This is used for returning values in functions
- Example:
fun example() { return "foo bar"; }
- This is used to evaluate a conditional statement
- Examples:
if(true) { print("bar"); }
- This is used to further evaluate a conditional statement following an
if
, can also be used in conjuction withif
for anelse if
statement - Examples:
if (false) { print("foo"); } else if (false) { print("bar"); } else { print("baz"); }
- This is used to loop while evaluating a conditional statement
- Example:
while (true) { print("This infinite loop with crash"); }
- This keyword is used to return to the top of the loop in a
while
loop - Example:
continue;
- This is used to break out of a loop
- Example:
break;
- This is used to create a scope block that can contain multiple lines
- Example:
fun example() { print("foo"); print("bar"); print("baz"); }
- This is used after the ending of your code block to close it off
- Example:
fun example() { print("foo"); print("bar"); print("baz"); }
- This is used for a try block which is accompanied with a
catch
keyword, used in case the block may throw an error - Example:
try { (-2)^0.5; } catch (error) { print("This is an imaginary number!"); }
- This must be used with
try
at the end of the block. It has a parameter that will contain the error message, this will only catchRuntimeError
s - Example:
try { (-2)^0.5; } catch (error) { print(error); }
These are the functions that Acuras Supports:
Anything inside brackets are parameters and these values are used in the function to perform an action
All functions can Throw an error if you input the incorrect Value type
- This is used to run a
.acuras
file, you can use one script to run other scripts - Parameter - StringValue - as a file path
- Example:
run("E:/foo/bar.acuras");
- This is used to stop a program
- Example:
stop();
- This is used to enable debug mode, which just prints all returns to console
- Parameter - BooleanValue
- Example:
debug(true);
- This is used to print a string value to console
- Parameter - Value - any value that you want to print
- Examples:
print("Hello World");
,print(90);
- This pauses your program for set amount of ms
- Parameter - NumberValue - any number that you want to sleep for in ms
- Example:
sleep(1000);
- This gets a pseudo random integer between 0 and the bound
- Parameter - NumberValue - the max number you want
- Returns NumberValue:
5
- Example:
random(10);
- This rounds a number to the nearest integer
- Parameter - NumberValue - any number that you want to round
- Returns NumberValue:
100
- Example:
round(99.9);
-
This rounds a number up to the next integer
-
Returns NumberValue:
1
-
Example:
roundUp(0.1);
- This rounds a number down to the next integer
- Parameter - NumberValue - any number that you want to round down
- Returns NumberValue:
0
- Example:
roundDown(0.9);
- This returns the remainder of num1/num2
- Parameters - NumberValue, NumberValue - the number that you to be divided, the number you want it to be divided by
- Returns NumberValue:
1
- Example:
modulus(9, 2);
- Returns the length of a value passed in, works with strings and lists
- Parameter - StringValue/ListValue - any string or list
- Returns NumberValue
34
- Example:
len("What is the length of this string?");
- Returns a string that has had a regex been replaced
- Parameters - StringValue, StringValue, StringValue - the string you want to modify, the regex, the replacement
- Example:
randomString = "this/is/random"; randomString = replaceAll(randomString, "/", " ");
- Returns the string but uppercase
- Parameter - StringValue - the string that you want to be converted
- Example:
randomString = "this is random"; randomString = uppercase(randomString);
- Returns the string but lowercase
- Parameter - StringValue - the string that you want to be converted
- Example:
randomString = "THiS iS rANdOm"; randomString = lowercase(randomString);
- Returns a list of characters from the string
- Parameter - StringValue - any string
- Returns ListValue:
["s", "t", "r", "i", "n", "g", " ", "T", "o", " ", "L", "i", "s", "t"]
- Example:
stringToList("stringToList");
- Returns string of whatever value input
- Parameter - Value - any value that you want a string of
- Returns StringValue:
"9008"
- Example:
stringOf(9008);
- Returns number of a string
- Parameter - StringValue - a number that is in string form
- Returns NumberValue:
8892
- Example:
numberOf("8892");
- This gets the current time as a string
- Returns NumberValue:
00:18
- Example:
getTime();
-
This returns a boolean based on whether value is a number
-
Returns BooleanValue:
false
-
Example:
isNumber("this is not a number");
- This returns a boolean based on whether value is a string
- Parameter - Value - any value
- Returns BooleanValue:
true
- Example:
isString("this is a string");
- This returns a boolean based on whether value is a boolean
- Parameter - Value - any value
- Returns BooleanValue:
false
- Example:
isBoolean(80);
- This returns a boolean based on whether value is a function
- Parameter - Value - any value
- Returns BooleanValue:
false
- Example:
isFunction(false);
- This returns a boolean based on whether value is a list
- Parameter - Value - any value
- Returns BooleanValue:
false
- Example:
isList(null);
- This is a list variable specific function, it returns the value at index of a list, index starts at 0
- Parameters - ListValue, NumberValue - the list you want the index of, the index you want
- Returns Value:
"foo"
- Throws
"Parameter 2 is out of bounds"
- Example:
var stringList = ["foo", "bar", "baz"]; getIndex(stringList, 0);
- This is a list variable specific function, it removes a value from a list at index
- Parameters - ListValue, NumberValue - the list you want to remove the index of, the index you want to remove
- Returns Value:
"foo"
- Throws
"Parameter 2 is out of bounds"
- Example:
var stringList = ["foo", "bar", "baz"]; removeIndex(stringList, 0);
- This is a list variable specific function, it allows you to add a value to a list
- Parameters - ListValue, Value - the list you want to append to, the value you want to append
- Example:
var list = []; append(list, 3.14159);
- This is a list variable specific function, it allows you to concatenate two lists
- Parameters - ListValue, ListValue - a list you want to concatenate, another list you want to concatenate
- Returns ListValue:
["foo", "bar", "baz"]
- Example:
var list1 = ["foo"]; var list2 = ["bar", "baz"]; concat(list1, list2);
These are functions that hook into Minecraft
- This allows you to add events with a function instead of declearing an event
- Parameter - Select StringValue - any event name (with or without "_")
- Example:
addGameEvent("onClientTick", fun () { message("client tick"); });
- This schedules a function to run in set amount of ms. This also pushes the function to a separate thread.
- Parameters - NumberValue, FunctionValue - number of ms, a function (without brackets) it cannot have parameters
- Example:
schedule(10000, stop);
- This allows you to manipulate whether your player is using
- Parameter - Select StringValue - "hold", "stop", or "once" - depending on what you want
- Example:
use("once");
- This allows you to manipulate whether your player is attacking
- Parameter - Select StringValue - "hold", "stop", or "once" - depending on what you want
- Example:
attack("hold");
- This allows you to send a message to your player, only they will see this
- Parameter - Value - any value you want to message the player
- Example:
message("Hello!");
- This allows you to set the current message displaying on the action bar
- Parameter - Value - any value you want to message the player
- Example:
messageActionBar("Hello!");
- This allows you to make your player send a message in chat, this includes commands
- Parameter - Value - any value you want the player to say
- Examples:
say("Hi :)");
say("/gamemode creative");
- This allows you to add your own custom commands
- Parameters - StringValue, NumberValue - the command name, the number of arguments
- Throws
"Invalid number of arguments"
- Example:
addCommand("cs", 0);
- This allows you to set the slot number your player is holding
- Parameter - Select NumberValue - number must be between 1-9
- Example:
setSelectedSlot(5);
- This allows you to manipulate the inventory screen
- Parameter - Select StringValue - "open", or "close" depending on what you want
- Example:
inventory("close");
- This allows you to set whether your player is holding the walk key or not
- Parameter - BooleanValue - true or false
- Example:
setWalking(true);
- This allows you to set whether your player is sprinting or not
- Parameter - BooleanValue - true or false
- Example:
setSprinting(false);
- This allows you to set whether your player is sneaking or not
- Parameter - BooleanValue - true or false
- Example:
setSneaking(true);
- This allows you to drop the item(s) you are currently holding, passing in true as a parameter will drop the whole stack
- Parameter - BooleanValue - true or false
- Example:
dropItemInHand(true);
- This allows you to drop all of a select item type from your inventory, pass in itemType as string
- Parameter - Select StringValue - any item id
- Example:
dropAll("diamond_block");
- This allows you to trade with a villager at a certain index, passing true into second parameter will drop all the traded items
- Parameters - Select NumberValue, BooleanValue - index of the trade must be in bounds, true or false
- Throws
"You are not in merchant GUI"
,"That trade is out of bounds"
- Example:
tradeIndex(2, true);
- This allows you to trade with a villager for a certain item, passing true into second parameter will drop all the traded items
- Parameters - Select StringValue, BooleanValue - any item id, true or false
- Throws
"You are not in merchant GUI"
,"That trade is out of bounds"
- Example:
tradeFor("quartz_block", true);
- This allows you to swap 2 slots with one another
- Parameters - Select NumberValue, Select NumberValue - slot number, another slot number
- Throws
"That slot is out of bounds"
- Example:
swapSlots(13, 46);
- This allows you to shift click a slot
- Parameters - Select NumberValue - slot number
- Throws
"That slot is out of bounds"
- Example:
shiftClickSlot(9);
- This allows you to drop a slot
- Parameter - Select NumberValue - slot number
- Throws
"That slot is out of bounds"
- Example:
dropSlot(14);
- This allows you to craft an item, you may need a small delay after calling the craft function as there is delay in the crafting function to prevent desync
- Parameter - Select ListValue(StringValue) - list of 9 strings that are item ids
- Throws
"Not in handled screen"
- Example:
craft(["birch_planks", "air", "air", "air", "air", "air", "air", "air", "air")]);
- ^ This would craft birch buttons
- This takes a screenshot
- Example:
screenshot();
- This allows you to manipulate where your player is looking
- Parameters - NumberValue, NumberValue - the yaw as a degree, the pitch as a degree
- Example:
look(-76.2, 80.1);
- This will make the player jump if they are on the ground
- Example:
jump();
- This will logout the player from the current world
- Example:
logout();
- This will clear the chat history
- Example:
clearChat();
- This stops the macro from ending after it has executed all of its code, meaning it needs to be stopped manually
- Example:
hold();
- This returns the current slot the player has selected as a number
- Returns NumberValue:
5
- Example:
getCurrentSlot();
- This returns the current item the player is holding as a string, if player was holding a grass block it would return "grass_block"
- Returns StringValue:
"grass_block"
- Example:
getHeldItem();
- This returns the current status effects the player currently has
- Returns ListValue:
["resistance", "fire_resistance", "regeneration"]
- Example:
getStatusEffects();
- This returns the block that the player is looking at as a string, if looking at nothing will return "air"
- Returns StringValue:
"diamond_block"
- Example:
getLookingAtBlock();
- This returns the entity the player is looking at as a string, if looking at no entity will return "none"
- Returns StringValue:
"villager"
- Example:
getLookingAtEntity();
- This returns the player's current health
- Returns NumberValue:
18
- Example:
getHealth();
- This returns the position as a list containing
x
,y
,z
,yaw
,pitch
- Returns ListValue:
[100, 40, 200, 90, 0]
- Example:
getPos();
- This returns the current dimension that the player is in as a string
- Returns StringValue:
"overworld"
- Example:
getDimension();
- This returns the block at the position given in the parameters as a string, if it is out of render then it will return "void_air"
- Returns StringValue:
"dirt"
- Example:
getBlockAt(getPos("x"), getPos("y") - 1, getPos("z"));
- This returns the path that your scripts are stored as a string
- Returns StringValue:
"C:/.minecraft/config/EssentialClient/Scripts"
- Example:
getScriptsPath();
- This returns whether a trade is disabled as a boolean, you can either pass an index or item type as a parameter
- Returns BooleanValue:
false
- Examples:
isTradeDisabled("experience_bottle");
isTradeDisabled(3);
- This returns the enchantments that a trade item has
- Throws
"You are not in merchant GUI"
,"That trade is out of bounds"
,"Invalid GUI or invalid index"
- Returns ListValue:
[["efficiency", 5]. ["unbreaking", 3], ["mending", 1]]
- Examples:
getEnchantmentsForTrade("diamond_pickaxe");
getEnchantmentsForTrade(5);
- This returns whether a villager has a trade for an item type as a boolean
- Throws
"You are not in merchant GUI"
,"That trade is out of bounds"
- Returns BooleanValue:
true
- Example:
doesVillagerHaveTrade("green_terracotta");
- This returns the price of the trade
- Throws
"You are not in merchant GUI"
,"That trade is out of bounds"
- Returns - NumberValue - number of emeralds
- Examples:
getPriceForTrade("diamond_pickaxe");
getPriceForTrade(5);
- This returns whether the players inventory is full as a boolean
- Returns BooleanValue:
true
- Example:
isInventoryFull();
- This returns whether a block is a block entity
- Parameter - Select StringValue - any block id
- Returns BooleanValue:
true
- Example:
isBlockEntity("hopper");
- This returns an integer for the item slot that wanted item type is in
- Parameter - Select StringValue - any item id
- Returns NumberValue:
38
- Example:
getSlotFor("diamond_pickaxe");
- This returns the current number of slots that the player can access (this changes depending on container)
- Returns NumberValue:
46
- Example:
getTotalSlots();
- This returns the item and item count in a current slot
- Throws
"That slot is out of bounds"
- Returns ListValue:
[shield, 1]
- Example:
getItemForSlot(46);
- This returns the enchantments for an item in dedicated slot
- Throws
"That slot is out of bounds"
- Returns ListValue:
[["efficiency", 4], ["mending", 1], ["unbeaking", 3]]
- Example:
getEnchantmentsForSlot(38);
- This returns the amount of durability the item in a dedicated slot has
- Returns NumberValue:
1300
- Example:
getDurabilityForSlot(17);
- This returns the latest chat message, it contains the creation tick of the message and the string of the message
- Returns ListValue:
[1400, "<senseiwells> This was sent in chat"]
- Example:
getLatestChatMessage();
- This returns a list of the online players
- Returns ListValue:
["senseiwells", "SuperSanta"]
- Example:
getOnlinePlayers();
- This returns the current screen name
- Returns StringValue:
"MerchantScreen"
- Example:
getCurrentScreenName()
- This returns the current screen title, this will change depending if it has a custom name
- Returns StringValue:
"Mason"
- Example:
getCurrentScreenTitle()
- This returns the current gamemode that the player is in
- Returns StringValue:
"creative"
- Example:
getGamemode();
- This returns the players name
- Returns StringValue:
"senseiwells"
- Example:
getPlayerName();
- This returns the current weather in the world
- Returns StringValue:
"rain"
- Example:
getWeather();
- This returns the current time of day
- Returns NumberValue:
1800
- Example:
getTimeOfDay();
- This returns the current biome you are in
- Returns StringValue:
"jungle_edge"
- Example:
getBiome();
- This returns whether the player is sneaking
- Returns BooleanValue:
false
- Example:
isSneaking();
- This returns whether the player is sprinting
- Returns BooleanValue:
true
- Example:
isSprinting();
- This returns whether the player is falling
- Returns BooleanValue:
false
- Example:
isFalling();
- This event gets called every client tick
- Example:
fun _onClientTick() { message("Hi"); }
- This event gets called when the players health changes
- Example:
fun _onHealthUpdate_() { message("Health Update"); }
- This event gets called when the player activates a totem
- Example:
fun _onTotem_() { message("You just used a totem"); }
- This event gets called when the player attacks
- Example:
fun _onAttack_() { message("You just attacked") }
- This event gets called when the player uses
- Example:
fun _onUse_() { message("You just used"); }
- This event gets called when the player picks block
- Example:
fun _onPickBlock_() { message("You just picked a block"); }
- This event gets called when the player closes a screen
- Example:
fun _onCloseScreen_() { message("You just closed screen"); }
- This event gets called when a set command that you added gets called, passes in a string and a list of strings
- Parameter - StringValue, ListValue - the name of the command, a list of arguments
- Example:
fun _onCommand_(commandName, arguments) { if (commandName == "cs") { message(stringOf(arguments)); } }
- This event gets called when you press a key, it passes in the key you pressed as a string
- Parameter - StringValue - the key that you pressed
- Example:
fun _onKeyPress_(key) { message("You just pressed " + key + " on your keyboard!"); }
- This event gets called when you hold a key - every tick, it passes in the key you are pressing as a string
- Parameter - StringValue - the key that you held
- Example:
fun _onKeyHold_(key) { message("You are pressing " + key + " on your keyboard!"); }
- This event gets called when you release a key, it passes in the key you released as a string
- Parameter - StringValue - the key that you released
- Example:
fun _onKeyRelease_(key) { message("You just released " + key + " on your keyboard!"); }
- This event gets called when a screen is opened and it will pass the name of the screen in
- Parameter - StringValue - the name of the screen you opened
- Example:
fun _onOpenScreen_(screen) { message("You just opened " + screen); }
- This event gets called when the player picks up an item/xp, the item name/exp will get passed in
- Parameter - StringValue - the entity that you picked up, can be item id or "experience_orb"
- Example:
fun _onPickUp_(entity) { message("You just picked up " + entity); }
- This event gets called when the player drops an item, the item name gets passed in
- Parameter - StringValue - the item you dropped as item id
- Example:
fun _onDropItem_(item) { message("You just dropped " + item); }
- This event gets called when you eat, the food gets passed in
- Parameter - StringValue - the food you ate as item id
- Example:
fun _onEat_(food) { message("You just ate " + food); }
- This event gets called when the player interacts with an item (e.g using an enderpearl), the item gets passed in
- Parameter - StringValue - the item you interacted with as item id
- Example:
fun _onInteractItem_(item) { message("You just interacted with " + item); }
- This event gets called when the player interacts with a block (e.g opening a chest), the block gets passed in
- Parameter - StringValue - the block you interacted with as block id
- Example:
fun _onInteractBlock_(block) { message("You just interacted with " + block); }
- This event gets called when the player interacts with an entity (e.g interacting with a villager), the entity gets passed in
- Parameter - StringValue - the entity you interacted with as an entity id
- Example:
fun _onInteractEntity_(entity) { message("You just interacted with " + entity); }
- This event gets called when a chat message is added to the chat screen, the message gets passed in
- Parameter - StringValue - the message that you send
- Example:
fun _onChatMessage_(string) { message("Message: " + string); }
- This event gets called when the player changes gamemode
- Parameter - StringValue - the gamemode you switched to
- Example:
fun _onGamemodeChange_(gamemode) { message("You just changed gamemode to: " + gamemode); }
- This event gets called when the player clicks on an inventory slot, slot number gets passed in
- Parameter - NumberValue - the slot you clicked on in your inventory
- Example:
fun _onClickSlot_(slotNum) { message("You just clicked on slot: " + slotNum); }
- This event gets called when the player breaks a block, block name, x, y, and z gets passed in
- Parameters - StringValue, NumberValue, NumberValue, NumberValue - block you broke as block id, the x coordinate, the y coordinate, the z coordinate
- Example:
fun _onBlockBroken_(block, x, y ,z) { message("You just broke " + block + " at " + stringOf(x) + " " + stringOf(y) + " " + stringOf(z)); }
I will probably upload a video about this shortly, if I have it will be linked here.
Top Tip - Don't run a while(true)
loop without at least 10ms delay :)
VSCode syntax highlighting file can be found here
For loops are useless, we have to work with while loops, thankfully it's still very simple to iterate through a list
// Lets sort this list for only strings
valueList = ["foo", 89, true, "bar", null, false, 3.14, "baz"];
stringList = [];
iterator = 0;
while (len(valueList) > iterator) {
value = getIndex(valueList, iterator);
if (isString(value)) {
append(stringList, value);
}
iterator = iterator + 1;
}
print(stringList);
//Expected list for stringList is ["foo", "bar", "baz"]
Yes this is possible, however for them to not interfere with eachother you need to put each one on its own thread.
This is possible by using the schedule()
function. We also need to use hold()
as otherwise the script will end
automatically as the main code has finished.
Here's an example:
// Here we must define our functions, remember that schedule() cannot take functions with arguments
fun runScript1() {
run(getScriptsPath() + "/script1.arucas");
}
fun runScript2() {
run(getScriptsPath() + "/script2.arucas");
}
// Here we can schedule both scripts to run
// I have staggered their start as to not cause any conflicts initialising
schedule(20, runScript1);
schedule(40, runScript2);
// Here the main script ends, and once it ends it will turn the script off automatically
// This would stop the other 2 scripts from running, so we need to call hold();
hold();
// Now the script will only end when the player toggles it off
Let's create a simple function that will send you a message if you are looking at a shulker box, this isn't practical at all but this is for example purpose.
fun isLookingAtBlockShulker() {
// I know this doesn't look amazing but it works
block = getLookingAtBlock();
if (
block == "shulker_box" ||
block == "white_shulker_box" ||
block == "orange_shulker_box" ||
block == "magenta_shulker_box" ||
block == "light_blue_shulker_box" ||
block == "yellow_shulker_box" ||
block == "lime_shulker_box" ||
block == "pink_shulker_box" ||
block == "gray_shulker_box" ||
block == "light_gray_shulker_box" ||
block == "cyan_shulker_box" ||
block == "purple_shulker_box" ||
block == "blue_shulker_box" ||
block == "brown_shulker_box" ||
block == "red_shulker_box" ||
block == "black_shulker_box"
) { return true; }
return false;
}
while (true) {
// The sleep statement here means that this will loop every 0.2 seconds
sleep(200);
if (isLookingAtBlockShulker()) { message("you are looking at a shulker"); }
// This sends a message to the client if they are looking at a shulker
}
Let's create a simple script that will give us a block if we are looking at it
fun giveBlock() {
block = getLookingAtBlock();
// We can't give the player "air", "water", or "lava", so we ignore those
if (
block == "air" ||
block == "water" ||
block == "lava" ||
) { return; }
say("/give senseiwells " + block);
}
while (true) {
giveBlock();
sleep(50);
// This will execute every tick
}
This obviously requires you to have OP on the server as it relies on using vanilla commands, but it stores all the information on the client essentially allowing you to use CommandCameraMode on any Server as long as you have the permissions :)
prevGamemode = null;
location = null;
// Inner scope just for adding commands, not needed but looks less messy
{
// adds the command you want and the number of arguments you can have
addCommand("cs", 0);
addCommand("c", 0);
addCommand("s", 0);
}
fun listString(list, index) {
return stringOf(list, index);
}
// This is the onCommand event, which gets called everytime you send a command with the name that you added previously
fun _onCommand_(command, arguments) {
if (command == "cs") {
if (getGamemode() != "spectator") {
prevGamemode = getGamemode();
location = getPos();
append(location, getDimension());
say("/gamemode spectator");
return;
}
if (prevGamemode == null) {
prevGamemode = getGamemode();
say("/gamemode survival");
}
else {
say("/gamemode " + prevGamemode);
}
// This is restoring the location
if (location != null) {
say(
"/execute in " + getIndex(location, 5) +
" run tp @s " + listString(location, 0) + " " +
listString(location, 1) + " " +
listString(location, 2) + " " +
listString(location, 3) + " " +
listString(location, 4)
);
}
}
else if (command == "c") {
say("/gamemode spectator");
}
else if (command == "s") {
say("/gamemode survival");
}
}
// Add a nice touch by letting the user know their gamemode :)
fun _onGamemodeChange_(gamemode) {
messageActionBar("§6You are now in §a" + gamemode);
}
hold();
This is meant to automate the process of infinite trading, you'd have a setup in the end in Minecraft and run this script and it should trade automatically for you infinitely!
wantedItems = ["golden_carrot", "apple"];
fun _onInteractEntity_(entity) {
sleep(2500);
if (entity != "villager" || getCurrentScreenName() != "MerchantScreen") {
return;
}
i = 0;
while (len(wantedItems) > i) {
item = getIndex(wantedItems, i);
message(item);
try {
if (doesVillagerHaveTrade(item)) {
while (!isTradeDisabled(item)) {
try tradeFor(item, false);
catch (error);
sleep(100);
}
}
}
catch (error) {
message(error);
}
lookAndDropItems(item);
i = i + 1;
}
sleep(100);
inventory("close");
sleep(400);
}
fun lookAndDropItems(item) {
//look(90, -24);
sleep(100);
dropAll(item);
sleep(100);
//look(90,0);
}
while (true) {
if (getLookingAtEntity() == "villager") {
if (getCurrentScreenName() != "MerchantScreen") {
use("once");
}
}
sleep(20);
}