5 CraftTweaker
Jonathan Coates edited this page 2021-12-18 11:47:02 +00:00

Important: This only applies for Minecraft versions between 1.12 and 1.16. In later versions, this functionality was replaced with datapacks.

CC: Tweaked has some relatively basic support for CraftTweaker. We currently expose the following API for customising turtle upgrades. This should allow you to add upgrades and remove and replace existing ones.

A note on turtle "adjectives"

Every turtle upgrade has an associated adjective, to describe what kind of turtle it produces. For instance, pickaxes are "Mining" and modems are "Wireless". When adding a new upgrade, you'll also need to add the adjective to the language file.

This is fairly easy to do. First, create a resource pack and an en_us.json file (see the Minecraft wiki for more information). Then add the following contents (replacing minecraft.diamond_pickaxe and Mining with the appropriate upgrade id and translation string).

{
      "upgrade.minecraft.diamond_pickaxe.adjective": "Mining"
}

This When adding a new upgrade, you may need to declare a

dan200.computercraft.turtle

dan200.computercraft.turtle.removeUpgrade(id: String)

Remove an upgrade with a specific name.

Example

dan200.computercraft.turtle.removeUpgrade("minecraft:diamond_pickaxe"); # Disable the mining upgrade

dan200.computercraft.turtle.removeUpgrade(stack: IItemStack)

Remove an upgrade which is crafted with a specific item.

Example

dan200.computercraft.turtle.removeUpgrade(<item:minecraft:diamond_pickaxe>); # Disable the mining upgrade

dan200.computercraft.turtle.addTool(id: String, craftItem: IItemStack[, toolItem: IItemStack][, kind: string])

Add a new turtle tool upgrade (such as a pickaxe or sword). One may choose to have the tool crafted with a different item than the tool itself, for instance crafting a diamond pick upgrade with an iron one.

"kind" allows you to specify which type of tool this is. This may be "axe", "hoe", "shovel", "sword" or the generic (and default) "tool". Kinds define special behaviour a tool might have, such as hoes tilling dirt when calling turtle.dig().

Example

# Add an iron pick upgrade
dan200.computercraft.turtle.addTool("minecraft:iron_pickaxe", <item:minecraft:iron_pickaxe>);

# Add a diamond pick tool crafted with an iron one
dan200.computercraft.turtle.addTool("minecraft:another_pickaxe", <item:minecraft:iron_pickaxe>, <item:minecraft:diamond_pickaxe>);

# Add a diamond sword upgrade, crafted with a stick
dan200.computercraft.turtle.addTool("minecraft:some_sword", <minecraft:stick>, <minecraft:iron_sword>, "sword");