add clickable commands
This commit is contained in:
parent
dabef4a3fd
commit
73962c7ecd
16 changed files with 147 additions and 133 deletions
|
@ -4,16 +4,17 @@ import java.util.List;
|
|||
|
||||
import client.Client;
|
||||
import client.gui.element.ActButton;
|
||||
import client.gui.element.Area;
|
||||
import client.gui.element.ButtonCallback;
|
||||
import client.gui.element.Element;
|
||||
import client.gui.element.Fill;
|
||||
import client.gui.element.PressType;
|
||||
import client.renderer.Drawing;
|
||||
import client.gui.element.FieldAction;
|
||||
import client.gui.element.Field;
|
||||
import client.gui.element.FieldCallback;
|
||||
import client.vars.BoolVar;
|
||||
import client.vars.CVar;
|
||||
import client.gui.element.TransparentArea;
|
||||
import client.window.Keysym;
|
||||
import common.collect.Lists;
|
||||
import common.color.TextColor;
|
||||
|
@ -24,6 +25,42 @@ import common.util.ExtMath;
|
|||
import common.util.HitPosition;
|
||||
|
||||
public class GuiConsole extends Gui implements FieldCallback {
|
||||
private class ConsoleArea extends Area {
|
||||
private final boolean background;
|
||||
|
||||
public ConsoleArea(int x, int y, int w, int h, String text, boolean background) {
|
||||
super(x, y, w, h, text);
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
if(this.background)
|
||||
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x3f000000);
|
||||
}
|
||||
|
||||
protected void onDoubleClick() {
|
||||
if(this.sel_start >= 0 && this.sel_end == this.sel_start) {
|
||||
for(int z = this.sel_start; z >= 0; z--) {
|
||||
char c = this.text.charAt(z);
|
||||
if(c == TextColor.COMMAND.code) {
|
||||
for(int n = z + 1; n < this.text.length(); n++) {
|
||||
c = this.text.charAt(n);
|
||||
if(c < 0x20) {
|
||||
GuiConsole.this.send("/" + this.text.substring(z + 1, n), false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if(c < 0x20) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onDoubleClick();
|
||||
}
|
||||
}
|
||||
|
||||
public static final GuiConsole INSTANCE = new GuiConsole();
|
||||
|
||||
private final List<String> sentMessages = Lists.<String>newArrayList();
|
||||
|
@ -39,7 +76,7 @@ public class GuiConsole extends Gui implements FieldCallback {
|
|||
private int autocompleteIndex;
|
||||
private List<String> foundPlayerNames = Lists.<String>newArrayList();
|
||||
private Field inputField;
|
||||
private TransparentArea logBox;
|
||||
private ConsoleArea logBox;
|
||||
|
||||
public GuiConsole setFull(boolean full) {
|
||||
this.full = full;
|
||||
|
@ -58,7 +95,7 @@ public class GuiConsole extends Gui implements FieldCallback {
|
|||
}
|
||||
}, "Löschen"));
|
||||
}
|
||||
this.logBox = this.add(new TransparentArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
|
||||
this.logBox = this.add(new ConsoleArea(0, this.full ? Element.BASE_HEIGHT : 0, width, height - Element.BASE_HEIGHT * (this.full ? 2 : 1), this.gm.getBuffer(), this.gm.world != null && !this.gm.charEditor));
|
||||
if(this.full)
|
||||
this.add(new Fill(640, 0, width - 640, 0));
|
||||
this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
|
||||
|
@ -115,22 +152,24 @@ public class GuiConsole extends Gui implements FieldCallback {
|
|||
{
|
||||
String s = this.inputField.getText().trim();
|
||||
|
||||
if (s.length() > 0)
|
||||
{
|
||||
if(this.sentMessages.isEmpty() || !((String)this.sentMessages.get(this.sentMessages.size() - 1)).equals(s))
|
||||
this.sentMessages.add(s);
|
||||
this.sentHistoryCursor = this.sentMessages.size();
|
||||
this.gm.exec(s);
|
||||
// if(this.gm.thePlayer != null)
|
||||
// this.gm.thePlayer.sendQueue.addToSendQueue(new CPacketMessage(CPacketMessage.Type.CHAT, s));
|
||||
}
|
||||
|
||||
this.inputField.setText("");
|
||||
if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
|
||||
this.gm.show(null);
|
||||
this.send(s, true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void send(String text, boolean clear) {
|
||||
if(!text.isEmpty()) {
|
||||
if(this.sentMessages.isEmpty() || !((String)this.sentMessages.get(this.sentMessages.size() - 1)).equals(text))
|
||||
this.sentMessages.add(text);
|
||||
this.sentHistoryCursor = this.sentMessages.size();
|
||||
this.gm.exec(text);
|
||||
}
|
||||
|
||||
if(clear)
|
||||
this.inputField.setText("");
|
||||
if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
|
||||
this.gm.show(null);
|
||||
}
|
||||
|
||||
protected void setText(String newChatText, boolean shouldOverwrite)
|
||||
{
|
||||
if (shouldOverwrite)
|
||||
|
|
|
@ -84,7 +84,7 @@ public class GuiInfo extends Gui {
|
|||
if(num == 14)
|
||||
sb.append('\n');
|
||||
if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) {
|
||||
sb.append(color + "#" + (char)(num < 10 ? ('0' + num) : ('A' + (num - 10))) + ' ');
|
||||
sb.append(color + "#" + color.colorId + ' ');
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,11 +67,10 @@ abstract class Textbox extends Element {
|
|||
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
|
||||
if(btn == Button.MOUSE_LEFT) {
|
||||
if(!shift && ((System.currentTimeMillis() - this.tmr_leftmb) <= (long)this.gm.dclickDelay)) {
|
||||
this.sel_start = this.sel_drag = 0;
|
||||
this.sel_end = this.text.length();
|
||||
this.onDoubleClick();
|
||||
}
|
||||
else {
|
||||
gui_text_select(x, y, shift);
|
||||
this.gui_text_select(x, y, shift);
|
||||
}
|
||||
this.tmr_leftmb = System.currentTimeMillis();
|
||||
}
|
||||
|
@ -81,7 +80,7 @@ abstract class Textbox extends Element {
|
|||
}
|
||||
|
||||
public void drag(int x, int y) {
|
||||
gui_text_select(x, y, true);
|
||||
this.gui_text_select(x, y, true);
|
||||
}
|
||||
|
||||
public void character(char code) {
|
||||
|
@ -248,4 +247,9 @@ abstract class Textbox extends Element {
|
|||
GL11.glDisable(GL11.GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
|
||||
protected void onDoubleClick() {
|
||||
this.sel_start = this.sel_drag = 0;
|
||||
this.sel_end = this.text.length();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package client.gui.element;
|
||||
|
||||
import client.renderer.Drawing;
|
||||
|
||||
public class TransparentArea extends Area {
|
||||
private final boolean background;
|
||||
|
||||
public TransparentArea(int x, int y, int w, int h, String text, boolean background) {
|
||||
super(x, y, w, h, text);
|
||||
this.background = background;
|
||||
}
|
||||
|
||||
protected void drawBackground() {
|
||||
if(this.background)
|
||||
Drawing.drawRect(this.pos_x, this.pos_y, this.size_x, this.size_y, 0x3f000000);
|
||||
}
|
||||
}
|
|
@ -49,6 +49,8 @@ public class BlockSnow extends Block
|
|||
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
|
||||
{
|
||||
int i = ((Integer)state.getValue(LAYERS)).intValue() - 1;
|
||||
if(i == 0)
|
||||
return null;
|
||||
float f = 0.125F;
|
||||
return new BoundingBox((double)pos.getX() + this.minX, (double)pos.getY() + this.minY, (double)pos.getZ() + this.minZ, (double)pos.getX() + this.maxX, (double)((float)pos.getY() + (float)i * f), (double)pos.getZ() + this.maxZ);
|
||||
}
|
||||
|
|
|
@ -5,48 +5,48 @@ import java.util.regex.Pattern;
|
|||
import common.util.Util;
|
||||
|
||||
public enum TextColor {
|
||||
NULL(0x00),
|
||||
RESET(0x01),
|
||||
BROWN(0x02, 0x8c5606),
|
||||
DBROWN(0x03, 0x56250b),
|
||||
DGREEN(0x04, 0x007f00),
|
||||
DRED(0x05, 0x7f0000),
|
||||
DMAGENTA(0x06, 0x6f006f),
|
||||
DVIOLET(0x07, 0x5400be),
|
||||
ORK(0x08, 0x487c00),
|
||||
ACID(0x09, 0x80ff00),
|
||||
NEWLINE(0x0a),
|
||||
COL1(0x0b, 0x000000),
|
||||
COL2(0x0c, 0x000000),
|
||||
COL3(0x0d, 0x000000),
|
||||
COL4(0x0e, 0x000000),
|
||||
COL5(0x0f, 0x000000),
|
||||
BLACK(0x10, 0x000000),
|
||||
DGRAY(0x11, 0x585858),
|
||||
GRAY(0x12, 0x808080),
|
||||
LGRAY(0x13, 0xc0c0c0),
|
||||
WHITE(0x14, 0xffffff),
|
||||
RED(0x15, 0xcf0000),
|
||||
GREEN(0x16, 0x00cf00),
|
||||
BLUE(0x17, 0x0000cf),
|
||||
YELLOW(0x18, 0xbfbf00),
|
||||
MAGENTA(0x19, 0xbf00bf),
|
||||
CYAN(0x1a, 0x00bfbf),
|
||||
VIOLET(0x1b, 0x6000ff),
|
||||
ORANGE(0x1c, 0xff7000),
|
||||
CRIMSON(0x1d, 0x601010),
|
||||
MIDNIGHT(0x1e, 0x000080),
|
||||
NEON(0x1f, 0x80c0f0),
|
||||
SPACE(0x20),
|
||||
UNKNOWN(0x7f),
|
||||
SGA_A(0x80),
|
||||
SGA_Z(0x99),
|
||||
BUG(0x9a),
|
||||
INVALID(0x9b),
|
||||
DEMON(0x9c),
|
||||
IMP(0x9d),
|
||||
HORNS(0x9e),
|
||||
BLKHEART(0x9f);
|
||||
NULL(0x00, "null"),
|
||||
RESET(0x01, 0, "reset", 'D'),
|
||||
CRIMSON(0x02, 0x601010, "crimson", 'C'),
|
||||
DRED(0x03, 0x7f0000, "dark_red", 'r'),
|
||||
RED(0x04, 0xcf0000, "red", 'R'),
|
||||
DBROWN(0x05, 0x56250b, "dark_brown", 'w'),
|
||||
ORANGE(0x06, 0xff7000, "orange", 'o'),
|
||||
BROWN(0x07, 0x8c5606, "brown", 'W'),
|
||||
LBROWN(0x08, 0x9c7636, "light_brown", 'l'),
|
||||
BEIGE(0x09, 0xcfcfaf, "beige", 'L'),
|
||||
NEWLINE(0x0a, "newline"),
|
||||
YELLOW(0x0b, 0xbfbf00, "yellow", 'y'),
|
||||
LYELLOW(0x0c, 0xffff7f, "light_yellow", 'Y'),
|
||||
ORK(0x0d, 0x487c00, "ork_green", 'O'),
|
||||
ACID(0x0e, 0x80ff00, "acid_green", 'a'),
|
||||
DGREEN(0x0f, 0x007f00, "dark_green", 'g'),
|
||||
GREEN(0x10, 0x00cf00, "green", 'G'),
|
||||
COMMAND(0x11, 0x00ff80, "command_green", 'd'),
|
||||
CYAN(0x12, 0x00bfbf, "cyan", 'c'),
|
||||
NEON(0x13, 0x80c0f0, "neon", 'n'),
|
||||
MIDNIGHT(0x14, 0x000080, "midnight", 'm'),
|
||||
BLUE(0x15, 0x0000cf, "blue", 'b'),
|
||||
LBLUE(0x16, 0x5f5fff, "light_blue", 'B'),
|
||||
VIOLET(0x17, 0x6000ff, "violet", 'V'),
|
||||
DVIOLET(0x18, 0x5400be, "dark_violet", 'v'),
|
||||
DMAGENTA(0x19, 0x6f006f, "dark_magenta", 'm'),
|
||||
MAGENTA(0x1a, 0xbf00bf, "magenta", 'M'),
|
||||
WHITE(0x1b, 0xffffff, "white", '4'),
|
||||
LGRAY(0x1c, 0xc0c0c0, "light_gray", '3'),
|
||||
GRAY(0x1d, 0x808080, "gray", '2'),
|
||||
DGRAY(0x1e, 0x585858, "dark_gray", '1'),
|
||||
BLACK(0x1f, 0x000000, "black", '0'),
|
||||
SPACE(0x20, "space"),
|
||||
UNKNOWN(0x7f, "unknown"),
|
||||
SGA_A(0x80, "dc_a"),
|
||||
SGA_Z(0x99, "dc_z"),
|
||||
BUG(0x9a, "bug"),
|
||||
INVALID(0x9b, "invalid"),
|
||||
DEMON(0x9c, "demon"),
|
||||
IMP(0x9d, "imp"),
|
||||
HORNS(0x9e, "horns"),
|
||||
BLKHEART(0x9f, "heart");
|
||||
|
||||
private static final Pattern STRIP_PATTERN = Pattern.compile("[\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u0009\u000b\u000c\r\u000e\u000f"
|
||||
+ "\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f]");
|
||||
|
@ -56,6 +56,8 @@ public enum TextColor {
|
|||
|
||||
private final String format;
|
||||
public final char code;
|
||||
public final String id;
|
||||
public final char colorId;
|
||||
public final int color;
|
||||
public final int shadow;
|
||||
|
||||
|
@ -71,14 +73,16 @@ public enum TextColor {
|
|||
return code < SHADOW.length ? SHADOW[code] : 0x000000;
|
||||
}
|
||||
|
||||
private TextColor(int code) {
|
||||
this(code, 0x000000);
|
||||
private TextColor(int code, String id) {
|
||||
this(code, 0, id, (char)0);
|
||||
}
|
||||
|
||||
private TextColor(int code, int color) {
|
||||
private TextColor(int code, int color, String id, char colorId) {
|
||||
this.format = Character.toString(this.code = (char)code);
|
||||
this.color = color;
|
||||
this.shadow = Util.mixColor(Util.mixColor(this.color, 0x000000), 0x000000);
|
||||
this.id = id;
|
||||
this.colorId = colorId;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
@ -1,37 +1,12 @@
|
|||
package common.util;
|
||||
|
||||
public class DC32 {
|
||||
public static final byte[] ASCII = { // 0x1f -> AUX1
|
||||
0, ' ', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'G', // $00, $80
|
||||
'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Z', 0 // $10, $90
|
||||
public static final byte[] DC32_TO_ASCII = {
|
||||
0, ' ', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'G',
|
||||
'H', 'I', 'K', 'L', 'M', 'N', 'O', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Z', 0
|
||||
};
|
||||
|
||||
public static final byte[] AUX1 = { // 0x01 -> lc / UC, 0x1f -> AUX2
|
||||
0, 0, '!', '"', '#', '$', '%', '&', '\'', '*', '+', ',', '-', '.', '/', 'F', // $20, $A0
|
||||
':', '1', 'J', ';', '=', '?', '0', '\\', 'Q', '^', '_', 'U', '|', '~', 'Y', 0 // $30, $B0
|
||||
};
|
||||
|
||||
public static final byte[] AUX2 = { // 0x0f -> [0x10 ~ 0x1f ... 0x0f -> UTF] | [0x01 ~ 0x0e -> AUX3], 0x0c -> STR_WSPC
|
||||
0, 0x01, '(', ')', '<', '>', '@', '[', ']', '`', '{', '}', 0, 0x7f, 0x0a, 0, // $40
|
||||
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f // $50
|
||||
};
|
||||
|
||||
public static final byte[] AUX3 = { // 0x01 -> SYM_DEMON
|
||||
0, 0, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0 // $60
|
||||
};
|
||||
|
||||
public static final char[] ASCII_TO_DC32 = {
|
||||
0x00, 0x41, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x4e, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
|
||||
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
|
||||
0x01, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x42, 0x43, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
|
||||
0x36, 0x31, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x30, 0x33, 0x44, 0x34, 0x45, 0x35,
|
||||
0x46, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x2f, 0x0f, 0x10, 0x11, 0x32, 0x12, 0x13, 0x14, 0x15, 0x16,
|
||||
0x17, 0x38, 0x18, 0x19, 0x1a, 0x3b, 0x1b, 0x1c, 0x1d, 0x3e, 0x1e, 0x47, 0x37, 0x48, 0x39, 0x3a,
|
||||
0x49, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0xaf, 0x8f, 0x90, 0x91, 0xb2, 0x92, 0x93, 0x94, 0x95, 0x96,
|
||||
0x97, 0xb8, 0x98, 0x99, 0x9a, 0xbb, 0x9b, 0x9c, 0x9d, 0xbe, 0x9e, 0x4a, 0x3c, 0x4b, 0x3d, 0x4d
|
||||
};
|
||||
|
||||
public static final byte[] ASCII_TO_DC32S = {
|
||||
public static final byte[] ASCII_TO_DC32 = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
|
|
|
@ -878,7 +878,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
BlockPos pos = origin;
|
||||
int radius = SVars.spawnRadius;
|
||||
if(radius > 0) {
|
||||
pos = world.getTopSolidOrLiquidBlock(pos.add(
|
||||
pos = world.getHighestFreePos(pos.add(
|
||||
ExtMath.clampi(world.rand.excl(-radius, radius), -World.MAX_SIZE + 1, World.MAX_SIZE - 1), 0,
|
||||
ExtMath.clampi(world.rand.excl(-radius, radius), -World.MAX_SIZE + 1, World.MAX_SIZE - 1)));
|
||||
}
|
||||
|
@ -1162,7 +1162,7 @@ public final class Server implements IThreadListener, Executor {
|
|||
newZ = ((double)pos.getZ()) + 0.5;
|
||||
}
|
||||
else {
|
||||
pos = world.getTopSolidOrLiquidBlock(new BlockPos(newX, 0, newZ));
|
||||
pos = world.getHighestFreePos(new BlockPos(newX, 0, newZ));
|
||||
newX = ((double)pos.getX()) + 0.5;
|
||||
newY = (double)pos.getY();
|
||||
newZ = ((double)pos.getZ()) + 0.5;
|
||||
|
|
|
@ -79,7 +79,7 @@ public class BiomeTian extends GenBiome
|
|||
{
|
||||
int i = rand.chOffset();
|
||||
int j = rand.chOffset();
|
||||
this.spikeGen.generate(worldIn, rand, worldIn.getTopSolidOrLiquidBlock(pos.add(i, 0, j)));
|
||||
this.spikeGen.generate(worldIn, rand, worldIn.getHighestFreePos(pos.add(i, 0, j)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -297,28 +297,28 @@ public abstract class GenBiome implements IBiome {
|
|||
{
|
||||
int j = rand.chOffset();
|
||||
int k = rand.chOffset();
|
||||
this.sandGen.generate(world, rand, world.getTopSolidOrLiquidBlock(pos.add(j, 0, k)));
|
||||
this.sandGen.generate(world, rand, world.getHighestFreePos(pos.add(j, 0, k)));
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < this.clayPerChunk; ++i1)
|
||||
{
|
||||
int l1 = rand.chOffset();
|
||||
int i6 = rand.chOffset();
|
||||
this.clayGen.generate(world, rand, world.getTopSolidOrLiquidBlock(pos.add(l1, 0, i6)));
|
||||
this.clayGen.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6)));
|
||||
}
|
||||
|
||||
for (int j1 = 0; j1 < this.sandPerChunk; ++j1)
|
||||
{
|
||||
int i2 = rand.chOffset();
|
||||
int j6 = rand.chOffset();
|
||||
this.gravelAsSandGen.generate(world, rand, world.getTopSolidOrLiquidBlock(pos.add(i2, 0, j6)));
|
||||
this.gravelAsSandGen.generate(world, rand, world.getHighestFreePos(pos.add(i2, 0, j6)));
|
||||
}
|
||||
|
||||
for (int i1 = 0; i1 < this.clayExtPerChunk; ++i1)
|
||||
{
|
||||
int l1 = rand.chOffset();
|
||||
int i6 = rand.chOffset();
|
||||
this.clayGenExt.generate(world, rand, world.getTopSolidOrLiquidBlock(pos.add(l1, 0, i6)));
|
||||
this.clayGenExt.generate(world, rand, world.getHighestFreePos(pos.add(l1, 0, i6)));
|
||||
}
|
||||
|
||||
int k1 = this.treesPerChunk;
|
||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
|||
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.color.TextColor;
|
||||
import common.util.BlockPos;
|
||||
import common.util.CharValidator;
|
||||
import common.util.Vec3;
|
||||
|
@ -22,6 +23,10 @@ public abstract class Command implements Executable {
|
|||
private int parPos = 0;
|
||||
private boolean parReq = true;
|
||||
|
||||
public static String asCommand(TextColor color, String command, Object ... args) {
|
||||
return String.format(TextColor.DGRAY + "[" + TextColor.COMMAND + "%s" + TextColor.DGRAY + "]" + color, String.format(command, args));
|
||||
}
|
||||
|
||||
protected Command(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package server.command.commands;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import common.color.TextColor;
|
||||
import common.entity.Entity;
|
||||
import common.util.BlockPos;
|
||||
import server.command.Command;
|
||||
|
@ -21,7 +22,8 @@ public class CommandFind extends Command {
|
|||
for(Entity entity : entities) {
|
||||
if(entity.isEntityAlive()) {
|
||||
BlockPos pos = entity.getPosition();
|
||||
exec.log("%s bei %d, %d, %d in %s gefunden", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getNameString());
|
||||
exec.log("%s bei %d, %d, %d in %s gefunden %s", entity.getCommandName(), pos.getX(), pos.getY(), pos.getZ(), entity.worldObj.dimension.getNameString(),
|
||||
asCommand(TextColor.RESET, "tp #%d", entity.getId()));
|
||||
done++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ public abstract class Spawner {
|
|||
for(int n = 0; n < count; ++n) {
|
||||
boolean flag = false;
|
||||
for(int m = 0; !flag && m < 4; ++m) {
|
||||
BlockPos pos = world.getTopSolidOrLiquidBlock(new BlockPos(mx, 0, mz));
|
||||
BlockPos pos = world.getHighestFreePos(new BlockPos(mx, 0, mz));
|
||||
if(canSpawnAt(EntityWaterNPC.class.isAssignableFrom(entry.type), world, pos)) {
|
||||
EntityLiving entity;
|
||||
try {
|
||||
|
|
|
@ -2268,27 +2268,27 @@ public final class WorldServer extends AWorldServer {
|
|||
return false;
|
||||
}
|
||||
|
||||
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) {
|
||||
public BlockPos getHighestFreePos(BlockPos pos) {
|
||||
ChunkServer chunk = this.getChunk(pos);
|
||||
int h = chunk.getTopSegment();
|
||||
if(h == Integer.MIN_VALUE)
|
||||
return new BlockPos(pos.getX(), 0, pos.getZ());
|
||||
BlockPos blockpos = new BlockPos(pos.getX(), h + 16, pos.getZ());
|
||||
BlockPos blockpos1;
|
||||
BlockPos free = new BlockPos(pos.getX(), h + 16, pos.getZ());
|
||||
BlockPos down;
|
||||
h = chunk.getBottomSegment();
|
||||
if(blockpos.getY() - h > 512)
|
||||
h = blockpos.getY() - 512;
|
||||
if(free.getY() - h > 512)
|
||||
h = free.getY() - 512;
|
||||
|
||||
for(; blockpos.getY() >= h; blockpos = blockpos1) {
|
||||
blockpos1 = blockpos.down();
|
||||
Material material = chunk.getBlock(blockpos1).getMaterial();
|
||||
for(; free.getY() >= h; free = down) {
|
||||
down = free.down();
|
||||
Material material = chunk.getBlock(down).getMaterial();
|
||||
|
||||
if(material.blocksMovement() && material != Material.LEAVES) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return blockpos;
|
||||
return free;
|
||||
}
|
||||
|
||||
public void removePlayerEntityDangerously(Entity entityIn) {
|
||||
|
|
|
@ -327,7 +327,7 @@ public class StructureScattered
|
|||
|
||||
if (p_74935_2_.isVecInside(blockpos$mutableblockpos))
|
||||
{
|
||||
i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos$mutableblockpos).getY(), worldIn.getSeaLevel());
|
||||
i += Math.max(worldIn.getHighestFreePos(blockpos$mutableblockpos).getY(), worldIn.getSeaLevel());
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1361,7 +1361,7 @@ public class StructureVillage
|
|||
|
||||
if (structureBoundingBoxIn.isVecInside(blockpos))
|
||||
{
|
||||
blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos).down();
|
||||
blockpos = worldIn.getHighestFreePos(blockpos).down();
|
||||
worldIn.setState(blockpos, iblockstate, 2);
|
||||
worldIn.setState(blockpos.down(), iblockstate1, 2);
|
||||
}
|
||||
|
@ -1581,7 +1581,7 @@ public class StructureVillage
|
|||
|
||||
if (p_74889_2_.isVecInside(blockpos$mutableblockpos))
|
||||
{
|
||||
i += Math.max(worldIn.getTopSolidOrLiquidBlock(blockpos$mutableblockpos).getY(), worldIn.getSeaLevel());
|
||||
i += Math.max(worldIn.getHighestFreePos(blockpos$mutableblockpos).getY(), worldIn.getSeaLevel());
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue