Add TICMaterial methods for checking if stat exists (fixes #782)

This commit is contained in:
Colin Wong 2021-10-11 22:16:15 -05:00
parent 78021c0715
commit 3fec35f976
3 changed files with 48 additions and 7 deletions

View file

@ -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 {

View file

@ -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);

View file

@ -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));
}
}