2017-03-28 18:15:41 +02:00
|
|
|
package malte0811.industrialWires.blocks.controlpanel;
|
|
|
|
|
|
|
|
import malte0811.industrialWires.client.RawQuad;
|
|
|
|
import malte0811.industrialWires.client.panelmodel.RawModelFontRenderer;
|
|
|
|
import net.minecraft.client.Minecraft;
|
|
|
|
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import net.minecraft.util.ResourceLocation;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class Label extends PanelComponent {
|
|
|
|
private static final ResourceLocation font = new ResourceLocation("minecraft", "textures/font/ascii.png");
|
|
|
|
String text;
|
2017-04-01 17:33:58 +02:00
|
|
|
RawModelFontRenderer renderer;
|
|
|
|
int color;
|
2017-03-28 18:15:41 +02:00
|
|
|
|
2017-04-01 17:33:58 +02:00
|
|
|
public Label(String text, int color) {
|
2017-03-28 18:15:41 +02:00
|
|
|
this();
|
|
|
|
this.text = text;
|
2017-04-01 17:33:58 +02:00
|
|
|
this.color = color;
|
2017-03-28 18:15:41 +02:00
|
|
|
}
|
|
|
|
public Label() {
|
|
|
|
super("label");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void writeCustomNBT(NBTTagCompound nbt) {
|
|
|
|
nbt.setString("text", text);
|
2017-04-01 17:33:58 +02:00
|
|
|
nbt.setInteger("color", color);
|
2017-03-28 18:15:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void readCustomNBT(NBTTagCompound nbt) {
|
|
|
|
text = nbt.getString("text");
|
2017-04-01 17:33:58 +02:00
|
|
|
color = nbt.getInteger("color");
|
2017-03-28 18:15:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<RawQuad> getQuads() {
|
|
|
|
RawModelFontRenderer render = fontRenderer();
|
2017-04-01 17:33:58 +02:00
|
|
|
render.drawString(text, 0, 0, 0xff000000|color);
|
2017-03-28 18:15:41 +02:00
|
|
|
return render.build();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
@Override
|
|
|
|
public Label copyOf() {
|
2017-04-01 17:33:58 +02:00
|
|
|
Label ret = new Label(text, color);
|
2017-03-28 18:15:41 +02:00
|
|
|
ret.setX(x);
|
|
|
|
ret.setY(y);
|
2017-04-01 17:33:58 +02:00
|
|
|
ret.panelHeight = panelHeight;
|
2017-03-28 18:15:41 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public AxisAlignedBB getBlockRelativeAABB() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean interactWith(Vec3d hitRelative, TileEntityPanel tile) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update(TileEntityPanel tile) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private RawModelFontRenderer fontRenderer() {
|
2017-04-01 17:33:58 +02:00
|
|
|
if (renderer==null) {
|
|
|
|
renderer = new RawModelFontRenderer(Minecraft.getMinecraft().gameSettings, font, Minecraft.getMinecraft().getTextureManager(),
|
|
|
|
false, 1);
|
|
|
|
}
|
|
|
|
return renderer;
|
2017-03-28 18:15:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|