mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
Reimplement item glow
This commit is contained in:
parent
903cb3a5eb
commit
e668578771
1 changed files with 75 additions and 1 deletions
|
@ -2,6 +2,9 @@ package com.brohoof.minelittlepony.renderer.layer;
|
||||||
|
|
||||||
import static net.minecraft.client.renderer.GlStateManager.*;
|
import static net.minecraft.client.renderer.GlStateManager.*;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
import org.lwjgl.opengl.GL14;
|
||||||
|
|
||||||
import com.brohoof.minelittlepony.model.PMAPI;
|
import com.brohoof.minelittlepony.model.PMAPI;
|
||||||
import com.brohoof.minelittlepony.model.PlayerModel;
|
import com.brohoof.minelittlepony.model.PlayerModel;
|
||||||
import com.brohoof.minelittlepony.model.pony.pm_newPonyAdv;
|
import com.brohoof.minelittlepony.model.pony.pm_newPonyAdv;
|
||||||
|
@ -10,13 +13,19 @@ import com.brohoof.minelittlepony.renderer.IRenderPony;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.model.ModelRenderer;
|
import net.minecraft.client.model.ModelRenderer;
|
||||||
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
|
||||||
|
import net.minecraft.client.renderer.block.model.ItemTransformVec3f;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
import net.minecraft.client.renderer.entity.RendererLivingEntity;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
|
import net.minecraft.client.renderer.entity.layers.LayerHeldItem;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerRenderer;
|
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.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.EnumAction;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class LayerHeldPonyItem implements LayerRenderer {
|
public class LayerHeldPonyItem implements LayerRenderer {
|
||||||
|
@ -117,7 +126,29 @@ public class LayerHeldPonyItem implements LayerRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, int glowColor) {
|
public void renderItemGlow(EntityLivingBase entity, ItemStack drop, int glowColor) {
|
||||||
// TODO reimplement
|
pushMatrix();
|
||||||
|
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 green = (glowColor >> 8 & 255) / 255.0F;
|
||||||
|
float blue = (glowColor & 255) / 255.0F;
|
||||||
|
float alpha = 0.2F;
|
||||||
|
enableBlend();
|
||||||
|
blendFunc(32769, 1);
|
||||||
|
GL14.glBlendColor(red, green, blue, alpha);
|
||||||
|
color(red, green, blue, alpha);
|
||||||
|
IBakedModel model = getItemModel(Minecraft.getMinecraft().getRenderItem(), entity, drop);
|
||||||
|
applyTransform(model.getItemCameraTransforms().thirdPerson);
|
||||||
|
if (!model.isGui3d()) {
|
||||||
|
scale(1.5, 1.5, 1.5);
|
||||||
|
} else {
|
||||||
|
translate(0,-0.01,0);
|
||||||
|
scale(.9, .9, .9);
|
||||||
|
}
|
||||||
|
Minecraft.getMinecraft().getRenderItem().renderItem(drop, model);
|
||||||
|
GL11.glPopAttrib();
|
||||||
|
disableBlend();
|
||||||
|
popMatrix();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -125,4 +156,47 @@ public class LayerHeldPonyItem implements LayerRenderer {
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adapted from RenderItem
|
||||||
|
private void applyTransform(ItemTransformVec3f transform) {
|
||||||
|
translate(transform.translation.x + RenderItem.debugItemOffsetX,
|
||||||
|
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.x + RenderItem.debugItemRotationOffsetX, 1.0F, 0.0F, 0.0F);
|
||||||
|
rotate(transform.rotation.z + RenderItem.debugItemRotationOffsetZ, 0.0F, 0.0F, 1.0F);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue