It compiles

This commit is contained in:
Matthew Messinger 2016-05-03 21:23:57 -04:00
parent a29869d6f4
commit 2d89d407f5
26 changed files with 332 additions and 362 deletions

View file

@ -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;

View file

@ -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();

View file

@ -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;

View file

@ -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) {

View file

@ -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<Boolean> 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<ResourceLocation> ci) {
Optional<ResourceLocation> 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<ResourceLocation> ci) {
Optional<ResourceLocation> 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<String> ci) {
MinecraftProfileTexture data = HDSkinManager.INSTANCE.getProfileData(gameProfile).get(Type.SKIN);
if (data != null) {

View file

@ -18,12 +18,14 @@ import net.minecraft.util.ResourceLocation;
@Mixin(TileEntitySkullRenderer.class)
public abstract class MixinSkullRenderer extends TileEntitySpecialRenderer<TileEntitySkull> {
@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<ResourceLocation> skin = HDSkinManager.INSTANCE.getSkinLocation(profile, Type.SKIN, true);
if (skin.isPresent())

View file

@ -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;

View file

@ -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<AbstractClientPlayer> implements IRenderPony {
public abstract class MixinRenderPlayer extends RenderLivingBase<AbstractClientPlayer> implements IRenderPony {
@Shadow
private boolean smallArms;
@ -44,7 +45,7 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity<AbstractCli
@Inject(
method = "<init>(" + "Lnet/minecraft/client/renderer/entity/RenderManager;" + "Z)V",
at = @At("RETURN") )
at = @At("RETURN"))
private void init(RenderManager renderManager, boolean useSmallArms, CallbackInfo ci) {
this.playerModel = smallArms ? PMAPI.ponySmall : PMAPI.pony;
this.mainModel = this.playerModel.getModel();
@ -58,29 +59,14 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity<AbstractCli
this.addLayer(new LayerPonyCape(this));
}
/**
* @reason render a pony instead of a human
* @author JoyJoy
*/
@Override
public void doRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks) {
@Inject(
method = "doRender(Lnet/minecraft/client/entity/AbstractClientPlayer;DDDFF)V",
at = @At("HEAD"))
private void onDoRender(AbstractClientPlayer player, double x, double y, double z, float yaw, float partialTicks, CallbackInfo ci) {
updateModel(player);
ItemStack currentItemStack = player.inventory.getCurrentItem();
this.playerModel.getModel().heldItemRight = currentItemStack == null ? 0 : 1;
if (currentItemStack != null && player.getItemInUseCount() > 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<AbstractCli
this.shadowSize = 0.5F;
}
double yOrigin1 = y;
if (player.isSneaking() && !(player instanceof EntityPlayerSP)) {
yOrigin1 -= 0.125D;
}
this.playerModel.getModel().isSleeping = player.isPlayerSleeping();
this.playerModel.getModel().swingProgress = getSwingProgress(player, partialTicks);
super.doRender(player, x, yOrigin1, z, yaw, partialTicks);
this.playerModel.getModel().aimedBow = false;
this.playerModel.getModel().isSneak = false;
this.playerModel.getModel().heldItemRight = 0;
}
@Inject(method = "renderLivingAt", at = @At("RETURN") )
@Inject(
method = "renderLivingAt",
at = @At("RETURN"))
private void setupPlayerScale(AbstractClientPlayer player, double xPosition, double yPosition, double zPosition, CallbackInfo ci) {
if (MineLittlePony.getConfig().showscale && !(playerModel.getModel() instanceof ModelHumanPlayer)) {
@ -127,18 +102,66 @@ public abstract class MixinRenderPlayer extends RendererLivingEntity<AbstractCli
}
}
@Inject(method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", at = @At("HEAD") )
@Inject(
method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At("HEAD"))
private void onRenderRightArm(AbstractClientPlayer player, CallbackInfo ci) {
updateModel(player);
bindEntityTexture(player);
}
@Inject(method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V", at = @At("HEAD") )
@Inject(
method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At("HEAD"))
private void onRenderLeftArm(AbstractClientPlayer player, CallbackInfo ci) {
updateModel(player);
bindEntityTexture(player);
}
@Redirect(
method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/model/ModelPlayer;bipedLeftArm:Lnet/minecraft/client/model/ModelRenderer;",
opcode = Opcodes.GETFIELD),
require = 2)
private ModelRenderer redirectLeftArm(ModelPlayer mr) {
return this.playerModel.getModel().steveLeftArm;
}
@Redirect(
method = "renderLeftArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/model/ModelPlayer;bipedLeftArmwear:Lnet/minecraft/client/model/ModelRenderer;",
opcode = Opcodes.GETFIELD),
require = 2)
private ModelRenderer redirectLeftArmwear(ModelPlayer mr) {
return this.playerModel.getModel().steveLeftArmwear;
}
@Redirect(
method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/model/ModelPlayer;bipedRightArm:Lnet/minecraft/client/model/ModelRenderer;",
opcode = Opcodes.GETFIELD),
require = 2)
private ModelRenderer redirectRightArm(ModelPlayer mr) {
return this.playerModel.getModel().steveRightArm;
}
@Redirect(
method = "renderRightArm(Lnet/minecraft/client/entity/AbstractClientPlayer;)V",
at = @At(
value = "FIELD",
target = "Lnet/minecraft/client/model/ModelPlayer;bipedRightArmwear:Lnet/minecraft/client/model/ModelRenderer;",
opcode = Opcodes.GETFIELD),
require = 2)
private ModelRenderer redirectRightArmwear(ModelPlayer mr) {
return this.playerModel.getModel().steveRightArmwear;
}
private void updateModel(AbstractClientPlayer player) {
this.thePony = MineLittlePony.getInstance().getManager().getPonyFromResourceRegistry(player);
thePony.checkSkin();

View file

@ -1,8 +1,6 @@
package com.brohoof.minelittlepony.model;
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 java.util.List;
import java.util.Random;
@ -24,7 +22,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EnumPlayerModelParts;
import net.minecraft.item.EnumAction;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.util.EnumHandSide;
import net.minecraft.util.math.MathHelper;
public abstract class AbstractPonyModel extends ModelPlayer {
@ -87,18 +86,6 @@ public abstract class AbstractPonyModel extends ModelPlayer {
}
}
@Override
public void renderRightArm() {
this.steveRightArm.render(0.0625F);
this.steveRightArmwear.render(0.0625F);
}
@Override
public void renderLeftArm() {
this.steveLeftArm.render(0.0625f);
this.steveLeftArmwear.render(0.0625f);
}
@Override
public void setRotationAngles(float Move, float Moveswing, float Loop, float Right, float Down, float Scale, Entity entityIn) {
if (doCancelRender()) {
@ -128,7 +115,6 @@ public abstract class AbstractPonyModel extends ModelPlayer {
modelplayer.bipedHead.showModel = true;
modelplayer.bipedHeadwear.showModel = true;
} else {
ItemStack itemstack = clientPlayer.inventory.getCurrentItem();
modelplayer.setInvisible(true);
modelplayer.bipedHeadwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.HAT);
modelplayer.bipedBodyWear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.JACKET);
@ -136,25 +122,49 @@ public abstract class AbstractPonyModel extends ModelPlayer {
modelplayer.bipedRightLegwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_PANTS_LEG);
modelplayer.bipedLeftArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.LEFT_SLEEVE);
modelplayer.bipedRightArmwear.showModel = clientPlayer.isWearing(EnumPlayerModelParts.RIGHT_SLEEVE);
modelplayer.heldItemLeft = 0;
modelplayer.aimedBow = false;
modelplayer.isSneak = clientPlayer.isSneaking();
if (itemstack == null) {
modelplayer.heldItemRight = 0;
ItemStack main = clientPlayer.getHeldItemMainhand();
ArmPose mainPose;
if (main == null) {
mainPose = ArmPose.EMPTY;
} else {
modelplayer.heldItemRight = 1;
mainPose = ArmPose.ITEM;
if (clientPlayer.getItemInUseCount() > 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;
}
}
}

View file

@ -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);
}
}

View file

@ -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 {

View file

@ -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();

View file

@ -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) {

View file

@ -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 {

View file

@ -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 {

View file

@ -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 {

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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 {

View file

@ -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);

View file

@ -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<T extends EntityLiving> 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;

View file

@ -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<EntityLivingBase> {
private final RendererLivingEntity<? extends EntityLivingBase> livingPonyEntity;
private final RenderLivingBase<? extends EntityLivingBase> livingPonyEntity;
private LayerHeldItem held;
public LayerHeldPonyItem(RendererLivingEntity<? extends EntityLivingBase> livingPony) {
public LayerHeldPonyItem(RenderLivingBase<? extends EntityLivingBase> livingPony) {
this.livingPonyEntity = livingPony;
this.held = new LayerHeldItem(livingPony);
}
@ -49,57 +42,51 @@ public class LayerHeldPonyItem implements LayerRenderer<EntityLivingBase> {
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<EntityLivingBase> {
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<EntityLivingBase> {
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);
}
}

View file

@ -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<EntityLivingBase> {
private static final Map<String, ResourceLocation> HUMAN_ARMORS = Maps.newHashMap();
private static final Map<ResourceLocation, ResourceLocation> PONY_ARMORS = Maps.newHashMap();
private RendererLivingEntity<? extends EntityLivingBase> renderer;
private RenderLivingBase<? extends EntityLivingBase> renderer;
private LayerBipedArmor humanArmor;
private PlayerModel pony;
public LayerPonyArmor(RendererLivingEntity<? extends EntityLivingBase> entity) {
public LayerPonyArmor(RenderLivingBase<? extends EntityLivingBase> 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<EntityLivingBase> {
}
}
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<EntityLivingBase> {
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;

View file

@ -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<AbstractClientPlayer> {
private RendererLivingEntity<? extends AbstractClientPlayer> renderer;
private RenderLivingBase<? extends AbstractClientPlayer> renderer;
private LayerCape cape;
public LayerPonyCape(RendererLivingEntity<? extends AbstractClientPlayer> entity) {
public LayerPonyCape(RenderLivingBase<? extends AbstractClientPlayer> entity) {
renderer = entity;
this.cape = new LayerCape((RenderPlayer) entity);
}

View file

@ -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<EntityLivingBase> {
private RendererLivingEntity<? extends EntityLivingBase> renderer;
private RenderLivingBase<? extends EntityLivingBase> renderer;
public LayerPonySkull(RendererLivingEntity<? extends EntityLivingBase> renderPony) {
public LayerPonySkull(RenderLivingBase<? extends EntityLivingBase> 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<EntityLivingBase> {
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<EntityLivingBase> {
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<EntityLivingBase> {
}
}
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);
}

View file

@ -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");