Skip to content

Commit

Permalink
Made material tool enchantability not implicitly tied to icon sets (#76)
Browse files Browse the repository at this point in the history
* Made material tool enchantability not implicitly tied to icon sets

- Nano Saber gets 33 enchantability, it inherited platinum's enchantability before but right now platinum doesn't have the tool property
- Deprecated old static helper method to get a material enchantability (delete outright?)

* Remove deprecated method
  • Loading branch information
Rongmario authored Aug 13, 2021
1 parent 1b3c241 commit ba74b2f
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 94 deletions.
25 changes: 1 addition & 24 deletions src/main/java/gregtech/api/items/toolitem/ToolMetaItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import gregtech.api.unification.material.Material;
import gregtech.api.unification.material.MaterialRegistry;
import gregtech.api.unification.material.Materials;
import gregtech.api.unification.material.info.MaterialIconSet;
import gregtech.api.unification.material.properties.DustProperty;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.material.properties.ToolProperty;
Expand Down Expand Up @@ -464,8 +463,7 @@ public boolean isEnchantable(ItemStack stack) {

@Override
public int getItemEnchantability(ItemStack stack) {
Material primaryMaterial = getToolMaterial(stack);
return getMaterialEnchantability(primaryMaterial);
return getToolMaterial(stack).getProperty(PropertyKey.TOOL).toolEnchantability;
}

@Override
Expand All @@ -477,27 +475,6 @@ public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantmen
return false;
}

public static int getMaterialEnchantability(Material material) {
if (material.getMaterialIconSet() == MaterialIconSet.SHINY ||
material.getMaterialIconSet() == MaterialIconSet.RUBY) {
return 33; //all shiny metals have gold enchantability
} else if (material.getMaterialIconSet() == MaterialIconSet.DULL ||
material.getMaterialIconSet() == MaterialIconSet.METALLIC) {
return 21; //dull metals have iron enchantability
} else if (material.getMaterialIconSet() == MaterialIconSet.GEM_VERTICAL ||
material.getMaterialIconSet() == MaterialIconSet.GEM_HORIZONTAL ||
material.getMaterialIconSet() == MaterialIconSet.DIAMOND ||
material.getMaterialIconSet() == MaterialIconSet.OPAL ||
material.getMaterialIconSet() == MaterialIconSet.NETHERSTAR) {
return 15; //standard gems have diamond enchantability
} else if (material.getMaterialIconSet() == MaterialIconSet.WOOD ||
material.getMaterialIconSet() == MaterialIconSet.ROUGH ||
material.getMaterialIconSet() == MaterialIconSet.FINE) {
return 11; //wood and stone has their default enchantability
}
return 10; //otherwise return lowest enchantability
}

@Override
public int getMaxItemDamage(ItemStack itemStack) {
T metaToolValueItem = getItem(itemStack);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -667,8 +667,8 @@ public Builder element(Element element) {
return this;
}

public Builder toolStats(float speed, float damage, int durability) {
properties.setProperty(PropertyKey.TOOL, new ToolProperty(speed, damage, durability));
public Builder toolStats(float speed, float damage, int durability, int enchantability) {
properties.setProperty(PropertyKey.TOOL, new ToolProperty(speed, damage, durability, enchantability));
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void register() {
.color(0x80C8F0)
.flags(EXT2_METAL, GENERATE_SMALL_GEAR, GENERATE_RING, GENERATE_FRAME, GENERATE_SPRING, GENERATE_SPRING_SMALL)
.element(Elements.Al)
.toolStats(10.0f, 2.0f, 128)
.toolStats(10.0f, 2.0f, 128, 21)
.cableProperties(GTValues.V[4], 1, 1)
.fluidPipeProperties(1166, 35, true)
.blastTemp(1700)
Expand Down Expand Up @@ -154,7 +154,7 @@ public static void register() {
.color(0xFFE6E6).iconSet(SHINY)
.flags(EXT2_METAL, GENERATE_ROTOR, GENERATE_DENSE)
.element(Elements.Cr)
.toolStats(12.0f, 3.0f, 512)
.toolStats(12.0f, 3.0f, 512, 33)
.fluidPipeProperties(2725, 40, true)
.blastTemp(1700)
.build();
Expand All @@ -164,7 +164,7 @@ public static void register() {
.color(0x5050FA).iconSet(METALLIC)
.flags(STD_METAL, GENERATE_GEAR)
.element(Elements.Co)
.toolStats(10.0f, 3.0f, 256)
.toolStats(10.0f, 3.0f, 256, 21)
.cableProperties(GTValues.V[1], 2, 2)
.itemPipeProperties(2560, 2.0f)
.build();
Expand Down Expand Up @@ -348,7 +348,7 @@ public static void register() {
.color(0xF0F0F5)
.flags(EXT2_METAL, GENERATE_ROTOR, GENERATE_DENSE)
.element(Elements.Ir)
.toolStats(7.0f, 3.0f, 2560)
.toolStats(7.0f, 3.0f, 2560, 21)
.fluidPipeProperties(3398, 140, true)
.blastTemp(2719)
.build();
Expand All @@ -359,7 +359,7 @@ public static void register() {
.flags(EXT2_METAL, MORTAR_GRINDABLE, GENERATE_DENSE, GENERATE_FRAME, GENERATE_ROTOR, GENERATE_SMALL_GEAR,
GENERATE_SPRING, GENERATE_SPRING_SMALL, EXCLUDE_BLOCK_CRAFTING_BY_HAND_RECIPES, BLAST_FURNACE_CALCITE_TRIPLE)
.element(Elements.Fe)
.toolStats(7.0f, 2.5f, 256)
.toolStats(7.0f, 2.5f, 256, 21)
.cableProperties(GTValues.V[2], 2, 3)
.build();

Expand Down Expand Up @@ -429,7 +429,7 @@ public static void register() {
.color(0xFAFAFA)
.flags(STD_METAL, GENERATE_FOIL)
.element(Elements.Mn)
.toolStats(7.0f, 2.0f, 512)
.toolStats(7.0f, 2.0f, 512, 21)
.build();

Meitnerium = new Material.Builder(62, "meitnerium")
Expand All @@ -448,7 +448,7 @@ public static void register() {
.ingot().fluid().ore()
.color(0xB4B4DC).iconSet(SHINY)
.element(Elements.Mo)
.toolStats(7.0f, 2.0f, 512)
.toolStats(7.0f, 2.0f, 512, 33)
.build();

Moscovium = new Material.Builder(65, "moscovium")
Expand All @@ -462,7 +462,7 @@ public static void register() {
.color(0x646464).iconSet(METALLIC)
.flags(STD_METAL, GENERATE_ROD)
.element(Elements.Nd)
.toolStats(7.0f, 2.0f, 512)
.toolStats(7.0f, 2.0f, 512, 21)
.blastTemp(1297)
.build();

Expand Down Expand Up @@ -526,7 +526,7 @@ public static void register() {
.color(0x3232FF).iconSet(METALLIC)
.flags(EXT2_METAL, GENERATE_ROTOR, GENERATE_DENSE)
.element(Elements.Os)
.toolStats(16.0f, 4.0f, 1280)
.toolStats(16.0f, 4.0f, 1280, 21)
.cableProperties(GTValues.V[5], 4, 2)
.itemPipeProperties(256, 8.0f)
.blastTemp(3306)
Expand All @@ -543,7 +543,7 @@ public static void register() {
.color(0x808080).iconSet(SHINY)
.flags(EXT2_METAL)
.element(Elements.Pd)
.toolStats(8.0f, 2.0f, 512)
.toolStats(8.0f, 2.0f, 512, 33)
.cableProperties(GTValues.V[5], 2, 1)
.blastTemp(1228)
.build();
Expand Down Expand Up @@ -772,7 +772,7 @@ public static void register() {
.color(0x001E00).iconSet(SHINY)
.flags(STD_METAL)
.element(Elements.Th)
.toolStats(6.0f, 2.0f, 512)
.toolStats(6.0f, 2.0f, 512, 33)
.build();

Thallium = new Material.Builder(110, "thallium")
Expand Down Expand Up @@ -803,7 +803,7 @@ public static void register() {
.color(0xDCA0F0).iconSet(METALLIC)
.flags(EXT2_METAL, GENERATE_ROTOR, GENERATE_SMALL_GEAR, GENERATE_SPRING, GENERATE_FRAME, GENERATE_DENSE)
.element(Elements.Ti)
.toolStats(7.0f, 3.0f, 1600)
.toolStats(7.0f, 3.0f, 1600, 21)
.cableProperties(GTValues.V[4], 4, 2)
.fluidPipeProperties(2426, 80, true)
.blastTemp(1941)
Expand All @@ -820,7 +820,7 @@ public static void register() {
.color(0x323232).iconSet(METALLIC)
.flags(EXT2_METAL, GENERATE_SPRING, GENERATE_SPRING_SMALL)
.element(Elements.W)
.toolStats(7.0f, 3.0f, 2560)
.toolStats(7.0f, 3.0f, 2560, 21)
.cableProperties(GTValues.V[5], 2, 2)
.fluidPipeProperties(4618, 90, true)
.blastTemp(3000)
Expand All @@ -831,15 +831,15 @@ public static void register() {
.color(0x32F032).iconSet(METALLIC)
.flags(STD_METAL)
.element(Elements.U238)
.toolStats(6.0f, 3.0f, 512)
.toolStats(6.0f, 3.0f, 512, 21)
.build();

Uranium235 = new Material.Builder(117, "uranium235")
.ingot(3).fluid().ore()
.color(0x46FA46).iconSet(SHINY)
.flags(STD_METAL, GENERATE_ROD)
.element(Elements.U235)
.toolStats(6.0f, 3.0f, 512)
.toolStats(6.0f, 3.0f, 512, 33)
.build();

Vanadium = new Material.Builder(118, "vanadium")
Expand Down Expand Up @@ -892,7 +892,7 @@ public static void register() {
.color(0x323232).iconSet(METALLIC)
.flags(EXT_METAL, GENERATE_FOIL, GENERATE_SPRING)
.element(Elements.Nq)
.toolStats(6.0f, 4.0f, 1280)
.toolStats(6.0f, 4.0f, 1280, 21)
.cableProperties(GTValues.V[7], 2, 2)
.fluidPipeProperties(19200, 1500, true)
.blastTemp(5400)
Expand All @@ -903,7 +903,7 @@ public static void register() {
.color(0x3C3C3C).iconSet(METALLIC)
.flags(EXT_METAL, GENERATE_FOIL)
.element(Elements.Nq1)
.toolStats(6.0f, 4.0f, 1280)
.toolStats(6.0f, 4.0f, 1280, 21)
.blastTemp(4500)
.build();

Expand All @@ -920,7 +920,7 @@ public static void register() {
.color(0xFAFAFA)
.flags(EXT2_METAL, GENERATE_ROTOR, GENERATE_SMALL_GEAR, GENERATE_FRAME)
.element(Elements.Nt)
.toolStats(24.0f, 12.0f, 655360)
.toolStats(24.0f, 12.0f, 655360, 21)
.fluidPipeProperties(1000000, 2800, true)
.build();

Expand All @@ -929,15 +929,15 @@ public static void register() {
.color(0x600000).iconSet(METALLIC)
.flags(EXT_METAL, GENERATE_FRAME)
.element(Elements.Tr)
.toolStats(20.0f, 6.0f, 10240)
.toolStats(20.0f, 6.0f, 10240, 21)
.build();

Duranium = new Material.Builder(129, "duranium")
.ingot(5).fluid()
.color(0x4BAFAF).iconSet(METALLIC)
.flags(EXT_METAL, GENERATE_FOIL)
.element(Elements.Dr)
.toolStats(16.0f, 5.0f, 5120)
.toolStats(16.0f, 5.0f, 5120, 21)
.cableProperties(GTValues.V[8], 1, 8)
.fluidPipeProperties(100000, 2000, true)
.build();
Expand Down
Loading

0 comments on commit ba74b2f

Please sign in to comment.