-
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. 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 find this extension on my discord server). 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.
To see what's avaiable in this language please visit the Arucas Wiki, this contains all the information you need about the base language, variable types, keywords, and syntax, and built in functions. Here you will be able to find some example scripts, showing what you are able to do with the base language.
ClientScript then adds ontop of this language more functions that allow you to control Minecraft. The information about what ClientScript adds is listed below...
ClientScript adds some new variable types for use in Minecraft.
MinecraftClient
- The general MinecraftClient instance
World
- The world that is/was loaded in Minecraft
Entity
- An entity in Minecraft
LivingEntity
- A living entity in Minecraft
OtherPlayer
- A player that is not the main player
Player
- The main player
Block
- A block in Minecraft
ItemStack
- An item in Minecraft
Text
- Strings that can be formatted for Minecraft
Screen
- A screen instance
These are functions that hook into the Minecraft client allowing you to create code for the game!
- This will return the MinecraftClient instance, this is the basic function that allows you to get other things inside Minecraft
- Returns - MinecraftClient: the minecraft client
- Example:
getMinecraftClient();
- This stops the script from terminating when it finishes executing
- Example:
hold();
-
This function is deprecated and you should use
runThreaded(function, list)
instead- an example of how to recreate schedule can be found in the example code section in the Arucas Wiki
- This schedules a function to be run after a set amount of time.
- Parameters - Number, Function: The first is the number of milliseconds, second is the function you want to run
These are functions that are linked directly into Minecraft and allow you to manipulate and get information from the game.
This will be used for examples:
client = getMinecraftClient();
- This gets the current player on the client
- Returns - Player: the main player
- Example:
client.getPlayer();
- This gets the current world that the client is in
- Returns - World: the current world
- Example:
client.getWorld();
- This gets an ItemStack from a string name, you can find all itemNames on Joa's Item Property Encyclopedia
- Parameter - String: the name of the item
- Returns - ItemStack: the itemstack representation of the string
- Throws:
"Invalid identifier name"
- Example:
client.itemFromString("diamond_pickaxe");
- This gets an Block from a string name, you can find all blockNames on Joa's Item Property Encyclopedia
- Parameter - String: the name of the block
- Returns - Block: the block representation of the string
- Throws:
"Invalid identifier name"
- Example:
client.blockFromString("grass_block");
- This gets an Entity from a string name, you can find all entityNames on Joa's Entity Property Encyclopedia
- Parameter - String: the entity representation
- Returns - Entity: the entity representation of the string
- Throws:
"Invalid identifier name"
- Example:
client.entityFromString("zombie_villager");
- This gets the text representation of a string, text can be formatted with colours and click events for the player to interact with
- Parameter - String: the string of the text you want
- Returns - Text: the text representation of the string
- Example:
client.textFromString("CLICK ME");
- This allows you to add events with a function instead of declearing an event
- Parameters - String, Function - name of the game event, any function that you want to execute on the event, this function must also have the correct parameters, see Events for more info
- Returns - Number: the eventId for that eventName, this can be used to remove a game event
- Examples:
3
,14
,54
- Examples:
- Throws:
"The event name must be a predefined event"
- Example:
client.addGameEvent("onClientTick", fun() {
client.getPlayer().message("client tick");
});
- This allows you to remove a game event function from running
- Parameters - String, Number: name of the game event, the event id of the event to remove
- Throws:
"The event name must be a predefined event"
,"Invalid eventId"
- Example:
client.removeGameEvent("onClientTick", 1);
- This removes all game events from running
- Example:
client.removeAllGameEvents();
- This allows you to register your own command in the game
- Parameters - String, List: the name of your command, a list of lists, the nested lists are the suggested arguments for that position
- Throws:
"You must pass in a list of lists as parameter 2 for addCommand()"
- Example:
client.addCommand("mycommand", [
["foo", "bar"], // Argument 1
["1", "2", "3"] // Argument 2... etc.
]);
- This allows you to simulate a key press inside of Minecraft, this will only press the key down
- Parameter - String: the key you want to press
- Throws:
"Tried to press unknown key"
- Example:
client.pressKey("p");
- This allows you to simulate a key release inside Minecraft, this is useful for keys that only work on release. For example:
f3
- Parameter - String: the key you want to press
- Throws:
"Tried to press unknown key"
- Example:
client.releaseKey("f3");
- This allows you to simulate a key being held inside Minecraft, this will press, and release the key
- Parameters - String, Number: the key you want to hold, the number of milliseconds you want it held for
- Throws:
"Tried to press unknown key"
- Example:
client.holdKey("w", 2000);
- This allows you to take a screenshot of the game
- Example:
client.screenshot();
- This allows you to play a sound around the player
- Parameters - String, Number, Number: the name of the sound you want to play (list of sounds here, click [show] for Java edition values, all valid sounds are in the far left column), the volume of the sound, the pitch of the sound
- Throws:
"Invalid identifier name"
- Example:
client.playSound("entity.lightning_bolt.thunder", 1, 1);
- This allows you to clear the chat hud
- Example:
client.clearChat();
- This returns the latest chat message
- Returns - String: the latest chat message
- Example:
"<senseiwells> o/"
- Example:
- Example:
client.getLatestChatMessage();
- Determines whether the players is in a singleplayer world
- Returns - Boolean: whether the player is in singleplayer
- Example:
client.isInSinglePlayer();
- This gets the current connected server's name that is set in the multiplayer screen
- Returns - String: the server name
- Example:
"Minecraft Server"
- Example:
- Throws:
"Failed to get server name"
- Example:
client.getServerName();
- This gets the script path, where all other scripts are stored.
- Returns - String: the path of all scripts
- Example:
"C:\Users\acer\AppData\Roaming\.minecraft\config\EssentialClient\Scripts"
- Example:
- Example:
client.getScriptsPath();
- This allows you to import a map of functions from built in utils, see here for the built in utils
- Parameter - String: the name of the util you want to import
- Returns - Map: a map of name of value and value, can return numbers or functions
- Example:
{"concat" : fun(s1, s2) { return s1 + s2 }, "pi" : 3.14159}
- Example:
- Throws:
"That util does not exist"
,"Failed to run Util file"
,"Invalid identifier name"
- Example:
stringUtils = client.importUtils("StringUtils");
- This sets the value of an EssentialClient Rule
- Parameters - String, Value: the name of the rule you want to set, the value you want to set it to
- Throws:
"Invalid ClientRule name"
and"Cannot set that value"
- Example:
client.setEssentialClientRule("highlightLavaSources", false); // Can also do "false"
client.setEssentialClientRule("customClientCape", "Minecon 2011");
- This resets the value of an EssentialClient Rule
- Parameter - String: the name of the rule you want to reset
- Throws:
"Invalid ClientRule name"
- Example:
client.resetEssentialClientRule("disableBossBar");
- This gets the value of an EssentialClient Rule
- Parameter - String: the name of the rule you want to get the value of
- Throws:
"Invalid ClientRule name"
- Example:
client.getEssentialClientValue("overrideCreativeWalkSpeed");
These are functions that can be applied to all entitys
This will be used for all examples:
client = getMinecraftClient();
entity = client.entityFromString("item_frame");
- This returns whether the entity is sneaking
- Returns - Boolean: whether the entitiy is sneakng
- Example:
entity.isSneaking()
- This returns whether the entity is sprinting
- Returns - Boolean: whether the entitiy is sprinting
- Example:
entity.isSprinting()
- This returns whether the entity is falling
- Returns - Boolean: whether the entitiy is falling
- Example:
entity.isFalling()
- This returns whether the entity is on the ground
- Returns - Boolean: whether the entitiy is on the ground
- Example:
entity.isOnGround()
- This returns whether the entity is touching water
- Returns - Boolean: whether the entitiy is touching water
- Example:
entity.isTouchingWater()
- This returns whether the entity is touching water or rain
- Returns - Boolean: whether the entitiy is touching water or rain
- Example:
entity.isTouchingWaterOrRain()
- This returns whether the entity is submerged in water
- Returns - Boolean: whether the entitiy is submerged in water
- Example:
entity.isSubmergedInWater()
- This returns whether the entity is in lava
- Returns - Boolean: whether the entitiy is in lava
- Example:
entity.isInLava()
- This returns whether the entity is on fire
- Returns - Boolean: whether the entitiy is on fire
- Example:
entity.isOnFire()
- This gets the block that the entity is currently looking at
- Returns - Block: the block the entity is looking at
- Example:
entity.getLookingAtBlock();
- This gets the position that the entity is looking at,
- Parameter - Number: the max distance you want to get the pos
- Returns - List: a list of the x, y, and z positions
- Example:
posList = entity.getLookingAtPos(10);
posX = posList.get(0);
posY = posList.get(1);
posZ = posList.get(2);
- This gets the entityId of the entity
- Returns - Number: the entityId
- Example:
entity.getEntityIdNumber();
- This gets the entity's current x position
- Returns - Number: the x position
- Example:
entity.getX();
- This gets the entity's current y position
- Returns - Number: the y position
- Example:
entity.getY();
- This gets the entity's current z position
- Returns - Number: the z position
- Example:
entity.getZ();
- This gets the entity's current yaw
- Returns - Number: the yaw
- Example:
entity.getYaw();
- This gets the entity's current pitch
- Returns - Number: the pitch
- Example:
entity.getPitch();
- This gets the entity's current dimension
- Returns - String: the dimension
- Examples:
"overworld"
,"the_nether"
,"the_end"
- Examples:
- Example:
entity.getDimension();
- This gets the entity's current biome (a list of all the biome ids can be found here)
- Returns - String: the biome
- Examples:
plains
,tall_birch_hills
- Examples:
- Example:
entity.getBiome();
- This gets the entity's type as a string representation, you can find all entityNames on Joa's Entity Property Encyclopedia
- Returns - String: the entity type
- Examples:
"armor_stand"
,"item_frame"
,"pig"
- Examples:
- Example:
entity.getEntityType();
- This gets the entity's age
- Returns - Number: the entities age
- Example:
entity.getAge();
- This gets the entity's custom name if it has one
- Returns - String / Null: the entities custom name, null if it has none
- Example:
entity.getCustomName();
- This gets the entity's Uuid
- Returns - String: the entities Uuid
- Example:
entity.getEntityUuid();
- This gets the entity's distance to another entity
- Returns - Number: the distance between the two entities
- Example:
world = client.getWorld();
player = client.getPlayer();
otherPlayer = world.getClosestPlayerEntity(player);
distance = player.getDistanceTo(otherPlayer);
- This gets the entity's squared distance to another entity
- Parameter - Entity: another entity
- Returns - Number: the squared distance between the two entities
- Example:
world = client.getWorld();
player = client.getPlayer();
otherPlayer = world.getClosestPlayerEntity(player);
squaredDistance = player.getSquaredDistanceTo(otherPlayer);
- This sets the entity to glowing, giving it the glowing effect on the client
- Parameter - Boolean: whether you want to disable/enable the glow effect
- Example:
entity.setGlowing(true);
These are functions that can be applied to all LivingEntities, LivingEntity extends Entity so LivingEntities can run all Entity functions too
This will be used for all examples:
client = getMinecraftClient();
livingEntity = client.entityFromString("pig");
- This gets the LivingEntity's status effects, you can find a list of all the ids of status effects here
- Returns - List: a list of all the status effects as strings, list can contain Null
- Example:
["regeneration", "resistance", "fire_resistance"]
- Example:
- Example:
livingEntity.getStatusEffects();
- This gets the LivingEntity's current health
- Returns - Number: the health of the entity
- Examples:
20
,10
- Examples:
- Example:
livingEntity.getHealth();
- This checks whether the LivingEntity is fly falling (gliding with an elytra)
- Returns - Boolean: whether the entity is fly falling
- Example:
livingEntity.isFlyFalling();
These are functions that can be applied to all OtherPlayers, OtherPlayer extends LivingEntity so OtherPlayer can run all LivingEntity (and Entity) functions too
client = getMinecraftClient();
player = client.getPlayer();
// I am using the main player here but these functions work for otherPlayers too
- This gets the player's current slot
- Returns - Number: the current slot number
- Example:
0
,4
,8
- Example:
- Example:
player.getCurrentSlot();
- This gets the player's current held item
- Returns - ItemStack: the ItemStack the player is holding in their main hand
- Example:
player.getCurrentSlot();
- This checks whether the player's inventory is full
- Returns - Boolean: whether the player's inventory is full
- Example:
player.isInventoryFull();
- This gets the player's name
- Returns - String: the player's name
- Example:
senseiwells
- Example:
- Example:
player.getPlayerName();
- This gets the player's current gamemode
- Returns - String: the gamemode
- Examples:
"survival"
,"creative"
- Examples:
- Example:
player.getGamemode();
- This gets the total number of slots in the player's screen
- Returns - Number: the total number of slots
- Example:
player.getTotalSlots();
- This gets an item for a slot in the player's inventory
- Parameter - Number: the slot number you want to find the item for
- Returns - ItemStack: the item in that slot
- Throws:
"That slot is out of bounds"
- Example:
player.getItemForSlot(10);
- This gets a slot for an item in the player's inventory
- Parameter - ItemStack: the ItemStack you want to search for
- Returns - Number / Null: the slot of that ItemStack, returns null if it cannot find a slot
- Example:
player.getSlotFor(client.itemFromString("diamond"))
- This gets a list of all the slots for an item in the player's inventory
- Parameter - ItemStack: the ItemStack you want to search for
- Returns - List: a list with all the slots of that ItemStack
- Example:
player.getAllSlotsFor(client.itemFromString("diamond"))
- This gets a map of all the player's abilities
- Returns - Map: a map of the abilities
- Example:
{"invulnerable" : false, "canFly" : false, "canBreakBlocks" : true, "isCreative" : false, "walkSpeed" : 1.0, "flySpeed" : 1.2}
- Example:
- Example:
player.getAbilities();
- This gets the amount of levels the player has
- Returns - Number: the amount of levels
- Example:
player.getLevels();
These are functions that can be applied to the main Player, Player extends OtherPlayer so Player can run all OtherPlayer (LivingEntity and Entity) functions too
This will be used for all examples:
client = getMinecraftClient();
player = client.getPlayer();
- This allows you to make your player use
- Parameter - String: this must be one of three: "hold", "stop", or "once"
- Throws:
"Must pass "hold", "stop" or "once" into use()"
- Example:
player.use("once");
- This allows you to make your player attack
- Parameter - String: this must be one of three: "hold", "stop", or "once"
- Throws:
"Must pass "hold", "stop" or "once" into use()"
- Example:
player.attack("hold");
- This will make the player jump if they are on the ground
- Example:
player.jump();
- This allows you to set the slot number your player is holding
- Parameter - Number: number must be between 0 - 8
- Throws:
"Number must be between 0 - 8"
- Example:
player.setSelectedSlot(5);
- 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:
player.say("hi");
,player.say("/gamemode creative");
- 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, if you pass in Text it will be formatted
- Example:
player.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, if you pass in Text it will be formatted
- Example:
player.messageActionBar("Hello!");
- This allows you to show a title and a subtitle to the player
- Parameter - Value / Null, Value / Null: any value you want to display to the player, pass null if you don't want to diplay one of them, if you pass in Text it will be formatted
- Example:
Player.showTitle("WOW", "subtitle");
- This opens the player's inventory screen
- Example:
player.openInventory();
- This closes the player's current screen and returns them to the game
- Example:
player.closeScreen();
- This allows you to set whether your player is holding the walk key or not
- Parameter - Boolean: whether you want them to walk
- Example:
player.setWalking(true);
- This allows you to set whether your player is holding the sneak key or not
- Parameter - Boolean: whether you want them to sneak
- Example:
player.setSneaking(true);
- This allows you to set whether your player is holding the sprinting key or not
- Parameter - Boolean: whether you want them to sprint
- Example:
player.setSprinting(true);
- This allows you to drop the item(s) you are currently holding in your main hand
- Parameter - Boolean: whether you want to drop the whole stack
- Example:
player.dropItemInHand(true);
- This allows you to drop all of a select item type from your inventory
- Parameter - ItemStack: the ItemStack you want to drop
- Example:
player.dropAll(client.itemFromString("diamond_block"));
- This allows you to swap 2 slots with one another
- Parameters - Number, Number: slot number, another slot number
- Throws
"That slot is out of bounds"
- Example:
player.swapSlots(13, 46);
- This allows you to shift click a slot
- Parameters - Select Number: a slot number
- Throws
"That slot is out of bounds"
- Example:
player.shiftClickSlot(9);
- This gets the current screen the player is in
- Returns - Screen / Null: the screen that the player is in, if the player is not in a screen, returns Null
- Example:
player.getCurrentScreen();
- This allows you to drop the items in a slot
- Parameter - Number: a slot number
- Example:
player.dropSlot(14);
- This allows you to manipulate where your player is looking
- Parameters - Number, Number: the yaw (between -180 - 180), and the pitch (between -90 - 90)
- Example:
player.look(-76.2, 80.1);
- This makes your player look towards a block position
- Parameters - Number, Number, Number: x position, y position, and z position
- Example:
player.lookAtPos(0.0, 0.0, 0.0);
- This allows you to craft a recipe, this can be 2x2 or 3x3
- Parameter - List: a list of ItemStacks making up the recipe you want to craft (must include air)
- Throws:
"Recipe must either be 3x3 or 2x2"
or"The recipe must only include items"
or"You must be in a crafting table to craft a 3x3"
- Example:
oakItem = client.itemFromString("oak_planks");
airItem = client.itemFromString("air");
player.craft([
oakItem, oakItem, oakItem,
oakItem, airItem, oakItem,
oakItem, oakItem, oakItem
// Chest crafting recipe
]);
- This allows you to use the stonecutter
- Parameters - ItemStack, ItemStack: the item you want to input, the item you want to output
- Returns - Boolean: returns false if the player doesn't have the inputItem, returns true if crafting was successful
- Throws:
"Not in stonecutter gui"
or"Recipe does not exist"
- Example:
player.stonecutter(client.itemFromString("stone"), client.itemFromString("stone_bricks"));
- This allows you to combine two items in an anvil
- Parameters - Function, Function: a function determining whether the first ItemStack meets a criteria, function determining whether the second ItemStack meets a criteria
- Returns - Boolean / Number: whether the anvilling was successful, if the player doesn't have enough levels it will return the cost of the anvilling
- Throws:
Not in anvil gui"
or""Invalid function parameter""
- Example:
// Enchant a pickaxe with mending
player.anvil(
// Predicate for pick
fun(item) {
// We want a netherite pickaxe without mending
if (item.getItemId() == "netherite_pickaxe") {
hasMending = item.getEnchantments().getKeys().contains("mending");
return !hasMending;
}
return false;
},
// Predicate for book
fun(item) {
// We want a book with mending
if (item.getItemId() == "enchanted_book") {
hasMending = item.getEnchantments().getKeys().contains("mending");
return hasMending;
}
return false;
}
);
- This allows you to name an item in an anvil
- Parameters - String, Function: the name you want to name it to, function determining whether the ItemStack meets a criteria
- Returns - Boolean / Number: whether the anvilling was successful, if the player doesn't have enough levels it will return the cost of the anvilling
- Throws:
"Not in anvil gui"
or"Invalid function parameter"
- Example:
// Rename any shulker box
player.anvil("Rocket Box",
fun(item) {
isShulker = item.getItemId().containsString("shulker_box"));
return isShulker;
}
);
- This forces the player to leave the world
- Parameter - String: the message you display on the disconnect screen
- Example:
player.logout("You've been lazy!")
- This allows a player to interact with an entity without have to click on the entity
- Parameter - Entity: the entity you want to interact with
- Example:
allEntities = client.getWorld().getAllEntities();
foreach (entity : allEntities) {
if (entity.getEntityType() == "villager" && player.getSquaredDistanceTo(entity) < 5) {
player.interactWithEntity(entity);
}
}
- This gets the entity that the player is currently looking at
- Returns - Entity / Null: the entity that the player is currently looking at, can be Null if there is no Entity
- Example:
player.getLookingAtEntity();
- This allows you to trade with a villager at a certain index
- Parameter - Number: the index of the trade you want to trade
- Throws:
"Not in merchant gui"
- Example:
player.tradeIndex(2);
- This gets the index of an ItemStack in a villagers trade list
- Parameter - ItemStack: the ItemStack that you want the index of
- Returns - Number / Null: the index of the trade, can return null if the villager doesn't have the trade
- Throws:
"Not in merchant gui"
- This gets an ItemStack of an index in a villagers trade list
- Parameter - Number: the index of the trade you want the ItemStack for
- Returns ItemStack: the ItemStack at the index
- Throws:
"That trade is out of bounds"
or"Not in merchant gui"
- This checks whether a villager has a trade or not
- Parameter - ItemStack: the ItemStack that you want to check
- Returns - Boolean: whether the villager has a trade for that ItemStack
- Throws:
"Not in merchant gui"
or"That trade is out of bounds"
- Example:
player.doesVillagerHaveTrade(client.itemFromString("diamond_pickaxe"));
- This checks whether a villager's trade is disabled
- Parameter - Number: the index of the trade you want to check
- Returns - Boolean: whether the trade is disabled
- Throws:
"Not in merchant gui"
or"That trade is out of bounds"
- Example:
player.isTradeDisabled(4);
- This gets the price of the trade at an index
- Parameter - Number: the index of the trade
- Returns - Number: the price of the trade
- Throws:
"Not in merchant gui"
or"That trade is out of bounds"
- Example:
player.getPriceForIndex(1);
These are functions that can be applied to Worlds
This will be used for all examples:
client = getMinecraftClient();
world = client.getWorld();
- This gets the Block in a World at set coordinates
- Parameters - Number, Number, Number: x position, y position, z position
- Returns - Block: the block at that position
- Example:
world.getBlockAt(0, 100, 0);
- This gets all of the Entities in a World
- Returns - List: a list of all the Entities in a World
- Example:
world.getAllEntities();
- This gets an Entity from an entityId
- Parameter - Number: an entityId
- Returns - Entity / Null: the Entity from the entityId, if no entity exists under that Id then it returns Null
- Example:
world.getEntityFromId(12);
- This gets a OtherPlayer from their username
- Parameter - String: the player's username
- Returns - OtherPlayer / Null: the OtherPlayer under the playerName, if the OtherPlayer doesn't exist then it will return Null
- Example:
world.getOtherPlayer("senseiwells");
- This will get all OtherPlayers in the world
- Returns - List: a list of all OtherPlayers
- Example:
world.getAllOtherPlayers();
- This will get the closest player to another entity in the world
- Parameters - Entity, Number: the entity you want to check from, the max distance you want to check (in blocks)
- Returns - OtherPlayer / Player / Null: it will get the closest player, if it's the main player it will return Player, if there are no players it can return Null
- Example:
world.getClosestPlayer(client.getPlayer(), 20);
- This will get the dimension name of the world
- Returns - String: the dimension name
- Example:
"overworld"
,"the_nether"
,"the_end"
- Example:
- Example:
world.getDimensionName();
- This will check whether it is raining in the world
- Returns - Boolean: whether it is raining
- Example:
world.isRaining();
- This will check whether it is thundering in the world
- Returns - Boolean: whether it is thundering
- Example:
world.isThundering();
- This will get the time of day, info on the time of day here
- Returns - Number: the time of day (0 - 23999)
- Example:
world.getTimeOfDay();
- This will render a partilce in the world, you can find a list of all the particle ids here
- Parameters - String, Number, Number, Number: the name of the particle, x position, y position, z position
- Throws:
"Particle Invalid"
or"Invalid identifier name"
- Example:
world.renderParticle("end_rod", 0, 100, 0);
- This function is deprecated, this is a dangerous function be careful with how you use it...
- This sets a ghost block in the world
- Parameters - Block, Number, Number, Number: the block you want to set, x position, y position, z position
- Example:
world.setGhostBlock(client.blockFromString("bedrock"), 0, 100, 0);
- This spawns a ghost entity in the world
- Parameters - Entity, Number, Number, Number, Number, Number: the entity you want to spawn, x position, y position, z position, head yaw (changes looking direction), pitch, body yaw (changes body direction)
- Returns - Number / Null: the ghost entity's id, if the spawn was unsuccessful it will return Null
- Example:
pig = client.entityFromString("pig");
entityId = world.spawnGhostEntity(pig, 0, 100, 0, 80, 10, 80);
- This removes a ghost entity in the world
- Parameter - Number: the entityId of the ghost entity you want to remove
- Throws:
"No such fake entity exists"
- Example:
pig = client.entityFromString("pig");
entityId = world.spawnGhostEntity(pig, 0, 100, 0, 80, 10, 80);
sleep(1000);
world.removeGhostEntity(entityId);
These are functions that can be applied to all ItemStacks
This will be used for all examples:
client = getMinecraftClient();
itemStack = client.itemFromString("grass_block");
- This gets the item id (name) of the ItemStack, you can find all itemNames on Joa's Item Property Encyclopedia
- Returns - String: the id of the ItemStack
- Example:
"grass_block"
,"diamond_pickaxe"
- Example:
- Example:
itemStack.getItemId();
- This gets the number of items in the stack
- Returns - Number: the amount of items in the stack
- Example:
itemStack.getCount();
- This gets the durability of the ItemStack
- Returns - Number: the durability, this will return 0 if it doesn't have durability
- Example:
itemStack.getDurability();
- This gets the maximum possible durability for that ItemStack
- Returns - Number: the max durability
- Example:
itemStack.getMaxDurability();
- This gets the enchantments of an ItemStack, you can find a list of all the ids of enchantments here
- Returns - Map: a map of the enchantments and there levels (String : Number), will return an empty map if there are no enchantments
- Example:
{"mending" : 1, "unbreaking" : 2}
- Example:
- Example:
itemStack.getEnchantments();
- This checks if the item is a block item (can be placed as a block)
- Returns - Boolean: whether it is a block item
- Example:
itemStack.isBlockItem();
- This gets the Block from an ItemStack
- Returns - Block: the block of the ItemStack
- Throws:
"Item cannot be converted to block"
- Example:
itemStack.asBlock();
- This checks whether the ItemStack is stackable
- Returns - Boolean: whether it's stackable
- Example:
itemStack.isStackable();
- This gets the maximum stack count that ItemStack can hold
- Returns - Number: the max count
- Example:
itemStack.getMaxCount();
- This gets the custom name for the ItemStack
- Returns - String: the custom name
- Example:
itemStack.getItemName();
- This checks whether the NBT tags of an ItemStack is equal to another
- Returns - Boolean: whether the NBT is equal
- Example:
itemStack.isNbtEqual(client.itemFromString("grass_block"));
- This will get a map of the Nbt of the item
- Returns - Map: a map of all the item Nbt
- Example:
{"BlockEntityTag" : {"Items" : [ {"Slot" : 0, "id" : "minecraft:spruce_planks", "Count" : 64} ] } }
- Example:
- Example:
itemStack.getNbt();
These are functions that can be applied to all Blocks
This will be used for all examples:
client = getMinecraftClient();
block = client.blockFromString("grass_block");
- This gets the block id (name) of the Block
- Returns - String: the id of the Block
- Example:
"grass_block"
,"diamond_block"
- Example:
- Example:
block.getBlockId();
- This checks whether the block is a block entity
- Returns - Boolean: whether it is a block entity
- Example:
block.isBlockEntity();
- This checks if the block is transparent
- Returns - Boolean: whether the block is transparent
- Example:
block.isTransparent();
- This gets the ItemStack representation of the block
- Returns - ItemStack: the ItemStack representation of the block
- Example:
block.asItemStack();
- This gets the Blocks blast resistance
- Returns - Number: the blast resistance of the block
- Example:
block.getBlastResistance();
- This gets the block properties of the Block, you can find a list of all block properties here
- Returns - Map: map of properties, empty map if there are no properties
- Example:
{"waterlogged" : true, "age" : 25, "type" : "double"}
- Example:
- Example:
block.getBlockProperties();
- This will return whether the block has a block position or not
- Returns - Boolean: whether the block has a position
- Example:
block.hasBlockPosition();
- This will get the x position of the block
- Returns - Number / Null: the x position of the block, Null if it doesn't have a position
- Example:
block.getBlockX();
- This will get the y position of the block
- Returns - Number / Null: the y position of the block, Null if it doesn't have a position
- Example:
block.getBlockY();
- This will get the z position of the block
- Returns - Number / Null: the z position of the block, Null if it doesn't have a position
- Example:
block.getBlockZ();
These are functions that can be applied to Text
This will be used for all examples:
client = getMinecraftClient();
text = client.textFromString("CLICK ME");
- This allows you to format text for Minecraft, list of formatting names can be found here
- Parameter - String: the formatting name, it must be the name of the format
- Returns - Text: the formatted text
- Throws:
"Invalid formatting: ..."
- Example:
text.formatText("DARK_RED").formatText("BOLD");
- This allows you to style your text with a click event
- Parameters - String, String: the event name, the value associated with the event
- Examples:
"open_url", "https://google.com"
,"open_file", "C:/Users/user/Desktop/thing.txt"
,"run_command", "/gamemode creative"
,"suggest_command", "/gamemode survival"
,"copy_to_clipboard", "This is your clipboard now :)"
- Examples:
- Throws:
"Invalid action: ..."
- Returns - Text: the styled text
- Example:
text.withClickEvent("open_url", "https://youtu.be/dQw4w9WgXcQ");
- This allows you to append two texts together
- Parameter - Text: a different text you want to append
- Returns - Text: the appended text
- Example:
text.append(client.textFromString(" NOW!"));
These are functions that can be applied to Screens
This will be used for all examples:
client = getMinecraftClient();
player = client.getPlayer();
screen = player.getCurrentScreen();
- This gets the Screen's name
- Returns - String: the screen's name
- Examples:
"Anvil"
,"Furnace"
,"Credits"
,"Merchant"
- Examples:
- Throws:
"Screen was null"
- Example:
screen.getScreenName();
- This gets the Screen's title
- Returns - String: the screen's title
- Example:
"Crafting"
,"Ender Chest"
,"Cleric"
- Example:
- Throws:
"Screen was null"
- Example:
screen.getTitle();
Events are on a separate wiki page, see here
Example Code is on a separate wiki page, see here