diff --git a/src/main/java/info/partonetrain/botaniacombat/BotaniaNerfConfiguredValues.java b/src/main/java/info/partonetrain/botaniacombat/BotaniaNerfConfiguredValues.java index b9c10c3..0184e9a 100644 --- a/src/main/java/info/partonetrain/botaniacombat/BotaniaNerfConfiguredValues.java +++ b/src/main/java/info/partonetrain/botaniacombat/BotaniaNerfConfiguredValues.java @@ -3,6 +3,14 @@ import me.shedaniel.autoconfig.AutoConfig; import net.minecraft.world.entity.ai.attributes.AttributeModifier; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static java.lang.System.getProperty; + public class BotaniaNerfConfiguredValues { //have default values loaded so mixins don't classload config public static boolean conformSoulscribe = false; public static int daggerDamageModifier = -3; @@ -30,4 +38,23 @@ public static void init(){ babylonDamage = AutoConfig.getConfigHolder(BotaniaCombatConfig.class).getConfig().botaniaNerfsConfig.babylonDamage; missileDamage = AutoConfig.getConfigHolder(BotaniaCombatConfig.class).getConfig().botaniaNerfsConfig.missileDamage; } + + public static void readFromFileDirectly() { + //this is necessary because Botania may register Soulscribe before config is read and conformSoulscribe is set + //however, mixin is always applied first; SoulscribeItemMixin calls this method + if (!conformSoulscribe) { //if it's false then it might not have been set + BotaniaCombat.LOGGER.info("Reading from config file directly to confirm conformSoulscribe option"); + final String configFileLoc = System.getProperty("user.dir") + "\\config\\botaniacombat.json5"; + Path configFilePath = Paths.get(configFileLoc); //converts to correct path regardless of platform + try { + String conformSoulscribeLine = Files.readAllLines(configFilePath).toString(); + if (conformSoulscribeLine.contains("\"conformSoulscribe\": true")) { + conformSoulscribe = true; + } + } catch (IOException e) { + BotaniaCombat.LOGGER.error("config error:" + e); + BotaniaCombat.LOGGER.info("Don't fret! Above error is most likely one-time occurrence from config file not existing yet"); + } + } + } } diff --git a/src/main/java/info/partonetrain/botaniacombat/mixin/nerf/SoulscribeItemMixin.java b/src/main/java/info/partonetrain/botaniacombat/mixin/nerf/SoulscribeItemMixin.java index 0bd048c..7c41196 100644 --- a/src/main/java/info/partonetrain/botaniacombat/mixin/nerf/SoulscribeItemMixin.java +++ b/src/main/java/info/partonetrain/botaniacombat/mixin/nerf/SoulscribeItemMixin.java @@ -1,5 +1,6 @@ package info.partonetrain.botaniacombat.mixin.nerf; +import info.partonetrain.botaniacombat.BotaniaCombat; import info.partonetrain.botaniacombat.BotaniaNerfConfiguredValues; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,9 +12,11 @@ public class SoulscribeItemMixin { @ModifyArgs(method= "(Lnet/minecraft/world/item/Item$Properties;)V", at = @At(value = "INVOKE", target = "Lvazkii/botania/common/item/equipment/tool/manasteel/ManasteelSwordItem;(Lnet/minecraft/world/item/Tier;IFLnet/minecraft/world/item/Item$Properties;)V")) private static void botaniacombat$conformSoulscribe(Args args){ + BotaniaNerfConfiguredValues.readFromFileDirectly(); if(BotaniaNerfConfiguredValues.conformSoulscribe){ args.set(1, (int)args.get(1) + BotaniaNerfConfiguredValues.daggerDamageModifier); args.set(2, BotaniaNerfConfiguredValues.daggerSpeed); + BotaniaCombat.LOGGER.info("BotaniaCombat conformed Soulscribe to dagger stats"); } } } diff --git a/src/main/java/info/partonetrain/botaniacombat/mixin/ranged/ManaBlasterMixin.java b/src/main/java/info/partonetrain/botaniacombat/mixin/ranged/ManaBlasterMixin.java index 444d8eb..549d424 100644 --- a/src/main/java/info/partonetrain/botaniacombat/mixin/ranged/ManaBlasterMixin.java +++ b/src/main/java/info/partonetrain/botaniacombat/mixin/ranged/ManaBlasterMixin.java @@ -21,11 +21,10 @@ @Mixin(ManaBlasterItem.class) public abstract class ManaBlasterMixin extends Item { @Unique - float damage = BotaniaNerfConfiguredValues.dmgLensDamage; + float damage; @Unique - AttributeModifier mod1 = new AttributeModifier(UUID.fromString("60dfc4ff-de55-4f4f-8b4b-a7748c26ec4d"), "Blaster mainhand modifier", damage, AttributeModifier.Operation.ADDITION); - @Unique - AttributeModifier mod2 = new AttributeModifier(UUID.fromString("2c9b7180-d04f-4b1f-9574-174969759856"), "Blaster offhand modifier", damage, AttributeModifier.Operation.ADDITION); + AttributeModifier mod1, mod2; + public ManaBlasterMixin(Properties properties) { super(properties); } @@ -33,6 +32,9 @@ public ManaBlasterMixin(Properties properties) { @Inject(method = "inventoryTick", at = @At("HEAD")) public void botaniacombat$setDamageLensNBT(ItemStack stack, Level world, Entity entity, int slot, boolean selected, CallbackInfo ci){ if(ManaBlasterItem.getLens(stack).is(BotaniaItems.lensDamage)){ + damage = BotaniaNerfConfiguredValues.dmgLensDamage; + mod1 = new AttributeModifier(UUID.fromString("60dfc4ff-de55-4f4f-8b4b-a7748c26ec4d"), "Blaster mainhand modifier", damage, AttributeModifier.Operation.ADDITION); + mod2 = new AttributeModifier(UUID.fromString("2c9b7180-d04f-4b1f-9574-174969759856"), "Blaster offhand modifier", damage, AttributeModifier.Operation.ADDITION); if(!stack.getAttributeModifiers(EquipmentSlot.MAINHAND).containsKey(EntityAttributes_RangedWeapon.DAMAGE.attribute)){ stack.addAttributeModifier(EntityAttributes_RangedWeapon.DAMAGE.attribute, mod1, EquipmentSlot.MAINHAND); stack.addAttributeModifier(EntityAttributes_RangedWeapon.DAMAGE.attribute, mod2, EquipmentSlot.OFFHAND);