59 lines
3.1 KiB
Java
59 lines
3.1 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* org.joml.Quaternionfc
|
|
*/
|
|
package net.minecraft.client.renderer.entity.layers;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.math.Axis;
|
|
import net.minecraft.client.model.ArmedModel;
|
|
import net.minecraft.client.model.EntityModel;
|
|
import net.minecraft.client.model.SpearAnimations;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.entity.RenderLayerParent;
|
|
import net.minecraft.client.renderer.entity.layers.RenderLayer;
|
|
import net.minecraft.client.renderer.entity.state.ArmedEntityRenderState;
|
|
import net.minecraft.client.renderer.item.ItemStackRenderState;
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
import net.minecraft.world.entity.HumanoidArm;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.SwingAnimationType;
|
|
import org.joml.Quaternionfc;
|
|
|
|
public class ItemInHandLayer<S extends ArmedEntityRenderState, M extends EntityModel<S>>
|
|
extends RenderLayer<S, M> {
|
|
public ItemInHandLayer(RenderLayerParent<S, M> renderer) {
|
|
super(renderer);
|
|
}
|
|
|
|
@Override
|
|
public void submit(PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords, S state, float yRot, float xRot) {
|
|
this.submitArmWithItem(state, ((ArmedEntityRenderState)state).rightHandItemState, ((ArmedEntityRenderState)state).rightHandItemStack, HumanoidArm.RIGHT, poseStack, submitNodeCollector, lightCoords);
|
|
this.submitArmWithItem(state, ((ArmedEntityRenderState)state).leftHandItemState, ((ArmedEntityRenderState)state).leftHandItemStack, HumanoidArm.LEFT, poseStack, submitNodeCollector, lightCoords);
|
|
}
|
|
|
|
protected void submitArmWithItem(S state, ItemStackRenderState item, ItemStack itemStack, HumanoidArm arm, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, int lightCoords) {
|
|
float ticksUsingItem;
|
|
if (item.isEmpty()) {
|
|
return;
|
|
}
|
|
poseStack.pushPose();
|
|
((ArmedModel)this.getParentModel()).translateToHand(state, arm, poseStack);
|
|
poseStack.mulPose((Quaternionfc)Axis.XP.rotationDegrees(-90.0f));
|
|
poseStack.mulPose((Quaternionfc)Axis.YP.rotationDegrees(180.0f));
|
|
boolean isLeftHand = arm == HumanoidArm.LEFT;
|
|
poseStack.translate((float)(isLeftHand ? -1 : 1) / 16.0f, 0.125f, -0.625f);
|
|
if (((ArmedEntityRenderState)state).attackTime > 0.0f && ((ArmedEntityRenderState)state).mainArm == arm && ((ArmedEntityRenderState)state).swingAnimationType == SwingAnimationType.STAB) {
|
|
SpearAnimations.thirdPersonAttackItem(state, poseStack);
|
|
}
|
|
if ((ticksUsingItem = ((ArmedEntityRenderState)state).ticksUsingItem(arm)) != 0.0f) {
|
|
(arm == HumanoidArm.RIGHT ? ((ArmedEntityRenderState)state).rightArmPose : ((ArmedEntityRenderState)state).leftArmPose).animateUseItem(state, poseStack, ticksUsingItem, arm, itemStack);
|
|
}
|
|
item.submit(poseStack, submitNodeCollector, lightCoords, OverlayTexture.NO_OVERLAY, ((ArmedEntityRenderState)state).outlineColor);
|
|
poseStack.popPose();
|
|
}
|
|
}
|
|
|