32 lines
1.6 KiB
Java
32 lines
1.6 KiB
Java
package com.atsuishio.superbwarfare.mixins;
|
|
|
|
import com.atsuishio.superbwarfare.init.ModTags;
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import net.minecraft.client.renderer.MultiBufferSource;
|
|
import net.minecraft.client.renderer.entity.layers.ItemInHandLayer;
|
|
import net.minecraft.world.entity.EntityType;
|
|
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 org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.injection.At;
|
|
import org.spongepowered.asm.mixin.injection.Inject;
|
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|
|
|
@Mixin(ItemInHandLayer.class)
|
|
public class ItemInHandLayerMixin {
|
|
|
|
@SuppressWarnings({"ConstantConditions"})
|
|
@Inject(method = "renderArmWithItem(Lnet/minecraft/world/entity/LivingEntity;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/world/item/ItemDisplayContext;Lnet/minecraft/world/entity/HumanoidArm;Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;I)V",
|
|
at = @At(value = "HEAD"), cancellable = true)
|
|
private void renderArmWithItemHead(LivingEntity entity, ItemStack stack, ItemDisplayContext display, HumanoidArm arm, PoseStack poseStack, MultiBufferSource source, int light, CallbackInfo ci) {
|
|
if (entity.getType() == EntityType.PLAYER && arm == HumanoidArm.LEFT) {
|
|
ItemStack mainHand = entity.getMainHandItem();
|
|
if (!mainHand.is(ModTags.Items.GUN)) return;
|
|
|
|
ci.cancel();
|
|
}
|
|
}
|
|
|
|
}
|