Add Display
parent
16de6af58f
commit
8a6accae6f
@ -0,0 +1,73 @@
|
|||||||
|
package net.brokenmoon.afloydwiremod.ter;
|
||||||
|
|
||||||
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||||
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
|
||||||
|
import net.brokenmoon.afloydwiremod.tileentity.DisplayTileEntity;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.src.Block;
|
||||||
|
import net.minecraft.src.FontRenderer;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.TileEntitySpecialRenderer;
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class TERDisplay extends TileEntitySpecialRenderer {
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileEntity, double d, double e, double f, float g) {
|
||||||
|
this.renderDisplay((DisplayTileEntity)tileEntity, d, e, f, g);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderDisplay(DisplayTileEntity tileEntity, double d, double e, double f, float g) {
|
||||||
|
if(tileEntity.inputs != null){
|
||||||
|
for(int it = 0; it < tileEntity.inputs.length; it++){
|
||||||
|
if(tileEntity.inputs[it] != null && tileEntity.isLineReversed != null){
|
||||||
|
this.renderTextLine(d, e, f, it, tileEntity.inputs[it].floatvalue, tileEntity.inputs[it].stringvalue, tileEntity.isLineReversed[it], Minecraft.getMinecraft().theWorld.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderTextLine(double d, double d1, double d2, int line, float floatvalue, String stringvalue, boolean reversed, int meta) {
|
||||||
|
String strToRender;
|
||||||
|
if(reversed) {
|
||||||
|
strToRender = floatvalue + stringvalue;
|
||||||
|
}else{
|
||||||
|
strToRender = stringvalue + floatvalue;
|
||||||
|
}
|
||||||
|
FontRenderer fontRenderer = this.getFontRenderer();
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef((float)d, (float)d1, (float)d2);
|
||||||
|
float yoff = 0.151f;
|
||||||
|
switch(meta) {
|
||||||
|
case 5:
|
||||||
|
GL11.glTranslatef(0.5f, yoff, 0.53f);
|
||||||
|
GL11.glRotatef(-90f, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
GL11.glTranslatef(0.5f, 1 - yoff, 0.47f);
|
||||||
|
GL11.glRotatef(90f, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
GL11.glTranslatef(0.5f, 0.47f, 1 - yoff);
|
||||||
|
GL11.glRotatef(180f, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GL11.glTranslatef(0.5f, 0.47f, yoff);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
GL11.glRotatef(90f, 0, 1, 0);
|
||||||
|
GL11.glTranslatef(-0.5f, 0.47f, yoff);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
GL11.glRotatef(-90f, 0, 1, 0);
|
||||||
|
GL11.glTranslatef(0.5f, 0.47f, - 1 + yoff);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
GL11.glScalef(0.02f, -0.02f, 0.02f);
|
||||||
|
fontRenderer.drawString(strToRender, -fontRenderer.getStringWidth(strToRender) / 2, line * 10 - 4 * 5, 0xFFFFFF);
|
||||||
|
fontRenderer.drawString(strToRender, -fontRenderer.getStringWidth(strToRender) / 2, line * 10 - 4 * 5, 0xFFFFFF);
|
||||||
|
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package net.brokenmoon.afloydwiremod.tileentity;
|
package net.brokenmoon.afloydwiremod.ter;
|
||||||
|
|
||||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||||
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
|
@ -0,0 +1,17 @@
|
|||||||
|
package net.brokenmoon.afloydwiremod.tile;
|
||||||
|
|
||||||
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileSided;
|
||||||
|
import net.brokenmoon.afloydwiremod.tileentity.DisplayTileEntity;
|
||||||
|
import net.minecraft.src.Material;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
|
||||||
|
public class DisplayTile extends AbstractWireTileSided {
|
||||||
|
public DisplayTile(int i, Material material) {
|
||||||
|
super(i, material);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected TileEntity getBlockEntity() {
|
||||||
|
return new DisplayTileEntity();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package net.brokenmoon.afloydwiremod.tileentity;
|
||||||
|
|
||||||
|
import net.brokenmoon.afloydwiremod.api.AbstractWireTileEntity;
|
||||||
|
import net.brokenmoon.afloydwiremod.gui.WiringButton;
|
||||||
|
import net.minecraft.src.NBTTagCompound;
|
||||||
|
|
||||||
|
public class DisplayTileEntity extends AbstractWireTileEntity {
|
||||||
|
public boolean[] isLineReversed = new boolean[4];
|
||||||
|
public DisplayTileEntity(){
|
||||||
|
super();
|
||||||
|
inputs = new WiringButton[4];
|
||||||
|
inputs[0] = new WiringButton(214, 220, "Line 1", 0);
|
||||||
|
inputs[1] = new WiringButton(214, 220, "Line 2", 1);
|
||||||
|
inputs[2] = new WiringButton(214, 220, "Line 3", 2);
|
||||||
|
inputs[3] = new WiringButton(214, 220, "Line 4", 3);
|
||||||
|
outputs = new WiringButton[0];
|
||||||
|
this.initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.readFromNBT(nbttagcompound);
|
||||||
|
for(int i = 0; i < isLineReversed.length; i++){
|
||||||
|
isLineReversed[i] = nbttagcompound.getBoolean("reverse" + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound nbttagcompound) {
|
||||||
|
super.writeToNBT(nbttagcompound);
|
||||||
|
for(int i = 0; i < isLineReversed.length; i++){
|
||||||
|
nbttagcompound.setBoolean("reverse" + i, isLineReversed[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 312 B |
Loading…
Reference in New Issue