1
0
Fork 0

improve gui

This commit is contained in:
Sen 2025-08-11 15:59:40 +02:00
parent a7dacc36f8
commit cc2c78d995
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
41 changed files with 369 additions and 579 deletions

View file

@ -457,8 +457,6 @@ public class Client implements IThreadListener {
public int fbY;
public int mouseX;
public int mouseY;
public int total;
public int progress = -1;
private long lastTicked = 0L;
private long debugUpdateTime = System.currentTimeMillis();
@ -520,7 +518,6 @@ public class Client implements IThreadListener {
public BlockPos pointedLiquid;
public DisplayMode vidMode;
public String dimensionName;
public String message;
private ChunkClient emptyChunk;
private ChunkClient outsideChunk;
@ -665,7 +662,7 @@ public class Client implements IThreadListener {
}
public void displayConnecting(ServerInfo server) {
this.show(GuiLoading.makeWaitTask("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ..."));
this.show(new GuiLoading("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ..."));
}
public void connect(final ServerInfo server) {

View file

@ -97,7 +97,7 @@ public class GuiConsole extends Gui implements FieldCallback {
}
this.logBox = this.add(new ConsoleArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
if(this.full)
this.add(new Fill(640, 0, width - 640, 0));
this.add(new Fill(640, 0, width - 640, 0, ""));
this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
this.inputField.setSelected();
this.sentHistoryCursor = this.sentMessages.size();

View file

@ -1,118 +1,19 @@
package client.gui;
import client.Client;
import client.gui.element.Bar;
import client.gui.element.Label;
public class GuiLoading extends Gui {
public static interface Callback {
void poll(Client gm, GuiLoading gui);
}
private final String message;
private final Callback callback;
private Label headerLabel;
private Label taskLabel;
private Bar progressBar1;
private Bar progressBar2;
public static GuiLoading makeServerTask(String message) {
return new GuiLoading(message, new Callback() {
public void poll(Client gm, GuiLoading gui) {
int progress = gm.progress;
if(progress < 0) {
gui.resetBar();
}
else {
gui.setBar(null, "Chunks", Math.max(1, gm.total));
gui.setProgress(progress);
}
gui.setTask(gm.message);
}
});
}
public static GuiLoading makeWaitTask(String message) {
return new GuiLoading(message, new Callback() {
public void poll(Client gm, GuiLoading gui) {
}
});
}
public GuiLoading(String message, Callback callback) {
public GuiLoading(String message) {
this.message = message;
this.callback = callback;
}
public void init(int width, int height) {
this.taskLabel = this.add(new Label(0, 40, 500, 0, ""));
this.progressBar1 = this.add(new Bar(0, 80, 500, 0));
this.progressBar2 = this.add(new Bar(0, 120, 500, 0));
this.shift();
this.headerLabel = this.add(new Label(0, 40, width, 0, this.message));
this.progressBar1.visible = false;
this.progressBar2.visible = false;
this.add(new Label(0, 40, width, 0, this.message));
}
public String getTitle() {
return this.message;
}
public void setTask(String task) {
this.taskLabel.setText(task == null ? "" : task);
}
public void setBar(String desc) {
this.progressBar1.visible = true;
this.progressBar1.setDescription(desc);
}
public void setBar(String desc, String unit, int total) {
this.progressBar1.visible = true;
this.progressBar1.setDescription(desc, unit, total);
}
public void setBar(String desc, int total) {
this.progressBar1.visible = true;
this.progressBar1.setDescription(desc, total);
}
public void setProgress(float progress) {
this.progressBar1.setProgress(progress);
}
public void resetBar() {
this.progressBar1.resetProgress();
this.progressBar1.visible = false;
}
public void setSub(String desc) {
this.progressBar2.visible = true;
this.progressBar2.setDescription(desc);
}
public void setSub(String desc, String unit, int total) {
this.progressBar2.visible = true;
this.progressBar2.setDescription(desc, unit, total);
}
public void setSub(String desc, int total) {
this.progressBar2.visible = true;
this.progressBar2.setDescription(desc, total);
}
public void setSubProgress(float progress) {
this.progressBar2.setProgress(progress);
}
public void resetSub() {
this.progressBar2.resetProgress();
this.progressBar2.visible = false;
}
public void updateScreen() {
if(this.callback != null)
this.callback.poll(this.gm, this);
}
}

View file

@ -390,7 +390,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) {
GuiChar.this.gm.show(GuiLoading.makeWaitTask("Lade Welt ..."));
GuiChar.this.gm.show(new GuiLoading("Lade Welt ..."));
Dimension dim = GuiChar.this.dimensions.get(GuiChar.this.dimension);
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText()));
GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, DimensionMapping.getId(dim)));

View file

@ -26,7 +26,7 @@ public class GuiBrewing extends GuiContainer {
}
public void addElements() {
this.label(Blocks.brewing_stand.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(Blocks.brewing_stand.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -18,7 +18,7 @@ public class GuiChest extends GuiContainer {
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -14,10 +14,11 @@ import client.Client;
import client.gui.Font;
import client.gui.Gui;
import client.gui.element.ActButton;
import client.gui.element.Bar;
import client.gui.element.ButtonCallback;
import client.gui.element.Field;
import client.gui.element.FontLabel;
import client.gui.element.FontMultiLabel;
import client.gui.element.DisplayLabel;
import client.gui.element.InventoryButton;
import client.gui.element.Label;
import client.gui.element.MultiLabel;
@ -199,7 +200,19 @@ public abstract class GuiContainer extends Gui
public Label label(String text, int x, int y) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new FontLabel(x, y + 10 * this.container_scale, 300, this.container_scale > 1 ? Font.MEDIUM : Font.SMALL, text, true));
return this.add(new FontLabel(x, y, 300, this.container_scale > 1 ? Font.LARGE : Font.SMALL, text, true));
}
public DisplayLabel display(String text, int x, int y, int w, int lines) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new DisplayLabel(x, y, w * this.container_scale, lines, this.container_scale > 1 ? Font.LARGE : Font.TINY, text));
}
public Bar bar(int x, int y, int w, int h) {
x = x * this.container_scale + this.container_x;
y = y * this.container_scale + this.container_y;
return this.add(new Bar(x, y, w * this.container_scale, h * this.container_scale, this.container_scale > 1 ? Font.LARGE : Font.TINY));
}
public void rect(int x, int y, int width, int height, int color) {
@ -286,7 +299,7 @@ public abstract class GuiContainer extends Gui
}
if(this.gm.itemCheat) {
this.cheatLabel = this.add(new FontLabel(this.cheatX, this.cheatY, this.cheatWidth * 18, Font.SMALL, "", true));
this.cheatDesc = this.add(new FontMultiLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 60, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
this.cheatDesc = this.add(new DisplayLabel(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4 + 18, this.cheatWidth * 18, 4, Font.SMALL, "Vorsicht: Schummeln\nwird mit Keule bestraft!!\n(Halte Strg beim Klick\nfür vollen Stapel)"));
this.cheatSearch = this.add(new Field(this.cheatX, this.cheatY + this.cheatHeight * 18 + 20 * ((CheatTab.values().length + (this.cheatWidth - 1)) / this.cheatWidth) + 4, this.cheatWidth * 18, 0, 128, null, ""));
this.cheatLast = "";
for(CheatTab tab : CheatTab.values()) {

View file

@ -16,7 +16,7 @@ public class GuiCrafting extends GuiContainer {
}
public void addElements() {
this.label("Handwerk (" + this.type.getDisplay() + ")", 26, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.type.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -1,10 +1,13 @@
package client.gui.container;
import client.gui.element.Bar;
import client.gui.element.DisplayLabel;
import client.gui.element.Label;
import common.inventory.ContainerTile;
import common.inventory.IInventory;
import common.entity.npc.EntityNPC;
import common.tileentity.Device;
import common.tileentity.Device.Status;
public class GuiDevice extends GuiContainer {
private final IInventory playerInv;
@ -12,28 +15,47 @@ public class GuiDevice extends GuiContainer {
private final Device tile;
private Label header;
private Label temp;
private Label desc;
private DisplayLabel desc;
private Bar progress;
private Bar temperature;
private Bar[] resources;
public GuiDevice(EntityNPC player, IInventory inv, Device tile) {
super(new ContainerTile(player, tile, inv));
this.playerInv = player;
this.tileInv = tile;
this.ySize = 153;
this.ySize = 194;
this.tile = tile;
}
public void updateScreen() {
super.updateScreen();
this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay() + " - " + this.tile.getStatus().name);
this.temp.setText(String.format("Temperatur: %d °", this.tile.getTemperature()));
this.header.setText(this.tile.getStatus().color + this.tile.getBlockType().getDisplay());
this.desc.setText(this.tile.formatDisplay((ContainerTile)this.inventorySlots));
if(this.progress != null) {
this.progress.setText(this.tile.getTotal() <= 0 || this.tile.getProgress() < 0 ? "" : String.format("%d/%d (%.1f %%)",
this.tile.getProgress(), this.tile.getTotal(), ((float)this.tile.getProgress() / (float)this.tile.getTotal()) * 100.0f));
this.progress.setProgress(this.tile.getTotal(), this.tile.getProgress());
}
if(this.temperature != null) {
this.temperature.setText(String.format("t: %d °C" + (this.tile.getMaxTemp() == Integer.MAX_VALUE ? "" : " (max. %d °C)"), this.tile.getTemperature(), this.tile.getMaxTemp()));
this.temperature.setProgress(this.tile.getMaxTemp() == Integer.MAX_VALUE ? (this.tile.getStatus() == Status.OFF || this.tile.getStatus() == Status.BROKEN ? 0 : this.tile.getTemperature()) : this.tile.getMaxTemp(), this.tile.getTemperature());
}
for(int z = 0; z < this.resources.length; z++) {
this.resources[z].setText(this.tile.getResource(z).format());
this.resources[z].setProgress(this.tile.getResource(z).getCapacity(), this.tile.getResource(z).getValue());
}
}
public void addElements() {
this.header = this.label("", 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.temp = this.label("", 8, 18);
this.desc = this.label("", 8, 28);
this.header = this.label("", 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
this.desc = this.display("", 8, 18, 160, 4);
this.progress = this.tile.hasProgress() ? this.bar(7, 70, 162, 9) : null;
this.temperature = this.tile.hasTemperature() ? this.bar(7, this.progress == null ? 70 : 60, 162, 9) : null;
this.resources = new Bar[this.tile.getNumResources()];
for(int z = 0; z < this.resources.length; z++) {
this.resources[z] = this.bar(7, 80 - (this.resources.length + (this.progress == null ? 0 : 1) + (this.temperature == null ? 0 : 1)) * 10 + z * 10, 162, 9);
}
}
}

View file

@ -14,7 +14,7 @@ public class GuiDispenser extends GuiContainer {
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -59,13 +59,13 @@ public class GuiEnchant extends GuiContainer implements ButtonCallback {
}
public void addElements() {
this.label(Blocks.enchanting_table.getDisplay(), 12, 5);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(Blocks.enchanting_table.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
for(int l = 0; l < 3; ++l) {
int i1 = 60;
int j1 = i1 + 2;
this.labels[l] = this.label("", j1, 16 + 19 * l);
this.mana[l] = this.label("", j1, 16 + 19 * l + 7);
this.labels[l] = this.label("", j1, 26 + 19 * l);
this.mana[l] = this.label("", j1, 26 + 19 * l + 7);
}
}

View file

@ -14,7 +14,7 @@ public class GuiEntity extends GuiContainer {
}
public void addElements() {
this.label(this.title, 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.title, 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -32,8 +32,8 @@ public class GuiFurnace extends GuiContainer {
}
public void addElements() {
this.label(this.block.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.block.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
private int getCookProgressScaled(int pixels) {

View file

@ -13,7 +13,7 @@ public class GuiHopper extends GuiContainer {
}
public void addElements() {
this.label(Blocks.hopper.getDisplay(), 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(Blocks.hopper.getDisplay(), 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -8,6 +8,5 @@ public class GuiInventory extends GuiContainer {
}
public void addElements() {
this.label("Handwerk", 86, 16);
}
}

View file

@ -40,8 +40,8 @@ public class GuiMerchant extends GuiContainer implements ButtonCallback {
}
public void addElements() {
this.label(this.title, 8, 6);
this.label("Inventar", 8, this.ySize - 96 + 2);
this.label(this.title, 8, 16);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
public void drawOverlays() {

View file

@ -30,7 +30,8 @@ public class GuiRepair extends GuiContainer {
}
public void addElements() {
this.label("Amboss", 60, 6);
this.info = this.label("", 60, 67);
this.label("Amboss", 8, 16);
this.info = this.label("", 60, 77);
this.label("Inventar", 8, this.ySize - 96 + 12);
}
}

View file

@ -1,26 +1,28 @@
package client.gui.element;
import client.gui.Font;
import client.renderer.Drawing;
import common.util.ExtMath;
import common.util.Util;
public class Bar extends Fill {
private final Font font;
private int color = 0x00ff00;
private int progress = 0;
private int total = 0;
private String desc = "";
private String unit = "";
private int amount = 0;
public Bar(int x, int y, int w, int h, boolean top, boolean left) {
super(x, y, w, h, "", top, left);
public Bar(int x, int y, int w, int h, Font font, boolean top, boolean left) {
super(x, y, w, h, top, left);
this.font = font;
this.setText("");
}
public Bar(int x, int y, int w, int h, boolean left) {
super(x, y, w, h, "", left);
public Bar(int x, int y, int w, int h, Font font, boolean left) {
this(x, y, w, h, font, false, left);
}
public Bar(int x, int y, int w, int h) {
super(x, y, w, h, "");
public Bar(int x, int y, int w, int h, Font font) {
this(x, y, w, h, font, false, false);
}
protected void drawBackground() {
@ -28,16 +30,24 @@ public class Bar extends Fill {
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, this.gm.style.fill_btm, this.gm.style.fill_top, 0xff000000, this.gm.style.brdr_top, this.gm.style.brdr_btm);
else
Drawing.drawGradientBorder(this.pos_x, this.pos_y, this.size_x, this.size_y, Util.mulColor(this.gm.style.fill_btm, 0.5f), Util.mulColor(this.gm.style.fill_top, 0.5f), 0xff000000, Util.mulColor(this.gm.style.brdr_top, 0.5f), Util.mulColor(this.gm.style.brdr_btm, 0.5f));
if(this.progress > 0) {
if(this.amount > 0) {
if(this.enabled)
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000));
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.amount, this.size_y - 4, this.color | 0xff000000, Util.mixColor(this.color | 0xff000000, 0xff000000));
else
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.progress, this.size_y - 4, Util.mulColor(this.color | 0xff000000, 0.5f), Util.mulColor(Util.mixColor(this.color | 0xff000000, 0xff000000), 0.5f));
Drawing.drawGradient(this.pos_x + 2, this.pos_y + 2, this.amount, this.size_y - 4, Util.mulColor(this.color | 0xff000000, 0.5f), Util.mulColor(Util.mixColor(this.color | 0xff000000, 0xff000000), 0.5f));
}
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Font.set(this.font);
Drawing.drawText(this.text, x1 + this.text_x, y1 + this.text_y, this.enabled ? this.gm.style.text_label : Util.mulColor(this.gm.style.text_label, 0.5f));
Font.unset();
}
public void updateText() {
Font.set(this.font);
super.updateText();
Font.unset();
}
protected int getMarginX() {
@ -48,50 +58,12 @@ public class Bar extends Fill {
return 0;
}
public Bar setDescription(String desc, String unit, int total) {
this.desc = desc == null ? "" : (desc + ": ");
this.unit = unit == null ? "" : (" " + unit);
this.total = total;
return this;
}
public Bar setDescription(String desc, int total) {
return this.setDescription(desc, null, total);
}
public Bar setDescription(String desc) {
this.desc = desc == null ? "" : (desc + ": ");
this.unit = "";
this.total = 0;
return this;
}
public Bar resetProgress() {
this.setText("");
this.progress = 0;
this.setDescription(null);
return this;
}
public Bar setProgressFill(int progress) {
this.progress = ExtMath.clampi(progress, 0, this.size_x - 4);
return this;
}
public Bar setProgressFill(float progress) {
return this.setProgressFill((int)(progress * (float)(this.size_x - 4)));
}
public Bar setProgress(float progress) {
if(this.total == 0)
this.setText(String.format("%s%.1f %%", this.desc, progress * 100.0f));
else
this.setText(String.format("%s%d/%d%s (%.1f %%)", this.desc, (int)progress, this.total, this.unit, (progress / (float)this.total) * 100.0f));
return this.setProgressFill(this.total == 0 ? progress : (progress / (float)this.total));
}
public Bar setColor(int color) {
this.color = color;
return this;
}
public void setProgress(int total, int progress) {
this.amount = progress < 0 || total <= 0 ? 0 : ExtMath.clampi((int)(((float)progress / (float)total) * (float)(this.size_x - 4)), 0, this.size_x - 4);
}
}

View file

@ -0,0 +1,41 @@
package client.gui.element;
import client.gui.Font;
import client.renderer.Drawing;
import common.util.Util;
public class DisplayLabel extends MultiLabel {
private final Font font;
public DisplayLabel(int x, int y, int w, int lines, Font font, String text) {
super(x, y, w, lines * font.getHeight() + 2, true);
this.font = font;
this.setText(text);
}
protected void drawBackground() {
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0xff000000, 0xff2f2f2f, 0xff5f5f5f);
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Font.set(this.font);
for(int z = 0; z < this.lines.length; z++) {
Drawing.drawText(z == this.lines.length - 1 && Util.ftime() % 1.0f < 0.5f ? this.lines[z] + "_" : this.lines[z], x1, y1 + z * Font.HEIGHT, 0xff00ff00);
}
Font.unset();
}
public void updateText() {
Font.set(this.font);
super.updateText();
Font.unset();
}
protected int getMarginX() {
return 2;
}
protected int getMarginY() {
return 1;
}
}

View file

@ -22,16 +22,10 @@ public class Fill extends Element {
this(x, y, w, h, text, false, false);
}
public Fill(int x, int y, int w, int h, boolean top, boolean left) {
this(x, y, w, h, "", top, left);
}
public Fill(int x, int y, int w, int h, boolean left) {
this(x, y, w, h, "", false, left);
}
public Fill(int x, int y, int w, int h) {
this(x, y, w, h, "", false, false);
protected Fill(int x, int y, int w, int h, boolean top, boolean left) {
super(x, y, w, h, null);
this.top = top;
this.left = left;
}

View file

@ -6,13 +6,15 @@ public class FontLabel extends Label {
private final Font font;
public FontLabel(int x, int y, int w, int h, Font font, String text, boolean left) {
super(x, y, w, h <= 0 ? font.getHeight() : h, text, left);
super(x, y, w, h <= 0 ? font.getHeight() : h, false, left);
this.font = font;
this.setText(text);
}
public FontLabel(int x, int y, int w, Font font, String text, boolean left) {
super(x, y - font.getHeight(), w, font.getHeight(), text, left);
super(x, y - font.getHeight(), w, font.getHeight(), false, left);
this.font = font;
this.setText(text);
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
@ -20,4 +22,10 @@ public class FontLabel extends Label {
super.drawForeground(x1, y1, x2, y2);
Font.unset();
}
public void updateText() {
Font.set(this.font);
super.updateText();
Font.unset();
}
}

View file

@ -1,18 +0,0 @@
package client.gui.element;
import client.gui.Font;
public class FontMultiLabel extends MultiLabel {
private final Font font;
public FontMultiLabel(int x, int y, int w, int h, Font font, String text) {
super(x, y, w, h, text);
this.font = font;
}
protected void drawForeground(int x1, int y1, int x2, int y2) {
Font.set(this.font);
super.drawForeground(x1, y1, x2, y2);
Font.unset();
}
}

View file

@ -30,6 +30,10 @@ public class Label extends Fill {
super(x, y - LABEL_HEIGHT, w, LABEL_HEIGHT, text);
}
protected Label(int x, int y, int w, int h, boolean top, boolean left) {
super(x, y, w, h <= 0 ? LABEL_HEIGHT : h, top, left);
}
protected void drawBackground() {
}

View file

@ -5,7 +5,7 @@ import client.renderer.Drawing;
import common.util.Util;
public class MultiLabel extends Fill {
private String[] lines;
protected String[] lines;
public MultiLabel(int x, int y, int w, int h, String text, boolean top) {
super(x, y, w, h, text, top, true);
@ -15,6 +15,10 @@ public class MultiLabel extends Fill {
super(x, y, w, h, text, false, true);
}
protected MultiLabel(int x, int y, int w, int h, boolean top) {
super(x, y, w, h, top, true);
}
public void setText(String str) {
super.setText(str);
this.lines = str.split("\n", -1);

View file

@ -5,7 +5,6 @@ import java.util.Map.Entry;
import client.Client;
import client.gui.Gui;
import client.gui.GuiConsole;
import client.gui.GuiLoading;
import client.gui.character.GuiChar;
import client.gui.character.GuiCharacters;
import client.gui.container.GuiBrewing;
@ -110,7 +109,6 @@ import common.packet.SPacketEntityVelocity;
import common.packet.SPacketHeldItemChange;
import common.packet.SPacketJoinGame;
import common.packet.SPacketKeepAlive;
import common.packet.SPacketLoading;
import common.packet.SPacketMapChunkBulk;
import common.packet.SPacketMessage;
import common.packet.SPacketMultiBlockChange;
@ -827,25 +825,6 @@ public class ClientPlayer implements IClientPlayer
// }
}
public void handleLoading(SPacketLoading packet) {
NetHandler.checkThread(packet, this, this.gm);
if(packet.getMessage() == null) {
if(packet.getTask() != null)
this.gm.message = packet.getTask();
if(packet.getTotal() >= 0)
this.gm.total = packet.getTotal();
if(packet.getProgress() >= -1)
this.gm.progress = packet.getProgress();
}
else {
this.gm.message = "";
this.gm.total = 0;
this.gm.progress = -1;
this.gm.show(GuiLoading.makeServerTask(packet.getMessage()));
}
}
// public void handleMessage(SPacketMessage packetIn)
// {
// NetHandler.checkThread(packetIn, this, this.gameController);

View file

@ -12,52 +12,50 @@ import java.util.Set;
public abstract class SmeltingRegistry {
private static final Map<ItemStack, ItemStack> smeltingList = Maps.<ItemStack, ItemStack>newHashMap();
private static final Map<ItemStack, Float> experienceList = Maps.<ItemStack, Float>newHashMap();
private static boolean compareItemStacks(ItemStack stack1, ItemStack stack2) {
return stack2.getItem() == stack1.getItem();
}
static void register() {
add(Items.sand, Items.glass, 0.1F);
add(Items.red_sand, Items.glass, 0.1F);
add(Items.porkchop, Items.cooked_porkchop, 0.35F);
add(Items.beef, Items.cooked_beef, 0.35F);
add(Items.chicken, Items.cooked_chicken, 0.35F);
add(Items.cobblestone, Items.stone, 0.1F);
add(Items.stonebrick, Items.cracked_stonebrick, 0.1F);
add(Items.clay_lump, Items.brick, 0.3F);
add(Items.clay, Items.hardened_clay, 0.35F);
add(Items.hellrock, Items.bloodbrick, 0.1F);
add(Items.sand, Items.glass);
add(Items.red_sand, Items.glass);
add(Items.porkchop, Items.cooked_porkchop);
add(Items.beef, Items.cooked_beef);
add(Items.chicken, Items.cooked_chicken);
add(Items.cobblestone, Items.stone);
add(Items.stonebrick, Items.cracked_stonebrick);
add(Items.clay_lump, Items.brick);
add(Items.clay, Items.hardened_clay);
add(Items.hellrock, Items.bloodbrick);
for(ItemFishFood.FishType fish : ItemFishFood.FishType.values()) {
add(ItemRegistry.byName(fish.getName()), ItemRegistry.byName("cooked_" + fish.getName()), 0.35F);
add(ItemRegistry.byName(fish.getName()), ItemRegistry.byName("cooked_" + fish.getName()));
}
for(OreType ore : OreType.values()) {
Item item = ItemRegistry.byName(ore.item);
add(ItemRegistry.byName(ore.name + "_ore"), item, ((float)ore.experience) / 3.0F);
add(ItemRegistry.byName(ore.name + "_ore"), item);
}
for(MetalType metal : MetalType.values()) {
Item item = ItemRegistry.byName(metal.isPowder ? (metal.name + "_powder") : (metal.name + "_ingot"));
add(ItemRegistry.byName(metal.name + "_ore"), item, 0.7F);
add(ItemRegistry.byName(metal.name + "_ore"), item);
}
for(WoodType wood : WoodType.values()) {
add(ItemRegistry.byName(wood.getName() + "_log"), Items.charcoal, 0.15F);
add(ItemRegistry.byName(wood.getName() + "_log"), Items.charcoal);
}
for(MineralType mineral : MineralType.values()) {
Item item = ItemRegistry.byName(mineral.name);
add(ItemRegistry.byName(mineral.name + "_ore"), item, ((float)mineral.experience) / 10.0F);
add(ItemRegistry.byName(mineral.name + "_ore"), item);
}
}
private static void add(Item input, Item output, float experience) {
add(new ItemStack(input), new ItemStack(output), experience);
private static void add(Item input, Item output) {
add(new ItemStack(input), new ItemStack(output));
}
private static void add(ItemStack input, ItemStack stack, float experience) {
private static void add(ItemStack input, ItemStack stack) {
smeltingList.put(input, stack);
experienceList.put(stack, Float.valueOf(experience));
}
public static ItemStack getResult(ItemStack stack) {
@ -70,16 +68,6 @@ public abstract class SmeltingRegistry {
return null;
}
public static float getExperience(ItemStack stack) {
for(Entry<ItemStack, Float> entry : experienceList.entrySet()) {
if(compareItemStacks(stack, (ItemStack)entry.getKey())) {
return ((Float)entry.getValue()).floatValue();
}
}
return 0.0F;
}
public static void getSmeltingList(Set<Item> set) {
for(ItemStack itemstack : smeltingList.values()) {
set.add(itemstack.getItem());

View file

@ -19,7 +19,7 @@ public class ContainerFurnace extends Container
this.tileFurnace = furnaceInventory;
this.addSlotToContainer(new Slot(furnaceInventory, 0, 56, 17));
this.addSlotToContainer(new SlotFurnaceFuel(furnaceInventory, 1, 56, 53));
this.addSlotToContainer(new SlotFurnaceOutput(playerInventory, furnaceInventory, 2, 116, 35));
this.addSlotToContainer(new SlotOutput(furnaceInventory, 2, 116, 35));
for (int i = 0; i < 3; ++i)
{

View file

@ -11,6 +11,8 @@ public class ContainerTile extends Container
private final IInventory tileInv;
private final Device tile;
private int temperature;
private int progress;
private int total;
private Status status = Status.OFF;
private final int[] resources;
@ -20,17 +22,27 @@ public class ContainerTile extends Container
this.tile = tile;
this.resources = new int[tile.getNumResources()];
tileInv.openInventory(player);
int i = 71;
int i = 112;
for (int j = 0; j < tileInv.getSizeInventory(); ++j)
int input = 0;
int output = 0;
for (int idx = 0; idx < tileInv.getSizeInventory(); ++idx)
{
final int index = j;
this.addSlotToContainer(new Slot(tileInv, j, 8 + j * 18, 40) {
final int index = idx;
this.addSlotToContainer(new Slot(tileInv, idx, 8 + (this.tile.isInput(index) ? input : 8 - output) * 18, 81) {
public boolean isItemValid(ItemStack stack)
{
return ContainerTile.this.tile.isItemValidForSlot(index, stack);
}
public boolean canCheatItem() {
return ContainerTile.this.tile.isInput(index);
}
});
if(this.tile.isInput(index))
++input;
else
++output;
}
for (int l = 0; l < 3; ++l)
@ -101,7 +113,9 @@ public class ContainerTile extends Container
{
super.onCraftGuiOpened(listener);
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
listener.sendProperty(this, this.resources.length + 1, this.tile.getStatus().ordinal());
listener.sendProperty(this, this.resources.length + 1, this.tile.getProgress());
listener.sendProperty(this, this.resources.length + 2, this.tile.getTotal());
listener.sendProperty(this, this.resources.length + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
}
@ -112,6 +126,10 @@ public class ContainerTile extends Container
if(id == this.resources.length)
this.tile.setTemperature(data);
else if(id == this.resources.length + 1)
this.tile.setProgress(data);
else if(id == this.resources.length + 2)
this.tile.setTotal(data);
else if(id == this.resources.length + 3)
this.tile.setStatus(Status.values()[data % Status.values().length]);
else
this.tile.getResource(id).setValue(data);
@ -126,8 +144,12 @@ public class ContainerTile extends Container
IPlayer listener = this.crafters.get(i);
if(this.temperature != this.tile.getTemperature())
listener.sendProperty(this, this.resources.length, this.tile.getTemperature());
if(this.progress != this.tile.getProgress())
listener.sendProperty(this, this.resources.length + 1, this.tile.getProgress());
if(this.total != this.tile.getTotal())
listener.sendProperty(this, this.resources.length + 2, this.tile.getTotal());
if(this.status != this.tile.getStatus())
listener.sendProperty(this, this.resources.length + 1, this.tile.getStatus().ordinal());
listener.sendProperty(this, this.resources.length + 3, this.tile.getStatus().ordinal());
for(int z = 0; z < this.resources.length; z++) {
if(this.resources[z] != this.tile.getResource(z).getValue())
listener.sendProperty(this, z, this.tile.getResource(z).getValue());
@ -135,6 +157,8 @@ public class ContainerTile extends Container
}
this.temperature = this.tile.getTemperature();
this.progress = this.tile.getProgress();
this.total = this.tile.getTotal();
this.status = this.tile.getStatus();
for(int z = 0; z < this.resources.length; z++) {
this.resources[z] = this.tile.getResource(z).getValue();

View file

@ -11,9 +11,6 @@ public class SlotFurnaceFuel extends Slot
super(inventoryIn, slotIndex, xPosition, yPosition);
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack stack)
{
return TileEntityFurnace.isItemFuel(stack) || isBucket(stack);

View file

@ -1,112 +0,0 @@
package common.inventory;
import common.entity.item.EntityXp;
import common.entity.npc.EntityNPC;
import common.init.SmeltingRegistry;
import common.item.ItemStack;
import common.util.ExtMath;
import common.vars.Vars;
public class SlotFurnaceOutput extends Slot
{
/** The player that is using the GUI where this slot resides. */
private EntityNPC thePlayer;
private int smelted;
public SlotFurnaceOutput(EntityNPC player, IInventory inventoryIn, int slotIndex, int xPosition, int yPosition)
{
super(inventoryIn, slotIndex, xPosition, yPosition);
this.thePlayer = player;
}
/**
* Check if the stack is a valid item for this slot. Always true beside for the armor slots.
*/
public boolean isItemValid(ItemStack stack)
{
return false;
}
/**
* Decrease the size of the stack in slot (first int arg) by the amount of the second int arg. Returns the new
* stack.
*/
public ItemStack decrStackSize(int amount)
{
if (this.getHasStack())
{
this.smelted += Math.min(amount, this.getStack().getSize());
}
return super.decrStackSize(amount);
}
public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack)
{
this.onCrafting(stack);
super.onPickupFromSlot(playerIn, stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood. Typically increases an
* internal count then calls onCrafting(item).
*/
protected void onCrafting(ItemStack stack, int amount)
{
this.smelted += amount;
this.onCrafting(stack);
}
/**
* the itemStack passed in is the output - ie, iron ingots, and pickaxes, not ore and wood.
*/
protected void onCrafting(ItemStack stack)
{
// stack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.smelted);
if (!this.thePlayer.worldObj.client && Vars.smeltingXP)
{
int xp = this.smelted;
float smeltXp = SmeltingRegistry.getExperience(stack);
if (smeltXp == 0.0F)
{
xp = 0;
}
else if (smeltXp < 1.0F)
{
int mxp = ExtMath.floorf((float)xp * smeltXp);
if (mxp < ExtMath.ceilf((float)xp * smeltXp) && Math.random() < (double)((float)xp * smeltXp - (float)mxp))
{
++mxp;
}
xp = mxp;
}
while (xp > 0)
{
int split = EntityXp.getXPSplit(xp);
xp -= split;
this.thePlayer.worldObj.spawnEntityInWorld(new EntityXp(this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, split));
}
}
this.smelted = 0;
// if (stack.getItem() == Items.iron_ingot)
// {
// this.thePlayer.triggerAchievement(AchievementList.acquireIron);
// }
//
// if (stack.getItem() == Items.cooked_fish)
// {
// this.thePlayer.triggerAchievement(AchievementList.cookFish);
// }
}
public boolean canCheatItem() {
return false;
}
}

View file

@ -0,0 +1,17 @@
package common.inventory;
import common.item.ItemStack;
public class SlotOutput extends Slot {
public SlotOutput(IInventory inventoryIn, int slotIndex, int xPosition, int yPosition) {
super(inventoryIn, slotIndex, xPosition, yPosition);
}
public boolean isItemValid(ItemStack stack) {
return false;
}
public boolean canCheatItem() {
return false;
}
}

View file

@ -46,7 +46,6 @@ import common.packet.SPacketEntityVelocity;
import common.packet.SPacketHeldItemChange;
import common.packet.SPacketJoinGame;
import common.packet.SPacketKeepAlive;
import common.packet.SPacketLoading;
import common.packet.SPacketMapChunkBulk;
import common.packet.SPacketMessage;
import common.packet.SPacketMultiBlockChange;
@ -97,7 +96,6 @@ public interface IClientPlayer extends NetHandler {
void handleDisconnect(SPacketDisconnect packet);
void handleCollectItem(SPacketCollectItem packet);
void handleMessage(SPacketMessage packet);
void handleLoading(SPacketLoading packet);
void handleAnimation(SPacketAnimation packet);
void handleSpawnMob(SPacketSpawnMob packet);
void handleTimeUpdate(SPacketTimeUpdate packet);

View file

@ -83,7 +83,6 @@ import common.packet.SPacketEntityVelocity;
import common.packet.SPacketHeldItemChange;
import common.packet.SPacketJoinGame;
import common.packet.SPacketKeepAlive;
import common.packet.SPacketLoading;
import common.packet.SPacketMapChunkBulk;
import common.packet.SPacketMessage;
import common.packet.SPacketMultiBlockChange;
@ -181,7 +180,6 @@ public enum PacketRegistry {
this.server(SPacketDimensionName.class);
this.server(SPacketCharacterList.class);
this.server(SPacketServerTick.class);
this.server(SPacketLoading.class);
this.server(SPacketDisplayForm.class);
this.server(SPacketServerConfig.class);
this.server(SPacketCelestials.class);

View file

@ -1,70 +0,0 @@
package common.packet;
import java.io.IOException;
import common.network.IClientPlayer;
import common.network.Packet;
import common.network.PacketBuffer;
public class SPacketLoading implements Packet<IClientPlayer> {
private String message;
private String task;
private int total = -1;
private int progress = -2;
public SPacketLoading() {
}
public SPacketLoading(String message) {
this.message = message;
}
public SPacketLoading(String task, int total) {
this.task = task;
this.total = total;
}
public SPacketLoading(int progress) {
this.progress = progress;
}
public void readPacketData(PacketBuffer buf) throws IOException {
this.message = buf.readString(128);
this.message = this.message != null && this.message.isEmpty() ? null : this.message;
if(this.message == null) {
this.task = buf.readString(128);
this.task = this.task != null && this.task.isEmpty() ? null : this.task;
this.total = buf.readInt();
this.progress = buf.readInt();
}
}
public void writePacketData(PacketBuffer buf) throws IOException {
buf.writeString(this.message == null ? "" : this.message);
if(this.message == null) {
buf.writeString(this.task == null ? "" : this.task);
buf.writeInt(this.total);
buf.writeInt(this.progress);
}
}
public void processPacket(IClientPlayer handler) {
handler.handleLoading(this);
}
public String getMessage() {
return this.message;
}
public String getTask() {
return this.task;
}
public int getTotal() {
return this.total;
}
public int getProgress() {
return this.progress;
}
}

View file

@ -15,7 +15,7 @@ import common.util.Color;
public abstract class Device extends TileEntity implements IInventory, ITickable {
public static enum Status {
OFF(Color.DARK_GRAY, "Inaktiv"),
OFF(Color.GRAY, "Inaktiv"),
COOLING(Color.YELLOW, "Abkühlen ..."),
RUNNING(Color.GREEN, "Aktiv"),
OVERHEAT(Color.RED, "Überhitzt!"),
@ -33,11 +33,15 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
protected final ItemStack[] inventory;
protected final MachineResource[] resources;
protected final Random rand = new Random();
protected final int inputs;
protected int temperature;
protected int progress = -1;
protected int total;
protected Status status = Status.OFF;
protected Device(int slots, MachineResource ... resources) {
this.inventory = new ItemStack[slots];
protected Device(int inputs, int outputs, MachineResource ... resources) {
this.inventory = new ItemStack[inputs + outputs];
this.inputs = inputs;
this.resources = resources;
}
@ -49,10 +53,14 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
return -1;
}
protected int getMaxTemp() {
public int getMaxTemp() {
return Integer.MAX_VALUE;
}
public boolean hasTemperature() {
return false;
}
protected abstract boolean executeFunction();
public MachineResource getResource(int slot) {
@ -71,6 +79,26 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
this.temperature = temp;
}
public int getProgress() {
return this.progress;
}
public void setProgress(int progress) {
this.progress = progress;
}
public int getTotal() {
return this.total;
}
public void setTotal(int total) {
this.total = total;
}
public boolean hasProgress() {
return false;
}
public Status getStatus() {
return this.status;
}
@ -101,7 +129,12 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
this.resources[i].fromTag(list.get(i));
}
this.temperature = tag.getInt("Temperature");
if(this.hasTemperature())
this.temperature = tag.getInt("Temperature");
if(this.hasProgress()) {
this.progress = tag.getInt("Progress");
this.total = tag.getInt("Total");
}
this.status = Status.values()[(int)tag.getByte("Status") % Status.values().length];
}
@ -127,7 +160,12 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
}
tag.setList("Resources", list);
tag.setInt("Temperature", this.temperature);
if(this.hasTemperature())
tag.setInt("Temperature", this.temperature);
if(this.hasProgress()) {
tag.setInt("Progress", this.progress);
tag.setInt("Total", this.total);
}
tag.setByte("Status", (byte)this.status.ordinal());
}
@ -196,7 +234,7 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return true;
return index < this.inputs;
}
public void detonate() {
@ -208,83 +246,75 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
if(this.worldObj != null && !this.worldObj.client && this.status != Status.BROKEN) {
int envTemp = (int)this.worldObj.getTemperatureC(this.getPos());
if(this.executeFunction()) {
if(this.getTempIncrement() < 0)
this.temperature = envTemp;
else
this.temperature += this.getTempIncrement();
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING;
if(this.temperature > this.getMaxTemp()) {
this.status = Status.BROKEN;
this.markDirty();
this.detonate();
return;
if(this.hasTemperature()) {
if(this.getTempIncrement() < 0)
this.temperature = envTemp;
else
this.temperature += this.getTempIncrement();
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT : Status.RUNNING;
if(this.temperature > this.getMaxTemp()) {
this.status = Status.BROKEN;
this.markDirty();
this.detonate();
return;
}
else {
this.markDirty();
}
}
else {
this.status = Status.RUNNING;
this.markDirty();
}
}
else {
int dec = this.getTempDecrement();
if(dec != 0) {
int prev = this.temperature;
if(dec < 0)
this.temperature = envTemp;
else
this.temperature -= dec;
this.temperature = ExtMath.clampi(this.temperature, envTemp, Integer.MAX_VALUE);
if(prev != this.temperature)
if(this.hasTemperature()) {
int dec = this.getTempDecrement();
if(dec != 0) {
int prev = this.temperature;
if(dec < 0)
this.temperature = envTemp;
else
this.temperature -= dec;
this.temperature = ExtMath.clampi(this.temperature, envTemp, Integer.MAX_VALUE);
if(prev != this.temperature)
this.markDirty();
else
dec = 0;
}
Status prev = this.status;
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT :
(this.temperature == envTemp ? Status.OFF : Status.COOLING);
if(dec == 0 && prev != this.status) {
this.markDirty();
else
dec = 0;
}
}
Status prev = this.status;
this.status = this.temperature >= (this.getMaxTemp() * 9) / 10 ? Status.OVERHEAT :
(this.temperature == envTemp ? Status.OFF : Status.COOLING);
if(dec == 0 && prev != this.status) {
else if(this.status != Status.OFF) {
this.status = Status.OFF;
this.markDirty();
}
}
if(this.temperature < envTemp) {
if(this.hasTemperature() && this.temperature < envTemp) {
this.temperature = envTemp;
this.markDirty();
}
}
}
public boolean isEmpty(int slot) {
if(slot == -1) {
for(ItemStack itemstack : this.inventory) {
if(itemstack != null)
return false;
}
return true;
}
else {
return this.inventory[slot] == null || this.inventory[slot].isEmpty();
}
public boolean isInput(int slot) {
return slot < this.inputs;
}
public boolean hasAmount(int slot, int amount) {
if(slot == -1) {
int n = 0;
for(ItemStack itemstack : this.inventory) {
if(itemstack != null && !itemstack.isEmpty())
n += itemstack.getSize();
}
return n >= amount;
}
else {
return this.inventory[slot] != null && this.inventory[slot].getSize() >= amount;
}
public boolean isInputEmpty(int slot) {
return this.inventory[slot] == null || this.inventory[slot].isEmpty();
}
public boolean isFull() {
for(ItemStack itemstack : this.inventory) {
if(itemstack == null || !itemstack.isFull()) {
return false;
}
}
return true;
public boolean hasInput(int slot, int amount) {
return this.inventory[slot] != null && this.inventory[slot].getSize() >= amount;
}
public boolean isOutputFull(int slot) {
return this.inventory[slot - this.inputs] != null && this.inventory[slot - this.inputs].isFull();
}
public int getField(int id) {
@ -312,5 +342,7 @@ public abstract class Device extends TileEntity implements IInventory, ITickable
return 0x8080ff;
}
public abstract String formatDisplay(ContainerTile inv);
public String formatDisplay(ContainerTile inv) {
return "";
}
}

View file

@ -13,18 +13,18 @@ import common.world.World;
public class DeviceEffectGenerator extends Device {
public DeviceEffectGenerator() {
super(2);
super(2, 0);
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0 ? stack.getItem() instanceof ItemPotion : (index == 1 ? stack.getItem() == Items.blazing_powder : false);
return index == 0 ? stack.getItem() instanceof ItemPotion potion && potion.getEffect() != null : (index == 1 ? stack.getItem() == Items.blazing_powder : false);
}
protected boolean executeFunction() {
if(!this.hasAmount(0, 1) || !this.hasAmount(1, 1) || !(this.getStackInSlot(0).getItem() instanceof ItemPotion potion))
if(!this.hasInput(0, 1) || !this.hasInput(1, 1) || !(this.getStackInSlot(0).getItem() instanceof ItemPotion potion))
return false;
StatusEffect effect = potion.getEffect();
if(effect == null || !this.hasAmount(1, effect.getAmplifier() + 1))
if(effect == null || !this.hasInput(1, effect.getAmplifier() + 1))
return false;
int levels = 4; // TODO: energy + selector (MachineControl)
double r = (double)(levels * 10 + 10);
@ -37,7 +37,7 @@ public class DeviceEffectGenerator extends Device {
if(!entity.hasEffect(effect.getPotion()) || entity.getEffect(effect.getPotion()).getAmplifier() < effect.getAmplifier() || entity.getEffect(effect.getPotion()).getRemaining() < 40) {
entity.addEffect(new StatusEffect(effect.getPotion(), 180, effect.getAmplifier()));
this.decrStackSize(1, effect.getAmplifier() + 1);
if(!this.hasAmount(1, effect.getAmplifier() + 1))
if(!this.hasInput(1, effect.getAmplifier() + 1))
break;
}
}
@ -51,8 +51,7 @@ public class DeviceEffectGenerator extends Device {
public String formatDisplay(ContainerTile inv) {
ItemStack stack = inv.getSlot(0).getStack();
if(stack == null)
return "Kein Trank vorhanden";
return String.format("Effekt: %s",
stack.getItem() instanceof ItemPotion potion ? (potion.getEffect() != null ? potion.getEffect().getEffectName() : "Keiner") : "<?>");
return "Trank einlegen";
return "Gebe Effekt " + (stack.getItem() instanceof ItemPotion potion && potion.getEffect() != null ? potion.getEffect().getEffectName() : "<?>");
}
}

View file

@ -12,7 +12,7 @@ import common.vars.Vars;
public class DeviceMobSpawner extends Device implements ITickable
{
public DeviceMobSpawner() {
super(1);
super(1, 0);
}
private int spawnDelay = 20;
@ -20,6 +20,10 @@ public class DeviceMobSpawner extends Device implements ITickable
private int maxSpawnDelay = 800;
private int spawnRange = 4;
public boolean hasProgress() {
return true;
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0 ? stack.getItem() instanceof ItemMobTemplate || stack.getItem() instanceof ItemCharTemplate : false;
}
@ -27,12 +31,12 @@ public class DeviceMobSpawner extends Device implements ITickable
public String formatDisplay(ContainerTile inv) {
ItemStack stack = inv.getSlot(0).getStack();
if(stack == null)
return "Keine DNA-Probe vorhanden";
return String.format("Erschaffe: %s", stack.getItem() instanceof ItemMobTemplate egg ? EntityRegistry.getEntityName(egg.getSpawnedId()) : ((stack.getItem() instanceof ItemCharTemplate egg ? egg.getCharName() : "<?>")));
return "DNA-Probe einlegen";
return "Erzeuge " + (stack.getItem() instanceof ItemMobTemplate egg ? EntityRegistry.getEntityName(egg.getSpawnedId()) : ((stack.getItem() instanceof ItemCharTemplate egg ? egg.getCharName() : "<?>")));
}
protected boolean executeFunction() {
if(!Vars.mobs || !Vars.spawners || !this.hasAmount(0, 1))
if(!Vars.mobs || !Vars.spawners || !this.hasInput(0, 1))
return false;
if (this.spawnDelay == -1)
this.resetTimer();

View file

@ -4,14 +4,15 @@ import common.init.Items;
import common.inventory.ContainerTile;
import common.item.ItemStack;
import common.tileentity.MachineResource.Type;
import common.util.Color;
public class DeviceTianReactor extends Device {
public DeviceTianReactor() {
super(2, new MachineResource(Type.OUTPUT, "output.energy", 1024, 0, 0));
super(2, 0, new MachineResource(Type.OUTPUT, "Gespeichert: $amount/$capacity TF", 1024, 0, 0));
}
protected boolean executeFunction() {
if(!this.hasAmount(0, 2))
if(!this.hasInput(0, 2))
return false;
if(this.rand.rarity(5))
return true;
@ -21,28 +22,36 @@ public class DeviceTianReactor extends Device {
return true;
}
public boolean hasTemperature() {
return true;
}
protected int getTempIncrement() {
return this.isEmpty(1) ? this.rand.range(20, 50) : (this.temperature >= this.rand.range(4200, 4250) ? 0 : this.rand.range(10, 15));
return this.isInputEmpty(1) ? this.rand.range(20, 50) : (this.temperature >= this.rand.range(4200, 4250) ? 0 : this.rand.range(10, 15));
}
protected int getTempDecrement() {
return this.isEmpty(1) ? this.rand.chance(0, 1, 3) : this.rand.range(1, 3);
return this.isInputEmpty(1) ? this.rand.chance(0, 1, 3) : this.rand.range(1, 3);
}
public boolean hasProgress() {
return true;
}
public boolean isItemValidForSlot(int index, ItemStack stack) {
return index == 0 ? stack.getItem() == Items.aluminium_ingot : (index == 1 ? stack.getItem() == Items.lead_block : false);
}
protected int getMaxTemp() {
public int getMaxTemp() {
return 8200;
}
public String formatDisplay(ContainerTile inv) {
return String.format("Gespeicherte Energie: %d TF", this.getResource(0).getValue());
}
public void detonate() {
this.worldObj.setBlockToAir(getPos());
this.worldObj.newExplosion(this.getXPos(), this.getYPos(), this.getZPos(), 120);
}
public String formatDisplay(ContainerTile inv) {
return this.status == Status.OVERHEAT ? Color.RED + "!!! GEFAHR !!! Reaktor ist\n" + Color.RED + "überhitzt und muss sofort\n" + Color.RED + "heruntergekühlt werden,\n" + Color.RED + "sonst droht Detonation!" : "";
}
}

View file

@ -105,4 +105,8 @@ public class MachineResource {
public boolean isAtCapacity(boolean over) {
return this.amount >= (this.capacity + (over ? this.overcharge : 0));
}
public String format() {
return this.name.replace("$amount", "" + this.amount).replace("$undercharge", "" + this.undercharge).replace("$overcharge", "" + this.overcharge).replace("$capacity", "" + this.capacity).replace("$entropy", "" + this.entropy);
}
}

View file

@ -25,8 +25,6 @@ public abstract class Vars {
public static boolean blockXP = true;
@Var(name = "dropBreedingXP")
public static boolean breedingXP = true;
@Var(name = "dropSmeltingXP")
public static boolean smeltingXP = true;
@Var(name = "dropFishingXP")
public static boolean fishingXP = true;
@Var(name = "dropMobXP")

View file

@ -93,7 +93,6 @@ import common.packet.SPacketDestroyEntities;
import common.packet.SPacketDisconnect;
import common.packet.SPacketDisplayForm;
import common.packet.SPacketKeepAlive;
import common.packet.SPacketLoading;
import common.packet.SPacketMapChunkBulk;
import common.packet.SPacketMessage;
import common.packet.SPacketPlayerPosLook;
@ -281,18 +280,6 @@ public class Player extends User implements Executor, IPlayer
return true;
}
public void displayLoading(String message) {
this.sendPacket(new SPacketLoading(message));
}
public void sendTask(String task, int total) {
this.sendPacket(new SPacketLoading(task, total));
}
public void sendProgress(int progress) {
this.sendPacket(new SPacketLoading(progress));
}
public void onEntityDeath() {
this.deathPos = this.entity.getPos();
this.entity.sendDeathMessage();