mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-27 15:33:18 +00:00
289 lines
12 KiB
Diff
289 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
|
|
{
|
|
@@ -53,7 +56,7 @@
|
|
this.func_110777_b(p_77014_1_);
|
|
this.field_77025_h.setSeed(187L);
|
|
GL11.glPushMatrix();
|
|
- float f2 = MathHelper.func_76126_a(((float)p_77014_1_.field_70292_b + p_77014_9_) / 10.0F + p_77014_1_.field_70290_d) * 0.1F + 0.1F;
|
|
+ float f2 = shouldBob() ? MathHelper.func_76126_a(((float)p_77014_1_.field_70292_b + p_77014_9_) / 10.0F + p_77014_1_.field_70290_d) * 0.1F + 0.1F : 0F;
|
|
float f3 = (((float)p_77014_1_.field_70292_b + p_77014_9_) / 20.0F + p_77014_1_.field_70290_d) * (180F / (float)Math.PI);
|
|
byte b0 = 1;
|
|
|
|
@@ -77,12 +80,19 @@
|
|
b0 = 5;
|
|
}
|
|
|
|
+ b0 = getMiniBlockCount(itemstack, b0);
|
|
+
|
|
GL11.glTranslatef((float)p_77014_2_, (float)p_77014_4_ + f2, (float)p_77014_6_);
|
|
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
float f6;
|
|
float f7;
|
|
int k;
|
|
|
|
+ if (ForgeHooksClient.renderEntityItem(p_77014_1_, itemstack, f2, f3, field_77025_h, field_76990_c.field_78724_e, field_147909_c, b0))
|
|
+ {
|
|
+ ;
|
|
+ }
|
|
+ else // Code Style break here to prevent the patch from editing this line
|
|
if (itemstack.func_94608_d() == 0 && itemstack.func_77973_b() instanceof ItemBlock && RenderBlocks.func_147739_a(Block.func_149634_a(itemstack.func_77973_b()).func_149645_b()))
|
|
{
|
|
Block block = Block.func_149634_a(itemstack.func_77973_b());
|
|
@@ -137,7 +147,7 @@
|
|
{
|
|
float f5;
|
|
|
|
- if (itemstack.func_94608_d() == 1 && itemstack.func_77973_b().func_77623_v())
|
|
+ if (/*itemstack.getItemSpriteNumber() == 1 &&*/ itemstack.func_77973_b().func_77623_v())
|
|
{
|
|
if (field_82407_g)
|
|
{
|
|
@@ -149,10 +159,10 @@
|
|
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
}
|
|
|
|
- for (int j = 0; j <= 1; ++j)
|
|
+ for (int j = 0; j < itemstack.func_77973_b().getRenderPasses(itemstack.func_77960_j()); ++j)
|
|
{
|
|
this.field_77025_h.setSeed(187L);
|
|
- IIcon iicon1 = itemstack.func_77973_b().func_77618_c(itemstack.func_77960_j(), j);
|
|
+ IIcon iicon1 = itemstack.func_77973_b().getIcon(itemstack, j);
|
|
|
|
if (this.field_77024_a)
|
|
{
|
|
@@ -161,11 +171,11 @@
|
|
f6 = (float)(k >> 8 & 255) / 255.0F;
|
|
f7 = (float)(k & 255) / 255.0F;
|
|
GL11.glColor4f(f5, f6, f7, 1.0F);
|
|
- this.func_77020_a(p_77014_1_, iicon1, b0, p_77014_9_, f5, f6, f7);
|
|
+ this.renderDroppedItem(p_77014_1_, iicon1, b0, p_77014_9_, f5, f6, f7, j);
|
|
}
|
|
else
|
|
{
|
|
- this.func_77020_a(p_77014_1_, iicon1, b0, p_77014_9_, 1.0F, 1.0F, 1.0F);
|
|
+ this.renderDroppedItem(p_77014_1_, iicon1, b0, p_77014_9_, 1.0F, 1.0F, 1.0F, j);
|
|
}
|
|
}
|
|
}
|
|
@@ -222,6 +232,11 @@
|
|
|
|
private void func_77020_a(EntityItem p_77020_1_, IIcon p_77020_2_, int p_77020_3_, float p_77020_4_, float p_77020_5_, float p_77020_6_, float p_77020_7_)
|
|
{
|
|
+ this.renderDroppedItem(p_77020_1_, p_77020_2_, p_77020_3_, p_77020_4_, p_77020_5_, p_77020_6_, p_77020_7_, 0);
|
|
+ }
|
|
+
|
|
+ private void renderDroppedItem(EntityItem p_77020_1_, IIcon p_77020_2_, int p_77020_3_, float p_77020_4_, float p_77020_5_, float p_77020_6_, float p_77020_7_, int pass)
|
|
+ {
|
|
Tessellator tessellator = Tessellator.field_78398_a;
|
|
|
|
if (p_77020_2_ == null)
|
|
@@ -276,11 +291,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 = (field_77025_h.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ float y = (field_77025_h.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ float z = (field_77025_h.nextFloat() * 2.0F - 1.0F) * 0.3F / 0.5F;
|
|
+ GL11.glTranslatef(x, y, f9 + f10);
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ GL11.glTranslatef(0f, 0f, f9 + f10);
|
|
+ }
|
|
|
|
if (itemstack.func_94608_d() == 0)
|
|
{
|
|
@@ -294,7 +322,7 @@
|
|
GL11.glColor4f(p_77020_5_, p_77020_6_, p_77020_7_, 1.0F);
|
|
ItemRenderer.func_78439_a(tessellator, f15, f4, f14, f5, ((IIcon)p_77020_2_).func_94211_a(), ((IIcon)p_77020_2_).func_94216_b(), f9);
|
|
|
|
- if (itemstack.func_77962_s())
|
|
+ if (itemstack.hasEffect(pass))
|
|
{
|
|
GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
@@ -362,6 +390,11 @@
|
|
|
|
public void func_77015_a(FontRenderer p_77015_1_, TextureManager p_77015_2_, ItemStack p_77015_3_, int p_77015_4_, int p_77015_5_)
|
|
{
|
|
+ this.renderItemIntoGUI(p_77015_1_, p_77015_2_, p_77015_3_, p_77015_4_, p_77015_5_, false);
|
|
+ }
|
|
+
|
|
+ public void renderItemIntoGUI(FontRenderer p_77015_1_, TextureManager p_77015_2_, ItemStack p_77015_3_, int p_77015_4_, int p_77015_5_, boolean renderEffect)
|
|
+ {
|
|
int k = p_77015_3_.func_77960_j();
|
|
Object object = p_77015_3_.func_77954_c();
|
|
GL11.glEnable(GL11.GL_BLEND);
|
|
@@ -420,11 +453,13 @@
|
|
GL11.glColorMask(true, true, true, true);
|
|
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
|
GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
- OpenGlHelper.func_148821_a(770, 771, 1, 0);
|
|
|
|
- for (l = 0; l <= 1; ++l)
|
|
+ Item item = p_77015_3_.func_77973_b();
|
|
+ for (l = 0; l < item.getRenderPasses(k); ++l)
|
|
{
|
|
- IIcon iicon = p_77015_3_.func_77973_b().func_77618_c(k, l);
|
|
+ OpenGlHelper.func_148821_a(770, 771, 1, 0);
|
|
+ p_77015_2_.func_110577_a(item.func_94901_k() == 0 ? TextureMap.field_110575_b : TextureMap.field_110576_c);
|
|
+ IIcon iicon = item.getIcon(p_77015_3_, l);
|
|
int i1 = p_77015_3_.func_77973_b().func_82790_a(p_77015_3_, l);
|
|
f = (float)(i1 >> 16 & 255) / 255.0F;
|
|
float f1 = (float)(i1 >> 8 & 255) / 255.0F;
|
|
@@ -435,7 +470,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.func_94149_a(p_77015_4_, p_77015_5_, iicon, 16, 16);
|
|
+
|
|
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
+ GL11.glEnable(GL11.GL_LIGHTING);
|
|
+
|
|
+ if (renderEffect && p_77015_3_.hasEffect(l))
|
|
+ {
|
|
+ renderEffect(p_77015_2_, p_77015_4_, p_77015_5_);
|
|
+ }
|
|
}
|
|
|
|
GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
@@ -462,8 +508,19 @@
|
|
GL11.glColor4f(f3, f4, 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.func_94149_a(p_77015_4_, p_77015_5_, (IIcon)object, 16, 16);
|
|
+
|
|
+ GL11.glDisable(GL11.GL_ALPHA_TEST);
|
|
GL11.glEnable(GL11.GL_LIGHTING);
|
|
+
|
|
+ if (renderEffect && p_77015_3_.hasEffect(0))
|
|
+ {
|
|
+ renderEffect(p_77015_2_, p_77015_4_, p_77015_5_);
|
|
+ }
|
|
+ GL11.glEnable(GL11.GL_LIGHTING);
|
|
}
|
|
|
|
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
@@ -477,7 +534,10 @@
|
|
|
|
try
|
|
{
|
|
- this.func_77015_a(p_82406_1_, p_82406_2_, p_82406_3_, p_82406_4_, p_82406_5_);
|
|
+ if (!ForgeHooksClient.renderInventoryItem(this.field_147909_c, p_82406_2_, p_82406_3_, field_77024_a, field_77023_b, (float)p_82406_4_, (float)p_82406_5_))
|
|
+ {
|
|
+ this.renderItemIntoGUI(p_82406_1_, p_82406_2_, p_82406_3_, p_82406_4_, p_82406_5_, true);
|
|
+ }
|
|
}
|
|
catch (Throwable throwable)
|
|
{
|
|
@@ -518,7 +578,8 @@
|
|
throw new ReportedException(crashreport);
|
|
}
|
|
|
|
- if (p_82406_3_.func_77962_s())
|
|
+ // Forge: Bugfix, Move this to a per-render pass, modders must handle themselves
|
|
+ if (false && p_82406_3_.func_77962_s())
|
|
{
|
|
GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
GL11.glDisable(GL11.GL_LIGHTING);
|
|
@@ -538,6 +599,23 @@
|
|
}
|
|
}
|
|
|
|
+ public void renderEffect(TextureManager manager, int x, int y)
|
|
+ {
|
|
+ GL11.glDepthFunc(GL11.GL_EQUAL);
|
|
+ GL11.glDisable(GL11.GL_LIGHTING);
|
|
+ GL11.glDepthMask(false);
|
|
+ manager.func_110577_a(field_110798_h);
|
|
+ GL11.glEnable(GL11.GL_ALPHA_TEST);
|
|
+ GL11.glEnable(GL11.GL_BLEND);
|
|
+ GL11.glColor4f(0.5F, 0.25F, 0.8F, 1.0F);
|
|
+ this.func_77018_a(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 func_77018_a(int p_77018_1_, int p_77018_2_, int p_77018_3_, int p_77018_4_, int p_77018_5_)
|
|
{
|
|
for (int j1 = 0; j1 < 2; ++j1)
|
|
@@ -638,4 +716,42 @@
|
|
{
|
|
this.func_76986_a((EntityItem)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
|
|
}
|
|
+
|
|
+ /*==================================== 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 =============================================*/
|
|
}
|