123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- package me.km.entities;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.model.ModelBiped;
- import net.minecraft.client.model.ModelPlayer;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.renderer.entity.RenderLivingBase;
- import net.minecraft.client.renderer.entity.layers.LayerArrow;
- import net.minecraft.client.renderer.entity.layers.LayerBipedArmor;
- import net.minecraft.client.renderer.entity.layers.LayerCustomHead;
- import net.minecraft.client.renderer.entity.layers.LayerElytra;
- import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
- import net.minecraft.item.EnumAction;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.EnumHandSide;
- import net.minecraft.util.ResourceLocation;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- @SideOnly(Side.CLIENT)
- public class RenderHuman extends RenderLivingBase<EntityHuman>
- {
- /** this field is used to indicate the 3-pixel wide arms */
- private final ModelHuman steve;
- private final ModelHuman alex;
- public RenderHuman()
- {
- super(Minecraft.getMinecraft().getRenderManager(), new ModelHuman(0, false), 0.5f);
- this.addLayer(new LayerBipedArmor(this));
- this.addLayer(new LayerHeldItem(this));
- this.addLayer(new LayerArrow(this));
- this.addLayer(new LayerCustomHead(this.getMainModel().bipedHead));
- this.addLayer(new LayerElytra(this));
-
- this.steve = this.getMainModel();
- this.alex = new ModelHuman(0, true);
- }
- @Override
- public final ModelHuman getMainModel()
- {
- return (ModelHuman) super.getMainModel();
- }
- @Override
- public void doRender(EntityHuman h, double x, double y, double z, float entityYaw, float partialTicks)
- {
- double d0 = y;
- if (h.isSneaking())
- {
- d0 = y - 0.125D;
- }
- this.setModelVisibilities(h);
- GlStateManager.enableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
- if(h.isSlim())
- {
- this.mainModel = alex;
- super.doRender(h, x, d0, z, entityYaw, partialTicks);
- this.mainModel = steve;
- }
- else
- {
- super.doRender(h, x, d0, z, entityYaw, partialTicks);
- }
- GlStateManager.disableBlendProfile(GlStateManager.Profile.PLAYER_SKIN);
- }
- private void setModelVisibilities(EntityHuman h)
- {
- ModelPlayer modelplayer = this.getMainModel();
-
- modelplayer.setVisible(true);
- modelplayer.bipedHeadwear.showModel = true;
- modelplayer.bipedBodyWear.showModel = true;
- modelplayer.bipedLeftLegwear.showModel = true;
- modelplayer.bipedRightLegwear.showModel = true;
- modelplayer.bipedLeftArmwear.showModel = true;
- modelplayer.bipedRightArmwear.showModel = true;
- modelplayer.isSneak = false;
- ModelBiped.ArmPose modelbiped$armpose = ModelBiped.ArmPose.EMPTY;
- ModelBiped.ArmPose modelbiped$armpose1 = ModelBiped.ArmPose.EMPTY;
- ItemStack mainHand = h.getHeldItemMainhand();
-
- if (!mainHand.isEmpty())
- {
- modelbiped$armpose = ModelBiped.ArmPose.ITEM;
- if (h.getItemInUseCount() > 0)
- {
- EnumAction enumaction = mainHand.getItemUseAction();
- if (enumaction == EnumAction.BLOCK)
- {
- modelbiped$armpose = ModelBiped.ArmPose.BLOCK;
- }
- else if (enumaction == EnumAction.BOW)
- {
- modelbiped$armpose = ModelBiped.ArmPose.BOW_AND_ARROW;
- }
- }
- }
-
- ItemStack offHand = h.getHeldItemMainhand();
- if (!offHand.isEmpty())
- {
- modelbiped$armpose1 = ModelBiped.ArmPose.ITEM;
- if (h.getItemInUseCount() > 0)
- {
- EnumAction enumaction1 = offHand.getItemUseAction();
- if (enumaction1 == EnumAction.BLOCK)
- {
- modelbiped$armpose1 = ModelBiped.ArmPose.BLOCK;
- }
- // FORGE: fix MC-88356 allow offhand to use bow and arrow animation
- else if (enumaction1 == EnumAction.BOW)
- {
- modelbiped$armpose1 = ModelBiped.ArmPose.BOW_AND_ARROW;
- }
- }
- }
- if (h.getPrimaryHand() == EnumHandSide.RIGHT)
- {
- modelplayer.rightArmPose = modelbiped$armpose;
- modelplayer.leftArmPose = modelbiped$armpose1;
- }
- else
- {
- modelplayer.rightArmPose = modelbiped$armpose1;
- modelplayer.leftArmPose = modelbiped$armpose;
- }
- }
-
- @Override
- public ResourceLocation getEntityTexture(EntityHuman h)
- {
- return h.getTexture();
- }
- @Override
- public void transformHeldFull3DItemLayer()
- {
- GlStateManager.translate(0.0F, 0.1875F, 0.0F);
- }
- @Override
- protected void preRenderCallback(EntityHuman entitylivingbaseIn, float partialTickTime)
- {
- GlStateManager.scale(0.9375F, 0.9375F, 0.9375F);
- }
- }
|