mirror of
https://github.com/TeamMidnightDust/SwordBlocking.git
synced 2025-12-16 23:05:10 +01:00
port: Chase the Skies (1.21.6)
This commit is contained in:
@@ -2,6 +2,7 @@ package eu.midnightdust.swordblocking;
|
||||
|
||||
import eu.midnightdust.swordblocking.config.SwordBlockingConfig;
|
||||
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
@@ -23,7 +24,7 @@ public class SwordBlockingClient {
|
||||
public static boolean canShieldSwordBlock(LivingEntity entity) {
|
||||
if (SwordBlockingConfig.enabled && (entity.getOffHandStack().getItem() instanceof ShieldItem || entity.getMainHandStack().getItem() instanceof ShieldItem)) {
|
||||
Item weaponItem = entity.getOffHandStack().getItem() instanceof ShieldItem ? entity.getMainHandStack().getItem() : entity.getOffHandStack().getItem();
|
||||
return weaponItem instanceof SwordItem || weaponItem instanceof AxeItem || weaponItem instanceof MaceItem;
|
||||
return weaponItem.getComponents().contains(DataComponentTypes.DAMAGE);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.item.HeldItemRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.ItemDisplayContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ModelTransformationMode;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Hand;
|
||||
@@ -32,8 +32,8 @@ public abstract class MixinHeldItemRenderer {
|
||||
@Shadow
|
||||
protected abstract void applySwingOffset(MatrixStack matrices, Arm arm, float swingProgress);
|
||||
|
||||
@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) {
|
||||
@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemDisplayContext;Lnet/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, ItemDisplayContext renderMode, MatrixStack matrices, VertexConsumerProvider vertexConsumer, int light, CallbackInfo ci) {
|
||||
if (SwordBlockingClient.shouldHideShield(entity, stack)) {
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user