diff --git a/build.gradle.kts b/build.gradle.kts index 6ace3d5..5632a46 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { } group = "de.daniel" -version = "2.3" +version = "2.4" repositories { mavenCentral() @@ -20,10 +20,10 @@ dependencies { mappings(loom.officialMojangMappings()) modImplementation("net.fabricmc:fabric-loader:0.15.11") - modImplementation("net.fabricmc.fabric-api:fabric-api:0.100.7+1.21") + modImplementation("net.fabricmc.fabric-api:fabric-api:0.100.8+1.21") modImplementation("net.fabricmc:fabric-language-kotlin:1.11.0+kotlin.2.0.0") - modApi("com.terraformersmc:modmenu:11.0.0") + modApi("com.terraformersmc:modmenu:11.0.1") } loom { diff --git a/src/main/java/de/daniel/bactromod/mixins/features/lowshield/MixinItemInHandRenderer.java b/src/main/java/de/daniel/bactromod/mixins/features/lowshield/MixinItemInHandRenderer.java index 6e1f296..669ad55 100644 --- a/src/main/java/de/daniel/bactromod/mixins/features/lowshield/MixinItemInHandRenderer.java +++ b/src/main/java/de/daniel/bactromod/mixins/features/lowshield/MixinItemInHandRenderer.java @@ -1,15 +1,11 @@ package de.daniel.bactromod.mixins.features.lowshield; import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Axis; import de.daniel.bactromod.config.Config; -import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.client.renderer.ItemInHandRenderer; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.entity.ItemRenderer; import net.minecraft.client.renderer.texture.OverlayTexture; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.item.ItemDisplayContext; import net.minecraft.world.item.ItemStack; @@ -28,9 +24,6 @@ public class MixinItemInHandRenderer { @Final private ItemRenderer itemRenderer; - @Shadow - public void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemDisplayContext itemDisplayContext, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i) {} - @Inject(method = "renderItem", at = @At(value = "HEAD"), cancellable = true) public void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemDisplayContext displayContext, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, CallbackInfo ci) { if (itemStack.is(Items.SHIELD) && displayContext.firstPerson()) { @@ -42,19 +35,4 @@ public void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemDispl } } - @Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V", ordinal = 11), cancellable = true) - public void shieldTransformAutoSpinAttack(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j, CallbackInfo ci) { - if (itemStack.is(Items.SHIELD) && Config.INSTANCE.load().getFixShieldRiptideTrident()) { - boolean bl = interactionHand == InteractionHand.MAIN_HAND; - HumanoidArm humanoidArm = bl ? abstractClientPlayer.getMainArm() : abstractClientPlayer.getMainArm().getOpposite(); - boolean bl2 = humanoidArm == HumanoidArm.RIGHT; - poseStack.translate(0.0F, 0.0F, 0.0F); - poseStack.mulPose(Axis.YP.rotationDegrees(0.0F)); - poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F)); - this.renderItem(abstractClientPlayer, itemStack, bl2 ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND : ItemDisplayContext.FIRST_PERSON_LEFT_HAND, !bl2, poseStack, multiBufferSource, j); - poseStack.popPose(); - ci.cancel(); - } - } - } \ No newline at end of file diff --git a/src/main/java/de/daniel/bactromod/mixins/features/riptidetridentshield/MixinItemInHandRenderer.java b/src/main/java/de/daniel/bactromod/mixins/features/riptidetridentshield/MixinItemInHandRenderer.java new file mode 100644 index 0000000..80ce783 --- /dev/null +++ b/src/main/java/de/daniel/bactromod/mixins/features/riptidetridentshield/MixinItemInHandRenderer.java @@ -0,0 +1,42 @@ +package de.daniel.bactromod.mixins.features.riptidetridentshield; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Axis; +import de.daniel.bactromod.config.Config; +import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.renderer.ItemInHandRenderer; +import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.world.InteractionHand; +import net.minecraft.world.entity.HumanoidArm; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.item.ItemDisplayContext; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ItemInHandRenderer.class) +public class MixinItemInHandRenderer { + + @Shadow + public void renderItem(LivingEntity livingEntity, ItemStack itemStack, ItemDisplayContext itemDisplayContext, boolean bl, PoseStack poseStack, MultiBufferSource multiBufferSource, int i) {} + + @Inject(method = "renderArmWithItem", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(FFF)V", ordinal = 11), cancellable = true) + public void shieldTransformAutoSpinAttack(AbstractClientPlayer abstractClientPlayer, float f, float g, InteractionHand interactionHand, float h, ItemStack itemStack, float i, PoseStack poseStack, MultiBufferSource multiBufferSource, int j, CallbackInfo ci) { + if (itemStack.is(Items.SHIELD) && Config.INSTANCE.load().getFixShieldRiptideTrident()) { + boolean bl = interactionHand == InteractionHand.MAIN_HAND; + HumanoidArm humanoidArm = bl ? abstractClientPlayer.getMainArm() : abstractClientPlayer.getMainArm().getOpposite(); + boolean bl2 = humanoidArm == HumanoidArm.RIGHT; + poseStack.translate(0.0F, 0.0F, 0.0F); + poseStack.mulPose(Axis.YP.rotationDegrees(0.0F)); + poseStack.mulPose(Axis.ZP.rotationDegrees(0.0F)); + this.renderItem(abstractClientPlayer, itemStack, bl2 ? ItemDisplayContext.FIRST_PERSON_RIGHT_HAND : ItemDisplayContext.FIRST_PERSON_LEFT_HAND, !bl2, poseStack, multiBufferSource, j); + poseStack.popPose(); + ci.cancel(); + } + } + +} diff --git a/src/main/resources/bactromod.mixins.json b/src/main/resources/bactromod.mixins.json index 28a8c0a..0cf44e3 100644 --- a/src/main/resources/bactromod.mixins.json +++ b/src/main/resources/bactromod.mixins.json @@ -11,6 +11,7 @@ "features.noopgmswitcher.MixinGameModeSwitcherScreen", "features.noopgmswitcher.MixinKeyboardHandler", "features.nopumpkinblur.MixinGui", + "features.riptidetridentshield.MixinItemInHandRenderer", "features.windowborder.MixinWindow", "settingsbutton.MixinCreditsAndAttributionScreen" ], diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 0d15824..9b6eb37 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -3,7 +3,7 @@ "id": "bactromod", "authors": ["Bactrosaurus", "FurnyGo"], "description": "A lightweight mod with some game optimizations and features.", - "version": "2.3", + "version": "2.4", "name": "BactroMod", "environment": "client", "license": "LGPL-3.0-only",