Move some enabled checks

This commit is contained in:
lowercasebtw
2024-12-06 18:12:43 -05:00
parent 5119e0b3ba
commit a6df4e73df
3 changed files with 6 additions and 6 deletions

View File

@@ -17,7 +17,7 @@ public class SwordBlockingClient {
} }
public static boolean isEntityBlocking(LivingEntity entity) { public static boolean isEntityBlocking(LivingEntity entity) {
return entity.isUsingItem() && canShieldSwordBlock(entity); return SwordBlockingConfig.enabled && entity.isUsingItem() && canShieldSwordBlock(entity);
} }
public static boolean canShieldSwordBlock(LivingEntity entity) { public static boolean canShieldSwordBlock(LivingEntity entity) {
@@ -30,7 +30,7 @@ public class SwordBlockingClient {
} }
public static boolean shouldHideShield(LivingEntity entity, ItemStack stack) { public static boolean shouldHideShield(LivingEntity entity, ItemStack stack) {
return (SwordBlockingConfig.alwaysHideShield && SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem) return SwordBlockingConfig.enabled && (SwordBlockingConfig.alwaysHideShield && SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem)
|| (SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem && SwordBlockingClient.canShieldSwordBlock(entity)); || (SwordBlockingConfig.hideShield && stack.getItem() instanceof ShieldItem && SwordBlockingClient.canShieldSwordBlock(entity));
} }
} }

View File

@@ -24,7 +24,7 @@ public abstract class MixinBipedEntityModel<T extends BipedEntityRenderState> {
@Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;animateArms(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;F)V", shift = At.Shift.BEFORE)) @Inject(method = "setAngles(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/BipedEntityModel;animateArms(Lnet/minecraft/client/render/entity/state/BipedEntityRenderState;F)V", shift = At.Shift.BEFORE))
private void swordBlocking$setBlockingAngles(T bipedEntityRenderState, CallbackInfo ci) { private void swordBlocking$setBlockingAngles(T bipedEntityRenderState, CallbackInfo ci) {
LivingEntity livingEntity = SwordBlockingClient.RENDER_STATE_TO_ENTITY_MAP.get(bipedEntityRenderState); LivingEntity livingEntity = SwordBlockingClient.RENDER_STATE_TO_ENTITY_MAP.get(bipedEntityRenderState);
if (!SwordBlockingConfig.enabled || livingEntity == null || !SwordBlockingClient.isEntityBlocking(livingEntity)) if (livingEntity == null || !SwordBlockingClient.isEntityBlocking(livingEntity))
return; return;
if (livingEntity.getOffHandStack().getItem() instanceof ShieldItem) if (livingEntity.getOffHandStack().getItem() instanceof ShieldItem)
this.positionRightArm(bipedEntityRenderState, BipedEntityModel.ArmPose.BLOCK); this.positionRightArm(bipedEntityRenderState, BipedEntityModel.ArmPose.BLOCK);

View File

@@ -34,7 +34,7 @@ public abstract class MixinHeldItemRenderer {
@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true) @Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ModelTransformationMode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At("HEAD"), cancellable = true)
public void swordBlocking$hideShield(LivingEntity entity, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { public void swordBlocking$hideShield(LivingEntity entity, ItemStack stack, ModelTransformationMode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
if (SwordBlockingConfig.enabled && SwordBlockingClient.shouldHideShield(entity, stack)) { if (SwordBlockingClient.shouldHideShield(entity, stack)) {
ci.cancel(); ci.cancel();
} }
} }
@@ -42,7 +42,7 @@ public abstract class MixinHeldItemRenderer {
@Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getActiveHand()Lnet/minecraft/util/Hand;", ordinal = 1)) @Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/AbstractClientPlayerEntity;getActiveHand()Lnet/minecraft/util/Hand;", ordinal = 1))
private Hand swordBlocking$changeActiveHand(AbstractClientPlayerEntity player, @Local(name = "hand") Hand hand) { private Hand swordBlocking$changeActiveHand(AbstractClientPlayerEntity player, @Local(name = "hand") Hand hand) {
Hand activeHand = player.getActiveHand(); Hand activeHand = player.getActiveHand();
if (SwordBlockingConfig.enabled && SwordBlockingClient.isEntityBlocking(player)) { if (SwordBlockingClient.isEntityBlocking(player)) {
return swordBlocking$getBlockingHand(activeHand); return swordBlocking$getBlockingHand(activeHand);
} else { } else {
return activeHand; return activeHand;
@@ -52,7 +52,7 @@ public abstract class MixinHeldItemRenderer {
@Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;")) @Redirect(method = "renderFirstPersonItem", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;getUseAction()Lnet/minecraft/item/consume/UseAction;"))
private UseAction swordBlocking$changeItemAction(ItemStack stack, @Local(argsOnly = true) AbstractClientPlayerEntity player, @Local(name = "hand") Hand hand) { private UseAction swordBlocking$changeItemAction(ItemStack stack, @Local(argsOnly = true) AbstractClientPlayerEntity player, @Local(name = "hand") Hand hand) {
UseAction defaultUseAction = stack.getUseAction(); UseAction defaultUseAction = stack.getUseAction();
if (SwordBlockingConfig.enabled && SwordBlockingClient.isEntityBlocking(player)) { if (SwordBlockingClient.isEntityBlocking(player)) {
return swordBlocking$getBlockingHand(player.getActiveHand()) == hand ? UseAction.BLOCK : defaultUseAction; return swordBlocking$getBlockingHand(player.getActiveHand()) == hand ? UseAction.BLOCK : defaultUseAction;
} else { } else {
return defaultUseAction; return defaultUseAction;