|
| 1 | +--- |
| 2 | +title: Tool Creation |
| 3 | +--- |
| 4 | + |
| 5 | +Tools can be made out of materials you create by calling toolStats inside the material's code. |
| 6 | + |
| 7 | +When working with tools you will need to load these classes at the top of your file. |
| 8 | +```js |
| 9 | +const $PropertyKey = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.PropertyKey'); |
| 10 | +const $ToolProperty = Java.loadClass('com.gregtechceu.gtceu.api.data.chemical.material.properties.ToolProperty'); |
| 11 | +``` |
| 12 | +toolStats has the following arguments: |
| 13 | + |
| 14 | +`.toolStats(float harvestSpeed, float attackDamage, int durability, int harvestLevel, GTToolType[] types)` |
| 15 | + |
| 16 | +- `harvestSpeed` is how fast the tool actually breaks blocks in world. |
| 17 | + - Takes a decimal number eg.(5.6). |
| 18 | +- `attackDamage` is the amount of damage per hit you deal to mobs/players. |
| 19 | + - Also takes a decimal number. |
| 20 | +- `durability` is the number of times the tool can be used before it breaks. |
| 21 | + - Takes a positive whole number up to 2.147 billion (e.g 700). |
| 22 | + This applies to both crafting use and in-world use. |
| 23 | + Crafting generally consumes 2 points of durability per use. |
| 24 | +- `harvestLevel` is the tier of block it can break. |
| 25 | + - Can take a number between 1-6 with 1 being wood, 6 being neutronium. |
| 26 | +- `GtToolType` is a group of tools in an object. |
| 27 | + - Must pass these as an array, using the [] notation. |
| 28 | + This argument can be left out if you want it to apply to all tool types. |
| 29 | + |
| 30 | +An example of this being actually used is included below |
| 31 | +```js title="example_tool_material.js" |
| 32 | +GTCEuStartupEvents.registry('gtceu:material', event => { |
| 33 | + event.create('aluminfrost') |
| 34 | + .ingot() |
| 35 | + .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(GTMaterialIconSet.DULL) |
| 36 | + .toolStats(new ToolProperty(12, 7, 3072, 6, |
| 37 | + [ |
| 38 | + GTToolType.DRILL_LV, |
| 39 | + GTToolType.MINING_HAMMER |
| 40 | + ] |
| 41 | + )) |
| 42 | +}); |
| 43 | +``` |
| 44 | +You can also add further arguments onto your tools such as: |
| 45 | +- `.unbreakable()` |
| 46 | + - Makes electric tools bypass durability effectively making them never break. |
| 47 | +- `.magnetic()` |
| 48 | + - Makes mined blocks and mob drops teleport to player inventory. |
| 49 | +- `attackSpeed(float)` |
| 50 | + - Set the attack speed of a tool made from this Material (animation time). |
| 51 | + Takes a decimal number. |
| 52 | +- `ignoreCraftingTools()` |
| 53 | + - Disable crafting tools being made from this Material. |
| 54 | +- `addEnchantmentForTools(enchantment, level)` |
| 55 | + - Enchantment is the default enchantment applied on tool creation. |
| 56 | + Level is the level of said enchantment. |
| 57 | +- `enchantability(int enchantability)` |
| 58 | + - Set the base enchantability of a tool made from this Material. |
| 59 | + Iron is 14, Diamond is 10, Stone is 5. |
| 60 | + Takes a whole number. |
| 61 | + |
| 62 | +Here is an example of using them in your material: |
| 63 | +```js title="example_tool_material.js" |
| 64 | +GTCEuStartupEvents.registry('gtceu:material', event => { |
| 65 | + event.create('aluminfrost') |
| 66 | + .ingot() |
| 67 | + .color(0xadd8e6).secondaryColor(0xc0c0c0).iconSet(GTMaterialIconSet.DULL) |
| 68 | + .toolStats($ToolProperty.Builder.of(1.8, 1.7, 700, 3, |
| 69 | + [GTToolType.SWORD, |
| 70 | + GTToolType.PICKAXE, |
| 71 | + GTToolType.SHOVEL, |
| 72 | + ]) |
| 73 | + .unbreakable() |
| 74 | + .addEnchantmentForTools(silk_touch, 1) |
| 75 | + .build()) |
| 76 | +}); |
| 77 | +``` |
| 78 | + |
| 79 | +You can also add more tool types to a GT material that already has a tool property. You do, however, have to remove the current tool property as it is immutable (not changeable). |
| 80 | +```js title="tool_replacement.js" |
| 81 | +GTCEuStartupEvents.materialModification(event => { |
| 82 | + if (GTMaterials.Iron.hasProperty($PropertyKey.TOOL)) { |
| 83 | + GTMaterials.Iron.removeProperty($PropertyKey.TOOL); |
| 84 | + } |
| 85 | + GTMaterials.Neutronium.setProperty($PropertyKey.TOOL, |
| 86 | + $ToolProperty.Builder.of(180, 5.9, 2147483647, 6, |
| 87 | + [ |
| 88 | + GTToolType.SOFT_MALLET, |
| 89 | + GTToolType.DRILL_LV |
| 90 | + ] |
| 91 | + ).build()); |
| 92 | +}); |
| 93 | +``` |
| 94 | +Here is a list of all the GtToolTypes |
| 95 | +- SWORD, |
| 96 | +- PICKAXE, |
| 97 | +- SHOVEL, |
| 98 | +- AXE, |
| 99 | +- HOE, |
| 100 | +- MINING_HAMMER, |
| 101 | +- SPADE, |
| 102 | +- SAW, |
| 103 | +- HARD_HAMMER, |
| 104 | +- SOFT_MALLET, |
| 105 | +- WRENCH, |
| 106 | +- FILE, |
| 107 | +- CROWBAR, |
| 108 | +- SCREWDRIVER, |
| 109 | +- MORTAR, |
| 110 | +- WIRE_CUTTER, |
| 111 | +- SCYTHE, |
| 112 | +- KNIFE, |
| 113 | +- BUTCHERY_KNIFE, |
| 114 | +- PLUNGER, |
| 115 | +- DRILL_LV, |
| 116 | +- DRILL_MV, |
| 117 | +- DRILL_HV, |
| 118 | +- DRILL_EV, |
| 119 | +- DRILL_IV, |
| 120 | +- CHAINSAW_LV, |
| 121 | +- WRENCH_LV, |
| 122 | +- WRENCH_HV, |
| 123 | +- WRENCH_IV, |
| 124 | +- BUZZSAW, |
| 125 | +- SCREWDRIVER_LV, |
| 126 | +- WIRE_CUTTER_LV, |
| 127 | +- WIRE_CUTTER_HV, |
| 128 | +- WIRE_CUTTER_IV, |
0 commit comments