diff --git a/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/TinkersEvolutionMixinCategory.java b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/TinkersEvolutionMixinCategory.java index cb28a09..0438ff3 100644 --- a/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/TinkersEvolutionMixinCategory.java +++ b/src/main/java/io/github/lxgaming/sledgehammer/configuration/category/mixin/TinkersEvolutionMixinCategory.java @@ -23,10 +23,18 @@ @ConfigSerializable public class TinkersEvolutionMixinCategory { + @Mapping(value = "tconevo.trait.draconicevolution.TraitEvolvedMixin", dependencies = "tconevo") + @Setting(value = "draconic-upgrade", comment = "If 'true', fixes unintended upgrading of Draconic Modifiers") + private boolean draconicUpgrade = false; + @Mapping(value = "tconevo.integration.redstonerepository.RedstoneRepositoryHooksImplMixin", dependencies = "tconevo") @Setting(value = "redstone-repository", comment = "If 'true', fixes NoClassDefFoundError with Redstone Repository") private boolean redstoneRepository = false; + public boolean isDraconicUpgrade() { + return draconicUpgrade; + } + public boolean isRedstoneRepository() { return redstoneRepository; } diff --git a/src/main/java/io/github/lxgaming/sledgehammer/mixin/tconevo/trait/draconicevolution/TraitEvolvedMixin.java b/src/main/java/io/github/lxgaming/sledgehammer/mixin/tconevo/trait/draconicevolution/TraitEvolvedMixin.java new file mode 100644 index 0000000..1bcded0 --- /dev/null +++ b/src/main/java/io/github/lxgaming/sledgehammer/mixin/tconevo/trait/draconicevolution/TraitEvolvedMixin.java @@ -0,0 +1,42 @@ +/* + * Copyright 2023 Alex Thomson + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.github.lxgaming.sledgehammer.mixin.tconevo.trait.draconicevolution; + +import net.minecraft.nbt.NBTTagCompound; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import slimeknights.tconstruct.library.utils.TinkerUtil; +import xyz.phanta.tconevo.trait.draconicevolution.ModifierDraconic; +import xyz.phanta.tconevo.trait.draconicevolution.TraitEvolved; + +@Mixin(value = TraitEvolved.class, remap = false) +public abstract class TraitEvolvedMixin { + + @Redirect( + method = "applyEffect", + at = @At( + value = "INVOKE", + target = "Lxyz/phanta/tconevo/trait/draconicevolution/ModifierDraconic;apply(Lnet/minecraft/nbt/NBTTagCompound;)V" + ) + ) + private void onApply(ModifierDraconic mod, NBTTagCompound rootCompound, NBTTagCompound modifierTag) { + if (!TinkerUtil.hasTrait(rootCompound, mod.identifier)) { + mod.apply(rootCompound); + } + } +} \ No newline at end of file diff --git a/src/main/resources/mixins.sledgehammer.tconevo.json b/src/main/resources/mixins.sledgehammer.tconevo.json index 3ee6de8..80915bf 100644 --- a/src/main/resources/mixins.sledgehammer.tconevo.json +++ b/src/main/resources/mixins.sledgehammer.tconevo.json @@ -7,7 +7,8 @@ "target": "@env(DEFAULT)", "compatibilityLevel": "JAVA_8", "mixins": [ - "integration.redstonerepository.RedstoneRepositoryHooksImplMixin" + "integration.redstonerepository.RedstoneRepositoryHooksImplMixin", + "trait.draconicevolution.TraitEvolvedMixin" ], "injectors": { "defaultRequire": 1