improve container gui
This commit is contained in:
parent
fe4a8fa6a5
commit
10abaef2b4
9 changed files with 47 additions and 173 deletions
|
@ -1388,7 +1388,7 @@ public class Client implements IThreadListener {
|
|||
GL15.glEnable(GL15.GL_SCISSOR_TEST);
|
||||
}
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, by);
|
||||
this.renderItem.renderInGui(itemstack, xPos, by);
|
||||
if(width < 40 && selected != index && selected != index + 1 && cnt != total - 1)
|
||||
GL15.glDisable(GL15.GL_SCISSOR_TEST);
|
||||
xPos += width >= 40 || selected == index || selected == index + 1 ? 40 : width;
|
||||
|
@ -1405,7 +1405,7 @@ public class Client implements IThreadListener {
|
|||
item = this.pointed.entity.getItem();
|
||||
if(item != null) {
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(new ItemStack(item), this.fbX / 2 - 180 + 4 + 1, this.hudMargin + 20 + 1);
|
||||
this.renderItem.renderInGui(new ItemStack(item), this.fbX / 2 - 180 + 4 + 1, this.hudMargin + 20 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -406,7 +406,7 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
GlState.enableDepth();
|
||||
this.itemRender.renderItemAndEffectIntoGUI(ITEM_LIST.get(i1), this.cheatX + 36 * l + 2, this.cheatY + k * 36 + 2);
|
||||
this.itemRender.renderInGui(ITEM_LIST.get(i1), this.cheatX + 36 * l + 2, this.cheatY + k * 36 + 2);
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
if(this.isPointInRegion(this.cheatX + 36 * l + 2, this.cheatY + k * 36 + 2, 32, 32, this.gm.mouseX, this.gm.mouseY))
|
||||
this.renderToolTip(ITEM_LIST.get(i1), mouseX, mouseY);
|
||||
|
@ -532,7 +532,7 @@ public abstract class GuiContainer extends Gui
|
|||
GL15.glPushMatrix();
|
||||
GL15.glTranslatef(0.0F, 0.0F, 32.0F);
|
||||
this.itemRender.zLevel = 200.0F;
|
||||
this.itemRender.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
this.itemRender.renderInGui(stack, x, y);
|
||||
this.drawnOverlays.add(new Overlay(stack, x, y, altText));
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
GL15.glPopMatrix();
|
||||
|
@ -586,7 +586,7 @@ public abstract class GuiContainer extends Gui
|
|||
this.itemRender.zLevel = 100.0F;
|
||||
|
||||
GlState.enableDepth();
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack, i, j);
|
||||
this.itemRender.renderInGui(itemstack, i, j);
|
||||
this.drawnOverlays.add(new Overlay(itemstack, i, j, s));
|
||||
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
|
@ -873,7 +873,7 @@ public abstract class GuiContainer extends Gui
|
|||
this.itemRender.zLevel = 100.0F;
|
||||
ItemStack itemstack = tab.getIcon();
|
||||
GlState.enableDepth();
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack, this.cheatX + 36 * (tab.getIndex() % this.cheatWidth) + 2, this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth) + 2);
|
||||
this.itemRender.renderInGui(itemstack, this.cheatX + 36 * (tab.getIndex() % this.cheatWidth) + 2, this.cheatY + this.cheatHeight * 36 + 8 + 40 * (tab.getIndex() / this.cheatWidth) + 2);
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
|
|
|
@ -105,13 +105,13 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
|
|||
GlState.enableColorMaterial();
|
||||
GlState.enableLighting();
|
||||
this.itemRender.zLevel = 100.0F;
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack, 36, 24);
|
||||
this.itemRender.renderInGui(itemstack, 36, 24);
|
||||
|
||||
if(itemstack1 != null) {
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack1, 62, 24);
|
||||
this.itemRender.renderInGui(itemstack1, 62, 24);
|
||||
}
|
||||
|
||||
this.itemRender.renderItemAndEffectIntoGUI(itemstack2, 120, 24);
|
||||
this.itemRender.renderInGui(itemstack2, 120, 24);
|
||||
this.itemRender.zLevel = 0.0F;
|
||||
GlState.disableLighting();
|
||||
|
||||
|
|
|
@ -9,97 +9,38 @@ import common.entity.item.EntityItem;
|
|||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.rng.Random;
|
||||
import common.util.ExtMath;
|
||||
|
||||
public class RenderEntityItem extends Render<EntityItem>
|
||||
{
|
||||
private final RenderItem itemRenderer;
|
||||
private Random field_177079_e = new Random();
|
||||
private final Random rand = new Random();
|
||||
|
||||
public RenderEntityItem(RenderManager renderManagerIn, RenderItem p_i46167_2_)
|
||||
public RenderEntityItem(RenderManager renderManagerIn, RenderItem renderer)
|
||||
{
|
||||
super(renderManagerIn);
|
||||
this.itemRenderer = p_i46167_2_;
|
||||
// this.shadowSize = 0.15F;
|
||||
// this.shadowOpaque = 0.75F;
|
||||
this.itemRenderer = renderer;
|
||||
}
|
||||
|
||||
private int func_177077_a(EntityItem itemIn, double p_177077_2_, double p_177077_4_, double p_177077_6_, float p_177077_8_, IBakedModel p_177077_9_)
|
||||
private boolean preRender(EntityItem entity, double x, double y, double z, float partial, IBakedModel model)
|
||||
{
|
||||
ItemStack itemstack = itemIn.getEntityItem();
|
||||
ItemStack itemstack = entity.getEntityItem();
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = p_177077_9_.isGui3d();
|
||||
int i = this.getMultiplier(itemstack);
|
||||
float f = 0.25F;
|
||||
float f1 = ExtMath.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F;
|
||||
GL15.glTranslatef((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F, (float)p_177077_6_);
|
||||
|
||||
if (flag || this.manager.gm != null)
|
||||
{
|
||||
float f3 = (((float)itemIn.getAge() + p_177077_8_) / 20.0F + itemIn.hoverStart) * (180F / (float)Math.PI);
|
||||
GL15.glRotatef(f3, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
if (!flag)
|
||||
{
|
||||
float f6 = -0.0F * (float)(i - 1) * 0.5F;
|
||||
float f4 = -0.0F * (float)(i - 1) * 0.5F;
|
||||
float f5 = -0.046875F * (float)(i - 1) * 0.5F;
|
||||
GL15.glTranslatef(f6, f4, f5);
|
||||
}
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return i;
|
||||
}
|
||||
if(item == null)
|
||||
return false;
|
||||
boolean flag = model.isGui3d();
|
||||
float f = flag ? 0.125F : 0.015625f;
|
||||
GL15.glTranslatef((float)x, (float)y + f, (float)z);
|
||||
if(!flag)
|
||||
GL15.glRotatef(-90.0f, 1.0F, 0.0F, 0.0F);
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getMultiplier(ItemStack stack)
|
||||
{
|
||||
int i = 1;
|
||||
|
||||
if (stack.getSize() > 48)
|
||||
{
|
||||
i = 5;
|
||||
}
|
||||
else if (stack.getSize() > 32)
|
||||
{
|
||||
i = 4;
|
||||
}
|
||||
else if (stack.getSize() > 16)
|
||||
{
|
||||
i = 3;
|
||||
}
|
||||
else if (stack.getSize() > 1)
|
||||
{
|
||||
i = 2;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the desired {@code T} type Entity.
|
||||
*/
|
||||
public void doRender(EntityItem entity, double x, double y, double z, float partialTicks)
|
||||
{
|
||||
ItemStack itemstack = entity.getEntityItem();
|
||||
this.field_177079_e.setSeed(187L);
|
||||
// boolean flag = false;
|
||||
|
||||
// if (
|
||||
this.rand.setSeed(187L);
|
||||
this.bindEntityTexture(entity);
|
||||
// )
|
||||
// {
|
||||
// this.renderManager.renderEngine.getTexture(this.getEntityTexture(entity)).unsetMipmap();
|
||||
// flag = true;
|
||||
// }
|
||||
|
||||
GlState.enableRescaleNormal();
|
||||
GlState.alphaFunc(GL15.GL_GREATER, 0.1F);
|
||||
|
@ -107,22 +48,11 @@ public class RenderEntityItem extends Render<EntityItem>
|
|||
GlState.tryBlendFuncSeparate(GL15.GL_SRC_ALPHA, GL15.GL_ONE_MINUS_SRC_ALPHA, GL15.GL_ONE, GL15.GL_ZERO);
|
||||
GL15.glPushMatrix();
|
||||
IBakedModel ibakedmodel = this.itemRenderer.getItemModelMesher().getItemModel(itemstack);
|
||||
int i = this.func_177077_a(entity, x, y, z, partialTicks, ibakedmodel);
|
||||
|
||||
for (int j = 0; j < i; ++j)
|
||||
if (this.preRender(entity, x, y, z, partialTicks, ibakedmodel))
|
||||
{
|
||||
if (ibakedmodel.isGui3d())
|
||||
{
|
||||
GL15.glPushMatrix();
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
float f = (this.field_177079_e.floatv() * 2.0F - 1.0F) * 0.15F;
|
||||
float f1 = (this.field_177079_e.floatv() * 2.0F - 1.0F) * 0.15F;
|
||||
float f2 = (this.field_177079_e.floatv() * 2.0F - 1.0F) * 0.15F;
|
||||
GL15.glTranslatef(f, f1, f2);
|
||||
}
|
||||
|
||||
GL15.glScalef(0.5F, 0.5F, 0.5F);
|
||||
this.itemRenderer.renderItem(itemstack, ibakedmodel);
|
||||
GL15.glPopMatrix();
|
||||
|
@ -132,7 +62,6 @@ public class RenderEntityItem extends Render<EntityItem>
|
|||
GL15.glPushMatrix();
|
||||
this.itemRenderer.renderItem(itemstack, ibakedmodel);
|
||||
GL15.glPopMatrix();
|
||||
GL15.glTranslatef(0.0F, 0.0F, 0.046875F);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,24 +70,11 @@ public class RenderEntityItem extends Render<EntityItem>
|
|||
GlState.disableBlend();
|
||||
this.bindEntityTexture(entity);
|
||||
|
||||
// if (flag)
|
||||
// {
|
||||
// this.renderManager.renderEngine.getTexture(this.getEntityTexture(entity)).restoreLastMipmap();
|
||||
// }
|
||||
|
||||
super.doRender(entity, x, y, z, partialTicks);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture.
|
||||
*/
|
||||
protected String getEntityTexture(EntityItem entity)
|
||||
{
|
||||
return TextureMap.BLOCKS;
|
||||
}
|
||||
|
||||
// protected boolean canRenderName(EntityItem entity)
|
||||
// {
|
||||
// return entity.getEntityItem().stackSize > 1 || super.canRenderName(entity);
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ public class RenderItem
|
|||
}
|
||||
}
|
||||
|
||||
public void renderItemAndEffectIntoGUI(final ItemStack stack, int xPosition, int yPosition)
|
||||
public void renderInGui(final ItemStack stack, int xPosition, int yPosition)
|
||||
{
|
||||
if (stack != null && stack.getItem() != null)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue