From 3fec35f97692dfe38a35998b4a3772082a0bd3b3 Mon Sep 17 00:00:00 2001 From: Colin Wong Date: Mon, 11 Oct 2021 22:16:15 -0500 Subject: [PATCH] Add TICMaterial methods for checking if stat exists (fixes #782) --- build.gradle | 7 ++-- .../tconstruct/materials/ITICMaterial.java | 38 +++++++++++++++++++ .../tconstruct/materials/TICMaterial.java | 10 +++-- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index dafd863..f718caf 100644 --- a/build.gradle +++ b/build.gradle @@ -5,9 +5,10 @@ buildscript { maven { url = "https://maven.minecraftforge.net" } } dependencies { - classpath('com.github.DStrand1:ForgeGradle:FG_2.3-SNAPSHOT') { - changing = true - } + // classpath('com.github.DStrand1:ForgeGradle:FG_2.3-SNAPSHOT') { + // changing = true + // } + classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT' } } plugins { diff --git a/src/main/java/com/blamejared/compat/tconstruct/materials/ITICMaterial.java b/src/main/java/com/blamejared/compat/tconstruct/materials/ITICMaterial.java index 3544422..9a249f6 100644 --- a/src/main/java/com/blamejared/compat/tconstruct/materials/ITICMaterial.java +++ b/src/main/java/com/blamejared/compat/tconstruct/materials/ITICMaterial.java @@ -17,6 +17,44 @@ public interface ITICMaterial { @ZenGetter("definition") ITICMaterialDefinition getDefinition(); + + @ZenMethod + boolean hasStats(String stat); + + @ZenMethod + default boolean hasHeadStats() { + return hasStats("head"); + } + + @ZenMethod + default boolean hasHandleStats() { + return hasStats("handle"); + } + + @ZenMethod + default boolean hasExtraStats() { + return hasStats("extra"); + } + + @ZenMethod + default boolean hasArrowStats() { + return hasStats("shaft"); + } + + @ZenMethod + default boolean hasFletchingStats() { + return hasStats("fletching"); + } + + @ZenMethod + default boolean hasBowStats() { + return hasStats("bow"); + } + + @ZenMethod + default boolean hasBowStringStats() { + return hasStats("bowstring"); + } @ZenSetter("durabilityHead") void setDurabilityHead(int durability); diff --git a/src/main/java/com/blamejared/compat/tconstruct/materials/TICMaterial.java b/src/main/java/com/blamejared/compat/tconstruct/materials/TICMaterial.java index 96ebd9f..bba16d6 100644 --- a/src/main/java/com/blamejared/compat/tconstruct/materials/TICMaterial.java +++ b/src/main/java/com/blamejared/compat/tconstruct/materials/TICMaterial.java @@ -31,6 +31,12 @@ public class TICMaterial implements ITICMaterial { public ITICMaterialDefinition getDefinition() { return new TICMaterialDefinition(material); } + + + @Override + public boolean hasStats(String stat) { + return material.hasStats(stat); + } @Override public void setDurabilityHead(int durability) { @@ -176,14 +182,10 @@ public class TICMaterial implements ITICMaterial { @Override public float getBowStringModifier() { return ((BowStringMaterialStats) material.getStats("bowstring")).modifier; - } @Override public void setBowStringModifier(float modifier) { CraftTweakerAPI.apply(new SetModifierAction(this, "bowstring", modifier)); - } - - } \ No newline at end of file