improve renaming and cheats

This commit is contained in:
Sen 2025-07-05 14:03:49 +02:00
parent 4d406a70e1
commit 7e9673dc25
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
36 changed files with 346 additions and 186 deletions

View file

@ -53,6 +53,7 @@ import client.gui.container.GuiContainer;
import client.gui.container.GuiInventory; import client.gui.container.GuiInventory;
import client.gui.element.Area; import client.gui.element.Area;
import client.gui.ingame.GuiGameOver; import client.gui.ingame.GuiGameOver;
import client.gui.ingame.GuiRename;
import client.network.ClientLoginHandler; import client.network.ClientLoginHandler;
import client.network.ClientPlayer; import client.network.ClientPlayer;
import client.network.DummyConnection; import client.network.DummyConnection;
@ -261,6 +262,12 @@ public class Client implements IThreadListener {
} }
} }
public static class StyleFunction implements EnumFunction<Style> {
public void apply(EnumVar cv, Style value) {
Client.CLIENT.rescale();
}
}
private interface DebugRunner { private interface DebugRunner {
void execute(Keysym key); void execute(Keysym key);
} }
@ -470,7 +477,7 @@ public class Client implements IThreadListener {
@Variable(name = "con_autoclose", category = CVarCategory.CONSOLE, display = "Schließen") @Variable(name = "con_autoclose", category = CVarCategory.CONSOLE, display = "Schließen")
public boolean conAutoclose = true; public boolean conAutoclose = true;
public boolean interrupted; public boolean interrupted;
@Variable(name = "gui_theme", category = CVarCategory.GUI, display = "Oberflächen-Design") @Variable(name = "gui_theme", category = CVarCategory.GUI, display = "Design", callback = StyleFunction.class)
public Style style = Style.DEFAULT; public Style style = Style.DEFAULT;
@Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen") @Variable(name = "gui_scroll_lines", category = CVarCategory.GUI, min = 1, max = 10, display = "Scrollbreite", unit = "Zeilen")
public int scrollLines = 3; public int scrollLines = 3;
@ -556,7 +563,7 @@ public class Client implements IThreadListener {
} }
public void displayConnecting(ServerInfo server) { public void displayConnecting(ServerInfo server) {
this.displayGuiScreen(GuiLoading.makeWaitTask("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ...")); this.show(GuiLoading.makeWaitTask("Verbinde zu " + (server.getAddress() == null ? "localhost" : server.getAddress()) + ":" + server.getPort() + " ..."));
} }
public void connect(final ServerInfo server) { public void connect(final ServerInfo server) {
@ -612,7 +619,7 @@ public class Client implements IThreadListener {
WorldClient world = new WorldClient(this, Space.INSTANCE); WorldClient world = new WorldClient(this, Space.INSTANCE);
this.loadWorld(world, EntityRegistry.getEntityID(EntityCpu.class)); this.loadWorld(world, EntityRegistry.getEntityID(EntityCpu.class));
this.player.setId(0); this.player.setId(0);
this.displayGuiScreen(null); this.show(null);
this.player.flying = true; this.player.flying = true;
this.player.noclip = true; this.player.noclip = true;
this.player.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1)); this.player.addEffect(new PotionEffect(Potion.FLYING, Integer.MAX_VALUE, 1));
@ -720,6 +727,8 @@ public class Client implements IThreadListener {
{ {
if(Bind.THROW.isPressed()) if(Bind.THROW.isPressed())
this.open.dropItem(); this.open.dropItem();
else if(Bind.RENAME.isPressed())
this.open.renameItem();
for(int z = 0; z < this.keyBindsHotbar.length; z++) { for(int z = 0; z < this.keyBindsHotbar.length; z++) {
if(this.keyBindsHotbar[z].isPressed()) if(this.keyBindsHotbar[z].isPressed())
this.open.useHotbar(z); this.open.useHotbar(z);
@ -772,6 +781,11 @@ public class Client implements IThreadListener {
{ {
this.player.dropOneItem(this.ctrl()); this.player.dropOneItem(this.ctrl());
} }
else if(Bind.RENAME.isPressed()) {
ItemStack stack = this.player.getCurrentEquippedItem();
if(stack != null)
this.show(new GuiRename(-1, stack, null));
}
this.primary |= Bind.PRIMARY.isPressed(); this.primary |= Bind.PRIMARY.isPressed();
this.secondary |= Bind.SECONDARY.isPressed(); this.secondary |= Bind.SECONDARY.isPressed();
@ -801,7 +815,7 @@ public class Client implements IThreadListener {
{ {
if (this.player.getHealth() <= 0) if (this.player.getHealth() <= 0)
{ {
this.displayGuiScreen(null); this.show(null);
} }
} }
@ -1294,7 +1308,7 @@ public class Client implements IThreadListener {
// } // }
// } // }
public void displayGuiScreen(Gui gui) public void show(Gui gui)
{ {
if(!this.refreshing) if(!this.refreshing)
this.waitingForFile = false; this.waitingForFile = false;
@ -1548,7 +1562,7 @@ public class Client implements IThreadListener {
inventoryplayer.setCurrentItem(item); inventoryplayer.setCurrentItem(item);
if(this.itemCheat) { if(this.itemCheat) {
this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item), inventoryplayer.currentItem, this.ctrl())); this.player.client.addToSendQueue(new CPacketCheat(new ItemStack(item), -2 - inventoryplayer.currentItem, this.ctrl()));
} }
} }
} }
@ -2110,7 +2124,7 @@ public class Client implements IThreadListener {
this.fb_y = Math.max(this.fb_raw_y / this.scale, MIN_HEIGHT); this.fb_y = Math.max(this.fb_raw_y / this.scale, MIN_HEIGHT);
if(this.open != null) { if(this.open != null) {
this.refreshing = true; this.refreshing = true;
this.displayGuiScreen(this.open); this.show(this.open);
this.refreshing = false; this.refreshing = false;
} }
} }
@ -2271,7 +2285,7 @@ public class Client implements IThreadListener {
this.sync(this.sync); this.sync(this.sync);
// this.startSound(true); // this.startSound(true);
this.getVar("tic_target").setDefault(); this.getVar("tic_target").setDefault();
this.displayGuiScreen(GuiMenu.INSTANCE); this.show(GuiMenu.INSTANCE);
Log.SYSTEM.info("Client gestartet in " + String.format("%.1f", (double)(System.currentTimeMillis() - time) / 1000.0) + " Sekunden"); Log.SYSTEM.info("Client gestartet in " + String.format("%.1f", (double)(System.currentTimeMillis() - time) / 1000.0) + " Sekunden");
while(!this.interrupted) { while(!this.interrupted) {
@ -2348,7 +2362,7 @@ public class Client implements IThreadListener {
public void disconnected(String msg) { public void disconnected(String msg) {
Log.NETWORK.info("Getrennt: %s", msg); Log.NETWORK.info("Getrennt: %s", msg);
this.unload(true); this.unload(true);
this.displayGuiScreen(new GuiInfo("Von Server getrennt", TextColor.RED + "Verbindung zum Server wurde getrennt\n\n" + TextColor.RESET + msg)); this.show(new GuiInfo("Von Server getrennt", TextColor.RED + "Verbindung zum Server wurde getrennt\n\n" + TextColor.RESET + msg));
} }
@ -2363,32 +2377,32 @@ public class Client implements IThreadListener {
} }
if(!(this.open instanceof GuiLoading)) { if(!(this.open instanceof GuiLoading)) {
if(!(this.open instanceof GuiConsole) && Bind.CONSOLE.isPressed()) { if(!(this.open instanceof GuiConsole) && Bind.CONSOLE.isPressed()) {
this.displayGuiScreen(GuiConsole.INSTANCE.setFull(true)); this.show(GuiConsole.INSTANCE.setFull(true));
} }
else if(this.open == null && Bind.COMMAND.isPressed()) { else if(this.open == null && Bind.COMMAND.isPressed()) {
this.displayGuiScreen(GuiConsole.INSTANCE.setFull(false)); this.show(GuiConsole.INSTANCE.setFull(false));
} }
// if(this.theWorld != null && this.open == null && Bind.COMMAND.isPressed()) { // if(this.theWorld != null && this.open == null && Bind.COMMAND.isPressed()) {
// this.displayGuiScreen(GuiChat.INSTANCE); // this.displayGuiScreen(GuiChat.INSTANCE);
// } // }
if(this.world != null && Bind.MENU.isPressed()) { if(this.world != null && Bind.MENU.isPressed()) {
if(this.open != (this.charEditor ? GuiChar.INSTANCE : null)) if(this.open != (this.charEditor ? GuiChar.INSTANCE : null))
this.displayGuiScreen(this.charEditor ? GuiChar.INSTANCE : null); this.show(this.charEditor ? GuiChar.INSTANCE : null);
else else
this.displayGuiScreen(GuiMenu.INSTANCE); this.show(GuiMenu.INSTANCE);
} }
else if(this.world == null && !(this.open instanceof GuiMenu) && Bind.MENU.isPressed()) { else if(this.world == null && !(this.open instanceof GuiMenu) && Bind.MENU.isPressed()) {
this.displayGuiScreen(GuiMenu.INSTANCE); this.show(GuiMenu.INSTANCE);
} }
if(this.world != null && !this.charEditor && Bind.INVENTORY.isPressed()) { if(this.world != null && !this.charEditor && Bind.INVENTORY.isPressed()) {
if(this.open instanceof GuiContainer) { if(this.open instanceof GuiContainer) {
this.displayGuiScreen(null); this.show(null);
} }
else if(this.open == null) { else if(this.open == null) {
if(this.player.isRiding() && this.player.vehicle instanceof EntityHorse) if(this.player.isRiding() && this.player.vehicle instanceof EntityHorse)
this.player.sendHorseInventory(); this.player.sendHorseInventory();
else else
this.displayGuiScreen(/* this.itemCheat ? new GuiCheat() : */ new GuiInventory(this.player)); this.show(/* this.itemCheat ? new GuiCheat() : */ new GuiInventory(this.player));
} }
} }
} }
@ -2506,7 +2520,7 @@ public class Client implements IThreadListener {
if(this.world != null && this.getNetHandler() != null) if(this.world != null && this.getNetHandler() != null)
this.getNetHandler().getConnection().closeChannel("Quitting"); this.getNetHandler().getConnection().closeChannel("Quitting");
this.unloadWorld(); this.unloadWorld();
this.displayGuiScreen(GuiMenu.INSTANCE); this.show(GuiMenu.INSTANCE);
} }
private void startSound(boolean load) { private void startSound(boolean load) {
@ -2552,7 +2566,7 @@ public class Client implements IThreadListener {
this.registerDebug(Keysym.H, "Hilfe zu Tastenkombinationen anzeigen", new DebugRunner() { this.registerDebug(Keysym.H, "Hilfe zu Tastenkombinationen anzeigen", new DebugRunner() {
public void execute(Keysym key) { public void execute(Keysym key) {
String bind = Bind.CHEAT.getInput() == null ? "n/a" : Bind.CHEAT.getInput().getDisplay(); String bind = Bind.CHEAT.getInput() == null ? "n/a" : Bind.CHEAT.getInput().getDisplay();
Client.this.displayGuiScreen(new GuiInfo("Hilfe zu Tastenkombinationen", TextColor.DGREEN + "" + Client.this.debug.size() + " Tastenkombinationen stehen zur Verfügung:\n" + Client.this.show(new GuiInfo("Hilfe zu Tastenkombinationen", TextColor.DGREEN + "" + Client.this.debug.size() + " Tastenkombinationen stehen zur Verfügung:\n" +
Util.buildLines(new Function<DebugFunction, String>() { Util.buildLines(new Function<DebugFunction, String>() {
public String apply(DebugFunction func) { public String apply(DebugFunction func) {
return TextColor.CYAN + bind + TextColor.RED + "+" + TextColor.GREEN + func.key.getDisplay() + TextColor.GRAY + " - " + TextColor.YELLOW + func.help; return TextColor.CYAN + bind + TextColor.RED + "+" + TextColor.GREEN + func.key.getDisplay() + TextColor.GRAY + " - " + TextColor.YELLOW + func.help;

View file

@ -67,6 +67,9 @@ public abstract class Gui {
public void dropItem() { public void dropItem() {
} }
public void renameItem() {
}
public void drawBackground() { public void drawBackground() {
} }

View file

@ -285,7 +285,7 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
if(this.selectedElement < 0) if(this.selectedElement < 0)
this.elements.add(server); this.elements.add(server);
this.save(); this.save();
this.gm.displayGuiScreen(this); this.gm.show(this);
} }
public boolean isNameTaken(String name) { public boolean isNameTaken(String name) {
@ -349,7 +349,7 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
if(button == this.deleteButton) { if(button == this.deleteButton) {
if(this.selectedElement >= 0) { if(this.selectedElement >= 0) {
this.elements.remove(this.selectedElement); this.elements.remove(this.selectedElement);
this.gm.displayGuiScreen(this); this.gm.show(this);
} }
} }
else if(button == this.selectButton) { else if(button == this.selectButton) {
@ -361,18 +361,18 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
} }
else if(button == this.createButton) { else if(button == this.createButton) {
this.setSelected(-1); this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo("", "", -1, "", "", "", null, -1L, null, false))); this.gm.show(new GuiServer(new ServerInfo("", "", -1, "", "", "", null, -1L, null, false)));
} }
else if(button == this.editButton) { else if(button == this.editButton) {
ServerInfo server = this.getSelected(); ServerInfo server = this.getSelected();
if(server != null) if(server != null)
this.gm.displayGuiScreen(new GuiServer(server)); this.gm.show(new GuiServer(server));
} }
else if(button == this.copyButton) { else if(button == this.copyButton) {
ServerInfo server = this.getSelected(); ServerInfo server = this.getSelected();
if(server != null) { if(server != null) {
this.setSelected(-1); this.setSelected(-1);
this.gm.displayGuiScreen(new GuiServer(new ServerInfo(server.name, server.address, server.port, server.user, server.password, server.access, server.keypair, -1L, null, server.enforceEncryption))); this.gm.show(new GuiServer(new ServerInfo(server.name, server.address, server.port, server.user, server.password, server.access, server.keypair, -1L, null, server.enforceEncryption)));
} }
} }
} }

View file

@ -127,7 +127,7 @@ public class GuiConsole extends Gui implements FieldCallback {
this.inputField.setText(""); this.inputField.setText("");
if((this.gm.conAutoclose || !this.full) && this.gm.world != null) if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
} }

View file

@ -62,7 +62,7 @@ public class GuiMenu extends Gui {
GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!"); GuiMenu.this.splashLabel.setText(TextColor.VIOLET + "Hax!");
} }
else { else {
GuiMenu.this.gm.displayGuiScreen(GuiConnect.INSTANCE); GuiMenu.this.gm.show(GuiConnect.INSTANCE);
} }
} }
}, "Server beitreten")); }, "Server beitreten"));
@ -71,13 +71,13 @@ public class GuiMenu extends Gui {
if(GuiMenu.this.hacked == 8) if(GuiMenu.this.hacked == 8)
GuiMenu.this.hacked++; GuiMenu.this.hacked++;
else else
GuiMenu.this.gm.displayGuiScreen(GuiServer.INSTANCE); GuiMenu.this.gm.show(GuiServer.INSTANCE);
} }
}, "Schnellverbindung")); }, "Schnellverbindung"));
this.add(new NavButton(0, 40, 180, 0, GuiOptions.getPage(), "Einstellungen")); this.add(new NavButton(0, 40, 180, 0, GuiOptions.getPage(), "Einstellungen"));
this.infoButton = this.add(new ActButton(0, 60, 180, 0, new ButtonCallback() { this.infoButton = this.add(new ActButton(0, 60, 180, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
GuiMenu.this.gm.displayGuiScreen(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE); GuiMenu.this.gm.show(GuiMenu.this.hacked == 10 ? GuiInfo.HAX : GuiInfo.INSTANCE);
} }
}, "Info / Mitwirkende") { }, "Info / Mitwirkende") {
public void drawHover() { public void drawHover() {

View file

@ -113,9 +113,9 @@ public class GuiServer extends Gui implements FieldCallback {
final PublicKey key = GuiServer.this.serverKey; final PublicKey key = GuiServer.this.serverKey;
final String digest = GuiServer.this.keyDigest; final String digest = GuiServer.this.keyDigest;
final String sdigest = GuiServer.this.serverDigest; final String sdigest = GuiServer.this.serverDigest;
GuiServer.this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() { GuiServer.this.gm.show(new GuiConfirm(new GuiConfirm.Callback() {
public void confirm(boolean confirmed) { public void confirm(boolean confirmed) {
GuiServer.this.gm.displayGuiScreen(GuiServer.this); GuiServer.this.gm.show(GuiServer.this);
GuiServer.this.nameBox.setText(name); GuiServer.this.nameBox.setText(name);
GuiServer.this.addrBox.setText(addr); GuiServer.this.addrBox.setText(addr);
GuiServer.this.portBox.setText(port); GuiServer.this.portBox.setText(port);

View file

@ -26,16 +26,16 @@ public enum Style implements Identifyable, Displayable {
public int fill_top; public int fill_top;
@Variable(type = IntType.COLOR, name = "color_button_btm", category = CVarCategory.GUI, display = "Knopf unten") @Variable(type = IntType.COLOR, name = "color_button_btm", category = CVarCategory.GUI, display = "Knopf unten")
public int fill_btm; public int fill_btm;
@Variable(type = IntType.COLOR, name = "color_textbox_top", category = CVarCategory.GUI, display = "Textfeld oben") @Variable(type = IntType.COLOR, name = "color_textbox_top", category = CVarCategory.GUI, display = "Eingabe oben")
public int field_top; public int field_top;
@Variable(type = IntType.COLOR, name = "color_textbox_btm", category = CVarCategory.GUI, display = "Textfeld unten") @Variable(type = IntType.COLOR, name = "color_textbox_btm", category = CVarCategory.GUI, display = "Eingabe unten")
public int field_btm; public int field_btm;
@Variable(type = IntType.COLOR, name = "color_label_text", category = CVarCategory.GUI, display = "Beschriftung") @Variable(type = IntType.COLOR, name = "color_label_text", category = CVarCategory.GUI, display = "Beschriftung")
public int text_label; public int text_label;
@Variable(type = IntType.COLOR, name = "color_button_text", category = CVarCategory.GUI, display = "Knopf Text") @Variable(type = IntType.COLOR, name = "color_button_text", category = CVarCategory.GUI, display = "Knopf Text")
public int text_base; public int text_base;
@Variable(type = IntType.COLOR, name = "color_textbox_text", category = CVarCategory.GUI, display = "Textfeld Text") @Variable(type = IntType.COLOR, name = "color_textbox_text", category = CVarCategory.GUI, display = "Eingabe Text")
public int text_field; public int text_field;
static { static {

View file

@ -243,7 +243,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public static class FilterFunction implements EnumFunction<FilterType> { public static class FilterFunction implements EnumFunction<FilterType> {
public void apply(EnumVar cv, FilterType value) { public void apply(EnumVar cv, FilterType value) {
if(Client.CLIENT.open instanceof GuiChar) if(Client.CLIENT.open instanceof GuiChar)
Client.CLIENT.displayGuiScreen(Client.CLIENT.open); Client.CLIENT.show(Client.CLIENT.open);
} }
} }
@ -284,7 +284,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() { GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) { public void selected(File file) {
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false)) if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, false))
GuiChar.this.gm.displayGuiScreen(GuiChar.this); GuiChar.this.gm.show(GuiChar.this);
} }
}); });
} }
@ -294,7 +294,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() { GuiChar.this.gm.showFileDialog(FileMode.FILE_LOAD_MULTI, "Skin konvertieren (schlank)", TEXTURE_FOLDER, new FileCallback() {
public void selected(File file) { public void selected(File file) {
if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true)) if(SkinConverter.convertSkin(file, TEXTURE_FOLDER, true))
GuiChar.this.gm.displayGuiScreen(GuiChar.this); GuiChar.this.gm.show(GuiChar.this);
} }
}); });
} }
@ -302,7 +302,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
this.addSelector("char_filter_species", 392, 12, 250, 0); this.addSelector("char_filter_species", 392, 12, 250, 0);
this.add(new ActButton(2, height - 30, 193, 0, new ButtonCallback() { this.add(new ActButton(2, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
GuiChar.this.gm.displayGuiScreen(GuiChar.this); GuiChar.this.gm.show(GuiChar.this);
} }
}, "Neu laden")); }, "Neu laden"));
this.templateButton = this.add(new ActButton(197, height - 30, 193, 0, new ButtonCallback() { this.templateButton = this.add(new ActButton(197, height - 30, 193, 0, new ButtonCallback() {
@ -335,7 +335,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
} }
} }
} }
GuiChar.this.gm.displayGuiScreen(GuiChar.this); GuiChar.this.gm.show(GuiChar.this);
} }
} }
}, "Vorlage kopieren")); }, "Vorlage kopieren"));
@ -382,7 +382,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() { this.add(new ActButton(width - 195, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) { if(GuiChar.this.gm.player != null) {
GuiChar.this.gm.displayGuiScreen(GuiLoading.makeWaitTask("Lade Welt ...")); GuiChar.this.gm.show(GuiLoading.makeWaitTask("Lade Welt ..."));
Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension); Dimension dim = UniverseRegistry.getBaseDimensions().get(GuiChar.this.dimension);
GuiChar.this.gm.player.client.addToSendQueue(new CPacketMessage(CPacketMessage.Type.INFO, descField.getText())); 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, UniverseRegistry.getId(dim))); GuiChar.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.CLOSE_EDITOR, UniverseRegistry.getId(dim)));
@ -392,7 +392,7 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() { this.cancelButton = this.add(new ActButton(width - 390, height - 30, 193, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
if(GuiChar.this.gm.player != null) if(GuiChar.this.gm.player != null)
GuiChar.this.gm.displayGuiScreen(GuiCharacters.INSTANCE); GuiChar.this.gm.show(GuiCharacters.INSTANCE);
} }
}, "Abbrechen")); }, "Abbrechen"));
this.setCharsAvailable(); this.setCharsAvailable();
@ -470,13 +470,13 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
public void updateScreen() { public void updateScreen() {
if(this.adjust == null && this.gm.getRenderManager().gm != null) if(this.adjust == null && this.gm.getRenderManager().gm != null)
this.gm.displayGuiScreen(this); this.gm.show(this);
} }
public void checkReopen() { public void checkReopen() {
if(this.adjust != null && this.waiting) { if(this.adjust != null && this.waiting) {
this.waiting = false; this.waiting = false;
this.gm.displayGuiScreen(this); this.gm.show(this);
} }
} }

View file

@ -107,11 +107,11 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
this.gm.getNetHandler().addToSendQueue(new CPacketAction(GuiCharacters.this.gm.charEditor ? Action.CANCEL_EDITOR : CPacketAction.Action.SELECT_CHARACTER, this.selectedElement)); this.gm.getNetHandler().addToSendQueue(new CPacketAction(GuiCharacters.this.gm.charEditor ? Action.CANCEL_EDITOR : CPacketAction.Action.SELECT_CHARACTER, this.selectedElement));
} }
else if(elem == this.deleteButtom && entry.character != null) { else if(elem == this.deleteButtom && entry.character != null) {
this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() { this.gm.show(new GuiConfirm(new GuiConfirm.Callback() {
public void confirm(boolean confirmed) { public void confirm(boolean confirmed) {
if(confirmed) if(confirmed)
GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement)); GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement));
GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this); GuiCharacters.this.gm.show(GuiCharacters.this);
} }
}, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie\nvon \"" + entry.character.name() + "\" werden für immer verloren sein!", "Löschen", "Abbrechen")); }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie\nvon \"" + entry.character.name() + "\" werden für immer verloren sein!", "Löschen", "Abbrechen"));
} }

View file

@ -67,7 +67,7 @@ public class GuiClass extends GuiList<GuiClass.ClassEntry> implements ButtonCall
ClassEntry entry = this.getSelected(); ClassEntry entry = this.getSelected();
if(entry != null && GuiClass.this.gm.player != null) { if(entry != null && GuiClass.this.gm.player != null) {
GuiClass.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal())); GuiClass.this.gm.player.client.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_CLASS, entry.clazz.ordinal()));
this.gm.displayGuiScreen(GuiChar.INSTANCE); this.gm.show(GuiChar.INSTANCE);
} }
} }
} }

View file

@ -15,6 +15,7 @@ import client.gui.element.Field;
import client.gui.element.InventoryButton; import client.gui.element.InventoryButton;
import client.gui.element.Label; import client.gui.element.Label;
import client.gui.element.MultiLabel; import client.gui.element.MultiLabel;
import client.gui.ingame.GuiRename;
import client.renderer.Drawing; import client.renderer.Drawing;
import client.renderer.GlState; import client.renderer.GlState;
import client.renderer.ItemRenderer; import client.renderer.ItemRenderer;
@ -498,8 +499,8 @@ public abstract class GuiContainer extends Gui
return; return;
if(this.cheatStack != null) { if(this.cheatStack != null) {
Slot slot = this.getSlotAtPosition(mouseX, mouseY); Slot slot = this.getSlotAtPosition(mouseX, mouseY);
if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.inventory == this.gm.player.inventory) if((mouseButton == 0 || mouseButton == 1) && slot != null && this.gm.player != null && slot.canCheatItem())
this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack, slot.getIndex(), mouseButton == 0 && this.cheatStack.size > 1)); this.gm.player.client.addToSendQueue(new CPacketCheat(this.cheatStack, slot.slotNumber, mouseButton == 0 && this.cheatStack.size > 1));
if(mouseButton != 1 && !this.gm.ctrl()) if(mouseButton != 1 && !this.gm.ctrl())
this.cheatStack = null; this.cheatStack = null;
return; return;
@ -714,6 +715,13 @@ public abstract class GuiContainer extends Gui
this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, this.gm.ctrl() ? 1 : 0, 4); this.handleMouseClick(this.theSlot, this.theSlot.slotNumber, this.gm.ctrl() ? 1 : 0, 4);
} }
} }
public void renameItem() {
if (this.gm != null && this.gm.player != null && this.theSlot != null && this.theSlot.canEditItem() && this.theSlot.getHasStack())
{
this.gm.show(new GuiRename(this.theSlot.slotNumber, this.theSlot.getStack(), this));
}
}
public void useHotbar(int slot) public void useHotbar(int slot)
{ {
@ -735,7 +743,7 @@ public abstract class GuiContainer extends Gui
{ {
if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead)) if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead))
{ {
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
else if(this.gm.itemCheat && !this.cheatSearch.getText().equals(this.cheatLast)) { else if(this.gm.itemCheat && !this.cheatSearch.getText().equals(this.cheatLast)) {
this.cheatLast = this.cheatSearch.getText(); this.cheatLast = this.cheatSearch.getText();
@ -865,7 +873,7 @@ public abstract class GuiContainer extends Gui
if(idx >= 0 && idx < ITEM_LIST.size()) { if(idx >= 0 && idx < ITEM_LIST.size()) {
if(slot >= 0 || instant) { if(slot >= 0 || instant) {
this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(idx), slot, full)); this.gm.player.client.addToSendQueue(new CPacketCheat(ITEM_LIST.get(idx), slot < 0 ? slot : -2 - slot, full));
} }
else { else {
this.cheatStack = ITEM_LIST.get(idx).copy(); this.cheatStack = ITEM_LIST.get(idx).copy();

View file

@ -11,7 +11,7 @@ public class NavButton extends ActButton {
public NavButton(int x, int y, int w, int h, Gui gui, String text) { public NavButton(int x, int y, int w, int h, Gui gui, String text) {
super(x, y, w, h, new ButtonCallback() { super(x, y, w, h, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
Client.CLIENT.displayGuiScreen(gui); Client.CLIENT.show(gui);
} }
}, text); }, text);
this.navGui = gui; this.navGui = gui;

View file

@ -119,6 +119,6 @@ public class GuiForm extends Gui implements ButtonCallback {
if(nethandler != null) { if(nethandler != null) {
nethandler.addToSendQueue(new CPacketForm(this.id, this.outputData)); nethandler.addToSendQueue(new CPacketForm(this.id, this.outputData));
} }
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
} }

View file

@ -25,7 +25,7 @@ public class GuiGameOver extends Gui {
this.button = this.add(new ActButton(100, 100, 200, 0, new ButtonCallback() { this.button = this.add(new ActButton(100, 100, 200, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
GuiGameOver.this.gm.player.respawnPlayer(); GuiGameOver.this.gm.player.respawnPlayer();
GuiGameOver.this.gm.displayGuiScreen(null); GuiGameOver.this.gm.show(null);
} }
}, "Wiederbeleben")); }, "Wiederbeleben"));
this.shift(); this.shift();

View file

@ -0,0 +1,56 @@
package client.gui.ingame;
import client.gui.Gui;
import client.gui.element.Label;
import client.gui.element.NavButton;
import client.gui.element.PressType;
import client.gui.element.FieldAction;
import client.gui.element.ActButton;
import client.gui.element.ButtonCallback;
import client.gui.element.Field;
import client.gui.element.FieldCallback;
import client.network.ClientPlayer;
import common.color.TextColor;
import common.item.ItemStack;
import common.packet.CPacketMessage;
public class GuiRename extends Gui implements FieldCallback, ButtonCallback {
private final String itemName;
private final String origName;
private final int slot;
private final Gui previous;
private Field lines;
private ActButton button;
public void init(int width, int height) {
this.add(new Label(0, -140, 300, 0, "Benenne " + this.itemName + " um"));
this.lines = this.add(new Field(0, 0, 300, 0, 50, this, this.origName));
this.add(new NavButton(0, 40, 149, 0, this.previous, "Abbrechen"));
this.button = this.add(new ActButton(151, 40, 149, 0, this, "Umbenennen"));
this.shift();
}
public String getTitle() {
return "Gegenstand umbenennen";
}
public GuiRename(int slot, ItemStack stack, Gui prev) {
this.itemName = stack.getItem().getDisplay(stack);
this.origName = stack.hasDisplayName() ? TextColor.stripCodes(stack.getDisplayName()) : "";
this.slot = slot;
this.previous = prev;
}
public void use(Field elem, FieldAction value) {
if(value == FieldAction.SEND)
this.use(this.button, PressType.PRIMARY);
}
public void use(ActButton elem, PressType action) {
ClientPlayer nethandler = this.gm.getNetHandler();
if(nethandler != null)
nethandler.addToSendQueue(new CPacketMessage(CPacketMessage.Type.ITEM, this.lines.getText(), this.slot));
this.gm.show(this.previous);
}
}

View file

@ -49,6 +49,6 @@ public class GuiSign extends Gui implements FieldCallback {
public void use(Field elem, FieldAction value) { public void use(Field elem, FieldAction value) {
if(value == FieldAction.SEND) if(value == FieldAction.SEND)
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
} }

View file

@ -13,6 +13,7 @@ public class GuiBinds extends GuiOptions {
} }
public void init(int width, int height) { public void init(int width, int height) {
int cols = 5;
int y = 0; int y = 0;
int x = 0; int x = 0;
for(Bind bind : Bind.values()) { for(Bind bind : Bind.values()) {
@ -40,18 +41,19 @@ public class GuiBinds extends GuiOptions {
}, new Formatter<ActButton>() { }, new Formatter<ActButton>() {
public String use(ActButton elem) { public String use(ActButton elem) {
if(bind == Bind.getWaiting()) if(bind == Bind.getWaiting())
return /* TextColor.BLINK + "" + */ TextColor.BLUE + "***"; return TextColor.BLUE + "***";
else else
return (bind.isDupe() ? TextColor.RED : TextColor.YELLOW) + (bind.getInput() == null ? "---" : bind.getInput().getDisplay()); return (bind.isDupe() ? TextColor.RED : TextColor.YELLOW) + (bind.getInput() == null ? "---" : bind.getInput().getDisplay());
} }
})); }));
if(++x == 4) { if(++x == cols) {
x = 0; x = 0;
y++; y++;
} }
} }
y += x != 0 ? 1 : 0; y += x != 0 ? 1 : 0;
this.add(new ActButton(0, 100 + y * 34, 150 * 4 + 2 * 3, 0, new ButtonCallback() { x = (150 * cols + 2 * (cols - 1) - 482) / 2;
this.add(new ActButton(x, 96 + y * 34, 482, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
boolean flag = false; boolean flag = false;
for(Bind bind : Bind.values()) { for(Bind bind : Bind.values()) {
@ -64,8 +66,8 @@ public class GuiBinds extends GuiOptions {
} }
} }
}, "Zurücksetzen")); }, "Zurücksetzen"));
this.addSelector("phy_sensitivity", 0, 140 + y * 34, 302, 0); this.addSelector("phy_sensitivity", x, 116 + y * 34, 240, 0);
this.addSelector("gui_dclick_delay", 304, 140 + y * 34, 302, 0); this.addSelector("gui_dclick_delay", x + 242, 116 + y * 34, 240, 0);
super.init(width, height); super.init(width, height);
} }

View file

@ -34,7 +34,7 @@ public class GuiDisplay extends GuiOptions {
GuiDisplay.this.gm.full(value); GuiDisplay.this.gm.full(value);
} }
}, "Vollbild")); }, "Vollbild"));
int maxModes = ExtMath.clampi((height - 120) / Font.YGLYPH, 4, 28); int maxModes = ExtMath.clampi((height - ((3 * 20 + 2) * 2 + 18 + 4)) / Font.YGLYPH, 4, 28);
DisplayMode[] dmodes = Window.getDisplayModes(); DisplayMode[] dmodes = Window.getDisplayModes();
if(dmodes != null) { if(dmodes != null) {
List<DisplayMode> modes = Lists.newArrayList(); List<DisplayMode> modes = Lists.newArrayList();

View file

@ -13,18 +13,18 @@ public class GuiSound extends GuiOptions {
int x = 0; int x = 0;
int y = 0; int y = 0;
for(Volume volume : Volume.values()) { for(Volume volume : Volume.values()) {
this.addSelector(volume.getCVarName(), x, y, 150, 0); this.addSelector(volume.getCVarName(), x, y, 240, 0);
x = (x == 0) ? 152 : 0; x = (x == 0) ? 242 : 0;
if(x == 0) if(x == 0)
y += 20; y += 20;
} }
this.addSelector("snd_enabled", 0, 50, 150, 0); this.addSelector("snd_enabled", 0, 50, 240, 0);
this.addSelector("snd_buffer_size", 0, 70, 150, 0); this.addSelector("snd_buffer_size", 0, 70, 240, 0);
this.addSelector("snd_frame_size", 152, 70, 150, 0); this.addSelector("snd_frame_size", 242, 70, 240, 0);
this.add(new ActButton(0, 100, 302, 0, new ButtonCallback() { this.add(new ActButton(0, 100, 482, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
GuiSound.this.gm.restartSound(false); GuiSound.this.gm.restartSound(false);
} }

View file

@ -3,36 +3,29 @@ package client.gui.options;
import client.gui.Style; import client.gui.Style;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.ButtonCallback; import client.gui.element.ButtonCallback;
import client.gui.element.Dropdown;
import client.gui.element.DropdownCallback;
import client.gui.element.Element; import client.gui.element.Element;
import client.gui.element.SelectableButton;
import client.gui.element.Slider;
import client.gui.element.SliderCallback;
import client.gui.element.Switch;
import client.gui.element.SwitchCallback;
import client.gui.element.FieldAction;
import client.gui.element.Field; import client.gui.element.Field;
import client.gui.element.FieldCallback;
import client.gui.element.PressType; import client.gui.element.PressType;
import client.vars.CVar; import client.vars.CVar;
import client.vars.ColorVar; import client.vars.ColorVar;
import client.gui.element.Toggle;
import client.gui.element.ToggleCallback;
public class GuiStyle extends GuiOptions implements DropdownCallback<String>, ButtonCallback, ToggleCallback, SwitchCallback<String>, SliderCallback, FieldCallback { public class GuiStyle extends GuiOptions {
private static final String[] STYLE_CVARS = { private static final String[] STYLE_CVARS = {
"color_button_top", "color_button_top",
"color_textbox_top",
"color_border_top",
"color_button_btm", "color_button_btm",
"color_textbox_btm",
"color_border_btm",
"color_button_text", "color_button_text",
"color_textbox_top",
"color_textbox_btm",
"color_textbox_text", "color_textbox_text",
"color_label_text"
"color_border_top",
"color_border_btm",
null,
"color_label_text",
null,
null
}; };
protected GuiStyle() { protected GuiStyle() {
@ -51,70 +44,42 @@ public class GuiStyle extends GuiOptions implements DropdownCallback<String>, Bu
} }
public void init(int width, int height) { public void init(int width, int height) {
int z; for(int z = 0; z < STYLE_CVARS.length; z++) {
for(z = 0; z < STYLE_CVARS.length; z++) { if(STYLE_CVARS[z] != null)
this.addSelector(STYLE_CVARS[z], (z % 3) * 122, z / 3 * 34, 120, 0); this.addSelector(STYLE_CVARS[z], (z / 3) * 120, (z % 3) * 34, 118, 0);
} }
z = 0;
for(Style theme : Style.values()) {
ButtonCallback callback = new ButtonCallback() {
public void use(ActButton elem, PressType action) {
if(GuiStyle.this.gm.style != theme) {
GuiStyle.this.gm.style = theme;
GuiStyle.this.gm.setDirty();
GuiStyle.this.gm.displayGuiScreen(GuiStyle.this);
}
}
};
this.add( // theme == this.gm.style ? new SelectedButton(10 + (z % 3) * 320, 360 + (z / 3) * 40, 300, 0, callback, theme.name) :
new SelectableButton((z % 3) * 122, 4 * 34 + (z / 3) * 20, 120, 0, callback, theme.name, theme == this.gm.style));
z++;
}
this.addSelector("gui_scale", 0, 5 * 34 + (Style.values().length / 3) * 20, 181, 0);
this.addSelector("gui_font", 183, 5 * 34 + (Style.values().length / 3) * 20, 181, 0);
if(this.gm.style != Style.CUSTOM) { this.addSelector("gui_theme", 0, 3 * 34, 240, 0);
this.add(new ActButton(0, 3 * 34, 364, 0, new ButtonCallback() { if(this.gm.style != Style.CUSTOM)
this.add(new ActButton(242, 3 * 34, 240, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
if(GuiStyle.this.gm.style != Style.CUSTOM) { if(GuiStyle.this.gm.style != Style.CUSTOM) {
GuiStyle.this.gm.style.copyToCustom(); GuiStyle.this.gm.style.copyToCustom();
GuiStyle.this.gm.style = Style.CUSTOM; GuiStyle.this.gm.style = Style.CUSTOM;
GuiStyle.this.gm.setDirty(); GuiStyle.this.gm.setDirty();
GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); GuiStyle.this.gm.show(GuiStyle.this);
} }
} }
}, "In angepasstes Design kopieren")); }, "In 'Angepasst' kopieren"));
} else
else { this.add(new ActButton(242, 3 * 34, 240, 0, new ButtonCallback() {
this.add(new ActButton(0, 3 * 34, 364, 0, new ButtonCallback() {
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
GuiStyle.this.gm.style = Style.CUSTOM; GuiStyle.this.gm.style = Style.CUSTOM;
for(String cvar : STYLE_CVARS) { for(String cvar : STYLE_CVARS) {
GuiStyle.this.gm.getVar(cvar).setDefault(); if(cvar != null)
GuiStyle.this.gm.getVar(cvar).setDefault();
} }
GuiStyle.this.gm.setDirty(); GuiStyle.this.gm.setDirty();
GuiStyle.this.gm.displayGuiScreen(GuiStyle.this); GuiStyle.this.gm.show(GuiStyle.this);
} }
}, "Angepasstes Design zurücksetzen")); }, "'Angepasst' zurücksetzen"));
}
this.addSelector("gui_scale", 0, 3 * 34 + 20, 240, 0);
this.addSelector("gui_font", 242, 3 * 34 + 20, 240, 0);
super.init(width, height); super.init(width, height);
} }
public String getTitle() { public String getTitle() {
return "Benutzeroberfläche"; return "Benutzeroberfläche";
} }
public void use(Field elem, FieldAction value) {
}
public void use(Slider elem, int value) {
}
public void use(Switch<String> elem, String value) {
}
public void use(Toggle elem, boolean value) {
}
public void use(ActButton elem, PressType action) {
}
public void use(Dropdown<String> elem, String value) {
}
} }

View file

@ -73,7 +73,7 @@ public class ClientLoginHandler implements IClientLoginHandler {
this.state = LoginState.CONFIRMING; this.state = LoginState.CONFIRMING;
this.gm.schedule(new Runnable() { this.gm.schedule(new Runnable() {
public void run() { public void run() {
ClientLoginHandler.this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() { ClientLoginHandler.this.gm.show(new GuiConfirm(new GuiConfirm.Callback() {
public void confirm(boolean confirmed) { public void confirm(boolean confirmed) {
if(confirmed) { if(confirmed) {
ClientLoginHandler.this.server.setServerKey(pubkey); ClientLoginHandler.this.server.setServerKey(pubkey);
@ -134,7 +134,7 @@ public class ClientLoginHandler implements IClientLoginHandler {
this.state = LoginState.CONFIRMING; this.state = LoginState.CONFIRMING;
this.gm.schedule(new Runnable() { this.gm.schedule(new Runnable() {
public void run() { public void run() {
ClientLoginHandler.this.gm.displayGuiScreen(new GuiConfirm(new GuiConfirm.Callback() { ClientLoginHandler.this.gm.show(new GuiConfirm(new GuiConfirm.Callback() {
public void confirm(boolean confirmed) { public void confirm(boolean confirmed) {
if(confirmed) { if(confirmed) {
ClientLoginHandler.this.server.setServerKey(null); ClientLoginHandler.this.server.setServerKey(null);

View file

@ -226,7 +226,7 @@ public class ClientPlayer implements IClientPlayer
this.gm.loadWorld(this.world, packetIn.getEntityType()); this.gm.loadWorld(this.world, packetIn.getEntityType());
// this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId(); // this.gameController.thePlayer.dimension = this.clientWorldController.dimension.getDimensionId();
this.gm.player.setId(packetIn.getEntityId()); this.gm.player.setId(packetIn.getEntityId());
this.gm.displayGuiScreen(this.gm.charEditor ? GuiChar.INSTANCE : null); this.gm.show(this.gm.charEditor ? GuiChar.INSTANCE : null);
// this.currentServerMaxPlayers = packetIn.getMaxPlayers(); // this.currentServerMaxPlayers = packetIn.getMaxPlayers();
// this.gameController.controller.setCheat(packetIn.getCheat()); // this.gameController.controller.setCheat(packetIn.getCheat());
// this.gameController.updateViewDistance(); // this.gameController.updateViewDistance();
@ -844,7 +844,7 @@ public class ClientPlayer implements IClientPlayer
this.gm.message = ""; this.gm.message = "";
this.gm.total = 0; this.gm.total = 0;
this.gm.progress = -1; this.gm.progress = -1;
this.gm.displayGuiScreen(GuiLoading.makeServerTask(packet.getMessage())); this.gm.show(GuiLoading.makeServerTask(packet.getMessage()));
} }
} }
@ -1083,7 +1083,7 @@ public class ClientPlayer implements IClientPlayer
// } // }
this.gm.setDimensionAndSpawnPlayer(packetIn.getEntityType()); this.gm.setDimensionAndSpawnPlayer(packetIn.getEntityType());
this.gm.displayGuiScreen(this.gm.charEditor ? GuiChar.INSTANCE : null); this.gm.show(this.gm.charEditor ? GuiChar.INSTANCE : null);
// this.gameController.controller.setCheat(packetIn.getCheat()); // this.gameController.controller.setCheat(packetIn.getCheat());
} }
@ -1115,62 +1115,62 @@ public class ClientPlayer implements IClientPlayer
if ("container".equals(id)) if ("container".equals(id))
{ {
this.gm.displayGuiScreen(new GuiChest(player.inventory, new InventoryBasic(title, slots))); this.gm.show(new GuiChest(player.inventory, new InventoryBasic(title, slots)));
} }
else if ("enchanting_table".equals(id)) else if ("enchanting_table".equals(id))
{ {
this.gm.displayGuiScreen(new GuiEnchant(player.inventory, player.worldObj, title)); this.gm.show(new GuiEnchant(player.inventory, player.worldObj, title));
} }
else if ("anvil".equals(id)) else if ("anvil".equals(id))
{ {
this.gm.displayGuiScreen(new GuiRepair(player.inventory, player.worldObj)); this.gm.show(new GuiRepair(player.inventory, player.worldObj));
} }
else if ("chest".equals(id)) else if ("chest".equals(id))
{ {
this.gm.displayGuiScreen(new GuiChest(player.inventory, local)); this.gm.show(new GuiChest(player.inventory, local));
} }
else if ("hopper".equals(id)) else if ("hopper".equals(id))
{ {
this.gm.displayGuiScreen(new GuiHopper(player.inventory, local)); this.gm.show(new GuiHopper(player.inventory, local));
} }
else if ("furnace".equals(id)) else if ("furnace".equals(id))
{ {
this.gm.displayGuiScreen(new GuiFurnace(player.inventory, local)); this.gm.show(new GuiFurnace(player.inventory, local));
} }
else if ("brewing_stand".equals(id)) else if ("brewing_stand".equals(id))
{ {
this.gm.displayGuiScreen(new GuiBrewing(player.inventory, local)); this.gm.show(new GuiBrewing(player.inventory, local));
} }
else if ("dispenser".equals(id) || "dropper".equals(id)) else if ("dispenser".equals(id) || "dropper".equals(id))
{ {
this.gm.displayGuiScreen(new GuiDispenser(player.inventory, local)); this.gm.show(new GuiDispenser(player.inventory, local));
} }
else if ("trade".equals(id)) else if ("trade".equals(id))
{ {
this.gm.displayGuiScreen(new GuiMerchant(player.inventory, title, player.worldObj)); this.gm.show(new GuiMerchant(player.inventory, title, player.worldObj));
} }
else if ("entity".equals(id)) else if ("entity".equals(id))
{ {
Entity entity = this.world.getEntityByID(packet.getEntityId()); Entity entity = this.world.getEntityByID(packet.getEntityId());
if(entity == null) if(entity == null)
return; return;
this.gm.displayGuiScreen(new GuiEntity(player.inventory, new AnimalChest(title, true, slots), entity)); this.gm.show(new GuiEntity(player.inventory, new AnimalChest(title, true, slots), entity));
} }
else if ("tile".equals(id)) else if ("tile".equals(id))
{ {
TileEntity tile = this.world.getTileEntity(packet.getTilePos()); TileEntity tile = this.world.getTileEntity(packet.getTilePos());
if(!(tile instanceof TileEntityDevice dev)) if(!(tile instanceof TileEntityDevice dev))
return; return;
this.gm.displayGuiScreen(new GuiTile(this.gm.player.inventory, local, dev)); this.gm.show(new GuiTile(this.gm.player.inventory, local, dev));
} }
else else
{ {
Block block = BlockRegistry.byName(id); Block block = BlockRegistry.byName(id);
if(block instanceof BlockWorkbench bench) { if(block instanceof BlockWorkbench bench) {
this.gm.displayGuiScreen(new GuiCrafting(player.inventory, player.worldObj, bench)); this.gm.show(new GuiCrafting(player.inventory, player.worldObj, bench));
} }
else { else {
this.gm.displayGuiScreen(new GuiChest(player.inventory, local)); this.gm.show(new GuiChest(player.inventory, local));
} }
} }
player.openContainer.windowId = packet.getWindowId(); player.openContainer.windowId = packet.getWindowId();
@ -1274,12 +1274,12 @@ public class ClientPlayer implements IClientPlayer
tileentity.setPos(packetIn.getSignPosition()); tileentity.setPos(packetIn.getSignPosition());
} }
this.gm.displayGuiScreen(new GuiSign(packetIn.getSignPosition(), ((TileEntitySign)tileentity).signText)); this.gm.show(new GuiSign(packetIn.getSignPosition(), ((TileEntitySign)tileentity).signText));
} }
public void handleForm(SPacketDisplayForm packet) { public void handleForm(SPacketDisplayForm packet) {
NetHandler.checkThread(packet, this, this.gm, this.world); NetHandler.checkThread(packet, this, this.gm, this.world);
this.gm.displayGuiScreen(new GuiForm(packet.getId(), packet.getTitle(), packet.getData())); this.gm.show(new GuiForm(packet.getId(), packet.getTitle(), packet.getData()));
} }
/** /**
@ -1366,7 +1366,7 @@ public class ClientPlayer implements IClientPlayer
{ {
NetHandler.checkThread(packetIn, this, this.gm, this.world); NetHandler.checkThread(packetIn, this, this.gm, this.world);
// this.gameController.thePlayer.closeScreenAndDropStack(); // this.gameController.thePlayer.closeScreenAndDropStack();
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
/** /**
@ -1625,10 +1625,10 @@ public class ClientPlayer implements IClientPlayer
this.gm.selectedCharacter = packet.getSelected(); this.gm.selectedCharacter = packet.getSelected();
if(this.gm.charEditor && this.gm.selectedCharacter >= 0) { if(this.gm.charEditor && this.gm.selectedCharacter >= 0) {
this.gm.charEditor = false; this.gm.charEditor = false;
this.gm.displayGuiScreen(null); this.gm.show(null);
} }
else if(this.gm.open instanceof GuiCharacters) { else if(this.gm.open instanceof GuiCharacters) {
this.gm.displayGuiScreen(this.gm.open); this.gm.show(this.gm.open);
} }
else if(this.gm.open instanceof GuiChar guichar) { else if(this.gm.open instanceof GuiChar guichar) {
guichar.setCharsAvailable(); guichar.setCharsAvailable();

View file

@ -31,6 +31,7 @@ public enum Bind implements Identifyable, CVar {
SELECT7("select7", "Auswahl #7", Keysym.N7), SELECT7("select7", "Auswahl #7", Keysym.N7),
SELECT8("select8", "Auswahl #8", Keysym.N8), SELECT8("select8", "Auswahl #8", Keysym.N8),
SELECT9("select9", "Auswahl #9", Keysym.N9), SELECT9("select9", "Auswahl #9", Keysym.N9),
RENAME("rename", "Umbenennen", Keysym.N),
CONSOLE("console", "Konsole", Keysym.F1), CONSOLE("console", "Konsole", Keysym.F1),
COMMAND("command", "Befehl / Chat", Keysym.C), COMMAND("command", "Befehl / Chat", Keysym.C),
INFO("info", "Infos einblenden", Keysym.TAB), INFO("info", "Infos einblenden", Keysym.TAB),

View file

@ -126,6 +126,19 @@ public abstract class Container
return slot != null ? slot.getStack() : null; return slot != null ? slot.getStack() : null;
} }
public void renameItem(int id, String name) {
if(id < 0 || id >= this.inventorySlots.size())
return;
Slot slot = this.inventorySlots.get(id);
if(slot != null && slot.canEditItem() && slot.getHasStack()) {
ItemStack stack = slot.getStack();
if(name.isBlank())
stack.clearCustomName();
else
stack.setStackDisplayName(name);
}
}
/** /**
* Handles slot click. * Handles slot click.
*/ */

View file

@ -186,6 +186,10 @@ public class ContainerBrewingStand extends Container
return 1; return 1;
} }
public boolean canCheatItem() {
return false;
}
// public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack) // public void onPickupFromSlot(EntityNPC playerIn, ItemStack stack)
// { // {
// if (stack.getItem() == Items.potion && stack.getMetadata() > 0) // if (stack.getItem() == Items.potion && stack.getMetadata() > 0)

View file

@ -59,6 +59,10 @@ public class ContainerEnchantment extends Container
{ {
return 1; return 1;
} }
public boolean canEditItem() {
return false;
}
}); });
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)

View file

@ -15,8 +15,16 @@ public class ContainerMerchant extends Container
this.theMerchant = merchant; this.theMerchant = merchant;
this.theWorld = worldIn; this.theWorld = worldIn;
this.merchantInventory = new InventoryMerchant(playerInventory.player, merchant); this.merchantInventory = new InventoryMerchant(playerInventory.player, merchant);
this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53)); this.addSlotToContainer(new Slot(this.merchantInventory, 0, 36, 53) {
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53)); public boolean canEditItem() {
return false;
}
});
this.addSlotToContainer(new Slot(this.merchantInventory, 1, 62, 53) {
public boolean canEditItem() {
return false;
}
});
this.addSlotToContainer(new SlotMerchantResult(playerInventory.player, this.merchantInventory, 2, 120, 53)); this.addSlotToContainer(new SlotMerchantResult(playerInventory.player, this.merchantInventory, 2, 120, 53));
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)

View file

@ -30,7 +30,11 @@ public class ContainerPlayer extends Container
{ {
for (int j = 0; j < 2; ++j) for (int j = 0; j < 2; ++j)
{ {
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18)); this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18) {
public boolean canEditItem() {
return false;
}
});
} }
} }

View file

@ -55,8 +55,16 @@ public class ContainerRepair extends Container
this.selfPosition = blockPosIn; this.selfPosition = blockPosIn;
this.theWorld = worldIn; this.theWorld = worldIn;
this.thePlayer = player; this.thePlayer = player;
this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47)); this.addSlotToContainer(new Slot(this.inputSlots, 0, 27, 47) {
this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47)); public boolean canEditItem() {
return false;
}
});
this.addSlotToContainer(new Slot(this.inputSlots, 1, 76, 47) {
public boolean canEditItem() {
return false;
}
});
this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47) this.addSlotToContainer(new Slot(this.outputSlot, 2, 134, 47)
{ {
public boolean isItemValid(ItemStack stack) public boolean isItemValid(ItemStack stack)
@ -120,6 +128,10 @@ public class ContainerRepair extends Container
worldIn.playAuxSFX(1021, blockPosIn, 0); worldIn.playAuxSFX(1021, blockPosIn, 0);
} }
} }
public boolean canCheatItem() {
return false;
}
}); });
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)

View file

@ -30,7 +30,11 @@ public class ContainerWorkbench extends Container
{ {
for (int j = 0; j < size; ++j) for (int j = 0; j < size; ++j)
{ {
this.addSlotToContainer(new Slot(this.craftMatrix, j + i * size, 26 + j * 18, 17 + i * 18)); this.addSlotToContainer(new Slot(this.craftMatrix, j + i * size, 26 + j * 18, 17 + i * 18) {
public boolean canEditItem() {
return false;
}
});
} }
} }

View file

@ -164,4 +164,12 @@ public class Slot
public int getIndex() { public int getIndex() {
return this.slotIndex; return this.slotIndex;
} }
public boolean canCheatItem() {
return true;
}
public boolean canEditItem() {
return this.canCheatItem();
}
} }

View file

@ -152,4 +152,8 @@ public class SlotCrafting extends Slot
} }
} }
} }
public boolean canCheatItem() {
return false;
}
} }

View file

@ -105,4 +105,8 @@ public class SlotFurnaceOutput extends Slot
// this.thePlayer.triggerAchievement(AchievementList.cookFish); // this.thePlayer.triggerAchievement(AchievementList.cookFish);
// } // }
} }
public boolean canCheatItem() {
return false;
}
} }

View file

@ -115,4 +115,8 @@ public class SlotMerchantResult extends Slot
return false; return false;
} }
public boolean canCheatItem() {
return false;
}
} }

View file

@ -10,27 +10,38 @@ public class CPacketMessage implements Packet<IPlayer>
{ {
private Type type; private Type type;
private String message; private String message;
private int arg;
public CPacketMessage() public CPacketMessage()
{ {
} }
public CPacketMessage(Type type, String str) public CPacketMessage(Type type, String str)
{
this(type, str, 0);
}
public CPacketMessage(Type type, String str, int arg)
{ {
this.type = type; this.type = type;
this.message = str.length() > type.length ? str.substring(0, type.length) :str; this.message = str.length() > type.length ? str.substring(0, type.length) : str;
this.arg = arg;
} }
public void readPacketData(PacketBuffer buf) throws IOException public void readPacketData(PacketBuffer buf) throws IOException
{ {
this.type = buf.readEnumValue(Type.class); this.type = buf.readEnumValue(Type.class);
this.message = buf.readString(this.type.length); this.message = buf.readString(this.type.length);
if(this.type.hasArg)
this.arg = buf.readVarInt();
} }
public void writePacketData(PacketBuffer buf) throws IOException public void writePacketData(PacketBuffer buf) throws IOException
{ {
buf.writeEnumValue(this.type); buf.writeEnumValue(this.type);
buf.writeString(this.message); buf.writeString(this.message);
if(this.type.hasArg)
buf.writeVarInt(this.arg);
} }
public void processPacket(IPlayer handler) public void processPacket(IPlayer handler)
@ -47,18 +58,29 @@ public class CPacketMessage implements Packet<IPlayer>
{ {
return this.message; return this.message;
} }
public int getArg()
{
return this.arg;
}
public static enum Type { public static enum Type {
COMMAND(IPlayer.MAX_CMD_LENGTH), COMMAND(IPlayer.MAX_CMD_LENGTH),
CHAT(IPlayer.MAX_CMD_LENGTH), CHAT(IPlayer.MAX_CMD_LENGTH),
DISPLAY(IPlayer.MAX_NICK_LENGTH), DISPLAY(IPlayer.MAX_NICK_LENGTH),
INFO(IPlayer.MAX_INFO_LENGTH); INFO(IPlayer.MAX_INFO_LENGTH),
// , ITEM(30); ITEM(30, true);
private final int length; private final int length;
private final boolean hasArg;
private Type(int length, boolean hasArg) {
this.length = length;
this.hasArg = hasArg;
}
private Type(int length) { private Type(int length) {
this.length = length; this(length, false);
} }
} }
} }

View file

@ -43,7 +43,6 @@ import common.inventory.Slot;
import common.inventory.SlotCrafting; import common.inventory.SlotCrafting;
import common.item.ItemControl; import common.item.ItemControl;
import common.item.ItemStack; import common.item.ItemStack;
import common.item.tool.ItemArmor;
import common.log.Log; import common.log.Log;
import common.net.util.concurrent.Future; import common.net.util.concurrent.Future;
import common.net.util.concurrent.GenericFutureListener; import common.net.util.concurrent.GenericFutureListener;
@ -1961,10 +1960,15 @@ public class Player extends User implements ICrafting, Executor, IPlayer
this.entity.setDescription(msg.isEmpty() ? null : msg); this.entity.setDescription(msg.isEmpty() ? null : msg);
break; break;
// case ITEM: case ITEM:
// if(this.entity.openContainer instanceof ContainerRepair) if(msg.length() > 30)
// ((ContainerRepair)this.entity.openContainer).updateItemName(msg); throw new IllegalArgumentException("Ungültiger Name");
// break; if(packetIn.getArg() == -1)
this.entity.inventoryContainer.renameItem(36 + this.entity.inventory.currentItem, msg);
else
this.entity.openContainer.renameItem(packetIn.getArg(), msg);
this.entity.openContainer.detectAndSendChanges();
break;
default: default:
throw new IllegalArgumentException("Ungültiger Nachrichten-Typ!"); throw new IllegalArgumentException("Ungültiger Nachrichten-Typ!");
@ -2873,35 +2877,51 @@ public class Player extends User implements ICrafting, Executor, IPlayer
if(this.charEditor || !this.isAdmin()) if(this.charEditor || !this.isAdmin())
return; return;
ItemStack stack = packet.getStack(); ItemStack stack = packet.getStack();
if (stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag()))) if(stack.getItem() != null && stack.size <= stack.getMaxStackSize() && stack.size > 0 && (!stack.hasTag() || stack.getItem().isValidTag(stack.getTag())))
{ {
int amount = stack.size; int amount = stack.size;
if(amount <= 0)
return;
if(packet.getSlot() == -1) { if(packet.getSlot() == -1) {
this.entity.inventory.addItemStackToInventory(stack); this.entity.inventory.addItemStackToInventory(stack);
amount -= stack.size; amount -= stack.size;
} if(amount <= 0)
else if(packet.getSlot() >= 0 && packet.getSlot() < this.entity.inventory.getSizeInventory() && (packet.getSlot() < this.entity.inventory.mainInventory.length || (stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).armorType.getArmorSlot() == packet.getSlot() - this.entity.inventory.mainInventory.length))) { return;
ItemStack old = this.entity.inventory.getStackInSlot(packet.getSlot());
if(old != null) {
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
stack.size = Math.min(stack.getMaxStackSize(), old.size + stack.size);
amount = stack.size - old.size;
}
else if(old.size == 1)
this.addFeed(TextColor.DRED + "* %s zerstört",
old.getColoredName(TextColor.DRED));
else
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
old.getColoredName(TextColor.DRED));
}
this.entity.inventory.setInventorySlotContents(packet.getSlot(), stack);
} }
else { else {
return; if(packet.getSlot() <= -2 - 9)
return;
Slot slot = packet.getSlot() < 0 ? this.entity.inventoryContainer.getSlot(36 + -2 - packet.getSlot()) : this.entity.openContainer.getSlot(packet.getSlot());
if(slot == null || !slot.canCheatItem())
return;
stack.size = Math.min(slot.getSlotStackLimit(), stack.size);
amount = stack.size;
if(amount <= 0)
return;
if(slot.getHasStack()) {
ItemStack old = slot.getStack();
if(ItemStack.areItemsEqual(stack, old) && ItemStack.areItemStackTagsEqual(stack, old)) {
stack.size = Math.min(slot.getSlotStackLimit(), Math.min(stack.getMaxStackSize(), old.size + stack.size));
amount = stack.size - old.size;
if(amount <= 0 || !slot.isItemValid(stack))
return;
}
else {
if(!slot.isItemValid(stack))
return;
if(old.size == 1)
this.addFeed(TextColor.DRED + "* %s zerstört",
old.getColoredName(TextColor.DRED));
else
this.addFeed(TextColor.DRED + "* %d %s zerstört", old.size,
old.getColoredName(TextColor.DRED));
}
}
else if(!slot.isItemValid(stack))
return;
slot.putStack(stack);
} }
this.entity.openContainer.detectAndSendChanges(); this.entity.openContainer.detectAndSendChanges();
if(amount <= 0)
return;
this.entity.worldObj.playSoundAtEntity(this.entity, SoundEvent.POP, 0.2F); this.entity.worldObj.playSoundAtEntity(this.entity, SoundEvent.POP, 0.2F);
if(amount == 1) if(amount == 1)
this.addFeed(TextColor.DGREEN + "* %s geschummelt", this.addFeed(TextColor.DGREEN + "* %s geschummelt",