From 868a5ed9ea67051ffb8c6f06f9d7133462997928 Mon Sep 17 00:00:00 2001 From: Sen Date: Tue, 18 Mar 2025 17:42:21 +0100 Subject: [PATCH] char gui --- java/src/game/Temp1.java | 1593 ----------------- java/src/game/entity/npc/EntityNPC.java | 2 +- java/src/game/gui/GuiMenu.java | 3 +- java/src/game/gui/GuiSkin.java | 825 ++++----- java/src/game/gui/element/GuiList.java | 4 + java/src/game/renderer/entity/Render.java | 3 +- .../renderer/texture/EntityTexManager.java | 23 +- 7 files changed, 366 insertions(+), 2087 deletions(-) diff --git a/java/src/game/Temp1.java b/java/src/game/Temp1.java index f717770..7b4974d 100644 --- a/java/src/game/Temp1.java +++ b/java/src/game/Temp1.java @@ -8,916 +8,9 @@ -package game.gui; -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileFilter; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.util.Arrays; -import java.util.List; -import java.util.Set; -import javax.imageio.ImageIO; -import game.Game; -import game.SKC; -import game.audio.SoundManager; -import game.collect.Lists; -import game.collect.Sets; -import game.entity.npc.Alignment; -import game.entity.npc.CharacterInfo; -import game.entity.npc.EntityNPC; -import game.entity.npc.SpeciesInfo; -import game.gui.element.Button; -import game.gui.inventory.GuiInventory; -import game.init.EntityRegistry; -import game.init.SpeciesRegistry; -import game.init.SpeciesRegistry.ModelType; -import game.io.FileUtils; -import game.network.NetHandlerPlayServer; -import game.packet.CPacketAction; -import game.packet.CPacketMessage; -import game.packet.CPacketSkin; -import game.renderer.GlState; -import game.renderer.texture.DynamicTexture; -import game.renderer.texture.EntityTexManager; -import game.renderer.texture.TextureUtil; -import com.google.common.base.Predicate; - -public class GuiSkin extends GuiList -{ - private class SkinEntry implements IGuiListEntry - { - private static final String SKINS_BUTTONS = "textures/gui/server_selection.png"; - -// private final GuiSkin owner; -// private final Game gm; - private final File skinFile; - private final String id; - private final ModelType model; - private final CharacterInfo charinfo; - private final BufferedImage skinImage; - private final String icon; - private DynamicTexture dyntex; - private long clickTime; - - protected SkinEntry(String id, File file, CharacterInfo charinfo, BufferedImage image, ModelType model) - { -// this.owner = parent; - this.skinFile = file; - this.charinfo = charinfo; - this.id = id; - this.model = model; -// this.gm = Game.getGame(); - if(this.skinFile != null) // { - this.skinImage = image; -// this.skin = skin.getName().substring(0, skin.getName().length() - 4); -// } - else // { - this.skinImage = null; -// this.skin = null; -// } - if(this.skinImage != null) { - this.icon = "skins/" + this.id + "/icon"; - this.dyntex = new DynamicTexture(this.skinImage); - GuiSkin.this.gm.getTextureManager().loadTexture(this.icon, this.dyntex); - } - else { - this.icon = null; - this.dyntex = null; - } - } - - public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) - { -// FontRenderer.drawString(this.skin == null ? "---" : this.skin, x + 32 + 3, y + 1, 16777215); - String str = // List list = FontRenderer.listFormattedStringToWidth( - (this.skinFile != null ? this.skinFile.getName() - : (this.charinfo == null ? "Standard" : ( - (this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ? - this.charinfo.spclass.type.toString() : - EntityRegistry.getEntityName(this.charinfo.species.id)) - + (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)) + " (" + this.charinfo.skin + ")"))); -// + TextColor.LIGHT_GRAY + " (" + TextColor.GREEN + -// this.model.display + TextColor.LIGHT_GRAY +")" -// , listWidth - 16 - 2); -// -// for (int i = 0; i < Math.min(list.size(), 2); ++i) -// { - SKC.drawString(str, x + 16 + 3, y, this.charinfo == null ? - (this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2); -// } - - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - -// if(this.model != ModelType.HUMANOID) { -// this.drawTextureAt(x, y, EntitySkinManager.HEAD_DEF); -// } - if (this.dyntex != null) - { - this.drawTextureAt(x, y, this.icon); - } - else if(this.charinfo == null) - { - this.drawTextureAt(x, y, EntityTexManager.getDefault(this.model)); - } - else - { - this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? - this.charinfo.skin.substring(1) : this.charinfo.skin)); - } - - if (/* this.gm.touchscreen || */ isSelected) - { - GuiSkin.this.gm.getTextureManager().bindTexture(SKINS_BUTTONS); - Gui.drawRect(x, y, x + 16, y + 16, -1601138544); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - int k1 = mouseX - x; - int l1 = mouseY - y; - - if (k1 < 16 && k1 > 0) - { - Gui.drawScaledCustomSizeModalRect(x, y, 0.0F, 32.0F, 32, 32, 16, 16, 256.0F, 256.0F); - } - } - } - - protected void drawTextureAt(int x, int y, String tex) - { - GuiSkin.this.gm.getTextureManager().bindTexture(tex); - GlState.enableBlend(); - GuiSkin.this.gm.getRenderManager().getRenderObject(this.model).renderHead(x, y, this.model.texWidth, this.model.texHeight, 2); - GlState.disableBlend(); - } - - public void deleteTexture() { - if(this.dyntex != null) { - GuiSkin.this.gm.getTextureManager().deleteTexture(this.icon); - this.dyntex = null; - } - } - - /** - * Returns true if the mouse has been pressed on this control. - */ - public boolean mousePressed(int slotIndex, int mx, int my) - { - if(GuiSkin.this.adjust.dragging) - return false; - if (System.currentTimeMillis() - this.clickTime < 250L) - { - GuiSkin.this.close(); - return true; - } - else { - BufferedImage img = this.skinImage; - boolean slim = false; - if(this.charinfo != null) { - try { - img = TextureUtil.readImage(FileUtils.getStream( - EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : - this.charinfo.skin))); - } - catch(IOException e) { - if(e instanceof FileNotFoundException) - Log.JNI.warn("Textur für Skin ist nicht vorhanden: " + - EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : - this.charinfo.skin)); - else - Log.JNI.error(e, "Konnte Textur nicht laden"); - return false; - } - slim = this.charinfo.skin.startsWith("~"); - } - else if(this.skinFile != null) { - slim = this.skinFile.getName().startsWith("slim_"); - } - GuiSkin.this.selectEntry(slotIndex, slim); - GuiSkin.this.selectSkin(this.id, img, slim, this.model); - if(mx < 16 && mx > 0) - GuiSkin.this.close(); - this.clickTime = System.currentTimeMillis(); - return false; - } - } - -// public void setSelected(int p_178011_1_, int p_178011_2_, int p_178011_3_) -// { -// } - - /** - * Fired when the mouse button is released. Arguments: index, x, y, mouseEvent, relativeX, relativeY - */ -// public void mouseReleased(int slotIndex, int x, int y, int mouseEvent, int relativeX, int relativeY) -// { -// } - - public File getFile() - { - return this.skinFile; - } - - public boolean canConvert() - { - return this.skinFile != null && this.model == ModelType.HUMANOID; - } - - public String getLocation() - { - return this.charinfo == null ? null : (this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : this.charinfo.skin); - } - - public boolean canCopy() - { - return this.charinfo != null; - } - -// public boolean mouseScrolled(int slotIndex, int mouseX, int mouseY, int offset, int relaX, int relaY) { -// return false; -// } - } - -// private static class SkinSelector extends GuiList -// { -// private final GuiSkin owner; - private final List skinList = Lists.newArrayList(); - private int selectedSlotIndex = -1; - -// public SkinSelector(GuiSkin ownerIn, ModelType model, String currentSkin, Game gmIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn) -// { -// super(gmIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn); -// this.owner = ownerIn; -//// this.setBackgroundDrawing(false); -// this.load(currentSkin, model); -// } - - /** - * Gets the IGuiListEntry object for the given index - */ - public SkinEntry getListEntry(int index) - { - return this.skinList.get(index); - } - - public int getSize() - { - return this.skinList.size(); - } - - public void setSelectedSlotIndex(int selectedSlotIndexIn) - { - this.selectedSlotIndex = selectedSlotIndexIn; - } - - /** - * Returns true if the element passed in is currently selected - */ - protected boolean isSelected(int slotIndex) - { - return slotIndex == this.selectedSlotIndex; - } - - public int getSelectedIndex() - { - return this.selectedSlotIndex; - } - - public static BufferedImage loadSkin(File file) - { - BufferedImage img = null; - try { - img = ImageIO.read(file); - } - catch(IOException e) { - return null; - } - if(img == null) { - return null; - } -// if(img.getWidth() != 64 || img.getHeight() != 64) { // || img.getType() != BufferedImage.TYPE_INT_ARGB) { -// return null; -// } - return img; - } - - public void load(String currentSkin, ModelType model) - { - this.unload(); - File[] files = new File("skins").listFiles(new FileFilter() { - public boolean accept(File pathname) { - return pathname.isFile() && pathname.getName().endsWith(".png"); - } - }); - int pos = 0; -// for(ModelType model : ModelType.values()) { - this.skinList.add(new SkinEntry("default", null, null, null, model)); - if("default".equals(currentSkin)) - this.setSelectedSlotIndex(pos); - pos++; -// } - if(files != null) { - Arrays.sort(files); - for(File file : files) - { - BufferedImage img = loadSkin(file); - if(img != null) { -// for(ModelType model : ModelType.values()) { - if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) { - this.skinList.add(new SkinEntry(file.getName(), file, null, img, model)); - if(file.getName().equals(currentSkin)) - this.setSelectedSlotIndex(pos); - pos++; - } -// } - } - } - } - for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { - for(CharacterInfo charinfo : species.chars) { - if(charinfo.species.renderer == model) { - // for(Entry entry : SpeciesRegistry.SKINS.entrySet()) { - this.skinList.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer)); - if(charinfo.skin.equals(currentSkin)) - this.setSelectedSlotIndex(pos); - pos++; - } - } - } - } - - public void unload() - { - for (SkinEntry entry : this.skinList) - { - entry.deleteTexture(); - } - - this.skinList.clear(); - } - - protected int getScrollBarX() - { - return 0; - } - - /** - * Gets the width of the list - */ - public int getListWidth() - { - return 274 - 20; - } - - public int getSlotHeight() - { - return 20; - } - - protected boolean isInList(int x, int y) - { - return x >= 6; - } -// } - - private class DragAdjust extends Button { - private int mouseX; - private int mouseY; - private float yawOffset; - private float pitchOffset; - public boolean dragging; - - public DragAdjust(int id, int x, int y, int w, int h) { - super(id, x, y, w, h, ""); - } - - public void drawButton(Game gm, int mouseX, int mouseY) { - if(this.visible && this.dragging) { - GuiSkin.this.yaw = this.yawOffset + (this.mouseX - mouseX) * 2.0f; - GuiSkin.this.pitch = this.pitchOffset + (this.mouseY - mouseY) * 2.0f; - } - if(this.visible) - drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0x20ffffff); - } - - public boolean mousePressed(Game gm, int mouseX, int mouseY) { - if(super.mousePressed(gm, mouseX, mouseY)) { - this.mouseX = mouseX; - this.mouseY = mouseY; - this.yawOffset = GuiSkin.this.yaw; - this.pitchOffset = GuiSkin.this.pitch; - this.dragging = true; - return true; - } - else { - return false; - } - } - - public void mouseReleased(int mouseX, int mouseY) { - this.dragging = false; - } - - public void playPressSound(SoundManager soundHandlerIn) { - } - } - - private class ButtonPart extends Button - { - private final ModelPart part; - - private ButtonPart(int id, int x, int y, int width, int height, ModelPart part) - { - super(id, x, y, width, height, GuiSkin.this.formatPart(part)); - this.part = part; - } - } - - private class ButtonAlign extends Button - { - private final Alignment align; - - private ButtonAlign(int id, int x, int y, int width, int height, Alignment align) - { - super(id, x, y, width, height, align.color + align.display); - this.align = align; - } - } - - private class HeightReceiver implements SliderReceiver { - private int height; - - private HeightReceiver(int value) { - this.height = value; - } - - public float getValue(Game gm) { - return this.height; - } - - public void setValue(Game gm, float value) { - this.height = (int)value; - if(gm.thePlayer != null) - gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, this.height)); - } - - public String formatValue(Game gm) { - return "Spieler-Größe: " + (int)this.height + " cm"; - } - } - -// private final Set parts = Sets.newHashSet(ModelPart.values()); - private Button convertButton; - private Button templateButton; -// private Button modelButton; - private DragAdjust adjust; - private float yaw; - private float pitch; - -// public GuiSkin(GuiScreen parentScreen) -// { -// this.parentScreen = parentScreen; -// } - - public void initGui() - { - this.load(this.gm.skinId.isEmpty() ? null : this.gm.skinId, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel()); - this.buttonList.add(new Button(8, 164, this.height - 28, 274 - 164, 20, "Neu laden")); - int flags = this.gm.thePlayer == null ? ~ModelPart.ARMS_SLIM.getMask() : this.gm.thePlayer.getModelParts(); - this.parts.clear(); - for(ModelPart part : ModelPart.values()) { - if((flags & part.getMask()) == part.getMask()) - this.parts.add(part); - } - this.buttonList.add(this.convertButton = new Button(9, 10, this.height - 28, 150, 20, - "Konvertieren: " + - (this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard"))); - this.buttonList.add(this.templateButton = new Button(10, this.width - 274, this.height - 28, 150, 20, - "Vorlage kopieren")); - this.buttonList.add(this.adjust = new DragAdjust(20, 274 + 10, 64, this.width - 274 - 274 - 20, this.height - 128)); - for (int z = 0; z < ModelPart.values().length; z++) - { - ModelPart part = ModelPart.values()[z]; - Button button = new ButtonPart(z + 500, this.width - 274 + (z & 1) * 134, 32 + 24 * (z >> 1), 130, 20, part); - if(part == ModelPart.ARMS_SLIM) - this.modelButton = button; - this.buttonList.add(button); - } - for (int z = 0; z < Alignment.values().length; z++) - { - Button button; - this.buttonList.add(button = new ButtonAlign(z + 600, this.width - 274 + (z % 3) * 89, this.height - 158 + 23 * (z / 3), 86, 20, - Alignment.values()[z])); - button.enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != Alignment.values()[z]; - } - new HeightReceiver(this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f)), - 120.0f, 320.0f, 1.0f) - } - - private void sendNameToServer() - { - String name = this.nameField.getText(); - if(name.isEmpty()) - this.nameField.setText(this.gm.thePlayer == null ? "..." : this.gm.thePlayer.getCustomNameTag()); - else if(this.gm.thePlayer != null) - this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name)); - } - - public void selectSkin(BufferedImage img, ModelType model) - { - this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model)); - } - - public void onGuiClosed() - { -// Keyboard.enableRepeatEvents(false); - - this.unload(); - } - - protected void actionPerformed(Button button) - { - if (button.enabled) - { - if (button.id == 0) - { - this.gm.displayGuiScreen(this.parentScreen); - } - else if (button.id == 8) - { - this.refreshList(); - } - else if (button.id == 9) - { - if(this.getSelectedIndex() >= 0) { - SkinEntry entry = this.getListEntry(this.getSelectedIndex()); - if(entry.getFile() != null && SkinConverter.convertSkin(entry.getFile(), new File("skins"), - slim)) { - this.refreshList(); - } - } - } - else if (button.id == 10) - { - if(this.getSelectedIndex() >= 0) { - SkinEntry entry = this.getListEntry(this.getSelectedIndex()); - if(entry.getLocation() != null) { - String loc = (this.parts.contains(ModelPart.ARMS_SLIM) ? "slim_" : "") + entry.getLocation(); - File file = new File(new File("skins"), loc + ".png"); - int z = 1; - while(file.exists()) { - file = new File(new File("skins"), loc + "_" + (++z) + ".png"); - } - InputStream in = null; - try { - in = FileUtils.getStream(EntityNPC.getSkinTexture(entry.getLocation())); - Files.copy(in, file.toPath()); - } - catch(Exception e) { - if(e instanceof FileNotFoundException) - Log.JNI.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(entry.getLocation())); - else - Log.JNI.error(e, "Konnte Textur nicht kopieren"); - } - finally { - FileUtils.closeQuietly(in); - } - this.refreshList(); - } - } - } - else if (button.id == 30) - { -// this.update = 2; - } -// else if (button instanceof ButtonPart) -// { -// ModelPart part = ((ButtonPart)button).part; -//// this.switchModelPartEnabled(part); -// if(!this.parts.contains(part)) -// this.parts.add(part); -// else -// this.parts.remove(part); -// if(this.gm.thePlayer != null) { -// int n = 0; -// for(ModelPart p : this.parts) { -// n |= p.getMask(); -// } -// this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_MODELPARTS, n)); -// } -// button.display = this.formatPart(part); -//// this.update = 2; -//// if(part == ModelPart.ARMS_SLIM) -//// this.convertButton.display = "Konvertieren: " + -//// (this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard"); -// } - else if (button instanceof ButtonAlign) - { - if(this.gm.thePlayer != null) { - this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, - ((ButtonAlign)button).align.ordinal())); - for(Button btn : this.buttonList) { - if(btn instanceof ButtonAlign) - btn.enabled = ((ButtonAlign)button).align != ((ButtonAlign)btn).align; - } - } - } - } - } - - public boolean canClose() { - return false; - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.drawBackground(); - super.drawScreen(mouseX, mouseY, partialTicks); - SKC.drawCentered("Charakter anpassen", this.width / 2, 20, 0xffffff); - SKC.drawString("Anzeigename", this.width - 274 + 2, this.height + 2 - 28 - 24 - 10, 10526880); - GuiInventory.drawEntity(274 + (this.width - 274 - 274) / 2, this.height / 2 + 80, 80.0f - / this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer); - } - -// private String formatPart(ModelPart part) -// { -// return part.getName() + ": " + ( -// this.parts.contains(part) ? (part == ModelPart.ARMS_SLIM ? "Schlank" : "An") : -// (part == ModelPart.ARMS_SLIM ? "Standard" : "Aus")); -// } -} - - - - - - -package game.gui.world; - -import java.io.File; - -import game.SKC; -import game.color.TextColor; -import game.gui.GuiScreen; -import game.gui.element.Button; -import game.gui.element.TextField; -import game.network.NetHandlerPlayServer; - -import com.google.common.base.Predicate; -import game.world.Region; - -public class GuiEdit extends GuiScreen { - public static interface Callback { - void confirm(String name); - } - - private final GuiWorlds parent; - private final String original; - private final boolean player; - private final String title; - private final String action; - private final String desc; - private final Callback callback; - - private TextField nameField; - private Button actionButton; - private boolean fileExists; - private boolean noChange; - - public GuiEdit(GuiWorlds parent, String original, boolean player, String title, String action, String desc, Callback callback) { - this.parent = parent; - this.original = original; - this.player = player; - this.title = title; - this.action = action; - this.desc = desc; - this.callback = callback; - } - - public void updateScreen() { -// this.nameField.updateCursorCounter(); - this.fileExists = false; - this.noChange = false; - String text = this.nameField.getText().trim(); - if(text.isEmpty() || (this.noChange = (text.equals(this.original) || (!this.player && !text.replaceAll("[\\./\"]", "_") - .equals(text))))) { - this.actionButton.enabled = false; - return; - } - if(this.player) - return; -// { -// if(!StringValidator.isValidUser(text)) -// this.actionButton.enabled = false; -// } -// else { -// for(String n : GuiCreate.DISALLOWED_FILES) { -// if(text.equalsIgnoreCase(n)) { -// this.actionButton.enabled = false; -// return; -// } -// } -// if(GuiCreate.DISALLOWED_FILES.contains(text.toUpperCase())) { -// this.actionButton.enabled = false; -// return; -// } - if(this.fileExists = (!text.isEmpty() && new File(Region.SAVE_DIR, text).exists())) - this.actionButton.enabled = false; -// } - } - - public void initGui() { -// Keyboard.enableRepeatEvents(true); - this.buttonList.clear(); - this.buttonList.add(this.actionButton = new Button(0, this.width / 2 - 100, this.height / 4 + 96 + 12, 200, 20, this.action)); - this.buttonList.add(new Button(1, this.width / 2 - 100, this.height / 4 + 120 + 12, 200, 20, "Abbrechen")); - this.nameField = new TextField(this.width / 2 - 100, 60, 200, 20); - this.nameField.setFocused(true); - if(this.player) { - this.nameField.setMaxStringLength(16); - this.nameField.setValidator(new Predicate() { - public boolean apply(String name) { - return NetHandlerPlayServer.isValidUser(name); - } - }); - } - else { - this.nameField.setValidator(new Predicate() { - public boolean apply(String name) { - for(int z = 0; z < name.length(); z++) { - if(GuiCreate.DISALLOWED_CHARS.contains(name.charAt(z))) - return false; - } - return true; - } - }); - } - this.nameField.setText(this.original == null ? "" : this.original); - this.actionButton.enabled = false; - } - -// public void onGuiClosed() { -// Keyboard.enableRepeatEvents(false); -// } - - protected void actionPerformed(Button button) { - if(button.enabled) { - if(button.id == 1) { - this.gm.displayGuiScreen(this.parent); - } - else if(button.id == 0) { - this.callback.confirm(this.nameField.getText().trim()); -// this.gm.displayGuiScreen(this.parent); - } - } - } - - protected void keyTyped(char typedChar, int keyCode) { -// this.nameField.textboxKeyTyped(typedChar, keyCode); - ((Button)this.buttonList.get(0)).enabled = this.nameField.getText().trim().length() > 0; - - if(keyCode == 28 || keyCode == 156) { - this.actionPerformed((Button)this.buttonList.get(0)); - } - } - - public boolean canClose() { - return false; - } - -// protected void mouseClicked(int mouseX, int mouseY, int mouseButton) { -// super.mouseClicked(mouseX, mouseY, mouseButton); -// this.nameField.mouseClicked(mouseX, mouseY, mouseButton); -// } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - this.drawBackground(); - SKC.drawCentered(this.title, this.width / 2, 20, 16777215); - SKC.drawString((this.actionButton.enabled ? "" : TextColor.DARK_RED) + this.desc + - (this.fileExists ? " - Existiert bereits" : (this.noChange ? " - Nicht geändert" : "")), this.width / 2 - 100, 47, 10526880); -// this.nameField.drawTextBox(); - super.drawScreen(mouseX, mouseY, partialTicks); - } -} - - - - - - -package game.gui.world; - -import java.io.File; -import java.util.Set; - -import game.SKC; -import game.collect.Sets; -import game.color.TextColor; -import game.gui.GuiScreen; -import game.gui.element.Button; -import game.init.UniverseRegistry; -import game.network.NetHandlerPlayServer; - -import com.google.common.base.Predicate; -import game.world.Region; - -public class GuiCreate extends GuiScreen -{ - public static final Set DISALLOWED_CHARS = Sets.newHashSet('/', '\n', '\r', '\t', '\u0000', '\f', '`', '?', '*', '\\', - '<', '>', '|', '\"', ':'); - - private GuiScreen parentScreen; - private TextField worldNameField; - private TextField worldUserField; - private boolean alreadyGenerated; - private boolean fileExists; - - public GuiCreate(GuiScreen parent) - { - UniverseRegistry.clear(); - this.parentScreen = parent; - } - - public void updateScreen() - { - this.fileExists = false; - String text = this.worldNameField.getText().trim(); - if(this.fileExists = (!text.isEmpty() && new File(Region.SAVE_DIR, text).exists())) - ((Button)this.buttonList.get(0)).enabled = false; - } - - public void initGui() - { - this.buttonList.add(new Button(0, this.width / 2 - 155, this.height - 28, 150, 20, "Neue Welt erstellen")); - this.buttonList.add(new Button(1, this.width / 2 + 5, this.height - 28, 150, 20, "Abbrechen")); - this.worldNameField = new TextField(this.width / 2 - 100, 60, 200, 20); - this.worldNameField.setFocused(true); - this.worldNameField.setValidator(new Predicate() { - public boolean apply(String name) { - for(int z = 0; z < name.length(); z++) { - if(DISALLOWED_CHARS.contains(name.charAt(z))) - return false; - } - return true; - } - }); - this.worldUserField = new TextField(this.width / 2 - 100, 98, 200, 20); - this.worldUserField.setMaxStringLength(16); - this.worldUserField.setValidator(new Predicate() { - public boolean apply(String name) { - return NetHandlerPlayServer.isValidUser(name); - } - }); - this.buttonList.get(0).enabled = false; - } - - protected void actionPerformed(Button button) - { - if (button.enabled) - { - if (button.id == 1) - { - this.gm.displayGuiScreen(this.parentScreen); - } - else if (button.id == 0) - { - this.gm.displayGuiScreen(null); - if(this.alreadyGenerated) - return; - this.alreadyGenerated = true; - this.gm.launchIntegratedServer(this.worldNameField.getText().trim(), this.worldUserField.getText()); - } - } - } - - protected void keyTyped(char typedChar, int keyCode) - { - if (keyCode == 28 || keyCode == 156) - { - this.actionPerformed((Button)this.buttonList.get(0)); - } - - ((Button)this.buttonList.get(0)).enabled = this.worldNameField.getText().length() > 0 && this.worldUserField.getText().length() > 0; - } - - public boolean canClose() { - return false; - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.drawBackground(); - SKC.drawCentered("Neue Welt erstellen", this.width / 2, 20, -1); - SKC.drawString((this.worldNameField.getText().trim().isEmpty() || this.fileExists /* || this.fileInvalid */ ? TextColor.DARK_RED : "") - + "Ordner der Welt" + (this.fileExists ? " - Existiert bereits" : ""), this.width / 2 - 100, 49, -6250336); - SKC.drawString((this.worldUserField.getText().isEmpty() ? TextColor.DARK_RED : "") + "Spielername", this.width / 2 - 100, 87, -6250336); - - super.drawScreen(mouseX, mouseY, partialTicks); - } -} @@ -1091,491 +184,6 @@ public class GuiServer extends GuiScreen { - - private boolean deleteWorld(int id, final boolean pruneOnly) - { - File worldDir = new File(Region.SAVE_DIR, this.getSaveAt(id)); - if (!worldDir.exists()) - { - return true; - } - Log.JNI.info((pruneOnly ? "Leere" : "Lösche") + " Welt " + worldDir); - boolean flag = false; - for (int i = 1; i <= 5; ++i) - { - Log.JNI.info("Versuch " + i + "..."); - - if (FileUtils.deleteFiles(worldDir.listFiles(new FileFilter() { - public boolean accept(File file) { - return !pruneOnly || (file.isDirectory() ? file.getName().equals("chunk") : file.getName().equals("signs.nbt")); - } - }))) - { - flag = true; - break; - } - - Log.JNI.warn("Konnte Inhalt nicht löschen."); - - if (i < 5) - { - try - { - Thread.sleep(500L); - } - catch (InterruptedException e) - { - ; - } - } - } - - return pruneOnly ? flag : worldDir.delete(); - } - - private static boolean copyFiles(File source, File dest, File[] files) - { - dest.mkdirs(); - if(files == null || !dest.isDirectory()) { - Log.JNI.warn("Konnte Ordner " + source + " nicht nach " + dest + " kopieren"); - return false; - } - boolean flag = true; - for (int i = 0; i < files.length; ++i) - { - File file = files[i]; - File nfile = new File(dest, file.getName()); - Log.JNI.info("Kopiere " + file + " nach " + nfile); - - if (file.isDirectory()) - { - flag &= copyFiles(file, nfile, file.listFiles()); - continue; - } - - try { - Files.copy(file.toPath(), nfile.toPath(), StandardCopyOption.REPLACE_EXISTING); -// Files.copy(file, nfile); - } - catch(IOException e) { - Log.JNI.error(e, "Konnte Datei " + file + " nicht nach " + nfile + " kopieren"); - flag = false; - } - } - return flag; - } - - - - - - - - private void copyWorld(String name) { - File oldDir = new File(Region.SAVE_DIR, this.getSaveAt(this.selectedIndex)); -// String name = this.getSaveAt(this.selectedIndex); -// while(new File(Region.SAVE_DIR, name).exists()) { -// name = name + "-"; -// } - File newDir = new File(Region.SAVE_DIR, name); - Log.JNI.info("Kopiere Welt " + oldDir + " nach " + newDir); - if(!copyFiles(oldDir, newDir, oldDir.listFiles())) { - this.warningTimer = 120; - this.warningMessage = "Fehler beim Kopieren der Welt, diese könnte unvollständig sein!"; - } -// try -// { -// this.loadLevelList(); -// } -// catch (Exception anvilconverterexception) -// { -// Log.error((String)"Konnte Weltliste nicht laden", (Throwable)anvilconverterexception); -// } - this.gm.displayGuiScreen(this); - } - - private void moveWorld(String dest) { - File oldDir = new File(Region.SAVE_DIR, this.getSaveAt(this.selectedIndex)); - File newDir = new File(Region.SAVE_DIR, dest); - Log.JNI.info("Kopiere Welt " + oldDir + " nach " + newDir); - if(!copyFiles(oldDir, newDir, oldDir.listFiles())) { - this.warningTimer = 120; - this.warningMessage = "Fehler beim Kopieren der Welt, diese könnte unvollständig sein!"; - return; - } - if(!this.deleteWorld(this.selectedIndex, false)) { - this.warningTimer = 120; - this.warningMessage = "Fehler beim Löschen der Welt!"; - } - this.gm.displayGuiScreen(this); - } - - - - - - - - private void changeUser(String user) { - File file = new File(new File(Region.SAVE_DIR, this.getSaveAt(this.selectedIndex)), "level.nbt"); - if(file.exists()) { - try { - NBTTagCompound tag = NBTLoader.readGZip(file); - tag.setString("Owner", user); - NBTLoader.writeGZip(tag, file); - } - catch(Exception e) { - Log.JNI.error(e, "Fehler beim Verarbeiten von " + file); - } - } - this.gm.displayGuiScreen(this); - } - - - - private void playWorld(String user) - { - this.gm.displayGuiScreen(null); - - if (!this.starting) - { - this.starting = true; - int index = this.selectedIndex; - if(user == null) - user = this.saveList.get(index).getUser(); - String dir = this.getSaveAt(index); - - if(new File(Region.SAVE_DIR, dir).isDirectory()) { - if(user == null) { - this.gm.displayGuiScreen(new GuiEdit(this, "", true, - "Spieler für '" + dir + "' festlegen", "Festlegen", "Spielername", new Callback() { - public void confirm(String name) { - GuiWorlds.this.playWorld(name); - } - })); - this.starting = false; - } - else { - } - } - } - } - - - - - - - this.gm.displayGuiScreen(new GuiEdit(this, this.saveList.get(this.selectedIndex).getUser(), true, - "Spieler für '" + this.getSaveAt(this.selectedIndex) + "' ändern", "Ändern", "Spielername", new Callback() { - public void confirm(String name) { - GuiWorlds.this.changeUser(name); - } - })); - } - else if (button.id == 0) - { - this.gm.displayGuiScreen(this.parentScreen); - } - else if (button.id == 7) - { - - } - else if (button.id == 9) - { - this.gm.displayGuiScreen(new GuiEdit(this, "", false, - "Welt '" + this.getSaveAt(this.selectedIndex) + "' kopieren", "Kopieren", "Ordner der Welt", new Callback() { - public void confirm(String name) { - GuiWorlds.this.copyWorld(name); - GuiWorlds.this.gm.displayGuiScreen(GuiWorlds.this); - } - })); - } - else if (button.id == 10) - { - this.gm.displayGuiScreen(new GuiEdit(this, this.getSaveAt(this.selectedIndex), false, - "Welt '" + this.getSaveAt(this.selectedIndex) + "' verschieben", "Verschieben", "Ordner der Welt", new Callback() { - public void confirm(String name) { - GuiWorlds.this.moveWorld(name); - GuiWorlds.this.gm.displayGuiScreen(GuiWorlds.this); - } - })); - - - - - - try - { - if(!Region.SAVE_DIR.exists() || !Region.SAVE_DIR.isDirectory()) - throw new RuntimeException("Kann den Speicherordner für Welten nicht lesen oder öffnen!"); - java.util.List list = Lists.newArrayList(); - File[] files = Region.SAVE_DIR.listFiles(); - if(files == null) - throw new RuntimeException("Kann den Speicherordner für Welten nicht lesen oder öffnen!"); - for(File file : files) { - if(!file.isDirectory()) - continue; - if(Region.loadWorldInfo(new File(Region.SAVE_DIR, file.getName())) == -1L && - Converter.getLegacyWorldInfo(new File(Region.SAVE_DIR, file.getName())) == null) { - list.add(new SaveInfo(file.getName(), "???", - null, file.lastModified(), 0L, true, - false, true, true)); - continue; - } - Dimension dim = Region.version < 0 ? null : UniverseRegistry.getDimension(Config.spawnDim); - if(dim != null) { - File dat = new File(new File(new File(new File(Region.SAVE_DIR, file.getName()), "chunk"), - dim.getDimensionName()), "data.nbt"); - try { - dim.fromNbt(NBTLoader.readGZip(dat).getCompoundTag("Generator")); - } - catch(Exception e) { - } - } - list.add(new SaveInfo(file.getName(), dim == null ? "???" : TextColor.stripCodes(dim.getFormattedName(true)), - Region.owner, Region.lastPlayed, dim == null ? 0L : dim.getSeed(), Region.version < 0, - Region.version <= -3, Region.version == -1, Region.version == -4)); - } - this.saveList = list; - Collections.sort(this.saveList); - } - catch (Exception e) - { - Log.JNI.error(e, "Konnte Weltliste nicht laden"); - this.saveList = Lists.newArrayList(); - create = false; - this.warningTimer = 120; - this.warningMessage = "Welten-Ordner nicht lesbar!"; - } - - - - - - - - private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); - - public boolean mousePressed(int slotIndex, int mouseX, int mouseY) - { - GuiWorlds.this.selectedIndex = slotIndex; - boolean sel = GuiWorlds.this.selectedIndex >= 0 && GuiWorlds.this.selectedIndex < GuiWorlds.this.getSize(); - boolean use = sel && !GuiWorlds.this.saveList.get(GuiWorlds.this.selectedIndex).isIncompatible(); - boolean cur = use && !GuiWorlds.this.saveList.get(GuiWorlds.this.selectedIndex).mustConvert(); - GuiWorlds.this.selectButton.display = sel && (!use || !cur) ? "Konvertieren" : "Welt spielen"; - GuiWorlds.this.selectButton.enabled = use; - GuiWorlds.this.deleteButton.enabled = sel; - GuiWorlds.this.pruneButton.enabled = cur; - GuiWorlds.this.copyButton.enabled = use; - GuiWorlds.this.moveButton.enabled = use; - GuiWorlds.this.seedButton.enabled = cur; - GuiWorlds.this.userButton.enabled = cur; - GuiWorlds.this.dupeButton.enabled = cur; - - - if (System.currentTimeMillis() - this.lastClick < 250L && use) - { - GuiWorlds.this.playWorld(null); - } - - this.lastClick = System.currentTimeMillis(); -// if (isDoubleClick && use) -// { -// -// } - return true; - } - - public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) - { - SaveInfo info = (SaveInfo)GuiWorlds.this.saveList.get(slotIndex); - - SKC.drawString((info.isIncompatible() ? TextColor.DARK_RED : "") + info.getFile() + (info.mustConvert() ? "" : - (TextColor.LIGHT_GRAY + " - " + TextColor.RESET + (info.getUser() == null ? "???" : info.getUser()))), x + 2, y + 1, 16777215); - SKC.drawString(info.mustConvert() ? (info.isIncompatible() ? TextColor.BLOOD_RED + "Version: Release 1.13 +" : - (info.isNewerRelease() ? "Version: Release 1.9 - Release 1.12.2" : (info.isOlderRelease() ? - "Version: Alpha 1.0 - Beta 1.2" : "Version: Beta 1.3 - Release 1.8.9"))) - : info.getName(), x + 2, y + 12, 8421504); - SKC.drawString(info.mustConvert() ? (info.isIncompatible() ? TextColor.BLOOD_RED + "Kann nicht konvertiert werden!" : - "Muss konvertiert werden!") : ( // "Kreativmodus: " + (info.isNoCreative() ? "Aus" : "An") + - "Zuletzt gespielt: " + DATE_FORMAT.format(new Date(info.getLastPlayed()))), x + 2, y + 12 + 10, 8421504); - } - - - - - -public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) - { - SKC.drawString(this.name, x + 16 + 3, y + 1, 16777215); - SKC.drawString(/* (this.gm.hideServerAddress ? "[***]" : */ this.address + - (this.access.isEmpty() ? "" : (" / " + this.access.replaceAll(".", "*"))), - x + 16 + 3, y + 12, 8421504); - SKC.drawString(this.user + (this.pass.isEmpty() ? "" : (" / " + this.pass.replaceAll(".", "*"))), - x + 16 + 3, y + 12 + 9, 8421504); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - if (/* this.gm.touchscreen || */ isSelected) - { - GuiMultiplayer.this.gm.getTextureManager().bindTexture(SERVER_SELECTION_BUTTONS); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - int k1 = mouseX - x; - int l1 = mouseY - y; - - if (GuiMultiplayer.this.canMoveUp(slotIndex)) - { - if (k1 < 16 && l1 < 16) - { - drawModalRectWithCustomSizedTexture(x, y, 96.0F, 32.0F, 32, 32, 256.0F, 256.0F); - } - else - { - drawModalRectWithCustomSizedTexture(x, y, 96.0F, 0.0F, 32, 32, 256.0F, 256.0F); - } - } - - if (GuiMultiplayer.this.canMoveDown(slotIndex)) - { - if (k1 < 16 && l1 > 16) - { - drawModalRectWithCustomSizedTexture(x, y, 64.0F, 32.0F, 32, 32, 256.0F, 256.0F); - } - else - { - drawModalRectWithCustomSizedTexture(x, y, 64.0F, 0.0F, 32, 32, 256.0F, 256.0F); - } - } - } - } - - - - - - - - int n = SKC.getStringWidth(this.splashText); - drawRect(0, logoY + 44 + 10 - 1, this.width / 2 - n / 2 - 10, logoY + 44 + 10 + 9 - 1, 0x7f7f00ff); - drawRect(this.width / 2 + n / 2 + 10, logoY + 44 + 10 - 1, this.width, logoY + 44 + 10 + 9 - 1, 0x7f7f00ff); - SKC.drawCentered(this.splashText, this.width / 2, logoY + 44 + 10, 0xff7f00ff); - - SKC.drawString(this.animBack, this.width - SKC.getStringWidth(this.animBack) - 2, this.height - 10, -1); - SKC.drawString(this.animStr, this.width - SKC.getStringWidth(this.animStr) - ((this.animWidth - this.animPos - 4) * 4), this.height - 12, - - - - -private static final Random RANDOM = new Random(); - - private int animWidth = 32; - private int animGrowth = 10; - private int[] animGrow = new int[this.animWidth]; - private String animStr = ""; - private String animBack = ""; - private int animPos; - private int animLen; - private int animDir; - private boolean animStep; - - private void resetAnimation() { - this.animStr = ""; - this.animBack = ""; - this.animPos = 0; - this.animLen = 0; - this.animDir = 0; - this.animStep = false; - this.animWidth = Math.max(5, (this.width - 5) / 4); - this.animGrowth = this.animWidth / 15; - this.animGrow = new int[this.animWidth]; - } - - public void updateScreen() { - if(this.animLen == 0) { - this.animDir = RANDOM.zrange(3) - 1; - this.animLen = this.animDir == 0 ? (2 + RANDOM.zrange(2)) : (8 + RANDOM.zrange(96)); - } - else { - this.animPos += this.animDir; - if(this.animPos == -1) { - this.animPos = 0; - this.animDir = 1; - } - else if(this.animPos == this.animWidth - 3) { - this.animPos = this.animWidth - 4; - this.animDir = -1; - } - this.animLen--; - } - this.animStep = !this.animStep; - StringBuilder sb = new StringBuilder(11); - sb.append(TextColor.GRAY); - sb.append("["); - sb.append(TextColor.YELLOW); - switch(this.animDir) { - case -1: - sb.append((this.animStep ? '>' : '-') + "' "); - break; - case 0: - sb.append("`" + (this.animStep ? 'O' : 'o') + "'"); - break; - case 1: - sb.append(" `" + (this.animStep ? '<' : '-')); - break; - } - sb.append(TextColor.GRAY); - sb.append("]"); - this.animStr = sb.toString(); - for(int z = this.animPos; z < this.animPos + 4; z++) { - this.animGrow[z] = 0; - } - for(int z = 0; z < this.animGrowth; z++) { - this.animGrow[RANDOM.zrange(this.animWidth)] += 1; - } - sb = new StringBuilder(this.animWidth + 2); - sb.append(TextColor.DARK_GREEN); - for(int z = 0; z < this.animWidth; z++) { - switch(this.animGrow[z] / 5) { - case 0: - sb.append(TextColor.BLACK); - break; - case 1: - sb.append(TextColor.GRAY); - break; - case 2: - case 3: - sb.append(TextColor.LIGHT_GRAY); - break; - case 4: - case 5: - case 6: - sb.append(TextColor.WHITE); - break; - case 7: - case 8: - case 9: - case 10: - sb.append(TextColor.LIGHT_PURPLE); - break; - case 11: - case 12: - case 13: - case 14: - case 15: - sb.append(TextColor.DARK_PURPLE); - break; - default: - sb.append(TextColor.VIOLET); - break; - } - sb.append(",."); - } - this.animBack = sb.toString(); - } - - - - - @@ -1619,146 +227,6 @@ private static final Random RANDOM = new Random(); - - - - - - - - -private void renderBossHealth() { - Iterator iter = BOSSBARS.values().iterator(); - int y = 0; - while(iter.hasNext()) { - BossStatus status = iter.next(); - Entity entity; - if(status.bossName != null && status.statusBarTime > 0 && - (entity = this.gm.thePlayer.worldObj.getEntityByID(status.eid)) != null) { - --status.statusBarTime; - // FontRenderer fontrenderer = this.gm.fontRenderer; -// Scaler scaledresolution = new Scaler(this.gm); - int i = this.gm.displayWidth; // scaledresolution.getWidth(); - int j = 182; - int k = i / 2 - j / 2; - int l = (int)(status.healthScale * (float)(j + 1)); - int i1 = 12; - if(entity instanceof EntityLiving) { - Vec3 color = new Vec3(((EntityLiving)entity).getColor()); - GlState.color((float)color.xCoord, (float)color.yCoord, (float)color.zCoord, 1.0F); - } - SKC.rect(k, y + i1, 0, 74, j, 5); - SKC.rect(k, y + i1, 0, 74, j, 5); - - if(l > 0) { - SKC.rect(k, y + i1, 0, 79, l, 5); - } - - String s = status.bossName + TextColor.GRAY + " [" + - EntityLiving.getHealthColor(status.health, status.maxHealth) + - status.health + TextColor.GRAY + " / " + EntityLiving.getMaxHpColor(status.maxHealth) + - status.maxHealth + TextColor.GRAY + "]"; - SKC.drawString(s, i / 2 - SKC.getStringWidth(s) / 2, y + i1 - 10, 16777215); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - this.gm.getTextureManager().bindTexture(icons); - y += 20; - } - else { - iter.remove(); - } - } - } - - - - - - - - public static void drawEntityOnScreen(int posX, int posY, float scale, float mouseX, float mouseY, EntityLiving ent) - { - GlState.enableColorMaterial(); - SKC.glPushMatrix(); - SKC.glTranslatef((float)posX, (float)posY, 50.0F); - SKC.glScalef(-scale, scale, scale); - SKC.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - float f = ent.yawOffset; - float f1 = ent.rotYaw; - float f2 = ent.rotPitch; - float f3 = ent.prevHeadYaw; - float f4 = ent.headYaw; - SKC.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - ItemRenderer.enableStandardItemLighting(); - SKC.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - SKC.glRotatef(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); - ent.yawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F; - ent.rotYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F; - ent.rotPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F; - ent.headYaw = ent.rotYaw; - ent.prevHeadYaw = ent.rotYaw; - SKC.glTranslatef(0.0F, 0.0F, 0.0F); - RenderManager rendermanager = Game.getGame().getRenderManager(); - rendermanager.setPlayerViewY(180.0F); -// rendermanager.setRenderShadow(false); - rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F); -// rendermanager.setRenderShadow(true); - ent.yawOffset = f; - ent.rotYaw = f1; - ent.rotPitch = f2; - ent.prevHeadYaw = f3; - ent.headYaw = f4; - SKC.glPopMatrix(); - ItemRenderer.disableStandardItemLighting(); - GlState.disableRescaleNormal(); - GlState.setActiveTexture(SKC.GL_TEXTURE1); - GlState.disableTexture2D(); - GlState.setActiveTexture(SKC.GL_TEXTURE0); - } - - public static void drawEntity(int posX, int posY, float scale, float yaw, float pitch, EntityLiving ent) - { - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - GlState.enableDepth(); - GlState.enableColorMaterial(); - SKC.glPushMatrix(); - SKC.glTranslatef((float)posX, (float)posY, 200.0F); - SKC.glScalef(-scale, scale, scale); - SKC.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - float f = ent.yawOffset; - float f1 = ent.rotYaw; - float f2 = ent.rotPitch; - float f3 = ent.prevHeadYaw; - float f4 = ent.headYaw; - SKC.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - ItemRenderer.enableStandardItemLighting(); - SKC.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - SKC.glTranslatef(0.0F, ent.height / 2, 0.0F); - SKC.glRotatef(-pitch, 1.0F, 0.0F, 0.0F); - ent.yawOffset = yaw; - ent.rotYaw = yaw; - ent.rotPitch = 0.0f; - ent.headYaw = ent.rotYaw; - ent.prevHeadYaw = ent.rotYaw; - SKC.glTranslatef(0.0F, -(ent.height / 2), 0.0F); - RenderManager rendermanager = Game.getGame().getRenderManager(); - rendermanager.setPlayerViewY(180.0F); - rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F); -// SKC.glTranslatef(0.0F, 0.0F, 0.0F); - ent.yawOffset = f; - ent.rotYaw = f1; - ent.rotPitch = f2; - ent.prevHeadYaw = f3; - ent.headYaw = f4; - SKC.glPopMatrix(); - ItemRenderer.disableStandardItemLighting(); - GlState.disableRescaleNormal(); - GlState.setActiveTexture(SKC.GL_TEXTURE1); - GlState.disableTexture2D(); - GlState.setActiveTexture(SKC.GL_TEXTURE0); - GlState.disableDepth(); - } - - @@ -1933,64 +401,3 @@ private void renderBossHealth() { */ - - - - -private static void makeQuad(float[] polys, int o, float x, float z, float p, float q, float y00, float y10, float y01, float y11) { - polys[o+0] = polys[o+25] = x; - polys[o+1] = polys[o+26] = y00; - polys[o+2] = polys[o+27] = z; - polys[o+3] = polys[o+28] = 0.0f; - polys[o+4] = polys[o+29] = 0.0f; - - polys[o+5] = x + p; - polys[o+6] = y10; - polys[o+7] = z; - polys[o+8] = p; - polys[o+9] = 0.0f; - - polys[o+10] = polys[o+15] = x + p; - polys[o+11] = polys[o+16] = y11; - polys[o+12] = polys[o+17] = z + q; - polys[o+13] = polys[o+18] = p; - polys[o+14] = polys[o+19] = q; - - polys[o+20] = x; - polys[o+21] = y01; - polys[o+22] = z + q; - polys[o+23] = 0.0f; - polys[o+24] = q; -} - -public static interface GraphFunc { - float apply(float x, float z); -} - -public static int makeGraph(GraphFunc func, int xvals, int zvals, float xoffset, float zoffset, float xrange, float zrange, float ysize) { - int x, z; - float[] vertices = new float[30 * xvals * zvals]; - for(x = 0; x < xvals; x++) { - for(z = 0; z < zvals; z++) { - makeQuad(vertices, (x + z * xvals) * 30, (float)x / (float)xvals, (float)z / (float)zvals, 1.0f / (float)xvals, 1.0f / (float)zvals, - func.apply(xoffset + (float)x / (float)xvals * xrange, zoffset + (float)z / (float)zvals * zrange) * ysize, - func.apply(xoffset + (float)(x + 1) / (float)xvals * xrange, zoffset + (float)z / (float)zvals * zrange) * ysize, - func.apply(xoffset + (float)x / (float)xvals * xrange, zoffset + (float)(z + 1) / (float)zvals * zrange) * ysize, - func.apply(xoffset + (float)(x + 1) / (float)xvals * xrange, zoffset + (float)(z + 1) / (float)zvals * zrange) * ysize); - } - } - SKC.glBufferData(sizeof(float) * 30 * xvals * zvals, vertices); - return xvals * zvals * 6; -} - -public static int test() { - final Ng gen = new Ng(...); - return makeGraph(new GraphFunc() { - public float apply(float x, float z) { - double n; - gen.generate(&n, (double)x, 0, (double)z, 1, 1, 1, 512.0, 512.0, 512.0); - return (float)(n / 512.0); - } - }, 128, 128, 0.0f, 0.0f, 512.0f, 512.0f, 0.125f); -} - diff --git a/java/src/game/entity/npc/EntityNPC.java b/java/src/game/entity/npc/EntityNPC.java index b6aa5a6..9fc4bc2 100755 --- a/java/src/game/entity/npc/EntityNPC.java +++ b/java/src/game/entity/npc/EntityNPC.java @@ -4608,7 +4608,7 @@ public abstract class EntityNPC extends EntityLiving public LayerExtra getExtrasLayer() { - return this.isPlayer() ? EntityTexManager.getLayer(this.getId()) : EntityTexManager.getNpcLayer(this.getChar()); + return this.isPlayer() ? EntityTexManager.getLayer(this.getId(), this.species.renderer) : EntityTexManager.getNpcLayer(this.getChar(), this.species.renderer); } public String getLocationSkin() diff --git a/java/src/game/gui/GuiMenu.java b/java/src/game/gui/GuiMenu.java index 41d608a..f0acffd 100644 --- a/java/src/game/gui/GuiMenu.java +++ b/java/src/game/gui/GuiMenu.java @@ -106,7 +106,8 @@ public class GuiMenu extends Gui { } else { this.add(new ActButton(0, 0, 400, 24, (Gui)null, "Zurück zum Spiel")); - this.add(new ActButton(0, 28, 400, 24, GuiOptions.getPage(), "Einstellungen")); + this.add(new ActButton(0, 28, 198, 24, GuiOptions.getPage(), "Einstellungen")); + this.add(new ActButton(202, 28, 198, 24, GuiSkin.INSTANCE, "Charakter")); if(!this.gm.isRemote() && !this.gm.debugWorld) { this.add(new Textbox(0, 56, 96, 24, 5, true, new Textbox.Callback() { public void use(Textbox elem, Action value) { diff --git a/java/src/game/gui/GuiSkin.java b/java/src/game/gui/GuiSkin.java index dcc501c..391f08a 100755 --- a/java/src/game/gui/GuiSkin.java +++ b/java/src/game/gui/GuiSkin.java @@ -8,66 +8,66 @@ import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.util.Arrays; -import java.util.List; -import java.util.Set; - import javax.imageio.ImageIO; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL13; + import game.Game; -import game.audio.SoundManager; -import game.collect.Lists; -import game.collect.Sets; import game.entity.npc.Alignment; import game.entity.npc.CharacterInfo; import game.entity.npc.EntityNPC; -import game.entity.npc.ModelPart; import game.entity.npc.SpeciesInfo; -import game.gui.element.Button; +import game.entity.types.EntityLiving; +import game.gui.element.ActButton; +import game.gui.element.ActButton.Mode; +import game.gui.element.Element; +import game.gui.element.GuiList; +import game.gui.element.Label; +import game.gui.element.ListEntry; import game.gui.element.Slider; -import game.gui.element.TextField; -import game.gui.element.Slider.SliderReceiver; -import game.gui.inventory.GuiInventory; +import game.gui.element.Textbox; +import game.gui.element.Textbox.Action; import game.init.EntityRegistry; import game.init.SpeciesRegistry; import game.init.SpeciesRegistry.ModelType; -import game.io.FileUtils; -import game.io.Log; -import game.lib.input.Keyboard; +import game.log.Log; import game.network.NetHandlerPlayServer; import game.packet.CPacketAction; import game.packet.CPacketMessage; -import game.renderer.FontRenderer; +import game.packet.CPacketSkin; +import game.renderer.Drawing; import game.renderer.GlState; -import game.renderer.texture.DynamicTexture; +import game.renderer.ItemRenderer; +import game.renderer.entity.Render; +import game.renderer.entity.RenderManager; import game.renderer.texture.EntityTexManager; import game.renderer.texture.TextureUtil; -import game.util.Predicate; +import game.util.FileUtils; +import game.util.SkinConverter; +import game.window.Button; -public class GuiSkin extends GuiScreen +public class GuiSkin extends GuiList { - private static class SkinEntry implements GuiListExtended.IGuiListEntry + protected class SkinEntry implements ListEntry { - private static final String SKINS_BUTTONS = "textures/gui/server_selection.png"; - - private final GuiSkin owner; - private final Game gm; private final File skinFile; private final String id; private final ModelType model; private final CharacterInfo charinfo; private final BufferedImage skinImage; - private final String icon; - private DynamicTexture dyntex; - private long clickTime; +// private final String icon; +// private DynamicTexture dyntex; + private final int dynId; - protected SkinEntry(GuiSkin parent, String id, File file, CharacterInfo charinfo, BufferedImage image, ModelType model) + protected SkinEntry(String id, File file, CharacterInfo charinfo, BufferedImage image, ModelType model) { - this.owner = parent; +// this.owner = parent; this.skinFile = file; this.charinfo = charinfo; this.id = id; this.model = model; - this.gm = Game.getGame(); +// this.gm = Game.getGame(); if(this.skinFile != null) // { this.skinImage = image; // this.skin = skin.getName().substring(0, skin.getName().length() - 4); @@ -77,43 +77,61 @@ public class GuiSkin extends GuiScreen // this.skin = null; // } if(this.skinImage != null) { - this.icon = "skins/" + this.id + "/icon"; - this.dyntex = new DynamicTexture(this.skinImage); - this.gm.getTextureManager().loadTexture(this.icon, this.dyntex); + int w = this.skinImage.getWidth(); + int h = this.skinImage.getHeight(); + int[] data = new int[w * h]; + this.skinImage.getRGB(0, 0, w, h, data, 0, w); + this.dynId = 0xffff0000 + GuiSkin.this.elements.size(); + EntityTexManager.setTexture(this.dynId, EntityTexManager.imageToComp(data, model), model); } else { - this.icon = null; - this.dyntex = null; + this.dynId = -1; } } - public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight, int mouseX, int mouseY, boolean isSelected) + public void draw(int x, int y, int mouseX, int mouseY, boolean hovered) { // FontRenderer.drawString(this.skin == null ? "---" : this.skin, x + 32 + 3, y + 1, 16777215); - List list = FontRenderer.listFormattedStringToWidth((this.skinFile != null ? this.skinFile.getName() + String str = // List list = FontRenderer.listFormattedStringToWidth( + (this.skinFile != null ? this.skinFile.getName() : (this.charinfo == null ? "Standard" : ( (this.charinfo.species.prefix && this.charinfo.spclass != null && this.charinfo.spclass.type != null ? this.charinfo.spclass.type.toString() : EntityRegistry.getEntityName(this.charinfo.species.id)) - + (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)) + " (" + this.charinfo.skin + ")"))) + + (this.charinfo.name.isEmpty() ? "" : (" " + this.charinfo.name)) + " (" + this.charinfo.skin + ")"))); // + TextColor.LIGHT_GRAY + " (" + TextColor.GREEN + // this.model.display + TextColor.LIGHT_GRAY +")" - , listWidth - 16 - 2); - - for (int i = 0; i < Math.min(list.size(), 2); ++i) - { - FontRenderer.drawString((String)list.get(i), x + 16 + 3, y + FontRenderer.FONT_HEIGHT * i, this.charinfo == null ? - (this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2); - } +// , listWidth - 16 - 2); +// +// for (int i = 0; i < Math.min(list.size(), 2); ++i) +// { + Drawing.drawText(str, x + 64 + 3, y, 0xff000000 | (this.charinfo == null ? + (this.skinFile != null ? 0xffffff : 0xc0c0c0) : this.charinfo.color1 | this.charinfo.color2)); +// } GlState.color(1.0F, 1.0F, 1.0F, 1.0F); // if(this.model != ModelType.HUMANOID) { // this.drawTextureAt(x, y, EntitySkinManager.HEAD_DEF); // } - if (this.dyntex != null) + + if (/* this.gm.touchscreen || */ hovered) { - this.drawTextureAt(x, y, this.icon); +// GuiSkin.this.gm.getTextureManager().bindTexture(SKINS_BUTTONS); + Drawing.drawRectColor(x, y, 64, 64, -1601138544); +// GlState.color(1.0F, 1.0F, 1.0F, 1.0F); +// int k1 = mouseX - x; +// int l1 = mouseY - y; +// +// if (k1 < 16 && k1 > 0) +// { +// Gui.drawScaledCustomSizeModalRect(x, y, 0.0F, 32.0F, 32, 32, 16, 16, 256.0F, 256.0F); +// } + } + + if (this.dynId != -1) + { + this.drawTextureAt(x, y, EntityTexManager.getSkin(this.dynId, this.model)); } else if(this.charinfo == null) { @@ -124,76 +142,74 @@ public class GuiSkin extends GuiScreen this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : this.charinfo.skin)); } - - if (/* this.gm.touchscreen || */ isSelected) - { - this.gm.getTextureManager().bindTexture(SKINS_BUTTONS); - Gui.drawRect(x, y, x + 16, y + 16, -1601138544); - GlState.color(1.0F, 1.0F, 1.0F, 1.0F); - int k1 = mouseX - x; - int l1 = mouseY - y; - - if (k1 < 16 && k1 > 0) - { - Gui.drawScaledCustomSizeModalRect(x, y, 0.0F, 32.0F, 32, 32, 16, 16, 256.0F, 256.0F); - } - } } protected void drawTextureAt(int x, int y, String tex) { - this.gm.getTextureManager().bindTexture(tex); +// GuiSkin.this.gm.getTextureManager().bindTexture(tex); GlState.enableBlend(); - this.gm.getRenderManager().getRenderObject(this.model).renderHead(x, y, this.model.texWidth, this.model.texHeight, 2); + GlState.enableDepth(); + Render.drawNames = false; + EntityTexManager.altTexture = tex; + EntityTexManager.altLayer = this.dynId; + EntityTexManager.altNpcLayer = this.dynId == -1 && this.charinfo != null ? this.charinfo.skin : null; + drawEntity(x + 32, y + 56, 28.0f + / GuiSkin.this.gm.thePlayer.getHeight(), -45.0f, -20.0f, GuiSkin.this.gm.thePlayer); + Render.drawNames = true; + EntityTexManager.altTexture = null; + EntityTexManager.altLayer = -1; + EntityTexManager.altNpcLayer = null; +// GuiSkin.this.gm.getRenderManager().getRenderObject(this.model).renderHead(x, y, this.model.texWidth, this.model.texHeight, 2); GlState.disableBlend(); + GlState.disableDepth(); } public void deleteTexture() { - if(this.dyntex != null) { - this.gm.getTextureManager().deleteTexture(this.icon); - this.dyntex = null; + if(this.dynId != -1) { + EntityTexManager.setTexture(this.dynId, null, null); } } - /** - * Returns true if the mouse has been pressed on this control. - */ - public boolean mousePressed(int slotIndex, int p_148278_2_, int p_148278_3_, int p_148278_4_, int p_148278_5_, int p_148278_6_) + public void select(boolean dclick, int mx, int my) { - if (Game.getSystemTime() - this.clickTime < 250L) +// if(GuiSkin.this.adjust.dragging) +// return; + if (dclick) { - this.owner.close(); - return true; + GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE); + return; } else { BufferedImage img = this.skinImage; - boolean slim = false; +// boolean slim = false; if(this.charinfo != null) { try { - img = TextureUtil.readImage(FileUtils.getStream( + img = TextureUtil.readImage(FileUtils.getResource( EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : this.charinfo.skin))); } catch(IOException e) { if(e instanceof FileNotFoundException) - Log.warn("Textur für Skin ist nicht vorhanden: " + + Log.JNI.warn("Textur für Skin ist nicht vorhanden: " + EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ? this.charinfo.skin.substring(1) : this.charinfo.skin)); else - Log.error("Konnte Textur nicht laden", e); - return false; + Log.JNI.error(e, "Konnte Textur nicht laden"); + return; } - slim = this.charinfo.skin.startsWith("~"); +// slim = this.charinfo.skin.startsWith("~"); } - else if(this.skinFile != null) { - slim = this.skinFile.getName().startsWith("slim_"); - } - this.owner.selectEntry(slotIndex, slim); - this.owner.selectSkin(this.id, img, slim, this.model); - if(p_148278_5_ < 16 && p_148278_5_ > 0) - this.owner.close(); - this.clickTime = Game.getSystemTime(); - return false; +// else if(this.skinFile != null) { +// slim = this.skinFile.getName().startsWith("slim_"); +// } +// GuiSkin.this.selectEntry(slotIndex, slim); + GuiSkin.this.convertButton1.enabled = this.canConvert(); + GuiSkin.this.convertButton2.enabled = this.canConvert(); + GuiSkin.this.templateButton.enabled = this.canCopy(); + GuiSkin.this.selectSkin(img, this.model); + if(mx < 16 && mx > 0) + GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE); + return; } } @@ -218,19 +234,6 @@ public class GuiSkin extends GuiScreen } } - private static class SkinSelector extends GuiListExtended - { - private final GuiSkin owner; - private final List skinList = Lists.newArrayList(); - private int selectedSlotIndex = -1; - - public SkinSelector(GuiSkin ownerIn, ModelType model, String currentSkin, Game gmIn, int widthIn, int heightIn, int topIn, int bottomIn, int slotHeightIn) - { - super(gmIn, widthIn, heightIn, topIn, bottomIn, slotHeightIn); - this.owner = ownerIn; -// this.setBackgroundDrawing(false); - this.load(currentSkin, model); - } public static BufferedImage loadSkin(File file) { @@ -260,9 +263,9 @@ public class GuiSkin extends GuiScreen }); int pos = 0; // for(ModelType model : ModelType.values()) { - this.skinList.add(new SkinEntry(this.owner, "default", null, null, null, model)); + this.elements.add(new SkinEntry("default", null, null, null, model)); if("default".equals(currentSkin)) - this.setSelectedSlotIndex(pos); + this.setSelected(pos); pos++; // } if(files != null) { @@ -273,9 +276,9 @@ public class GuiSkin extends GuiScreen if(img != null) { // for(ModelType model : ModelType.values()) { if(img.getWidth() == model.texWidth && img.getHeight() == model.texHeight) { - this.skinList.add(new SkinEntry(this.owner, file.getName(), file, null, img, model)); + this.elements.add(new SkinEntry(file.getName(), file, null, img, model)); if(file.getName().equals(currentSkin)) - this.setSelectedSlotIndex(pos); + this.setSelected(pos); pos++; } // } @@ -286,9 +289,9 @@ public class GuiSkin extends GuiScreen for(CharacterInfo charinfo : species.chars) { if(charinfo.species.renderer == model) { // for(Entry entry : SpeciesRegistry.SKINS.entrySet()) { - this.skinList.add(new SkinEntry(this.owner, charinfo.skin, null, charinfo, null, charinfo.species.renderer)); + this.elements.add(new SkinEntry(charinfo.skin, null, charinfo, null, charinfo.species.renderer)); if(charinfo.skin.equals(currentSkin)) - this.setSelectedSlotIndex(pos); + this.setSelected(pos); pos++; } } @@ -297,432 +300,282 @@ public class GuiSkin extends GuiScreen public void unload() { - for (SkinEntry entry : this.skinList) + for (SkinEntry entry : this.elements) { entry.deleteTexture(); } - this.skinList.clear(); + this.elements.clear(); } - protected int getScrollBarX() - { - return 0; - } - - /** - * Gets the width of the list - */ public int getListWidth() { - return 274 - 20; + return 254; } - - protected boolean isInList(int x, int y) - { - return x >= 6; - } - } + + public int getSlotHeight() + { + return 64 + 4; + } - private class DragAdjust extends Button { + private class DragAdjust extends Element { private int mouseX; private int mouseY; private float yawOffset; private float pitchOffset; - public boolean dragging; +// public boolean dragging; - public DragAdjust(int id, int x, int y, int w, int h) { - super(id, x, y, w, h, ""); + public DragAdjust(int x, int y, int w, int h) { + super(x, y, w, h, null); } - public void drawButton(Game gm, int mouseX, int mouseY) { - if(this.visible && this.dragging) { - GuiSkin.this.yaw = this.yawOffset + (this.mouseX - mouseX) * 2.0f; - GuiSkin.this.pitch = this.pitchOffset + (this.mouseY - mouseY) * 2.0f; - } - if(this.visible) - drawRect(this.xPosition, this.yPosition, this.xPosition + this.width, this.yPosition + this.height, 0x20ffffff); + protected void drawBackground() { +// if(this.dragging) { +// +// } + Drawing.drawRectColor(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x20ffffff); + } + + protected void drawForeground(int x1, int y1, int x2, int y2) { + } + + public void drag(int x, int y) { + GuiSkin.this.yaw = this.yawOffset + (this.mouseX - x) * 2.0f; + GuiSkin.this.pitch = this.pitchOffset + (this.mouseY - y) * 2.0f; } - public boolean mousePressed(Game gm, int mouseX, int mouseY) { - if(super.mousePressed(gm, mouseX, mouseY)) { - this.mouseX = mouseX; - this.mouseY = mouseY; - this.yawOffset = GuiSkin.this.yaw; - this.pitchOffset = GuiSkin.this.pitch; - this.dragging = true; - return true; - } - else { - return false; - } + public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) { + this.mouseX = x; + this.mouseY = y; + this.yawOffset = GuiSkin.this.yaw; + this.pitchOffset = GuiSkin.this.pitch; +// this.dragging = true; } - public void mouseReleased(int mouseX, int mouseY) { - this.dragging = false; - } +// public void mouserel() { +// this.dragging = false; +// } - public void playPressSound(SoundManager soundHandlerIn) { + public boolean canHover() { + return false; } } - - private class ButtonPart extends Button - { - private final ModelPart part; - - private ButtonPart(int id, int x, int y, int width, int height, ModelPart part) - { - super(id, x, y, width, height, GuiSkin.this.formatPart(part)); - this.part = part; - } - } - - private class ButtonAlign extends Button - { - private final Alignment align; - - private ButtonAlign(int id, int x, int y, int width, int height, Alignment align) - { - super(id, x, y, width, height, align.color + align.display); - this.align = align; - } - } - private class HeightReceiver implements SliderReceiver { - private int height; - - private HeightReceiver(int value) { - this.height = value; - } - - public float getValue(Game gm) { - return this.height; - } - - public void setValue(Game gm, float value) { - this.height = (int)value; - if(gm.thePlayer != null) - gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, this.height)); - } - - public String formatValue(Game gm) { - return "Spieler-Größe: " + (int)this.height + " cm"; - } - } + public static final GuiSkin INSTANCE = new GuiSkin(); - private final Set parts = Sets.newHashSet(ModelPart.values()); - private final GuiScreen parentScreen; - - private SkinSelector listSelector; - private Button convertButton; - private Button templateButton; - private Button modelButton; + private ActButton convertButton1; + private ActButton convertButton2; + private ActButton templateButton; private DragAdjust adjust; - private TextField nameField; - private boolean initialized; -// private int update; private float yaw; private float pitch; - - public GuiSkin(GuiScreen parentScreen) - { - this.parentScreen = parentScreen; + + private GuiSkin() { } - public void updateScreen() + public void init(int width, int height) { -// if(this.update > 0) -// this.update -= 1; - this.nameField.updateCursorCounter(); -// if(this.gm.nickChanged) { -// this.nameField.setText(this.gm.nickname); -// this.gm.nickChanged = false; -// } - } - - public void initGui() - { - Keyboard.enableRepeatEvents(true); - this.buttonList.clear(); - - if (!this.initialized) - { - this.initialized = true; - this.listSelector = new SkinSelector(this, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel(), this.gm.skinId.isEmpty() ? null : this.gm.skinId, - this.gm, 274, this.height, 32, this.height - 32, 20); - } - else - { - this.listSelector.setDimensions(274, this.height, 32, this.height - 32); - } - - this.buttonList.add(new Button(8, 164, this.height - 28, 274 - 164, 20, "Neu laden")); - int flags = this.gm.thePlayer == null ? ~ModelPart.ARMS_SLIM.getMask() : this.gm.thePlayer.getModelParts(); - this.parts.clear(); - for(ModelPart part : ModelPart.values()) { - if((flags & part.getMask()) == part.getMask()) - this.parts.add(part); - } - this.buttonList.add(this.convertButton = new Button(9, 10, this.height - 28, 150, 20, - "Konvertieren: " + - (this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard"))); - this.buttonList.add(this.templateButton = new Button(10, this.width - 274, this.height - 28, 150, 20, - "Vorlage kopieren")); - this.buttonList.add(this.adjust = new DragAdjust(20, 274 + 10, 64, this.width - 274 - 274 - 20, this.height - 128)); - for (int z = 0; z < ModelPart.values().length; z++) - { - ModelPart part = ModelPart.values()[z]; - Button button = new ButtonPart(z + 500, this.width - 274 + (z & 1) * 134, 32 + 24 * (z >> 1), 130, 20, part); - if(part == ModelPart.ARMS_SLIM) - this.modelButton = button; - this.buttonList.add(button); - } + super.init(width, height); + this.setDimensions(274, height, 52, height - 52); + this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel()); + this.convertButton1 = this.add(new ActButton(4, 4, 266, 20, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + SkinEntry skin = GuiSkin.this.getSelected(); + if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), false)) + GuiSkin.this.gm.displayGuiScreen(GuiSkin.this); + } + }, "Konvertieren: Standard")); + this.convertButton2 = this.add(new ActButton(4, 28, 266, 20, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + SkinEntry skin = GuiSkin.this.getSelected(); + if(skin != null && skin.getFile() != null && SkinConverter.convertSkin(skin.getFile(), new File("skins"), true)) + GuiSkin.this.gm.displayGuiScreen(GuiSkin.this); + } + }, "Konvertieren: Schlank")); + this.add(new ActButton(4, height - 48, 266, 20, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + GuiSkin.this.gm.displayGuiScreen(GuiSkin.this); + } + }, "Neu laden")); + this.templateButton = this.add(new ActButton(4, height - 24, 266, 20, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + SkinEntry skin = GuiSkin.this.getSelected(); + if(skin != null && skin.getLocation() != null) { + String loc = skin.getLocation(); + File file = new File(new File("skins"), loc + ".png"); + int z = 1; + while(file.exists()) { + file = new File(new File("skins"), loc + "_" + (++z) + ".png"); + } + InputStream in = null; + try { + in = FileUtils.getResource(EntityNPC.getSkinTexture(loc)); + Files.copy(in, file.toPath()); + } + catch(Exception e) { + if(e instanceof FileNotFoundException) + Log.JNI.warn("Textur ist nicht zum Kopieren vorhanden: " + EntityNPC.getSkinTexture(loc)); + else + Log.JNI.error(e, "Konnte Textur nicht kopieren"); + } + finally { + if(in != null) { + try { + in.close(); + } + catch(Throwable e) { + } + } + } + GuiSkin.this.gm.displayGuiScreen(GuiSkin.this); + } + } + }, "Vorlage kopieren")); + this.adjust = this.add(new DragAdjust(274 + 10, 64, width - 274 - 274 - 20, height - 128)); + final ActButton[] alignBtns = new ActButton[Alignment.values().length]; for (int z = 0; z < Alignment.values().length; z++) { - Button button; - this.buttonList.add(button = new ButtonAlign(z + 600, this.width - 274 + (z % 3) * 89, this.height - 158 + 23 * (z / 3), 86, 20, - Alignment.values()[z])); - button.enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != Alignment.values()[z]; + final Alignment align = Alignment.values()[z]; + alignBtns[z] = this.add(new ActButton(width - 274 + (z % 3) * 89, height - 158 + 23 * (z / 3), 86, 20, new ActButton.Callback() { + public void use(ActButton elem, Mode action) { + if(GuiSkin.this.gm.thePlayer != null) { + GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, align.ordinal())); + for(ActButton btn : alignBtns) { + btn.enabled = btn != elem; + } + } + } + }, align.color + align.display)); + alignBtns[z].enabled = this.gm.thePlayer == null || this.gm.thePlayer.getAlignment() != align; } -// this.gm.setFloatValue(Options.PLAYER_HEIGHT, ); - this.buttonList.add(new Slider(30, this.width - 274, this.height - 28 - 54, 264, 20, - new HeightReceiver(this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f)), - 120.0f, 320.0f, 1.0f) -// protected void mouseDragged(Game gm, int mouseX, int mouseY) { -// if(this.visible && this.dragging) -// GuiSkin.this.update = 2; -// super.mouseDragged(gm, mouseX, mouseY); -// } -// -// public boolean mouseScrolled(Game gm, int mouseX, int mouseY, int offset) { -// if(super.mouseScrolled(gm, mouseX, mouseY, offset)) { -// GuiSkin.this.update = 2; -// return true; -// } -// return false; -// } - ); - this.buttonList.add(new Button(0, this.width - 274 + 154, this.height - 28, 264 - 154, 20, "Fertig")); - this.convertButton.enabled = false; + this.add(new Slider(width - 274, height - 28 - 54, 264, 20, 1, 120, 320, 180, this.gm.thePlayer == null ? 180 : (int)(this.gm.thePlayer.getSpecies().size * this.gm.thePlayer.getHeight() * 100.0f + 0.5f), new Slider.Callback() { + public void use(Slider elem, int value) { + if(GuiSkin.this.gm.thePlayer != null) + GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_HEIGHT, value)); + } + }, "Spieler-Größe", "cm")); + this.add(new Label(width - 274 + 2, height + 2 - 28 - 24 - 10, 200, 20, "Anzeigename", true)); + this.add(new ActButton(width - 274 + 154, height - 28, 264 - 154, 20, GuiMenu.INSTANCE, "Fertig")); + Textbox nameField = this.add(new Textbox(width - 274 + 2, height + 2 - 28 - 24, 260, 16, NetHandlerPlayServer.MAX_NICK_LENGTH, true, new Textbox.Callback() { + public void use(Textbox elem, Action value) { + if(value == Action.SEND || value == Action.UNFOCUS) { + String name = elem.getText(); + if(name.isEmpty()) + elem.setText(GuiSkin.this.gm.thePlayer == null ? "..." : GuiSkin.this.gm.thePlayer.getCustomNameTag()); + else if(GuiSkin.this.gm.thePlayer != null) + GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name)); + } + } + }, NetHandlerPlayServer.VALID_NICK, this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag())); + this.convertButton1.enabled = false; + this.convertButton2.enabled = false; this.templateButton.enabled = false; - this.nameField = new TextField(this.width - 274 + 2, this.height + 2 - 28 - 24, 260, 16); - this.nameField.setMaxStringLength(32); - this.nameField.setText(this.gm.thePlayer == null ? "" : this.gm.thePlayer.getCustomNameTag()); - this.nameField.setValidator(new Predicate() - { - public boolean apply(String name) - { - return NetHandlerPlayServer.isValidNick(name); - } - }); -// this.gm.nickChanged = false; } - private void sendNameToServer() + public void selectSkin(BufferedImage img, ModelType model) { - String name = this.nameField.getText(); - if(name.isEmpty()) - this.nameField.setText(this.gm.thePlayer == null ? "..." : this.gm.thePlayer.getCustomNameTag()); - else if(this.gm.thePlayer != null) - this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.DISPLAY, name)); - } - - public void selectSkin(String id, BufferedImage img, boolean slim, ModelType model) - { - this.gm.setSkin(img, id, model, slim); - } - - public void close() { - this.gm.displayGuiScreen(this.parentScreen); - } - - public void selectEntry(int index, boolean slim) - { - this.listSelector.setSelectedSlotIndex(index); - if(this.listSelector.getSelectedIndex() >= 0) { - SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex()); - if(slim != this.parts.contains(ModelPart.ARMS_SLIM)) - try { - this.actionPerformed(this.modelButton); - } - catch(IOException e) { - } -// this.update = 2; - this.convertButton.enabled = entry.canConvert(); - this.templateButton.enabled = entry.canCopy(); - } - else { - this.convertButton.enabled = false; - this.templateButton.enabled = false; - } - } - - public boolean doesGuiPauseGame() - { - return false; - } - - public void handleMouseInput() throws IOException - { - super.handleMouseInput(); - if(!this.adjust.dragging) - this.listSelector.handleMouseInput(); + this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model)); } public void onGuiClosed() { - Keyboard.enableRepeatEvents(false); + this.unload(); + } + + public void drawOverlays() + { + drawEntity(274 + (this.gm.fb_x - 274 - 274) / 2, this.gm.fb_y / 2 + 160, 160.0f + / this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer); + } + + public String getTitle() { + return "Charakter anpassen"; + } + + - this.listSelector.unload(); - } - protected void actionPerformed(Button button) throws IOException - { - if (button.enabled) - { - if (button.id == 0) - { - this.gm.displayGuiScreen(this.parentScreen); - } - else if (button.id == 8) - { - this.refreshList(); - } - else if (button.id == 9) - { - if(this.listSelector.getSelectedIndex() >= 0) { - SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex()); - if(entry.getFile() != null && SkinConverter.convertSkin(entry.getFile(), new File("skins"), - this.parts.contains(ModelPart.ARMS_SLIM))) { - this.refreshList(); - } - } - } - else if (button.id == 10) - { - if(this.listSelector.getSelectedIndex() >= 0) { - SkinEntry entry = this.listSelector.getListEntry(this.listSelector.getSelectedIndex()); - if(entry.getLocation() != null) { - String loc = (this.parts.contains(ModelPart.ARMS_SLIM) ? "slim_" : "") + entry.getLocation(); - File file = new File(new File("skins"), loc + ".png"); - int z = 1; - while(file.exists()) { - file = new File(new File("skins"), loc + "_" + (++z) + ".png"); - } - InputStream in = null; - try { - in = FileUtils.getStream(EntityNPC.getSkinTexture(entry.getLocation())); - Files.copy(in, file.toPath()); - } - catch(Exception e) { - if(e instanceof FileNotFoundException) - Log.warn("Textur ist nicht zum Kopieren vorhanden: " + FileUtils.getStream(EntityNPC.getSkinTexture(entry.getLocation()))); - else - Log.error("Konnte Textur nicht kopieren", e); - } - finally { - FileUtils.closeQuietly(in); - } - this.refreshList(); - } - } - } - else if (button.id == 30) - { -// this.update = 2; - } - else if (button instanceof ButtonPart) - { - ModelPart part = ((ButtonPart)button).part; -// this.switchModelPartEnabled(part); - if(!this.parts.contains(part)) - this.parts.add(part); - else - this.parts.remove(part); - if(this.gm.thePlayer != null) { - int n = 0; - for(ModelPart p : this.parts) { - n |= p.getMask(); - } - this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_MODELPARTS, n)); - } - button.display = this.formatPart(part); -// this.update = 2; - if(part == ModelPart.ARMS_SLIM) - this.convertButton.display = "Konvertieren: " + - (this.parts.contains(ModelPart.ARMS_SLIM) ? "Schlank" : "Standard"); - } - else if (button instanceof ButtonAlign) - { - if(this.gm.thePlayer != null) { - this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_ALIGN, - ((ButtonAlign)button).align.ordinal())); - for(Button btn : this.buttonList) { - if(btn instanceof ButtonAlign) - btn.enabled = ((ButtonAlign)button).align != ((ButtonAlign)btn).align; - } - } - } - } - } - - public void refreshList() - { - this.gm.displayGuiScreen(new GuiSkin(this.parentScreen)); - } +// public static void drawEntityOnScreen(int posX, int posY, float scale, float mouseX, float mouseY, EntityLiving ent) +// { +// GlState.enableColorMaterial(); +// SKC.glPushMatrix(); +// SKC.glTranslatef((float)posX, (float)posY, 50.0F); +// SKC.glScalef(-scale, scale, scale); +// SKC.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); +// float f = ent.yawOffset; +// float f1 = ent.rotYaw; +// float f2 = ent.rotPitch; +// float f3 = ent.prevHeadYaw; +// float f4 = ent.headYaw; +// SKC.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); +// ItemRenderer.enableStandardItemLighting(); +// SKC.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); +// SKC.glRotatef(-((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); +// ent.yawOffset = (float)Math.atan((double)(mouseX / 40.0F)) * 20.0F; +// ent.rotYaw = (float)Math.atan((double)(mouseX / 40.0F)) * 40.0F; +// ent.rotPitch = -((float)Math.atan((double)(mouseY / 40.0F))) * 20.0F; +// ent.headYaw = ent.rotYaw; +// ent.prevHeadYaw = ent.rotYaw; +// SKC.glTranslatef(0.0F, 0.0F, 0.0F); +// RenderManager rendermanager = Game.getGame().getRenderManager(); +// rendermanager.setPlayerViewY(180.0F); +//// rendermanager.setRenderShadow(false); +// rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F); +//// rendermanager.setRenderShadow(true); +// ent.yawOffset = f; +// ent.rotYaw = f1; +// ent.rotPitch = f2; +// ent.prevHeadYaw = f3; +// ent.headYaw = f4; +// SKC.glPopMatrix(); +// ItemRenderer.disableStandardItemLighting(); +// GlState.disableRescaleNormal(); +// GlState.setActiveTexture(SKC.GL_TEXTURE1); +// GlState.disableTexture2D(); +// GlState.setActiveTexture(SKC.GL_TEXTURE0); +// } - protected void keyTyped(char typedChar, int keyCode) throws IOException + public static void drawEntity(int posX, int posY, float scale, float yaw, float pitch, EntityLiving ent) { - if(this.nameField.isFocused() && keyCode == Keyboard.KEY_RETURN || keyCode == Keyboard.KEY_NUMPADENTER) { - this.sendNameToServer(); - this.nameField.setFocused(false); - } - else { - this.nameField.textboxKeyTyped(typedChar, keyCode); - } - if(keyCode == Keyboard.KEY_F5) - this.refreshList(); - else - super.keyTyped(typedChar, keyCode); - } - - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.drawBackground(); -// this.drawGradientRect(0, 0, this.width, this.height - 32, 0xC0101010, 0xD0101010); - this.listSelector.drawScreen(mouseX, mouseY, partialTicks); -// this.drawBackground(0, this.height - 32, this.width, 32); -// drawRect(284, 64, this.width - 284, this.height - 64, 0x20000000); - FontRenderer.drawCenteredString("Charakter anpassen", this.width / 2, 20, 0xffffff); - FontRenderer.drawStringWithShadow("Anzeigename", this.nameField.xPosition, this.nameField.yPosition - 10, 10526880); - this.nameField.drawTextBox(); - super.drawScreen(mouseX, mouseY, partialTicks); - GuiInventory.drawEntity(274 + (this.width - 274 - 274) / 2, this.height / 2 + 80, 80.0f /* * - 1.8f */ / this.gm.thePlayer.getHeight(), this.yaw, this.pitch, this.gm.thePlayer); - } - - protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException - { - super.mouseClicked(mouseX, mouseY, mouseButton); - this.listSelector.mouseClicked(mouseX, mouseY, mouseButton); - boolean flag = this.nameField.isFocused(); - this.nameField.mouseClicked(mouseX, mouseY, mouseButton); - if(flag && !this.nameField.isFocused()) - this.sendNameToServer(); -// else if(!flag && this.nameField.isFocused()) -// this.nameField.setText(TextColor.getCodes(this.nameField.getText())); - } - - protected void mouseReleased(int mouseX, int mouseY, int state) - { - super.mouseReleased(mouseX, mouseY, state); - this.listSelector.mouseReleased(mouseX, mouseY, state); - } - - private String formatPart(ModelPart part) - { - return part.getName() + ": " + ( - this.parts.contains(part) ? (part == ModelPart.ARMS_SLIM ? "Schlank" : "An") : - (part == ModelPart.ARMS_SLIM ? "Standard" : "Aus")); + GlState.color(1.0F, 1.0F, 1.0F, 1.0F); + GlState.enableDepth(); + GlState.enableColorMaterial(); + GL11.glPushMatrix(); + GL11.glTranslatef((float)posX, (float)posY, 200.0F); + GL11.glScalef(-scale, scale, scale); + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + float f = ent.yawOffset; + float f1 = ent.rotYaw; + float f2 = ent.rotPitch; + float f3 = ent.prevHeadYaw; + float f4 = ent.headYaw; + GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); + ItemRenderer.enableStandardItemLighting(); + GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, ent.height / 2, 0.0F); + GL11.glRotatef(-pitch, 1.0F, 0.0F, 0.0F); + ent.yawOffset = yaw; + ent.rotYaw = yaw; + ent.rotPitch = 0.0f; + ent.headYaw = ent.rotYaw; + ent.prevHeadYaw = ent.rotYaw; + GL11.glTranslatef(0.0F, -(ent.height / 2), 0.0F); + RenderManager rendermanager = Game.getGame().getRenderManager(); + rendermanager.setPlayerViewY(180.0F); + rendermanager.renderEntity(ent, 0.0D, 0.0D, 0.0D, 1.0F); +// GL11.glTranslatef(0.0F, 0.0F, 0.0F); + ent.yawOffset = f; + ent.rotYaw = f1; + ent.rotPitch = f2; + ent.prevHeadYaw = f3; + ent.headYaw = f4; + GL11.glPopMatrix(); + ItemRenderer.disableStandardItemLighting(); + GlState.disableRescaleNormal(); + GlState.setActiveTexture(GL13.GL_TEXTURE1); + GlState.disableTexture2D(); + GlState.setActiveTexture(GL13.GL_TEXTURE0); + GlState.disableDepth(); } } + diff --git a/java/src/game/gui/element/GuiList.java b/java/src/game/gui/element/GuiList.java index 520882f..2d9445c 100755 --- a/java/src/game/gui/element/GuiList.java +++ b/java/src/game/gui/element/GuiList.java @@ -73,6 +73,10 @@ public abstract class GuiList extends Gui public final int getSize() { return this.elements.size(); } + + public final void setSelected(int index) { + this.selectedElement = index; + } protected int getContentHeight() { diff --git a/java/src/game/renderer/entity/Render.java b/java/src/game/renderer/entity/Render.java index 3dc66b5..3682601 100755 --- a/java/src/game/renderer/entity/Render.java +++ b/java/src/game/renderer/entity/Render.java @@ -20,6 +20,7 @@ import game.world.World; public abstract class Render { + public static boolean drawNames = true; // private static final String shadowTextures = "textures/world/shadow.png"; protected final RenderManager renderManager; @@ -310,7 +311,7 @@ public abstract class Render protected void renderLivingLabel(T entityIn, String str, double x, double y, double z, int maxDistance) { double d0 = entityIn.getDistanceSqToEntity(this.renderManager.livingPlayer); - if (d0 <= (double)(maxDistance * maxDistance)) { + if (d0 <= (double)(maxDistance * maxDistance) && drawNames) { // WCF.glPushMatrix(); // WCF.glTranslatef((float)x, (float)y + entityIn.height + 0.5f, (float)z); // float f = 1.0f / 64.0f; diff --git a/java/src/game/renderer/texture/EntityTexManager.java b/java/src/game/renderer/texture/EntityTexManager.java index 4efecc2..252df61 100755 --- a/java/src/game/renderer/texture/EntityTexManager.java +++ b/java/src/game/renderer/texture/EntityTexManager.java @@ -25,12 +25,17 @@ import game.util.FileUtils; public abstract class EntityTexManager { + public static String altTexture = null; + public static int altLayer = -1; + public static String altNpcLayer = null; + public static final int MAX_SKIN_SIZE = 65536; private static final Set USER_TEXTURES = Sets.newHashSet(); private static final Map USER_LAYERS = Maps.newHashMap(); private static final Map NPC_LAYERS = Maps.newHashMap(); private static final Map DEF_TEXTURES = Maps.newEnumMap(ModelType.class); + private static final Map DEF_LAYERS = Maps.newEnumMap(ModelType.class); public static void loadNpcTextures() { TextureManager manager = Game.getGame().getTextureManager(); @@ -75,6 +80,9 @@ public abstract class EntityTexManager } dyntex.updateDynamicTexture(); LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue()); + if(EntityNPC.getSkinTexture(skin).equals(getDefault(entry.getValue()))) { + DEF_LAYERS.put(entry.getValue(), extra); + } if(extra != null) { extra = NPC_LAYERS.put(skin, extra); } @@ -116,6 +124,10 @@ public abstract class EntityTexManager dyntex.updateDynamicTexture(); // setCape(cape, image); } +// for(ModelType model : ModelType.values()) { +// if(DEF_TEXTURES.get(model) == null) +// Log.IO.warn(altNpcLayer); +// } } public static String getDefault(ModelType model) { @@ -137,19 +149,20 @@ public abstract class EntityTexManager return "capes/" + name.toLowerCase() + "/dyn"; } - public static LayerExtra getLayer(int id) + public static LayerExtra getLayer(int id, ModelType model) { - return USER_LAYERS.get(id); + return altNpcLayer != null ? getNpcLayer(altNpcLayer, model) : (altLayer != -1 ? USER_LAYERS.get(altLayer) : (USER_TEXTURES.contains(id) ? USER_LAYERS.get(id) : DEF_LAYERS.get(model))); } - public static LayerExtra getNpcLayer(String skin) + public static LayerExtra getNpcLayer(String skin, ModelType model) { - return NPC_LAYERS.get((skin.startsWith("~") ? skin.substring(1) : skin).toLowerCase()); + return Game.getGame().getTextureManager().getTexture(getNpcSkinLocation(skin.startsWith("~") ? skin.substring(1) : skin)) != null ? + NPC_LAYERS.get((skin.startsWith("~") ? skin.substring(1) : skin).toLowerCase()) : DEF_LAYERS.get(model); } public static String getSkin(int id, ModelType model) { - String loc = getSkinLocation(id); + String loc = altTexture != null ? altTexture : getSkinLocation(id); return Game.getGame().getTextureManager().getTexture(loc) != null ? loc : getDefault(model); }