diff --git a/common/build.gradle b/common/build.gradle index f28814475..f51b09344 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -26,6 +26,8 @@ dependencies{ exclude(group: "net.fabricmc.fabric-api") exclude(group: "com.github.LlamaLad7") } + implementation("io.github.llamalad7:mixinextras-common:0.2.0-beta.11") + annotationProcessor("io.github.llamalad7:mixinextras-common:0.2.0-beta.11") modImplementation("com.github.Trins-mods:CT-Fabric-Fluid-Support:${project.ct_fabric_fluid_support_hash}") modImplementation("io.github.feltmc:fabricated-forge-tag-extensions:${rootProject.fabricated_forge_hash}") { transitive false } modCompileOnly "me.shedaniel:RoughlyEnoughItems-api:${rootProject.rei_version}" diff --git a/common/src/main/java/muramasa/antimatter/mixin/PlayerMixin.java b/common/src/main/java/muramasa/antimatter/mixin/PlayerMixin.java index 28c1c9a96..a2636574b 100644 --- a/common/src/main/java/muramasa/antimatter/mixin/PlayerMixin.java +++ b/common/src/main/java/muramasa/antimatter/mixin/PlayerMixin.java @@ -1,4 +1,27 @@ package muramasa.antimatter.mixin; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import muramasa.antimatter.Data; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.MobType; +import net.minecraft.world.entity.monster.Creeper; +import net.minecraft.world.entity.monster.Ghast; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(Player.class) public class PlayerMixin { + @WrapOperation(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/EnchantmentHelper;getDamageBonus(Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/entity/MobType;)F")) + private float redirectDamageBonus(ItemStack stack, MobType type, Operation original, Entity target){ + if (target instanceof LivingEntity living){ + if (living instanceof Creeper || living instanceof Ghast){ + type = Data.CREEPER; + } + } + return original.call(stack, type); + } } diff --git a/common/src/main/resources/antimatter.mixins.json b/common/src/main/resources/antimatter.mixins.json index 8a2c30f93..8747b3925 100644 --- a/common/src/main/resources/antimatter.mixins.json +++ b/common/src/main/resources/antimatter.mixins.json @@ -27,6 +27,7 @@ "IngredientAccessor", "ItemStackMixin", "LeavesBlockMixin", + "PlayerMixin", "RepairItemRecipeMixin", "ServerBlockUpdateMixin", "SimpleReloadInstanceMixin" diff --git a/forge/build.gradle b/forge/build.gradle index 1fbbb3616..34d4364c4 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -49,6 +49,7 @@ dependencies { modImplementation("earth.terrarium:botarium-forge-1.18.2:${project.botarium_version}") modImplementation(include("com.gtnewhorizon.structurelib:structurelib-forge:${project.structurelib_version}-${project.minecraft_version}")) modImplementation(include("com.teamresourceful.resourcefullib:resourcefullib-forge-1.18.2:${project.resourcefullib_version}")) + modImplementation(include("io.github.llamalad7:mixinextras-forge:0.2.0-beta.11")) modImplementation("dev.latvian.mods:kubejs-forge:${rootProject.kubejs_version}") modImplementation("curse.maven:the-one-probe-245211:${rootProject.top_forge_file}") }