More work on item glow

This commit is contained in:
Matthew Messinger 2015-12-12 04:24:38 -05:00
parent c8bdab408c
commit 22d2c18e79
2 changed files with 43 additions and 69 deletions

View file

@ -1,13 +1,6 @@
package com.brohoof.minelittlepony.model.pony; package com.brohoof.minelittlepony.model.pony;
import static net.minecraft.client.renderer.GlStateManager.blendFunc; import static net.minecraft.client.renderer.GlStateManager.*;
import static net.minecraft.client.renderer.GlStateManager.color;
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 java.util.Random; import java.util.Random;
@ -900,9 +893,9 @@ public class pm_newPonyAdv extends ModelPony {
this.headpiece[2].render(this.scale); this.headpiece[2].render(this.scale);
if (this.heldItemRight != 0 && this.metadata.getGlowColor() != 0) { if (this.heldItemRight != 0 && this.metadata.getGlowColor() != 0) {
GL11.glPushAttrib(24577); GL11.glPushAttrib(24577);
GL11.glDisable(GL11.GL_TEXTURE_2D); disableTexture2D();
GL11.glDisable(GL11.GL_LIGHTING); disableLighting();
GL11.glEnable(GL11.GL_BLEND); enableBlend();
float var4 = (this.metadata.getGlowColor() >> 16 & 255) / 255.0F; float var4 = (this.metadata.getGlowColor() >> 16 & 255) / 255.0F;
float green = (this.metadata.getGlowColor() >> 8 & 255) / 255.0F; float green = (this.metadata.getGlowColor() >> 8 & 255) / 255.0F;
float blue = (this.metadata.getGlowColor() & 255) / 255.0F; float blue = (this.metadata.getGlowColor() & 255) / 255.0F;
@ -911,6 +904,10 @@ public class pm_newPonyAdv extends ModelPony {
this.hornglow[0].render(this.scale); this.hornglow[0].render(this.scale);
color(var4, green, blue, 0.2F); color(var4, green, blue, 0.2F);
this.hornglow[1].render(this.scale); this.hornglow[1].render(this.scale);
enableTexture2D();
enableLighting();
disableBlend();
popAttrib(); popAttrib();
} }
} }

View file

@ -25,8 +25,8 @@ import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
public class LayerHeldPonyItem implements LayerRenderer { public class LayerHeldPonyItem implements LayerRenderer {
@ -72,50 +72,27 @@ public class LayerHeldPonyItem implements LayerRenderer {
ItemStack drop = entity.getHeldItem(); ItemStack drop = entity.getHeldItem();
if (drop != null) { if (drop != null) {
pushMatrix(); pushMatrix();
if (box != null) { if (pony.getModel().isChild) {
box.postRender(scalefactor * 0.0625F); translate(0.0F, 0.625F, 0.0F);
rotate(-20.0F, -1.0F, 0.0F, 0.0F);
scale(0.5F, 0.5F, 0.5F);
} }
box.postRender(scalefactor * 0.0625F);
translate(posx, posy, posz); translate(posx, posy, posz);
EnumAction playerAction = null; if (entity instanceof EntityPlayer && ((EntityPlayer) entity).fishEntity != null) {
if (entity instanceof EntityPlayer) { drop = new ItemStack(Items.stick);
EntityPlayer is3D = (EntityPlayer) entity;
if (is3D.fishEntity != null) {
drop = new ItemStack(Items.stick);
}
if (is3D.getItemInUseCount() > 0) {
playerAction = drop.getItemUseAction();
}
} }
if (drop.getItem() == Items.bow) { Item item = drop.getItem();
rotate(-20.0F, 0.0F, 1.0F, 0.0F); 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); rotate(45.0F, 0.0F, 1.0F, 0.0F);
} else if (drop.getItem().isFull3D()) { float f8 = 0.375F;
if (drop.getItem().shouldRotateAroundWhenRendering()) { scale(-f8, -f8, f8);
rotate(180.0F, 0.0F, 0.0F, 1.0F);
translate(0.0F, -0.125F, 0.0F);
}
if (playerAction == EnumAction.BLOCK && entity instanceof EntityPlayer
&& ((EntityPlayer) entity).getItemInUseCount() > 0) {
translate(0.05F, 0.0F, -0.1F);
rotate(-50.0F, 0.0F, 1.0F, 0.0F);
rotate(-10.0F, 1.0F, 0.0F, 0.0F);
rotate(-60.0F, 0.0F, 0.0F, 1.0F);
}
} }
float g;
float b;
int var20;
var20 = drop.getItem().getColorFromItemStack(drop, 0);
float var19 = (var20 >> 16 & 255) / 255.0F;
g = (var20 >> 8 & 255) / 255.0F;
b = (var20 & 255) / 255.0F;
color(var19, g, b, 1.0F);
Minecraft.getMinecraft().getItemRenderer().renderItem(entity, drop, TransformType.THIRD_PERSON); Minecraft.getMinecraft().getItemRenderer().renderItem(entity, drop, TransformType.THIRD_PERSON);
if (pony.getModel().metadata.getRace().hasHorn() && pony.getModel().metadata.getGlowColor() != 0) { if (pony.getModel().metadata.getRace().hasHorn() && pony.getModel().metadata.getGlowColor() != 0) {
@ -127,29 +104,32 @@ public class LayerHeldPonyItem implements LayerRenderer {
} }
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, int glowColor) { public void renderItemGlow(EntityLivingBase entity, ItemStack drop, int glowColor) {
pushMatrix();
GL11.glPushAttrib(GL11.GL_CURRENT_BIT | GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT); GL11.glPushAttrib(GL11.GL_CURRENT_BIT | GL11.GL_ENABLE_BIT | GL11.GL_COLOR_BUFFER_BIT);
// GlStateManager.disableLighting();
float red = (glowColor >> 16 & 255) / 255.0F; float red = (glowColor >> 16 & 255) / 255.0F;
float green = (glowColor >> 8 & 255) / 255.0F; float green = (glowColor >> 8 & 255) / 255.0F;
float blue = (glowColor & 255) / 255.0F; float blue = (glowColor & 255) / 255.0F;
float alpha = 0.2F; float alpha = 0.2F;
disableLighting();
enableBlend(); enableBlend();
blendFunc(32769, 1); blendFunc(GL11.GL_CONSTANT_COLOR, 1);
GL14.glBlendColor(red, green, blue, alpha); GL14.glBlendColor(red / 2, green / 2, blue / 2, alpha);
color(red, green, blue, alpha);
IBakedModel model = getItemModel(Minecraft.getMinecraft().getRenderItem(), entity, drop); IBakedModel model = getItemModel(Minecraft.getMinecraft().getRenderItem(), entity, drop);
applyTransform(model.getItemCameraTransforms().thirdPerson); if (model.isGui3d()) {
if (!model.isGui3d()) { // disabling textures for items messes up bounds
scale(1.5, 1.5, 1.5); disableTexture2D();
} else {
translate(0,-0.01,0);
scale(.9, .9, .9);
} }
scale(2, 2, 2);
applyTransform(model.getItemCameraTransforms().thirdPerson);
scale(1.1, 1.1, 1.1);
Minecraft.getMinecraft().getRenderItem().renderItem(drop, model); Minecraft.getMinecraft().getRenderItem().renderItem(drop, model);
GL11.glPopAttrib();
disableBlend(); disableBlend();
popMatrix(); enableLighting();
enableTexture2D();
popAttrib();
// I hate rendering
} }
@Override @Override
@ -187,17 +167,14 @@ public class LayerHeldPonyItem implements LayerRenderer {
return ibakedmodel; return ibakedmodel;
} }
// Adapted from RenderItem // Copied from RenderItem
//@formatter:off
private void applyTransform(ItemTransformVec3f transform) { private void applyTransform(ItemTransformVec3f transform) {
translate(transform.translation.x + RenderItem.debugItemOffsetX, translate(transform.translation.x + RenderItem.debugItemOffsetX, transform.translation.y + RenderItem.debugItemOffsetY, transform.translation.z + RenderItem.debugItemOffsetZ);
transform.translation.y + RenderItem.debugItemOffsetY,
transform.translation.z + RenderItem.debugItemOffsetZ);
translate(0f, .063f, -0.18);
rotate(transform.rotation.y + RenderItem.debugItemRotationOffsetY, 0.0F, 1.0F, 0.0F); rotate(transform.rotation.y + RenderItem.debugItemRotationOffsetY, 0.0F, 1.0F, 0.0F);
rotate(transform.rotation.x + RenderItem.debugItemRotationOffsetX, 1.0F, 0.0F, 0.0F); rotate(transform.rotation.x + RenderItem.debugItemRotationOffsetX, 1.0F, 0.0F, 0.0F);
rotate(transform.rotation.z + RenderItem.debugItemRotationOffsetZ, 0.0F, 0.0F, 1.0F); rotate(transform.rotation.z + RenderItem.debugItemRotationOffsetZ, 0.0F, 0.0F, 1.0F);
scale(transform.scale.x + RenderItem.debugItemScaleX, transform.scale.y + RenderItem.debugItemScaleY, transform.scale.z + RenderItem.debugItemScaleZ);
} }
//@formatter:on
} }