Skip to content

Commit

Permalink
Moved riptide shield fix to different package
Browse files Browse the repository at this point in the history
  • Loading branch information
Bactrosaurus committed Aug 4, 2024
1 parent 34c92a1 commit 6adee79
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 26 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "de.daniel"
version = "2.3"
version = "2.4"

repositories {
mavenCentral()
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()) {
Expand All @@ -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();
}
}

}
Original file line number Diff line number Diff line change
@@ -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();
}
}

}
1 change: 1 addition & 0 deletions src/main/resources/bactromod.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"features.noopgmswitcher.MixinGameModeSwitcherScreen",
"features.noopgmswitcher.MixinKeyboardHandler",
"features.nopumpkinblur.MixinGui",
"features.riptidetridentshield.MixinItemInHandRenderer",
"features.windowborder.MixinWindow",
"settingsbutton.MixinCreditsAndAttributionScreen"
],
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6adee79

Please sign in to comment.