fixes, cmds
This commit is contained in:
parent
868a5ed9ea
commit
c906760bd4
13 changed files with 295 additions and 134 deletions
|
@ -294,7 +294,7 @@ public class Game implements IThreadListener {
|
|||
public EntityNPC thePlayer;
|
||||
public HitPosition pointed;
|
||||
|
||||
@Variable(name = "chunk_view_distance", category = CVarCategory.WORLD, min = 2, max = 128, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
||||
@Variable(name = "chunk_view_distance", category = CVarCategory.WORLD, min = 2, max = 16 /* 128 */, callback = DistanceFunction.class, display = "Sichtweite", unit = "Chunks")
|
||||
public int renderDistance = 8;
|
||||
@Variable(name = "chunk_build_time", category = CVarCategory.WORLD, min = 1, max = 100, display = "Max. Zeit für Chunk-Bau pro Frame", unit = "ms")
|
||||
public int maxBuildTime = 8;
|
||||
|
@ -2293,6 +2293,9 @@ public class Game implements IThreadListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.displayGuiScreen(GuiMenu.INSTANCE);
|
||||
}
|
||||
server = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +1,5 @@
|
|||
|
||||
|
||||
|
||||
//private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
package game.gui.server;
|
||||
|
||||
import game.SKC;
|
||||
|
|
|
@ -14,6 +14,7 @@ import game.entity.npc.EntityNPC;
|
|||
import game.entity.types.EntityLiving;
|
||||
import game.item.Item;
|
||||
import game.item.ItemStack;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.world.BlockPos;
|
||||
import game.world.State;
|
||||
import game.world.Vec3;
|
||||
|
@ -403,4 +404,8 @@ public class ScriptArgs {
|
|||
public WorldServer getWorld(String name) {
|
||||
return this.getUnchecked(name);
|
||||
}
|
||||
|
||||
public NBTTagCompound getTag(String name) {
|
||||
return this.getUnchecked(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
package game.command;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import game.command.DoubleParser.DefType;
|
||||
import game.world.World;
|
||||
|
||||
public abstract class ScriptExecutable implements Executable {
|
||||
private final String name;
|
||||
private final Map<String, Parameter> parameters = Maps.newHashMap();
|
||||
|
@ -31,6 +35,62 @@ public abstract class ScriptExecutable implements Executable {
|
|||
return this;
|
||||
}
|
||||
|
||||
protected ScriptExecutable addParameter(ArgumentParser parser) {
|
||||
return this.addParameter(parser.getName(), parser);
|
||||
}
|
||||
|
||||
protected ScriptExecutable addParameter(char shortName, ArgumentParser parser) {
|
||||
return this.addParameter(parser.getName(), shortName, parser);
|
||||
}
|
||||
|
||||
protected ScriptExecutable addVector(String name, boolean defaulted) {
|
||||
return this.addParameter(name, new DoubleParser("x", defaulted ? DefType.X : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE), new DoubleParser("y", defaulted ? DefType.Y : null, 0.0, (double)World.HEIGHT), new DoubleParser("z", defaulted ? DefType.Z : null, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addWorld(String name, boolean defaulted) {
|
||||
return this.addParameter(new WorldParser(name, false, defaulted));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addInt(String name, char shortName, int min, int max, int def) {
|
||||
return this.addParameter(shortName, new IntParser(name, false, def, min, max, def));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addInt(String name, int min, int max, int def) {
|
||||
return this.addParameter(new IntParser(name, false, def, min, max, def));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addFlag(String name, char shortName) {
|
||||
return this.addParameter(name, shortName);
|
||||
}
|
||||
|
||||
protected ScriptExecutable addFlag(String name) {
|
||||
return this.addParameter(name, name.charAt(0));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addEnum(String name, Object ... values) {
|
||||
return this.addParameter(new EnumParser(name, null, values));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addEnumDef(String name, Object def, Object ... values) {
|
||||
return this.addParameter(new EnumParser(name, null, values));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addEnum(String name, Collection<?> values) {
|
||||
return this.addEnum(name, (Object[])values.toArray(new String[values.size()]));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addEnumDef(String name, Object def, Collection<?> values) {
|
||||
return this.addEnumDef(name, def, (Object[])values.toArray(new String[values.size()]));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addTag(String name) {
|
||||
return this.addParameter(new TagParser(name, null));
|
||||
}
|
||||
|
||||
protected ScriptExecutable addTag(String name, char shortName) {
|
||||
return this.addParameter(shortName, new TagParser(name, null));
|
||||
}
|
||||
|
||||
public Object exec(ScriptEnvironment env, ScriptArgs args) {
|
||||
return null;
|
||||
}
|
||||
|
|
22
java/src/game/command/TagParser.java
Normal file
22
java/src/game/command/TagParser.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package game.command;
|
||||
|
||||
import game.nbt.NBTException;
|
||||
import game.nbt.NBTParser;
|
||||
import game.nbt.NBTTagCompound;
|
||||
|
||||
public class TagParser extends DefaultingParser {
|
||||
public TagParser(String name, NBTTagCompound def, Object ... completions) {
|
||||
super(name, def, completions);
|
||||
}
|
||||
|
||||
public NBTTagCompound parse(ScriptEnvironment env, String input) {
|
||||
NBTTagCompound value;
|
||||
try {
|
||||
value = NBTParser.parseTag(input);
|
||||
}
|
||||
catch(NBTException e) {
|
||||
throw new ScriptException(e, "Ungültiger NBT-Tag '%s'", input);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
|
@ -4,20 +4,15 @@ import java.util.Set;
|
|||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import game.command.DoubleParser;
|
||||
import game.command.DoubleParser.DefType;
|
||||
import game.command.EnumParser;
|
||||
import game.command.IntParser;
|
||||
import game.command.ScriptArgs;
|
||||
import game.command.ScriptEnvironment;
|
||||
import game.command.ScriptException;
|
||||
import game.command.ScriptExecutable;
|
||||
import game.command.WorldParser;
|
||||
import game.entity.Entity;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.EntityRegistry;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.world.Vec3;
|
||||
import game.world.World;
|
||||
import game.world.WorldServer;
|
||||
|
||||
public class CommandSpawn extends ScriptExecutable {
|
||||
|
@ -27,13 +22,14 @@ public class CommandSpawn extends ScriptExecutable {
|
|||
for(Class<? extends Entity> clazz : EntityRegistry.getAllClasses()) {
|
||||
names.add(EntityRegistry.getEntityString(clazz));
|
||||
}
|
||||
this.addParameter("type", new EnumParser("type", null, (Object[])names.toArray(new String[names.size()])));
|
||||
this.addEnum("type", names);
|
||||
this.setParamsOptional();
|
||||
this.addParameter("position", new DoubleParser("x", DefType.X, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE), new DoubleParser("y", DefType.Y, 0.0, (double)World.HEIGHT), new DoubleParser("z", DefType.Z, (double)(-World.MAX_SIZE), (double)World.MAX_SIZE));
|
||||
this.addParameter("dim", new WorldParser("dim", false, true));
|
||||
|
||||
this.addParameter("noinit", 'n');
|
||||
this.addParameter("count", 'c', new IntParser("count", false, 1, 1, 1024));
|
||||
this.addVector("position", true);
|
||||
this.addWorld("dim", true);
|
||||
this.addTag("tag");
|
||||
this.addFlag("noinit");
|
||||
this.addInt("count", 'c', 1, 1024, 1);
|
||||
this.addTag("postTag", 'p');
|
||||
}
|
||||
|
||||
public Object exec(ScriptEnvironment env, ScriptArgs args) {
|
||||
|
@ -42,14 +38,28 @@ public class CommandSpawn extends ScriptExecutable {
|
|||
Vec3 pos = args.getVector("position");
|
||||
int count = args.getInt("count");
|
||||
boolean init = !args.has("noinit");
|
||||
NBTTagCompound tag = args.getTag("tag");
|
||||
NBTTagCompound postTag = args.getTag("postTag");
|
||||
for(int z = 0; z < count; z++) {
|
||||
Entity entity = EntityRegistry.createEntityByName(type, world);
|
||||
if(entity == null)
|
||||
throw new ScriptException("Objekt konnte nicht erzeugt werden");
|
||||
entity.setLocationAndAngles(pos.xCoord, pos.yCoord, pos.zCoord, world.rand.floatv() * 360.0f, 0.0f);
|
||||
if(tag != null) {
|
||||
NBTTagCompound ent = new NBTTagCompound();
|
||||
entity.writeToNBT(ent);
|
||||
ent.merge(tag);
|
||||
entity.readFromNBT(ent);
|
||||
}
|
||||
if(init && (entity instanceof EntityLiving))
|
||||
((EntityLiving)entity).onInitialSpawn(null);
|
||||
world.spawnEntityInWorld(entity);
|
||||
if(postTag != null) {
|
||||
NBTTagCompound ent = new NBTTagCompound();
|
||||
entity.writeToNBT(ent);
|
||||
ent.merge(postTag);
|
||||
entity.readFromNBT(ent);
|
||||
}
|
||||
}
|
||||
env.getExecutor().logConsole("%s%s bei %d, %d, %d in %s erschaffen", count == 1 ? "" : (count + "x "), EntityRegistry.getEntityName(type), (int)pos.xCoord, (int)pos.yCoord, (int)pos.zCoord, world.dimension.getFormattedName(false));
|
||||
return null;
|
||||
|
|
|
@ -2,14 +2,20 @@ package game.gui;
|
|||
|
||||
import game.color.TextColor;
|
||||
import game.gui.element.Dropdown;
|
||||
import game.gui.element.Element;
|
||||
import game.gui.element.Fill;
|
||||
import game.gui.element.Slider;
|
||||
import game.gui.element.Toggle;
|
||||
import game.util.Formatter;
|
||||
import game.window.Button;
|
||||
import game.window.DisplayMode;
|
||||
import game.window.Window;
|
||||
|
||||
public class GuiDisplay extends GuiOptions {
|
||||
private static final String[] DISTANCES = new String[] {"Gruselig", "Winzig", "Gering", "Normal", "Weit"};
|
||||
|
||||
private Element distanceSlider;
|
||||
|
||||
protected GuiDisplay() {
|
||||
}
|
||||
|
||||
|
@ -66,7 +72,7 @@ public class GuiDisplay extends GuiOptions {
|
|||
this.addSelector("con_position", 30, 280, 440, 24);
|
||||
|
||||
this.addSelector("gl_fov", 30, 360, 440, 24);
|
||||
this.addSelector("chunk_view_distance", 30, 400, 440, 24);
|
||||
this.distanceSlider = this.addSelector("chunk_view_distance", 30, 400, 440, 24);
|
||||
this.addSelector("chunk_build_time", 490, 400, 440, 24);
|
||||
super.init(width, height);
|
||||
}
|
||||
|
@ -74,4 +80,18 @@ public class GuiDisplay extends GuiOptions {
|
|||
public String getTitle() {
|
||||
return "Grafik und Anzeige";
|
||||
}
|
||||
|
||||
private String getDistanceName() {
|
||||
int distance = this.gm.renderDistance;
|
||||
distance = distance > 16 ? 16 : distance;
|
||||
String str = distance < 0 ? DISTANCES[0] : DISTANCES[(distance + 1) / 4];
|
||||
if(distance > 2 && (((distance + 1) / 2) & 1) == 1)
|
||||
str = str + "+";
|
||||
return String.format("Sichtweite: %d Chunks [%d Blöcke, %s]", this.gm.renderDistance, this.gm.renderDistance * 16, str);
|
||||
}
|
||||
|
||||
public void updateScreen() {
|
||||
if(!Button.isMouseDown())
|
||||
this.distanceSlider.setText(this.getDistanceName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ public class GuiMenu extends Gui {
|
|||
GuiMenu.this.gm.unload(true);
|
||||
// GuiMenu.this.gm.displayGuiScreen(INSTANCE);
|
||||
}
|
||||
}, this.gm.isRemote() ? "Verbindung trennen" : "Welt schließen"));
|
||||
}, this.gm.isRemote() ? "Server verlassen und Verbindung trennen" : "Welt speichern und schließen"));
|
||||
this.shift();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,8 +139,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
|||
}
|
||||
else
|
||||
{
|
||||
this.drawTextureAt(x, y, EntityNPC.getSkinTexture(this.charinfo.skin.startsWith("~") ?
|
||||
this.charinfo.skin.substring(1) : this.charinfo.skin));
|
||||
this.drawTextureAt(x, y, EntityTexManager.getNpcSkin(this.charinfo.skin, this.model));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -153,7 +152,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
|||
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
|
||||
drawEntity(x + 32, y + 60, 28.0f
|
||||
/ GuiSkin.this.gm.thePlayer.getHeight(), -45.0f, -20.0f, GuiSkin.this.gm.thePlayer);
|
||||
Render.drawNames = true;
|
||||
EntityTexManager.altTexture = null;
|
||||
|
@ -234,6 +233,199 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
|||
}
|
||||
}
|
||||
|
||||
private class DragAdjust extends Element {
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
private float yawOffset;
|
||||
private float pitchOffset;
|
||||
// public boolean dragging;
|
||||
|
||||
public DragAdjust(int x, int y, int w, int h) {
|
||||
super(x, y, w, h, null);
|
||||
}
|
||||
|
||||
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 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 mouserel() {
|
||||
// this.dragging = false;
|
||||
// }
|
||||
|
||||
public boolean canHover() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiSkin INSTANCE = new GuiSkin();
|
||||
|
||||
private ActButton convertButton1;
|
||||
private ActButton convertButton2;
|
||||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
private float yaw = -15.0f;
|
||||
private float pitch = -15.0f;
|
||||
|
||||
private GuiSkin() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
super.init(width, height);
|
||||
this.setDimensions(400, height, 52, height - 52);
|
||||
this.load(null, this.gm.thePlayer == null ? ModelType.HUMANOID : this.gm.thePlayer.getModel());
|
||||
this.convertButton1 = this.add(new ActButton(10, height - 48, 200, 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(10, height - 24, 200, 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(240, height - 48, 150, 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(240, height - 24, 150, 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(400 + 10, 64, width - 400 - 400 - 20, height - 128));
|
||||
|
||||
// final ActButton[] speciesBtns = new ActButton[SpeciesRegistry.SPECIMEN.size()];
|
||||
for(int z = 0; z < SpeciesRegistry.SPECIMEN.size(); z++) {
|
||||
final SpeciesInfo species = SpeciesRegistry.SPECIMEN.get(z);
|
||||
// speciesBtns[z] =
|
||||
this.add(new ActButton(width - 400 + (z % 2) * 196, 4 + 23 * (z / 2), 194, 20, new ActButton.Callback() {
|
||||
public void use(ActButton elem, Mode action) {
|
||||
if(GuiSkin.this.gm.thePlayer != null) {
|
||||
GuiSkin.this.gm.displayGuiScreen(GuiMenu.INSTANCE);
|
||||
GuiSkin.this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketAction(CPacketAction.Action.SET_SPECIES, EntityRegistry.getEntityID(species.clazz)));
|
||||
// for(ActButton btn : speciesBtns) {
|
||||
// btn.enabled = btn != elem;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}, EntityRegistry.getEntityName(EntityRegistry.getEntityString(species.clazz)))) // ;
|
||||
// speciesBtns[z]
|
||||
.enabled = this.gm.thePlayer == null || this.gm.thePlayer.getClass() != species.clazz;
|
||||
}
|
||||
|
||||
final ActButton[] alignBtns = new ActButton[Alignment.values().length];
|
||||
for (int z = 0; z < Alignment.values().length; z++)
|
||||
{
|
||||
final Alignment align = Alignment.values()[z];
|
||||
alignBtns[z] = this.add(new ActButton(width - 400 + (z % 3) * 131, height - 198 + 23 * (z / 3), 129, 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.add(new Slider(width - 400, height - 28 - 84, 390, 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 - 400, height + 2 - 28 - 24 - 30, 390, 20, "Anzeigename", true));
|
||||
this.add(new ActButton(width - 274 + 154, height - 24, 264 - 154, 20, GuiMenu.INSTANCE, "Fertig"));
|
||||
Textbox nameField = this.add(new Textbox(width - 400, height + 2 - 28 - 34, 390, 20, 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;
|
||||
}
|
||||
|
||||
public void selectSkin(BufferedImage img, ModelType model)
|
||||
{
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model));
|
||||
}
|
||||
|
||||
public void onGuiClosed()
|
||||
{
|
||||
this.unload();
|
||||
}
|
||||
|
||||
public void drawOverlays()
|
||||
{
|
||||
drawEntity(400 + (this.gm.fb_x - 400 - 400) / 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";
|
||||
}
|
||||
|
||||
public static BufferedImage loadSkin(File file)
|
||||
{
|
||||
|
@ -310,7 +502,7 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
|||
|
||||
public int getListWidth()
|
||||
{
|
||||
return 254;
|
||||
return 400 - 20;
|
||||
}
|
||||
|
||||
public int getSlotHeight()
|
||||
|
@ -318,182 +510,6 @@ public class GuiSkin extends GuiList<GuiSkin.SkinEntry>
|
|||
return 64 + 4;
|
||||
}
|
||||
|
||||
private class DragAdjust extends Element {
|
||||
private int mouseX;
|
||||
private int mouseY;
|
||||
private float yawOffset;
|
||||
private float pitchOffset;
|
||||
// public boolean dragging;
|
||||
|
||||
public DragAdjust(int x, int y, int w, int h) {
|
||||
super(x, y, w, h, null);
|
||||
}
|
||||
|
||||
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 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 mouserel() {
|
||||
// this.dragging = false;
|
||||
// }
|
||||
|
||||
public boolean canHover() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiSkin INSTANCE = new GuiSkin();
|
||||
|
||||
private ActButton convertButton1;
|
||||
private ActButton convertButton2;
|
||||
private ActButton templateButton;
|
||||
private DragAdjust adjust;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
private GuiSkin() {
|
||||
}
|
||||
|
||||
public void init(int width, int height)
|
||||
{
|
||||
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++)
|
||||
{
|
||||
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.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;
|
||||
}
|
||||
|
||||
public void selectSkin(BufferedImage img, ModelType model)
|
||||
{
|
||||
this.gm.getNetHandler().addToSendQueue(new CPacketSkin(img, model));
|
||||
}
|
||||
|
||||
public void onGuiClosed()
|
||||
{
|
||||
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";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// public static void drawEntityOnScreen(int posX, int posY, float scale, float mouseX, float mouseY, EntityLiving ent)
|
||||
// {
|
||||
|
|
|
@ -262,6 +262,15 @@ public abstract class EntityRegistry {
|
|||
return integer == null ? 0 : integer.intValue();
|
||||
}
|
||||
|
||||
public static int getEntityID(Class<? extends Entity> clazz) {
|
||||
Integer integer = CLASS_TO_ID.get(clazz);
|
||||
return integer == null ? 0 : integer.intValue();
|
||||
}
|
||||
|
||||
public static Class<? extends Entity> getEntityClass(int id) {
|
||||
return ID_TO_CLASS.get(id);
|
||||
}
|
||||
|
||||
public static String getEntityString(Entity entityIn) {
|
||||
return CLASS_TO_STRING.get(entityIn.getClass());
|
||||
}
|
||||
|
|
|
@ -287,6 +287,7 @@ public class NetConnection extends SimpleChannelInboundHandler<Packet>
|
|||
// {
|
||||
// ((ITickable)this.packetListener).update();
|
||||
// }
|
||||
if(this.channel != null)
|
||||
this.channel.flush();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,6 +57,8 @@ import game.item.ItemStack;
|
|||
import game.log.Log;
|
||||
import game.material.Material;
|
||||
import game.nbt.NBTTagCompound;
|
||||
import game.nbt.NBTTagDouble;
|
||||
import game.nbt.NBTTagFloat;
|
||||
import game.nbt.NBTTagList;
|
||||
import game.nbt.NBTTagString;
|
||||
import game.packet.CPacketAction;
|
||||
|
@ -1481,6 +1483,13 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
return this.characters;
|
||||
}
|
||||
|
||||
public NBTTagCompound addCharacter(String id) {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
this.characters.add(tag);
|
||||
tag.setString("id", id);
|
||||
return tag;
|
||||
}
|
||||
|
||||
public NBTTagCompound getSelectedCharacter(boolean create) {
|
||||
NBTTagCompound tag = this.characters.isEmpty() || this.selected < 0 ? null : this.characters.get(this.selected);
|
||||
if(create && tag == null) {
|
||||
|
@ -2801,6 +2810,27 @@ public class NetHandlerPlayServer extends NetHandler implements ICrafting, Scrip
|
|||
}
|
||||
break;
|
||||
|
||||
case SET_SPECIES:
|
||||
Class<? extends Entity> clazz = EntityRegistry.getEntityClass(packetIn.getAuxData());
|
||||
if(EntityNPC.class.isAssignableFrom(clazz)) {
|
||||
NBTTagCompound tag = this.addCharacter(EntityRegistry.getEntityString(clazz));
|
||||
tag.setInteger("Dimension", this.entity.worldObj.dimension.getDimensionId());
|
||||
NBTTagList pos = new NBTTagList();
|
||||
pos.appendTag(new NBTTagDouble(this.entity.posX));
|
||||
pos.appendTag(new NBTTagDouble(this.entity.posY));
|
||||
pos.appendTag(new NBTTagDouble(this.entity.posZ));
|
||||
tag.setTag("Pos", pos);
|
||||
NBTTagList rot = new NBTTagList();
|
||||
rot.appendTag(new NBTTagFloat(this.entity.rotYaw));
|
||||
rot.appendTag(new NBTTagFloat(this.entity.rotPitch));
|
||||
tag.setTag("Rotation", rot);
|
||||
tag.setString("CustomName", this.entity.getCustomNameTag());
|
||||
tag.setString("Align", this.entity.getAlignment().name);
|
||||
tag.setFloat("Height", this.entity.getHeight());
|
||||
this.server.swapPlayer(this, tag);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IllegalArgumentException("Ungültige Aktion!");
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ public class CPacketAction implements Packet<NetHandlerPlayServer>
|
|||
// REQUEST_STATS,
|
||||
// SET_MODELPARTS,
|
||||
SET_HEIGHT,
|
||||
SET_SPECIES,
|
||||
SELECT_TRADE,
|
||||
// SET_BEACON,
|
||||
INTERACT,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue