mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 14:34:28 +00:00
295 lines
12 KiB
Diff
295 lines
12 KiB
Diff
--- ../src-base/minecraft/net/minecraft/client/renderer/entity/RenderItem.java
|
|
+++ ../src-work/minecraft/net/minecraft/client/renderer/entity/RenderItem.java
|
|
@@ -17,6 +17,7 @@
|
|
import net.minecraft.crash.CrashReportCategory;
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.entity.item.EntityItem;
|
|
+import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemBlock;
|
|
import net.minecraft.item.ItemCloth;
|
|
import net.minecraft.item.ItemStack;
|
|
@@ -27,6 +28,8 @@
|
|
import org.lwjgl.opengl.GL11;
|
|
import org.lwjgl.opengl.GL12;
|
|
|
|
+import net.minecraftforge.client.ForgeHooksClient;
|
|
+
|
|
@SideOnly(Side.CLIENT)
|
|
public class RenderItem extends Render
|
|
{
|
|
@@ -56,7 +59,7 @@
|
|
this.bindEntityTexture(par1EntityItem);
|
|
this.random.setSeed(187L);
|
|
GL11.glPushMatrix();
|
|
- float f2 = MathHelper.sin(((float)par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F;
|
|
+ float f2 = shouldBob() ? MathHelper.sin(((float)par1EntityItem.age + par9) / 10.0F + par1EntityItem.hoverStart) * 0.1F + 0.1F : 0F;
|
|
float f3 = (((float)par1EntityItem.age + par9) / 20.0F + par1EntityItem.hoverStart) * (180F / (float)Math.PI);
|
|
byte b0 = 1;
|
|
|
|
@@ -80,12 +83,19 @@
|
|
b0 = 5;
|
|
}
|
|
|
|
+ b0 = getMiniBlockCount(itemstack, b0);
|
|
+
|
|
GL11.glTranslatef((float)par2, (float)par4 + f2, (float)par6);
|
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
float f7;
|
|
float f6;
|
|
int k;
|
|
|
|
+ if (ForgeHooksClient.renderEntityItem(par1EntityItem, itemstack, f2, f3, random, renderManager.renderEngine, field_147909_c, b0))
|
|
+ {
|
|
+ ;
|
|
+ }
|
|
+ else // Code Style break here to prevent the patch from editing this line
|
|
if (itemstack.getItemSpriteNumber() == 0 && itemstack.getItem() instanceof ItemBlock && RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemstack.getItem()).getRenderType()))
|
|
{
|
|
Block block = Block.getBlockFromItem(itemstack.getItem());
|
|
@@ -140,7 +150,7 @@
|
|
{
|
|
float f5;
|
|
|
|
- if (itemstack.getItemSpriteNumber() == 1 && itemstack.getItem().requiresMultipleRenderPasses())
|
|
+ if (/*itemstack.getItemSpriteNumber() == 1 &&*/ itemstack.getItem().requiresMultipleRenderPasses())
|
|
{
|
|
if (renderInFrame)
|
|
{
|
|
@@ -152,10 +162,10 @@
|
|
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
}
|
|
|
|
- for (int j = 0; j <= 1; ++j)
|
|
+ for (int j = 0; j < itemstack.getItem().getRenderPasses(itemstack.getItemDamage()); ++j)
|
|
{
|
|
this.random.setSeed(187L);
|
|
- IIcon iicon1 = itemstack.getItem().getIconFromDamageForRenderPass(itemstack.getItemDamage(), j);
|
|
+ IIcon iicon1 = itemstack.getItem().getIcon(itemstack, j);
|
|
|
|
if (this.renderWithColor)
|
|
{
|
|
@@ -164,11 +174,11 @@
|
|
f6 = (float)(k >> 8 & 255) / 255.0F;
|
|
f7 = (float)(k & 255) / 255.0F;
|
|
GL11.glColor4f(f5, f6, f7, 1.0F);
|
|
- this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, f5, f6, f7);
|
|
+ this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, f5, f6, f7, j);
|
|
}
|
|
else
|
|
{
|
|
- this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, 1.0F, 1.0F, 1.0F);
|
|
+ this.renderDroppedItem(par1EntityItem, iicon1, b0, par9, 1.0F, 1.0F, 1.0F, j);
|
|
}
|
|
}
|
|
}
|
|
@@ -227,6 +237,12 @@
|
|
// JAVADOC METHOD $$ func_77020_a
|
|
private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7)
|
|
{
|
|
+ this.renderDroppedItem(par1EntityItem, par2Icon, par3, par4, par5, par6, par7, 0);
|
|
+ }
|
|
+
|
|
+ // JAVADOC METHOD $$ renderDroppedItem
|
|
+ private void renderDroppedItem(EntityItem par1EntityItem, IIcon par2Icon, int par3, float par4, float par5, float par6, float par7, int pass)
|
|
+ {
|
|
Tessellator tessellator = Tessellator.instance;
|
|
|
|
if (par2Icon == null)
|
|
@@ -281,11 +297,24 @@
|
|
b0 = 4;
|
|
}
|
|
|
|
+ b0 = getMiniItemCount(itemstack, b0);
|
|
+
|
|
GL11.glTranslatef(-f7, -f8, -((f9 + f10) * (float)b0 / 2.0F));
|
|
|
|
for (int k = 0; k < b0; ++k)
|
|
{
|
|
- GL11.glTranslatef(0.0F, 0.0F, f9 + f10);
|
|
+ // Makes items offset when in 3D, like when in 2D, looks much better. Considered a vanilla bug...
|
|
+ if (k > 0 && shouldSpreadItems())
|
|
+ {
|
|
+ float x = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ float y = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ float z = (random.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ GL11.glTranslatef(x, y, f9 + f10);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ GL11.glTranslatef(0f, 0f, f9 + f10);
|
|
+ }
|
|
|
|
if (itemstack.getItemSpriteNumber() == 0)
|
|
{
|
|
@@ -299,7 +328,7 @@
|
|
GL11.glColor4f(par5, par6, par7, 1.0F);
|
|
ItemRenderer.renderItemIn2D(tessellator, f15, f4, f14, f5, ((IIcon)par2Icon).getIconWidth(), ((IIcon)par2Icon).getIconHeight(), f9);
|
|
|
|
- if (itemstack.hasEffect())
|
|
+ if (itemstack.hasEffect(pass))
|
|
{
|
|
GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
@@ -368,6 +397,12 @@
|
|
// JAVADOC METHOD $$ func_77015_a
|
|
public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5)
|
|
{
|
|
+ this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, false);
|
|
+ }
|
|
+
|
|
+ // JAVADOC METHOD $$ renderItemIntoGUI
|
|
+ public void renderItemIntoGUI(FontRenderer par1FontRenderer, TextureManager par2TextureManager, ItemStack par3ItemStack, int par4, int par5, boolean renderEffect)
|
|
+ {
|
|
int k = par3ItemStack.getItemDamage();
|
|
Object object = par3ItemStack.getIconIndex();
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
@@ -426,11 +461,13 @@
|
|
GL11.glColorMask(true, true, true, true);
|
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
- OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
|
|
|
- for (l = 0; l <= 1; ++l)
|
|
+ Item item = par3ItemStack.getItem();
|
|
+ for (l = 0; l < item.getRenderPasses(k); ++l)
|
|
{
|
|
- IIcon iicon = par3ItemStack.getItem().getIconFromDamageForRenderPass(k, l);
|
|
+ OpenGlHelper.glBlendFunc(770, 771, 1, 0);
|
|
+ par2TextureManager.bindTexture(item.getSpriteNumber() == 0 ? TextureMap.locationBlocksTexture : TextureMap.locationItemsTexture);
|
|
+ IIcon iicon = item.getIcon(par3ItemStack, l);
|
|
int i1 = par3ItemStack.getItem().getColorFromItemStack(par3ItemStack, l);
|
|
f = (float)(i1 >> 16 & 255) / 255.0F;
|
|
float f1 = (float)(i1 >> 8 & 255) / 255.0F;
|
|
@@ -441,7 +478,18 @@
|
|
GL11.glColor4f(f, f1, f2, 1.0F);
|
|
}
|
|
|
|
+ GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, ad renderEffect can derp them up.
|
|
+ GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
+
|
|
this.renderIcon(par4, par5, iicon, 16, 16);
|
|
+
|
|
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
+ GL11.glEnable(GL11.GL_LIGHTING);
|
|
+
|
|
+ if (renderEffect && par3ItemStack.hasEffect(l))
|
|
+ {
|
|
+ renderEffect(par2TextureManager, par4, par5);
|
|
+ }
|
|
}
|
|
|
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
@@ -468,8 +516,19 @@
|
|
GL11.glColor4f(f4, f3, f, 1.0F);
|
|
}
|
|
|
|
+ GL11.glDisable(GL11.GL_LIGHTING); //Forge: Make sure that render states are reset, ad renderEffect can derp them up.
|
|
+ GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
+
|
|
this.renderIcon(par4, par5, (IIcon)object, 16, 16);
|
|
+
|
|
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
+
|
|
+ if (renderEffect && par3ItemStack.hasEffect(0))
|
|
+ {
|
|
+ renderEffect(par2TextureManager, par4, par5);
|
|
+ }
|
|
+ GL11.glEnable(GL11.GL_LIGHTING);
|
|
}
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
@@ -484,7 +543,10 @@
|
|
|
|
try
|
|
{
|
|
- this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5);
|
|
+ if (!ForgeHooksClient.renderInventoryItem(this.field_147909_c, par2TextureManager, par3ItemStack, renderWithColor, zLevel, (float)par4, (float)par5))
|
|
+ {
|
|
+ this.renderItemIntoGUI(par1FontRenderer, par2TextureManager, par3ItemStack, par4, par5, true);
|
|
+ }
|
|
}
|
|
catch (Throwable throwable)
|
|
{
|
|
@@ -525,6 +587,7 @@
|
|
throw new ReportedException(crashreport);
|
|
}
|
|
|
|
+ /* Forge: Bugfix, Move this to a per-render pass, modders must handle themselves
|
|
if (par3ItemStack.hasEffect())
|
|
{
|
|
GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
@@ -540,11 +603,29 @@
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
GL11.glDepthFunc(GL11.GL_LEQUAL);
|
|
}
|
|
+ */
|
|
|
|
this.zLevel -= 50.0F;
|
|
}
|
|
}
|
|
|
|
+ public void renderEffect(TextureManager manager, int x, int y)
|
|
+ {
|
|
+ GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
+ GL11.glDisable(GL11.GL_LIGHTING);
|
|
+ GL11.glDepthMask(false);
|
|
+ manager.bindTexture(RES_ITEM_GLINT);
|
|
+ GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
+ GL11.glEnable(GL11.GL_BLEND);
|
|
+ GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
|
+ this.renderGlint(x * 431278612 + y * 32178161, x - 2, y - 2, 20, 20);
|
|
+ GL11.glDepthMask(true);
|
|
+ GL11.glDisable(GL11.GL_BLEND);
|
|
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
+ GL11.glEnable(GL11.GL_LIGHTING);
|
|
+ GL11.glDepthFunc(GL11.GL_LEQUAL);
|
|
+ }
|
|
+
|
|
private void renderGlint(int par1, int par2, int par3, int par4, int par5)
|
|
{
|
|
for (int j1 = 0; j1 < 2; ++j1)
|
|
@@ -649,4 +730,42 @@
|
|
{
|
|
this.doRender((EntityItem)par1Entity, par2, par4, par6, par8, par9);
|
|
}
|
|
+
|
|
+ /*==================================== FORGE START ===========================================*/
|
|
+
|
|
+ /**
|
|
+ * Items should spread out when rendered in 3d?
|
|
+ * @return
|
|
+ */
|
|
+ public boolean shouldSpreadItems()
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Items should have a bob effect
|
|
+ * @return
|
|
+ */
|
|
+ public boolean shouldBob()
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ public byte getMiniBlockCount(ItemStack stack, byte original)
|
|
+ {
|
|
+ return original;
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Allows for a subclass to override how many rendered items appear in a
|
|
+ * "mini item 3d stack"
|
|
+ * @param stack The item stack
|
|
+ * @param original The default amount vanilla would use
|
|
+ * @return
|
|
+ */
|
|
+ public byte getMiniItemCount(ItemStack stack, byte original)
|
|
+ {
|
|
+ return original;
|
|
+ }
|
|
+ /*==================================== FORGE END =============================================*/
|
|
}
|