Starting to work on printing the filtered items above the rejector
This commit is contained in:
parent
d1dfaad6dd
commit
6cd86ee3c5
3 changed files with 69 additions and 5 deletions
50
src/minecraft/assemblyline/client/render/RenderHelper.java
Normal file
50
src/minecraft/assemblyline/client/render/RenderHelper.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class RenderHelper
|
||||
{
|
||||
public static void renderFloatingText(String text, float x, float y, float z)
|
||||
{
|
||||
RenderManager renderManager = RenderManager.instance;
|
||||
FontRenderer fontRenderer = renderManager.getFontRenderer();
|
||||
float scale = 0.027f;
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.0F, (float) y + 2.3F, (float) z);
|
||||
GL11.glNormal3f(0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
|
||||
GL11.glScalef(-scale, -scale, scale);
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
int yOffset = 0;
|
||||
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
tessellator.startDrawingQuads();
|
||||
int stringMiddle = fontRenderer.getStringWidth(text) / 2;
|
||||
tessellator.setColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (-stringMiddle - 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (8 + yOffset), 0.0D);
|
||||
tessellator.addVertex((double) (stringMiddle + 1), (double) (-1 + yOffset), 0.0D);
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, 553648127);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glDepthMask(true);
|
||||
fontRenderer.drawString(text, -fontRenderer.getStringWidth(text) / 2, yOffset, -1);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package assemblyline.client.render;
|
||||
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
@ -8,6 +9,7 @@ import org.lwjgl.opengl.GL11;
|
|||
import assemblyline.client.model.ModelSorter;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.machine.TileEntityRejector;
|
||||
import assemblyline.common.machine.filter.ItemFilter;
|
||||
|
||||
public class RenderSorter extends TileEntitySpecialRenderer
|
||||
{
|
||||
|
@ -46,7 +48,16 @@ public class RenderSorter extends TileEntitySpecialRenderer
|
|||
model.renderMain(0.0625F);
|
||||
model.renderPiston(0.0625F, pos);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
ItemStack filter = tileEntity.getFilter();
|
||||
if (filter != null)
|
||||
{
|
||||
ItemStack filterItem = ItemFilter.getFilters(filter).get(0);
|
||||
if (filterItem != null)
|
||||
{
|
||||
RenderHelper.renderFloatingText(filterItem.getDisplayName(), (float) x + 0.5f, (float) y, (float) z + 0.5f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package assemblyline.common.machine;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -46,7 +48,7 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
|||
*/
|
||||
private enum PacketTypes
|
||||
{
|
||||
ANIMATION, GUI, SETTINGON
|
||||
ANIMATION, INVENTORY, SETTINGON
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +126,7 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
|||
@Override
|
||||
public Packet getDescriptionPacket()
|
||||
{
|
||||
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData(PacketTypes.GUI));
|
||||
return PacketManager.getPacket(AssemblyLine.CHANNEL, this, this.getPacketData(PacketTypes.INVENTORY));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,7 +201,7 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
|||
public Object[] getPacketData(PacketTypes id)
|
||||
{
|
||||
if (id == PacketTypes.ANIMATION) { return new Object[] { id.ordinal(), this.firePiston }; }
|
||||
if (id == PacketTypes.GUI)
|
||||
if (id == PacketTypes.INVENTORY)
|
||||
{
|
||||
Object[] da = new Object[this.guiButtons.length + 1];
|
||||
da[0] = id.ordinal();
|
||||
|
@ -220,12 +222,13 @@ public class TileEntityRejector extends TileEntityAssemblyNetwork implements IRo
|
|||
{
|
||||
int id = dataStream.readInt();
|
||||
PacketTypes pID = PacketTypes.values()[id];
|
||||
DataInputStream inputStream = new DataInputStream((InputStream) dataStream);
|
||||
|
||||
if (pID == PacketTypes.ANIMATION)
|
||||
{
|
||||
this.firePiston = dataStream.readBoolean();
|
||||
}
|
||||
else if (pID == PacketTypes.GUI)
|
||||
else if (pID == PacketTypes.INVENTORY)
|
||||
{
|
||||
for (int i = 0; i < this.guiButtons.length; i++)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue