diff --git a/src/forge/java/com/brohoof/minelittlepony/forge/PonyArmors.java b/src/forge/java/com/brohoof/minelittlepony/forge/PonyArmors.java index 2e9027f8..2623b2fc 100644 --- a/src/forge/java/com/brohoof/minelittlepony/forge/PonyArmors.java +++ b/src/forge/java/com/brohoof/minelittlepony/forge/PonyArmors.java @@ -1,7 +1,5 @@ package com.brohoof.minelittlepony.forge; -import com.brohoof.minelittlepony.forge.IPonyArmor; - import net.minecraft.client.model.ModelBase; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java index 6f2c63bb..9f894837 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/GuiSkins.java @@ -1,31 +1,6 @@ package com.voxelmodpack.hdskins.gui; -import static net.minecraft.client.renderer.GlStateManager.blendFunc; -import static net.minecraft.client.renderer.GlStateManager.color; -import static net.minecraft.client.renderer.GlStateManager.colorMask; -import static net.minecraft.client.renderer.GlStateManager.depthMask; -import static net.minecraft.client.renderer.GlStateManager.disableAlpha; -import static net.minecraft.client.renderer.GlStateManager.disableBlend; -import static net.minecraft.client.renderer.GlStateManager.disableColorMaterial; -import static net.minecraft.client.renderer.GlStateManager.disableCull; -import static net.minecraft.client.renderer.GlStateManager.disableDepth; -import static net.minecraft.client.renderer.GlStateManager.disableFog; -import static net.minecraft.client.renderer.GlStateManager.disableTexture2D; -import static net.minecraft.client.renderer.GlStateManager.enableAlpha; -import static net.minecraft.client.renderer.GlStateManager.enableBlend; -import static net.minecraft.client.renderer.GlStateManager.enableColorMaterial; -import static net.minecraft.client.renderer.GlStateManager.enableCull; -import static net.minecraft.client.renderer.GlStateManager.enableDepth; -import static net.minecraft.client.renderer.GlStateManager.enableTexture2D; -import static net.minecraft.client.renderer.GlStateManager.loadIdentity; -import static net.minecraft.client.renderer.GlStateManager.matrixMode; -import static net.minecraft.client.renderer.GlStateManager.popAttrib; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.rotate; -import static net.minecraft.client.renderer.GlStateManager.scale; -import static net.minecraft.client.renderer.GlStateManager.translate; -import static net.minecraft.client.renderer.GlStateManager.viewport; +import static net.minecraft.client.renderer.GlStateManager.*; import java.awt.Color; import java.awt.Window.Type; @@ -75,15 +50,15 @@ import net.minecraft.client.gui.GuiMainMenu; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.texture.DynamicTexture; import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.I18n; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Session; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.TextFormatting; public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpenFileCallback, IPanoramaRenderer { private static final int MAX_SKIN_DIMENSION = 8192; @@ -446,7 +421,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); byte blendIterations = 8; Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); + VertexBuffer vb = tessellator.getBuffer(); for (int blendPass = 0; blendPass < blendIterations * blendIterations; ++blendPass) { pushMatrix(); @@ -481,11 +456,11 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe this.mc.getTextureManager().bindTexture(cubemapTextures[cubeSide]); // wr.setColorRGBA_I(0xffffff, 255 / (blendPass + 1)); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); - wr.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).endVertex(); - wr.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).endVertex(); - wr.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).endVertex(); - wr.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).endVertex(); + vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + vb.pos(-1.0D, -1.0D, 1.0D).tex(0.0D, 0.0D).endVertex(); + vb.pos(1.0D, -1.0D, 1.0D).tex(1.0D, 0.0D).endVertex(); + vb.pos(1.0D, 1.0D, 1.0D).tex(1.0D, 1.0D).endVertex(); + vb.pos(-1.0D, 1.0D, 1.0D).tex(0.0D, 1.0D).endVertex(); tessellator.draw(); popMatrix(); } @@ -494,7 +469,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe colorMask(true, true, true, false); } - wr.setTranslation(0.0D, 0.0D, 0.0D); + vb.setTranslation(0.0D, 0.0D, 0.0D); colorMask(true, true, true, true); depthMask(true); enableCull(); @@ -510,17 +485,16 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); colorMask(true, true, true, false); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + VertexBuffer vb = tessellator.getBuffer(); + vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); byte blurPasses = 4; for (int blurPass = 0; blurPass < blurPasses; ++blurPass) { -// wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (blurPass + 1)); float var7 = (blurPass - blurPasses / 2) / 256.0F; - wr.pos(this.width, this.height, this.zLevel).tex(0.0F + var7, 0.0D).endVertex(); - wr.pos(this.width, 0.0D, this.zLevel).tex(1.0F + var7, 0.0D).endVertex(); - wr.pos(0.0D, 0.0D, this.zLevel).tex(1.0F + var7, 1.0D).endVertex(); - wr.pos(0.0D, this.height, this.zLevel).tex(0.0F + var7, 1.0D).endVertex(); + vb.pos(this.width, this.height, this.zLevel).tex(0.0F + var7, 0.0D).endVertex(); + vb.pos(this.width, 0.0D, this.zLevel).tex(1.0F + var7, 0.0D).endVertex(); + vb.pos(0.0D, 0.0D, this.zLevel).tex(1.0F + var7, 1.0D).endVertex(); + vb.pos(0.0D, this.height, this.zLevel).tex(0.0F + var7, 1.0D).endVertex(); } tessellator.draw(); @@ -541,18 +515,18 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe viewport(0, 0, this.mc.displayWidth, this.mc.displayHeight); Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer wr = tessellator.getWorldRenderer(); - wr.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); + VertexBuffer vb = tessellator.getBuffer(); + vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX); float aspect = this.width > this.height ? 120.0F / this.width : 120.0F / this.height; float uSample = this.height * aspect / 256.0F; float vSample = this.width * aspect / 256.0F; GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); // wr.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F); - wr.pos(0.0D, this.height, this.zLevel).tex(0.5F - uSample, 0.5F + vSample).endVertex(); - wr.pos(this.width, this.height, this.zLevel).tex(0.5F - uSample, 0.5F - vSample).endVertex(); - wr.pos(this.width, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F - vSample).endVertex(); - wr.pos(0.0D, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F + vSample).endVertex(); + vb.pos(0.0D, this.height, this.zLevel).tex(0.5F - uSample, 0.5F + vSample).endVertex(); + vb.pos(this.width, this.height, this.zLevel).tex(0.5F - uSample, 0.5F - vSample).endVertex(); + vb.pos(this.width, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F - vSample).endVertex(); + vb.pos(0.0D, 0.0D, this.zLevel).tex(0.5F + uSample, 0.5F + vSample).endVertex(); tessellator.draw(); return true; } @@ -618,7 +592,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe if (this.fetchingSkin) { String opacity1; if (this.throttledByMojang) { - opacity1 = EnumChatFormatting.RED + mojang; + opacity1 = TextFormatting.RED + mojang; String stringWidth = wait; int stringWidth1 = this.fontRendererObj.getStringWidth(opacity1) / 2; int stringWidth2 = this.fontRendererObj.getStringWidth(stringWidth) / 2; @@ -684,7 +658,7 @@ public class GuiSkins extends GuiScreen implements IUploadCompleteCallback, IOpe RenderManager rm = Minecraft.getMinecraft().getRenderManager(); rm.playerViewY = 180.0F; - rm.renderEntityWithPosYaw(thePlayer, 0.0D, 0.0D, 0.0D, 1.0F, 1.0F); + rm.renderEntityStatic(thePlayer, 0, false); popMatrix(); RenderHelper.disableStandardItemLighting(); diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java index 450e85c3..d95a3dbe 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/gui/RenderPlayerModel.java @@ -1,9 +1,6 @@ package com.voxelmodpack.hdskins.gui; -import static net.minecraft.client.renderer.GlStateManager.popAttrib; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.scale; +import static net.minecraft.client.renderer.GlStateManager.*; import org.lwjgl.opengl.GL11; diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java index 5e3c161e..242c0dec 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinImageBufferDownload.java @@ -19,12 +19,14 @@ import net.minecraft.client.renderer.ImageBufferDownload; @Mixin(ImageBufferDownload.class) public abstract class MixinImageBufferDownload implements IImageBuffer { - @Inject(method = "parseUserSkin", + @Inject( + method = "parseUserSkin", locals = LocalCapture.CAPTURE_FAILSOFT, - at = @At(value = "INVOKE", + at = @At( + value = "INVOKE", shift = Shift.BEFORE, target = "Ljava/awt/Graphics;dispose()V", - remap = false) ) + remap = false)) private void update(BufferedImage image, CallbackInfo ci, BufferedImage image2, Graphics graphics) { // convert skins from mojang server if (image.getHeight() == 32) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java index 225bb112..776e291f 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinPlayerInfo.java @@ -27,9 +27,10 @@ public abstract class MixinPlayerInfo { @Shadow public String skinType; - @Inject(method = "hasLocationSkin", + @Inject( + method = "hasLocationSkin", cancellable = true, - at = @At("RETURN") ) + at = @At("RETURN")) private void hasLocationSkin(CallbackInfoReturnable ci) { if (locationSkin == null) { // in case has no skin @@ -38,9 +39,10 @@ public abstract class MixinPlayerInfo { } } - @Inject(method = "getLocationSkin", + @Inject( + method = "getLocationSkin", cancellable = true, - at = @At("RETURN") ) + at = @At("RETURN")) private void getLocationSkin(CallbackInfoReturnable ci) { Optional skin = HDSkinManager.INSTANCE.getSkinLocation(gameProfile, Type.SKIN, true); if (skin.isPresent()) { @@ -49,9 +51,10 @@ public abstract class MixinPlayerInfo { } } - @Inject(method = "getLocationCape", + @Inject( + method = "getLocationCape", cancellable = true, - at = @At("RETURN") ) + at = @At("RETURN")) private void getLocationCape(CallbackInfoReturnable ci) { Optional cape = HDSkinManager.INSTANCE.getSkinLocation(gameProfile, Type.CAPE, true); if (cape.isPresent()) { @@ -60,9 +63,10 @@ public abstract class MixinPlayerInfo { } } - @Inject(method = "getSkinType", + @Inject( + method = "getSkinType", cancellable = true, - at = @At("RETURN") ) + at = @At("RETURN")) private void getSkinType(CallbackInfoReturnable ci) { MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(gameProfile).get(Type.SKIN); if (data != null) { diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java index 549ed06e..c82cc04a 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/mixin/MixinSkullRenderer.java @@ -18,12 +18,14 @@ import net.minecraft.util.ResourceLocation; @Mixin(TileEntitySkullRenderer.class) public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer { - @Redirect(method = "renderSkull", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V", - ordinal = 4)) + @Redirect( + method = "renderSkull", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/tileentity/TileEntitySkullRenderer;bindTexture(Lnet/minecraft/util/ResourceLocation;)V", + ordinal = 4)) private void onBindTexture(TileEntitySkullRenderer tesr, ResourceLocation rl, float x, float y, float z, EnumFacing facing, float rotation, int meta, - GameProfile profile, int p_180543_8_) { + GameProfile profile, int p_180543_8_, float ticks) { if (profile != null) { Optional skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true); if (skin.isPresent()) diff --git a/src/main/java/com/brohoof/minelittlepony/hdskins/gui/GuiSkinsMineLP.java b/src/main/java/com/brohoof/minelittlepony/hdskins/gui/GuiSkinsMineLP.java index 90946168..5b1417f9 100644 --- a/src/main/java/com/brohoof/minelittlepony/hdskins/gui/GuiSkinsMineLP.java +++ b/src/main/java/com/brohoof/minelittlepony/hdskins/gui/GuiSkinsMineLP.java @@ -3,7 +3,6 @@ package com.brohoof.minelittlepony.hdskins.gui; import java.awt.image.BufferedImage; import com.brohoof.minelittlepony.PonyManager; -import com.brohoof.minelittlepony.hdskins.gui.EntityPonyModel; import com.brohoof.minelittlepony.util.MineLPLogger; import com.mojang.authlib.GameProfile; import com.voxelmodpack.hdskins.gui.EntityPlayerModel; diff --git a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java index 7de6a234..1a68fd9b 100644 --- a/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java +++ b/src/main/java/com/brohoof/minelittlepony/mixin/MixinRenderPlayer.java @@ -2,10 +2,12 @@ package com.brohoof.minelittlepony.mixin; import static net.minecraft.client.renderer.GlStateManager.scale; +import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import com.brohoof.minelittlepony.MineLittlePony; @@ -21,17 +23,16 @@ import com.brohoof.minelittlepony.renderer.layer.LayerPonyCape; import com.brohoof.minelittlepony.renderer.layer.LayerPonySkull; import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.entity.EntityPlayerSP; +import net.minecraft.client.model.ModelPlayer; +import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.renderer.entity.layers.LayerArrow; -import net.minecraft.item.EnumAction; -import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @Mixin(RenderPlayer.class) -public abstract class MixinRenderPlayer extends RendererLivingEntity implements IRenderPony { +public abstract class MixinRenderPlayer extends RenderLivingBase implements IRenderPony { @Shadow private boolean smallArms; @@ -44,7 +45,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity 0) { - EnumAction action = currentItemStack.getItemUseAction(); - if (action == EnumAction.BLOCK) { - this.playerModel.getModel().heldItemRight = 3; - } else if (action == EnumAction.BOW) { - this.playerModel.getModel().aimedBow = true; - } - } this.playerModel.getModel().isSneak = player.isSneaking(); this.playerModel.getModel().isFlying = thePony.isPegasusFlying(player); - this.playerModel.getModel().isRiding = player.isRiding(); if (MineLittlePony.getConfig().showscale) { if (this.playerModel.getModel().metadata.getRace() != null) { @@ -100,22 +86,11 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity 0) { - EnumAction enumaction = itemstack.getItemUseAction(); + EnumAction enumaction = main.getItemUseAction(); if (enumaction == EnumAction.BLOCK) { - modelplayer.heldItemRight = 3; + mainPose = ArmPose.BLOCK; } else if (enumaction == EnumAction.BOW) { - modelplayer.aimedBow = true; + mainPose = ArmPose.BOW_AND_ARROW; } } } + + ItemStack off = clientPlayer.getHeldItemMainhand(); + ArmPose offPose; + if (off == null) { + offPose = ArmPose.EMPTY; + } else { + offPose = ArmPose.ITEM; + + if (clientPlayer.getItemInUseCount() > 0) { + EnumAction enumaction = off.getItemUseAction(); + + if (enumaction == EnumAction.BLOCK) { + offPose = ArmPose.BLOCK; + } + } + } + + if (clientPlayer.getPrimaryHand() == EnumHandSide.RIGHT) { + modelplayer.rightArmPose = mainPose; + modelplayer.leftArmPose = offPose; + } else { + modelplayer.leftArmPose = mainPose; + modelplayer.rightArmPose = offPose; + } } } diff --git a/src/main/java/com/brohoof/minelittlepony/model/ModelHornGlow.java b/src/main/java/com/brohoof/minelittlepony/model/ModelHornGlow.java index d94d1772..44809c27 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/ModelHornGlow.java +++ b/src/main/java/com/brohoof/minelittlepony/model/ModelHornGlow.java @@ -5,7 +5,7 @@ import com.brohoof.minelittlepony.renderer.HornGlowRenderer; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; public class ModelHornGlow extends ModelBox { @@ -75,10 +75,10 @@ public class ModelHornGlow extends ModelBox { } @Override - public void render(WorldRenderer renderer, float par2) { + public void render(VertexBuffer buffer, float par2) { TexturedQuad[] var3 = this.quadList; for (TexturedQuad var6 : var3) { - var6.draw(renderer, par2); + var6.draw(buffer, par2); } } diff --git a/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java b/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java index eee32853..c6db009e 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java +++ b/src/main/java/com/brohoof/minelittlepony/model/part/PegasusWings.java @@ -6,7 +6,7 @@ import com.brohoof.minelittlepony.model.BodyPart; import com.brohoof.minelittlepony.model.PonyModelConstants; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class PegasusWings implements IPonyPart, PonyModelConstants { diff --git a/src/main/java/com/brohoof/minelittlepony/model/part/UnicornHorn.java b/src/main/java/com/brohoof/minelittlepony/model/part/UnicornHorn.java index ce5761a6..b5f00bf2 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/part/UnicornHorn.java +++ b/src/main/java/com/brohoof/minelittlepony/model/part/UnicornHorn.java @@ -9,6 +9,7 @@ import com.brohoof.minelittlepony.model.AbstractPonyModel; import com.brohoof.minelittlepony.model.PonyModelConstants; import com.brohoof.minelittlepony.renderer.HornGlowRenderer; +import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.client.model.ModelRenderer; public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants { @@ -41,7 +42,7 @@ public class UnicornHorn extends AbstractHeadPart implements PonyModelConstants super.render(data, scale); if (data.getRace() != null && data.getRace().hasHorn()) { this.horn.render(scale); - if (pony.heldItemRight != 0 && data.getGlowColor() != 0) { + if ((pony.leftArmPose != ArmPose.EMPTY || pony.rightArmPose != ArmPose.EMPTY) && data.getGlowColor() != 0) { GL11.glPushAttrib(24577); disableTexture2D(); disableLighting(); diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java index f9fb032c..64fdc460 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelPlayerPony.java @@ -1,7 +1,6 @@ package com.brohoof.minelittlepony.model.pony; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; +import static net.minecraft.client.renderer.GlStateManager.*; import com.brohoof.minelittlepony.model.AbstractPonyModel; import com.brohoof.minelittlepony.model.BodyPart; @@ -14,7 +13,7 @@ import com.brohoof.minelittlepony.renderer.PlaneRenderer; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConstants { @@ -141,9 +140,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst this.ponySleep(); } - if (this.aimedBow) { - this.aimBow(tick); - } + this.aimBow(leftArmPose, rightArmPose, tick); this.fixSpecialRotations(); this.fixSpecialRotationPoints(move); @@ -321,11 +318,16 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void holdItem() { - if (this.heldItemRight != 0 && !this.rainboom && (!this.metadata.getRace().hasHorn() || this.metadata.getGlowColor() == 0)) { - this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - 0.3141593F; - this.steveRightArm.rotateAngleX = this.steveRightArm.rotateAngleX * 0.5F - 0.3141593F; + if (!this.rainboom && (!this.metadata.getRace().hasHorn() || this.metadata.getGlowColor() != 0)) { + if (this.rightArmPose != ArmPose.EMPTY) { + this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - (float) Math.PI / 10F; + this.steveRightArm.rotateAngleX = this.steveRightArm.rotateAngleX * 0.5F - (float) Math.PI / 10F; + } + if (this.leftArmPose != ArmPose.EMPTY) { + this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.05F - (float) Math.PI / 10F; + this.steveLeftArm.rotateAngleX = this.steveLeftArm.rotateAngleX * 0.05F - (float) Math.PI / 10F; + } } - } protected void swingItem(float swingProgress) { @@ -336,7 +338,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst float f22 = MathHelper.sin(f16 * 3.1415927F); float f28 = MathHelper.sin(swingProgress * 3.1415927F); float f33 = f28 * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F; - if (this.metadata.getRace().hasHorn() && this.metadata.getGlowColor() != 0 && this.heldItemRight != 0) { + if (this.metadata.getRace().hasHorn() && this.metadata.getGlowColor() != 0 && this.rightArmPose != ArmPose.EMPTY) { this.unicornarm.rotateAngleX = (float) (this.unicornarm.rotateAngleX - (f22 * 1.2D + f33)); this.unicornarm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F; this.unicornarm.rotateAngleZ = f28 * -0.4F; @@ -353,7 +355,7 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst } protected void swingArms(float tick) { - if (this.heldItemRight != 0 && !this.isSleeping) { + if (this.rightArmPose != ArmPose.EMPTY && !this.isSleeping) { float cosTickFactor = MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; float sinTickFactor = MathHelper.sin(tick * 0.067F) * 0.05F; if (this.metadata.getRace().hasHorn() && this.metadata.getGlowColor() != 0) { @@ -445,29 +447,45 @@ public class ModelPlayerPony extends AbstractPonyModel implements PonyModelConst shiftRotationPoint(this.bipedLeftLeg, 0.0F, 2.0F, -8.0F); } - protected void aimBow(float tick) { - if (this.metadata.getRace().hasHorn() && this.metadata.getGlowColor() != 0) { - this.aimBowUnicorn(tick); - } else { - this.aimBowPony(tick); - } + protected void aimBow(ArmPose leftArm, ArmPose rightArm, float tick) { + if (leftArm == ArmPose.BOW_AND_ARROW || rightArm == ArmPose.BOW_AND_ARROW) { + if (this.metadata.getRace().hasHorn() && this.metadata.getGlowColor() != 0) { + this.aimBowUnicorn(tick); + } else { + this.aimBowPony(leftArm, rightArm, tick); + } + } } - protected void aimBowPony(float tick) { - this.bipedRightArm.rotateAngleZ = 0.0F; - this.bipedRightArm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - this.bipedRightArm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; - this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - shiftRotationPoint(this.bipedRightArm, 0.0F, 0.0F, 1.0F); + protected void aimBowPony(ArmPose leftArm, ArmPose rightArm, float tick) { + // TODO test left arm + if (rightArm == ArmPose.BOW_AND_ARROW) { + this.bipedRightArm.rotateAngleZ = 0.0F; + this.bipedRightArm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; + this.bipedRightArm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; + this.bipedRightArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + this.bipedRightArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; + shiftRotationPoint(this.bipedRightArm, 0.0F, 0.0F, 1.0F); + } else if (leftArm == ArmPose.BOW_AND_ARROW) { + this.bipedLeftArm.rotateAngleZ = 0.0F; + this.bipedLeftArm.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; + this.bipedLeftArm.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; + this.bipedLeftArm.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; + this.bipedLeftArm.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; + shiftRotationPoint(this.bipedLeftArm, 0.0F, 0.0F, 1.0F); + } - this.bipedRightArmwear.rotateAngleZ = 0.0F; - this.bipedRightArmwear.rotateAngleY = -0.06F + this.bipedHead.rotateAngleY; - this.bipedRightArmwear.rotateAngleX = ROTATE_270 + this.bipedHead.rotateAngleX; - this.bipedRightArmwear.rotateAngleZ += MathHelper.cos(tick * 0.09F) * 0.05F + 0.05F; - this.bipedRightArmwear.rotateAngleX += MathHelper.sin(tick * 0.067F) * 0.05F; - shiftRotationPoint(this.bipedRightArmwear, 0.0F, 0.0F, 1.0F); + // this.bipedRightArmwear.rotateAngleZ = 0.0F; + // this.bipedRightArmwear.rotateAngleY = -0.06F + + // this.bipedHead.rotateAngleY; + // this.bipedRightArmwear.rotateAngleX = ROTATE_270 + + // this.bipedHead.rotateAngleX; + // this.bipedRightArmwear.rotateAngleZ += MathHelper.cos(tick * 0.09F) * + // 0.05F + 0.05F; + // this.bipedRightArmwear.rotateAngleX += MathHelper.sin(tick * 0.067F) + // * 0.05F; + // shiftRotationPoint(this.bipedRightArmwear, 0.0F, 0.0F, 1.0F); } protected void aimBowUnicorn(float tick) { diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelSkeletonPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelSkeletonPony.java index b1128624..33e4a76a 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelSkeletonPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelSkeletonPony.java @@ -1,11 +1,8 @@ package com.brohoof.minelittlepony.model.pony; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.scale; -import static net.minecraft.client.renderer.GlStateManager.translate; +import static net.minecraft.client.renderer.GlStateManager.*; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelSkeletonPony extends ModelPlayerPony { @@ -15,6 +12,10 @@ public class ModelSkeletonPony extends ModelPlayerPony { @Override protected void rotateLegs(float move, float swing, float tick) { + if (true){ + super.rotateLegs(move, swing, tick); + return; + } float rightArmRotateAngleX; float leftArmRotateAngleX; float rightLegRotateAngleX; @@ -71,7 +72,7 @@ public class ModelSkeletonPony extends ModelPlayerPony { this.steveRightArm.rotateAngleZ = 0.0F; this.unicornarm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.heldItemRight != 0) { + if (this.rightArmPose != ArmPose.EMPTY) { var8 = MathHelper.sin(this.swingProgress * 3.1415927F); var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); if (this.metadata.getGlowColor() == 0) { @@ -98,7 +99,7 @@ public class ModelSkeletonPony extends ModelPlayerPony { @Override protected void fixSpecialRotationPoints(float move) { - if (this.heldItemRight != 0 && this.metadata.getGlowColor() == 0) { + if (this.rightArmPose != ArmPose.EMPTY && this.metadata.getGlowColor() == 0) { setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F); } @@ -107,13 +108,19 @@ public class ModelSkeletonPony extends ModelPlayerPony { @Override protected void renderLegs() { pushMatrix(); - translate(0.05F, -0.21F, -0.0F); - scale(0.5F, 1.15F, 0.5F); + if (this.leftArmPose != ArmPose.EMPTY && this.metadata.getRace().hasHorn()) { + translate(0.1F, 0.3F, -0.1F); + scale(0.5F, 0.5F, 1.2F); + } else { + translate(0.05F, -0.21F, -0.0F); + scale(0.5F, 1.15F, 0.5F); + } + this.bipedLeftArm.render(this.scale); popMatrix(); pushMatrix(); - if (this.heldItemRight != 0 && this.metadata.getGlowColor() == 0) { + if (this.rightArmPose != ArmPose.EMPTY && this.metadata.getRace().hasHorn()) { translate(-0.1F, 0.3F, 0.1F); scale(0.5F, 0.5F, 1.2F); } else { diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java index cdee9e76..c0e9b890 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelVillagerPony.java @@ -2,7 +2,7 @@ package com.brohoof.minelittlepony.model.pony; import com.brohoof.minelittlepony.renderer.PlaneRenderer; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelVillagerPony extends ModelPlayerPony { diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelZombiePony.java b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelZombiePony.java index 104a08e6..4ce2ac4a 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/ModelZombiePony.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/ModelZombiePony.java @@ -1,8 +1,6 @@ package com.brohoof.minelittlepony.model.pony; -import com.brohoof.minelittlepony.model.pony.ModelPlayerPony; - -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelZombiePony extends ModelPlayerPony { @@ -69,7 +67,7 @@ public class ModelZombiePony extends ModelPlayerPony { this.steveRightArm.rotateAngleZ = 0.0F; this.unicornarm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.heldItemRight == 0) { + if (this.rightArmPose == ArmPose.EMPTY) { var8 = MathHelper.sin(this.swingProgress * (float) Math.PI); var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * (float) Math.PI); if (MathHelper.sin(move / 20.0F) < 0.0F) { @@ -93,7 +91,7 @@ public class ModelZombiePony extends ModelPlayerPony { @Override protected void fixSpecialRotationPoints(float move) { - if (this.heldItemRight == 0) { + if (this.rightArmPose == ArmPose.EMPTY) { if (MathHelper.sin(move / 20.0F) < 0.0F) { shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F); } else { diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java index ec9fa9c8..34a7b4e7 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelPonyArmor.java @@ -4,7 +4,7 @@ import com.brohoof.minelittlepony.model.pony.ModelPlayerPony; import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.model.ModelRenderer; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelPonyArmor extends ModelPlayerPony { @@ -80,9 +80,7 @@ public class ModelPonyArmor extends ModelPlayerPony { this.ponySleep(); } - if (this.aimedBow) { - this.aimBow(tick); - } + this.aimBow(leftArmPose, rightArmPose, tick); // this.fixSpecialRotationPoints(aniparams.move); } diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java index 35c943a1..d0f6c2ec 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelSkeletonPonyArmor.java @@ -1,8 +1,6 @@ package com.brohoof.minelittlepony.model.pony.armor; -import com.brohoof.minelittlepony.model.pony.armor.ModelPonyArmor; - -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelSkeletonPonyArmor extends ModelPonyArmor { @@ -60,7 +58,7 @@ public class ModelSkeletonPonyArmor extends ModelPonyArmor { this.steveRightArm.rotateAngleZ = 0.0F; this.unicornarm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.heldItemRight != 0) { + if (this.rightArmPose != ArmPose.EMPTY) { var8 = MathHelper.sin(this.swingProgress * 3.1415927F); var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); if (this.metadata.getGlowColor() == 0) { @@ -85,7 +83,7 @@ public class ModelSkeletonPonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { - if (this.heldItemRight != 0 && this.metadata.getGlowColor() == 0) { + if (this.rightArmPose != ArmPose.EMPTY && this.metadata.getGlowColor() == 0) { setRotationPoint(this.bipedRightArm, -1.5F, 9.5F, 4.0F); } diff --git a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java index 8c1b1bf9..6c878351 100644 --- a/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/model/pony/armor/ModelZombiePonyArmor.java @@ -1,8 +1,6 @@ package com.brohoof.minelittlepony.model.pony.armor; -import com.brohoof.minelittlepony.model.pony.armor.ModelPonyArmor; - -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class ModelZombiePonyArmor extends ModelPonyArmor { @@ -60,7 +58,7 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { this.steveRightArm.rotateAngleZ = 0.0F; this.unicornarm.rotateAngleZ = 0.0F; this.bipedLeftArm.rotateAngleZ = 0.0F; - if (this.heldItemRight == 0) { + if (this.rightArmPose == ArmPose.EMPTY) { var8 = MathHelper.sin(this.swingProgress * 3.1415927F); var9 = MathHelper.sin((1.0F - (1.0F - this.swingProgress) * (1.0F - this.swingProgress)) * 3.1415927F); if (MathHelper.sin(move / 20.0F) < 0.0F) { @@ -85,7 +83,7 @@ public class ModelZombiePonyArmor extends ModelPonyArmor { @Override protected void fixSpecialRotationPoints(float move) { - if (this.heldItemRight == 0) { + if (this.rightArmPose == ArmPose.EMPTY) { if (MathHelper.sin(move / 20.0F) < 0.0F) { shiftRotationPoint(this.bipedRightArm, 0.5F, 1.5F, 3.0F); } else { diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/PlaneRenderer.java b/src/main/java/com/brohoof/minelittlepony/renderer/PlaneRenderer.java index 01576da6..e0405680 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/PlaneRenderer.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/PlaneRenderer.java @@ -1,10 +1,6 @@ package com.brohoof.minelittlepony.renderer; -import static net.minecraft.client.renderer.GlStateManager.callList; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.rotate; -import static net.minecraft.client.renderer.GlStateManager.translate; +import static net.minecraft.client.renderer.GlStateManager.*; import org.lwjgl.opengl.GL11; @@ -14,7 +10,7 @@ import net.minecraft.client.model.PositionTextureVertex; import net.minecraft.client.model.TexturedQuad; import net.minecraft.client.renderer.GLAllocation; import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; +import net.minecraft.client.renderer.VertexBuffer; public class PlaneRenderer extends ModelRenderer { public float textureWidth; @@ -390,7 +386,7 @@ public class PlaneRenderer extends ModelRenderer { private void compileDisplayList(float f) { this.displayList = GLAllocation.generateDisplayLists(1); GL11.glNewList(this.displayList, 4864); - WorldRenderer wr = Tessellator.getInstance().getWorldRenderer(); + VertexBuffer wr = Tessellator.getInstance().getBuffer(); for (TexturedQuad face : this.faces) { face.draw(wr, f); diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java index 4dd77f12..1338ce28 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/RenderPonyMob.java @@ -11,6 +11,7 @@ import com.brohoof.minelittlepony.renderer.layer.LayerHeldPonyItem; import com.brohoof.minelittlepony.renderer.layer.LayerPonyArmor; import com.brohoof.minelittlepony.renderer.layer.LayerPonySkull; +import net.minecraft.client.model.ModelBiped.ArmPose; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLiving; @@ -40,16 +41,13 @@ public abstract class RenderPonyMob extends RenderLiving yOrigin -= 0.125D; } super.doRender(entity, xPosition, yOrigin, zPosition, yaw, partialTicks); - this.playerModel.getModel().aimedBow = false; - this.playerModel.getModel().isSneak = false; - this.playerModel.getModel().heldItemRight = 0; } @Override protected void preRenderCallback(T entitylivingbaseIn, float partialTickTime) { - ItemStack heldItem = entitylivingbaseIn.getHeldItem(); - this.playerModel.getModel().heldItemRight = heldItem == null ? 0 : 1; + ItemStack heldItem = entitylivingbaseIn.getHeldItemMainhand(); + this.playerModel.getModel().rightArmPose = heldItem == null ? ArmPose.EMPTY : ArmPose.ITEM; this.playerModel.getModel().isSneak = false; this.playerModel.getModel().isFlying = false; diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java index 8390e42a..ce006cd7 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerHeldPonyItem.java @@ -5,37 +5,30 @@ import static net.minecraft.client.renderer.GlStateManager.*; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL14; -import com.brohoof.minelittlepony.PonySize; +import com.brohoof.minelittlepony.PonyData; import com.brohoof.minelittlepony.ducks.IRenderPony; -import com.brohoof.minelittlepony.model.BodyPart; import com.brohoof.minelittlepony.model.PlayerModel; import com.brohoof.minelittlepony.model.pony.ModelHumanPlayer; -import com.brohoof.minelittlepony.model.pony.ModelPlayerPony; import net.minecraft.client.Minecraft; -import net.minecraft.client.model.ModelRenderer; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.renderer.RenderItem; +import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; -import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerHeldItem; import net.minecraft.client.renderer.entity.layers.LayerRenderer; -import net.minecraft.client.resources.model.IBakedModel; -import net.minecraft.client.resources.model.ModelResourceLocation; -import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumHandSide; public class LayerHeldPonyItem implements LayerRenderer { - private final RendererLivingEntity livingPonyEntity; + private final RenderLivingBase livingPonyEntity; private LayerHeldItem held; - public LayerHeldPonyItem(RendererLivingEntity livingPony) { + public LayerHeldPonyItem(RenderLivingBase livingPony) { this.livingPonyEntity = livingPony; this.held = new LayerHeldItem(livingPony); } @@ -49,57 +42,51 @@ public class LayerHeldPonyItem implements LayerRenderer { p_177141_7_, scale); return; } - if (!pony.getModel().isSleeping) { - if (pony.getModel().metadata.getRace().hasHorn() && pony.getModel().metadata.getGlowColor() != 0) { - ModelPlayerPony model = (ModelPlayerPony) pony.getModel(); - if (pony.getModel().aimedBow) { - renderDrop(pony, entity, model.unicornarm, 1.0F, 0.15F, 0.9375F, 0.0625F); - } else if (pony.getModel().metadata.getSize() == PonySize.FOAL) { - renderDrop(pony, entity, model.unicornarm, 1.0F, 0.35F, 0.5375F, -0.8F); - } else { - renderDrop(pony, entity, model.unicornarm, 1.0F, 0.35F, 0.5375F, -0.45F); - } - } else if (pony.getModel().metadata.getSize() == PonySize.FOAL) { - renderDrop(pony, entity, pony.getModel().bipedRightArm, 1.0F, 0.08F, 0.8375F, 0.0625F); - } else { - renderDrop(pony, entity, pony.getModel().bipedRightArm, 1.0F, -0.0625F, 0.8375F, 0.0625F); - } - } - } + boolean mainRight = entity.getPrimaryHand() == EnumHandSide.RIGHT; + ItemStack itemMain = entity.getHeldItemMainhand(); + ItemStack itemOff = entity.getHeldItemOffhand(); + ItemStack left = mainRight ? itemOff : itemMain; + ItemStack right = mainRight ? itemMain : itemOff; - protected void renderDrop(PlayerModel pony, EntityLivingBase entity, ModelRenderer box, float scalefactor, - float posx, float posy, float posz) { - ItemStack drop = entity.getHeldItem(); - if (drop != null) { + if (left != null || right != null) { pushMatrix(); - pony.getModel().transform(BodyPart.LEGS); - box.postRender(scalefactor * 0.0625F); - - translate(posx, posy, posz); - if (entity instanceof EntityPlayer && ((EntityPlayer) entity).fishEntity != null) { - drop = new ItemStack(Items.stick); + if (this.livingPonyEntity.getMainModel().isChild) { + translate(0, 0.625, 0); + rotate(-20, -1, 0, 0); + scale(.5, .5, .5); } - Item item = drop.getItem(); - if (item instanceof ItemBlock && ((ItemBlock) item).getBlock().getRenderType() == 2) { - translate(0.0F, 0.1875F, -0.3125F); - rotate(20.0F, 1.0F, 0.0F, 0.0F); - rotate(45.0F, 0.0F, 1.0F, 0.0F); - float f8 = 0.375F; - scale(-f8, -f8, f8); - } - - Minecraft.getMinecraft().getItemRenderer().renderItem(entity, drop, TransformType.THIRD_PERSON); - - if (pony.getModel().metadata.getRace().hasHorn() && pony.getModel().metadata.getGlowColor() != 0) { - this.renderItemGlow(entity, drop, pony.getModel().metadata.getGlowColor()); - } + renderHeldItem(entity, right, ItemCameraTransforms.TransformType.THIRD_PERSON_RIGHT_HAND, EnumHandSide.RIGHT); + renderHeldItem(entity, left, ItemCameraTransforms.TransformType.THIRD_PERSON_LEFT_HAND, EnumHandSide.LEFT); popMatrix(); } } - public void renderItemGlow(EntityLivingBase entity, ItemStack drop, int glowColor) { + private void renderHeldItem(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand) { + if (drop != null) { + GlStateManager.pushMatrix(); + ((ModelBiped) this.livingPonyEntity.getMainModel()).postRenderArm(0.0625F, hand); + + if (entity.isSneaking()) { + GlStateManager.translate(0.0F, 0.2F, 0.0F); + } + + GlStateManager.rotate(-90.0F, 1.0F, 0.0F, 0.0F); + GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); + boolean isLeft = hand == EnumHandSide.LEFT; + GlStateManager.translate(isLeft ? -0.0625F : 0.0625F, 0.125F, -0.625F); + Minecraft.getMinecraft().getItemRenderer().renderItemSide(entity, drop, transform, isLeft); + GlStateManager.popMatrix(); + + PonyData metadata = ((IRenderPony) this.livingPonyEntity).getPony().getModel().metadata; + if (metadata.getRace().hasHorn() && metadata.getGlowColor() != 0) { + this.renderItemGlow(entity, drop, transform, hand, metadata.getGlowColor()); + } + } + } + + public void renderItemGlow(EntityLivingBase entity, ItemStack drop, ItemCameraTransforms.TransformType transform, EnumHandSide hand, int glowColor) { GL11.glPushAttrib(GL11.GL_CURRENT_BIT | GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT); float red = (glowColor >> 16 & 255) / 255.0F; @@ -110,11 +97,11 @@ public class LayerHeldPonyItem implements LayerRenderer { enableBlend(); blendFunc(GL11.GL_CONSTANT_COLOR, 1); GL14.glBlendColor(red, green, blue, alpha); - IBakedModel model = getItemModel(Minecraft.getMinecraft().getRenderItem(), entity, drop); + IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(drop, null, null); scale(2, 2, 2); - applyTransform(model.getItemCameraTransforms(), TransformType.THIRD_PERSON); + model.getItemCameraTransforms().applyTransform(transform); RenderItem renderItem = Minecraft.getMinecraft().getRenderItem(); scale(1.1, 1.1, 1.1); @@ -135,38 +122,4 @@ public class LayerHeldPonyItem implements LayerRenderer { public boolean shouldCombineTextures() { return false; } - - // Copied from RenderItem.renderItemModelForEntity - private IBakedModel getItemModel(RenderItem renderer, Entity entityToRenderFor, ItemStack stack) { - IBakedModel ibakedmodel = renderer.getItemModelMesher().getItemModel(stack); - - if (entityToRenderFor instanceof EntityPlayer) { - EntityPlayer entityplayer = (EntityPlayer) entityToRenderFor; - Item item = stack.getItem(); - ModelResourceLocation modelresourcelocation = null; - - if (item == Items.fishing_rod && entityplayer.fishEntity != null) { - modelresourcelocation = new ModelResourceLocation("fishing_rod_cast", "inventory"); - } else if (item == Items.bow && entityplayer.getItemInUse() != null) { - int i = stack.getMaxItemUseDuration() - entityplayer.getItemInUseCount(); - - if (i >= 18) { - modelresourcelocation = new ModelResourceLocation("bow_pulling_2", "inventory"); - } else if (i > 13) { - modelresourcelocation = new ModelResourceLocation("bow_pulling_1", "inventory"); - } else if (i > 0) { - modelresourcelocation = new ModelResourceLocation("bow_pulling_0", "inventory"); - } - } - - if (modelresourcelocation != null) { - ibakedmodel = renderer.getItemModelMesher().getModelManager().getModel(modelresourcelocation); - } - } - return ibakedmodel; - } - - private void applyTransform(ItemCameraTransforms camera, TransformType type) { - camera.applyTransform(type); - } } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java index 3553babb..b842179b 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyArmor.java @@ -16,10 +16,11 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerBipedArmor; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor.ArmorMaterial; import net.minecraft.item.ItemStack; @@ -32,57 +33,58 @@ public class LayerPonyArmor implements LayerRenderer { private static final Map HUMAN_ARMORS = Maps.newHashMap(); private static final Map PONY_ARMORS = Maps.newHashMap(); - private RendererLivingEntity renderer; + private RenderLivingBase renderer; private LayerBipedArmor humanArmor; private PlayerModel pony; - public LayerPonyArmor(RendererLivingEntity entity) { + public LayerPonyArmor(RenderLivingBase entity) { this.renderer = entity; this.humanArmor = new LayerBipedArmor(entity); } @Override - public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, float ticks, float p_177141_5_, float p_177141_6_, - float p_177141_7_, float scale) { + public void doRenderLayer(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float ticks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { pony = ((IRenderPony) renderer).getPony(); if (pony.getModel() instanceof ModelHumanPlayer) { - humanArmor.doRenderLayer(entity, p_177141_2_, p_177141_3_, ticks, p_177141_5_, p_177141_6_, p_177141_7_, scale); + humanArmor.doRenderLayer(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale); } else { - for (int i = 4; i > 0; i--) { - renderArmor(entity, p_177141_2_, p_177141_3_, ticks, p_177141_5_, p_177141_6_, p_177141_7_, scale, i); - } + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.FEET); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.LEGS); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.CHEST); + renderArmor(entity, limbSwing, limbSwingAmount, ticks, ageInTicks, netHeadYaw, headPitch, scale, EntityEquipmentSlot.HEAD); + } } - private void renderArmor(EntityLivingBase entitylivingbaseIn, float p_177141_2_, float p_177141_3_, float partialTicks, float p_177141_5_, - float p_177141_6_, float p_177141_7_, float scale, int armorSlot) { - ItemStack itemstack = entitylivingbaseIn.getCurrentArmor(armorSlot - 1); + private void renderArmor(EntityLivingBase entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale, + EntityEquipmentSlot armorSlot) { + ItemStack itemstack = entity.getItemStackFromSlot(armorSlot); if (itemstack != null && itemstack.getItem() instanceof ItemArmor) { ItemArmor itemarmor = (ItemArmor) itemstack.getItem(); - boolean isLegs = armorSlot == 2; + boolean isLegs = armorSlot == EntityEquipmentSlot.CHEST; AbstractPonyModel modelbase = isLegs ? pony.getArmor().modelArmor : pony.getArmor().modelArmorChestplate; - modelbase = getArmorModel(entitylivingbaseIn, itemstack, armorSlot, modelbase); + modelbase = getArmorModel(entity, itemstack, isLegs ? 2 : 1, modelbase); modelbase.setModelAttributes(this.pony.getModel()); - modelbase.setLivingAnimations(entitylivingbaseIn, p_177141_2_, p_177141_3_, partialTicks); + modelbase.setLivingAnimations(entity, limbSwing, limbSwingAmount, partialTicks); prepareToRender((ModelPonyArmor) modelbase, armorSlot); - this.renderer.bindTexture(getArmorTexture(entitylivingbaseIn, itemstack, isLegs ? 2 : 1, null)); + this.renderer.bindTexture(getArmorTexture(entity, itemstack, isLegs ? 2 : 1, null)); if (itemarmor.getArmorMaterial() == ArmorMaterial.LEATHER) { int j = itemarmor.getColor(itemstack); float f7 = (j >> 16 & 255) / 255.0F; float f8 = (j >> 8 & 255) / 255.0F; float f9 = (j & 255) / 255.0F; GlStateManager.color(f7, f8, f9, 1); - modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale); - this.renderer.bindTexture(getArmorTexture(entitylivingbaseIn, itemstack, isLegs ? 2 : 1, "overlay")); + modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); + this.renderer.bindTexture(getArmorTexture(entity, itemstack, isLegs ? 2 : 1, "overlay")); } GlStateManager.color(1, 1, 1, 1); - modelbase.render(entitylivingbaseIn, p_177141_2_, p_177141_3_, p_177141_5_, p_177141_6_, p_177141_7_, scale); + modelbase.render(entity, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale); if (itemstack.isItemEnchanted()) { - this.renderEnchantment(entitylivingbaseIn, modelbase, p_177141_2_, p_177141_3_, partialTicks, p_177141_5_, p_177141_6_, p_177141_7_, scale); + this.renderEnchantment(entity, modelbase, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); } } } @@ -110,19 +112,20 @@ public class LayerPonyArmor implements LayerRenderer { } } - private void prepareToRender(ModelPonyArmor model, int slot) { + @SuppressWarnings("incomplete-switch") + private void prepareToRender(ModelPonyArmor model, EntityEquipmentSlot slot) { model.setInvisible(false); switch (slot) { // feet - case 1: + case FEET: model.bipedRightArm.showModel = true; model.bipedLeftArm.showModel = true; model.bipedRightLeg.showModel = true; model.bipedLeftLeg.showModel = true; break; // legs - case 2: + case LEGS: model.bipedRightLeg.showModel = true; model.bipedLeftLeg.showModel = true; model.bipedRightArm.showModel = true; @@ -130,11 +133,11 @@ public class LayerPonyArmor implements LayerRenderer { model.extBody.showModel = true; break; // chest - case 3: + case CHEST: model.extBody.showModel = true; break; // head - case 4: + case HEAD: model.bipedHead.showModel = true; for (ModelRenderer m : model.extHead) { m.showModel = true; diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyCape.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyCape.java index 21fc01ef..f582bbc7 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyCape.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonyCape.java @@ -1,9 +1,6 @@ package com.brohoof.minelittlepony.renderer.layer; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.rotate; -import static net.minecraft.client.renderer.GlStateManager.translate; +import static net.minecraft.client.renderer.GlStateManager.*; import com.brohoof.minelittlepony.ducks.IRenderPony; import com.brohoof.minelittlepony.model.BodyPart; @@ -11,19 +8,19 @@ import com.brohoof.minelittlepony.model.PlayerModel; import com.brohoof.minelittlepony.model.pony.ModelHumanPlayer; import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.client.renderer.entity.layers.LayerCape; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.entity.player.EnumPlayerModelParts; -import net.minecraft.util.MathHelper; +import net.minecraft.util.math.MathHelper; public class LayerPonyCape implements LayerRenderer { - private RendererLivingEntity renderer; + private RenderLivingBase renderer; private LayerCape cape; - public LayerPonyCape(RendererLivingEntity entity) { + public LayerPonyCape(RenderLivingBase entity) { renderer = entity; this.cape = new LayerCape((RenderPlayer) entity); } diff --git a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java index 699d494f..adfdef8c 100644 --- a/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java +++ b/src/main/java/com/brohoof/minelittlepony/renderer/layer/LayerPonySkull.java @@ -1,11 +1,6 @@ package com.brohoof.minelittlepony.renderer.layer; -import static net.minecraft.client.renderer.GlStateManager.color; -import static net.minecraft.client.renderer.GlStateManager.popMatrix; -import static net.minecraft.client.renderer.GlStateManager.pushMatrix; -import static net.minecraft.client.renderer.GlStateManager.rotate; -import static net.minecraft.client.renderer.GlStateManager.scale; -import static net.minecraft.client.renderer.GlStateManager.translate; +import static net.minecraft.client.renderer.GlStateManager.*; import com.brohoof.minelittlepony.ducks.IRenderPony; import com.brohoof.minelittlepony.model.AbstractPonyModel; @@ -16,13 +11,14 @@ import com.mojang.authlib.GameProfile; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType; -import net.minecraft.client.renderer.entity.RendererLivingEntity; +import net.minecraft.client.renderer.entity.RenderLivingBase; import net.minecraft.client.renderer.entity.layers.LayerRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySkullRenderer; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.init.Items; +import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; @@ -33,16 +29,16 @@ import net.minecraft.util.EnumFacing; public class LayerPonySkull implements LayerRenderer { - private RendererLivingEntity renderer; + private RenderLivingBase renderer; - public LayerPonySkull(RendererLivingEntity renderPony) { + public LayerPonySkull(RenderLivingBase renderPony) { this.renderer = renderPony; } @Override - public void doRenderLayer(EntityLivingBase entity, float p_177141_2_, float p_177141_3_, + public void doRenderLayer(EntityLivingBase entity, float limbSwing, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { - ItemStack itemstack = entity.getCurrentArmor(3); + ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (itemstack != null && itemstack.getItem() != null) { AbstractPonyModel model = getModel().getModel(); Item item = itemstack.getItem(); @@ -59,11 +55,11 @@ public class LayerPonySkull implements LayerRenderer { color(1, 1, 1, 1); if (item instanceof ItemBlock) { renderBlock(entity, itemstack); - } else if (item == Items.skull) { + } else if (item == Items.SKULL) { if (model instanceof ModelPlayerPony) { translate(0, 0, -.15); } - renderSkull(itemstack, isVillager); + renderSkull(itemstack, isVillager, limbSwing); } popMatrix(); } @@ -79,7 +75,7 @@ public class LayerPonySkull implements LayerRenderer { Minecraft.getMinecraft().getItemRenderer().renderItem(entity, itemstack, TransformType.HEAD); } - private void renderSkull(ItemStack itemstack, boolean isVillager) { + private void renderSkull(ItemStack itemstack, boolean isVillager, float limbSwing) { float f = 1.1875f; scale(f, -f, -f); if (isVillager) { @@ -99,8 +95,7 @@ public class LayerPonySkull implements LayerRenderer { } } - TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F, - itemstack.getMetadata(), profile, -1); + TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.45F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), profile, -1, limbSwing); } diff --git a/src/main/java/com/brohoof/minelittlepony/util/MineLPLogger.java b/src/main/java/com/brohoof/minelittlepony/util/MineLPLogger.java index eb72caaf..18bde8ca 100644 --- a/src/main/java/com/brohoof/minelittlepony/util/MineLPLogger.java +++ b/src/main/java/com/brohoof/minelittlepony/util/MineLPLogger.java @@ -1,10 +1,11 @@ package com.brohoof.minelittlepony.util; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import com.mumfrey.liteloader.util.log.LiteLoaderLogger; + public class MineLPLogger { private static Logger logger = LogManager.getLogger("MineLittlePony");