add clickable commands

This commit is contained in:
Sen 2025-07-15 14:34:07 +02:00
parent dabef4a3fd
commit 73962c7ecd
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
16 changed files with 147 additions and 133 deletions

View file

@ -4,16 +4,17 @@ import java.util.List;
import client.Client; import client.Client;
import client.gui.element.ActButton; import client.gui.element.ActButton;
import client.gui.element.Area;
import client.gui.element.ButtonCallback; import client.gui.element.ButtonCallback;
import client.gui.element.Element; import client.gui.element.Element;
import client.gui.element.Fill; import client.gui.element.Fill;
import client.gui.element.PressType; import client.gui.element.PressType;
import client.renderer.Drawing;
import client.gui.element.FieldAction; import client.gui.element.FieldAction;
import client.gui.element.Field; import client.gui.element.Field;
import client.gui.element.FieldCallback; import client.gui.element.FieldCallback;
import client.vars.BoolVar; import client.vars.BoolVar;
import client.vars.CVar; import client.vars.CVar;
import client.gui.element.TransparentArea;
import client.window.Keysym; import client.window.Keysym;
import common.collect.Lists; import common.collect.Lists;
import common.color.TextColor; import common.color.TextColor;
@ -24,6 +25,42 @@ import common.util.ExtMath;
import common.util.HitPosition; import common.util.HitPosition;
public class GuiConsole extends Gui implements FieldCallback { 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(); public static final GuiConsole INSTANCE = new GuiConsole();
private final List<String> sentMessages = Lists.<String>newArrayList(); private final List<String> sentMessages = Lists.<String>newArrayList();
@ -39,7 +76,7 @@ public class GuiConsole extends Gui implements FieldCallback {
private int autocompleteIndex; private int autocompleteIndex;
private List<String> foundPlayerNames = Lists.<String>newArrayList(); private List<String> foundPlayerNames = Lists.<String>newArrayList();
private Field inputField; private Field inputField;
private TransparentArea logBox; private ConsoleArea logBox;
public GuiConsole setFull(boolean full) { public GuiConsole setFull(boolean full) {
this.full = full; this.full = full;
@ -58,7 +95,7 @@ public class GuiConsole extends Gui implements FieldCallback {
} }
}, "Löschen")); }, "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) if(this.full)
this.add(new Fill(640, 0, width - 640, 0)); this.add(new Fill(640, 0, width - 640, 0));
this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, "")); this.inputField = this.add(new Field(0, height - Element.BASE_HEIGHT, width, 0, IPlayer.MAX_CMD_LENGTH, this, ""));
@ -115,21 +152,23 @@ public class GuiConsole extends Gui implements FieldCallback {
{ {
String s = this.inputField.getText().trim(); String s = this.inputField.getText().trim();
if (s.length() > 0) this.send(s, true);
{ }
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));
} }
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(""); this.inputField.setText("");
if((this.gm.conAutoclose || !this.full) && this.gm.world != null) if((this.gm.conAutoclose || !this.full) && this.gm.world != null)
this.gm.show(null); this.gm.show(null);
} }
}
protected void setText(String newChatText, boolean shouldOverwrite) protected void setText(String newChatText, boolean shouldOverwrite)
{ {

View file

@ -84,7 +84,7 @@ public class GuiInfo extends Gui {
if(num == 14) if(num == 14)
sb.append('\n'); sb.append('\n');
if((color.code >= Log.CHR_COLORS1 && color.code <= Log.CHR_COLORE1) || (color.code >= Log.CHR_COLORS2 && color.code <= Log.CHR_COLORE2)) { 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++; num++;
} }
} }

View file

@ -67,11 +67,10 @@ abstract class Textbox extends Element {
public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) { public void mouse(Button btn, int x, int y, boolean ctrl, boolean shift) {
if(btn == Button.MOUSE_LEFT) { if(btn == Button.MOUSE_LEFT) {
if(!shift && ((System.currentTimeMillis() - this.tmr_leftmb) <= (long)this.gm.dclickDelay)) { if(!shift && ((System.currentTimeMillis() - this.tmr_leftmb) <= (long)this.gm.dclickDelay)) {
this.sel_start = this.sel_drag = 0; this.onDoubleClick();
this.sel_end = this.text.length();
} }
else { else {
gui_text_select(x, y, shift); this.gui_text_select(x, y, shift);
} }
this.tmr_leftmb = System.currentTimeMillis(); this.tmr_leftmb = System.currentTimeMillis();
} }
@ -81,7 +80,7 @@ abstract class Textbox extends Element {
} }
public void drag(int x, int y) { 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) { public void character(char code) {
@ -248,4 +247,9 @@ abstract class Textbox extends Element {
GL11.glDisable(GL11.GL_SCISSOR_TEST); GL11.glDisable(GL11.GL_SCISSOR_TEST);
} }
} }
protected void onDoubleClick() {
this.sel_start = this.sel_drag = 0;
this.sel_end = this.text.length();
}
} }

View file

@ -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);
}
}

View file

@ -49,6 +49,8 @@ public class BlockSnow extends Block
public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state) public BoundingBox getCollisionBoundingBox(World worldIn, BlockPos pos, State state)
{ {
int i = ((Integer)state.getValue(LAYERS)).intValue() - 1; int i = ((Integer)state.getValue(LAYERS)).intValue() - 1;
if(i == 0)
return null;
float f = 0.125F; 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); 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);
} }

View file

@ -5,48 +5,48 @@ import java.util.regex.Pattern;
import common.util.Util; import common.util.Util;
public enum TextColor { public enum TextColor {
NULL(0x00), NULL(0x00, "null"),
RESET(0x01), RESET(0x01, 0, "reset", 'D'),
BROWN(0x02, 0x8c5606), CRIMSON(0x02, 0x601010, "crimson", 'C'),
DBROWN(0x03, 0x56250b), DRED(0x03, 0x7f0000, "dark_red", 'r'),
DGREEN(0x04, 0x007f00), RED(0x04, 0xcf0000, "red", 'R'),
DRED(0x05, 0x7f0000), DBROWN(0x05, 0x56250b, "dark_brown", 'w'),
DMAGENTA(0x06, 0x6f006f), ORANGE(0x06, 0xff7000, "orange", 'o'),
DVIOLET(0x07, 0x5400be), BROWN(0x07, 0x8c5606, "brown", 'W'),
ORK(0x08, 0x487c00), LBROWN(0x08, 0x9c7636, "light_brown", 'l'),
ACID(0x09, 0x80ff00), BEIGE(0x09, 0xcfcfaf, "beige", 'L'),
NEWLINE(0x0a), NEWLINE(0x0a, "newline"),
COL1(0x0b, 0x000000), YELLOW(0x0b, 0xbfbf00, "yellow", 'y'),
COL2(0x0c, 0x000000), LYELLOW(0x0c, 0xffff7f, "light_yellow", 'Y'),
COL3(0x0d, 0x000000), ORK(0x0d, 0x487c00, "ork_green", 'O'),
COL4(0x0e, 0x000000), ACID(0x0e, 0x80ff00, "acid_green", 'a'),
COL5(0x0f, 0x000000), DGREEN(0x0f, 0x007f00, "dark_green", 'g'),
BLACK(0x10, 0x000000), GREEN(0x10, 0x00cf00, "green", 'G'),
DGRAY(0x11, 0x585858), COMMAND(0x11, 0x00ff80, "command_green", 'd'),
GRAY(0x12, 0x808080), CYAN(0x12, 0x00bfbf, "cyan", 'c'),
LGRAY(0x13, 0xc0c0c0), NEON(0x13, 0x80c0f0, "neon", 'n'),
WHITE(0x14, 0xffffff), MIDNIGHT(0x14, 0x000080, "midnight", 'm'),
RED(0x15, 0xcf0000), BLUE(0x15, 0x0000cf, "blue", 'b'),
GREEN(0x16, 0x00cf00), LBLUE(0x16, 0x5f5fff, "light_blue", 'B'),
BLUE(0x17, 0x0000cf), VIOLET(0x17, 0x6000ff, "violet", 'V'),
YELLOW(0x18, 0xbfbf00), DVIOLET(0x18, 0x5400be, "dark_violet", 'v'),
MAGENTA(0x19, 0xbf00bf), DMAGENTA(0x19, 0x6f006f, "dark_magenta", 'm'),
CYAN(0x1a, 0x00bfbf), MAGENTA(0x1a, 0xbf00bf, "magenta", 'M'),
VIOLET(0x1b, 0x6000ff), WHITE(0x1b, 0xffffff, "white", '4'),
ORANGE(0x1c, 0xff7000), LGRAY(0x1c, 0xc0c0c0, "light_gray", '3'),
CRIMSON(0x1d, 0x601010), GRAY(0x1d, 0x808080, "gray", '2'),
MIDNIGHT(0x1e, 0x000080), DGRAY(0x1e, 0x585858, "dark_gray", '1'),
NEON(0x1f, 0x80c0f0), BLACK(0x1f, 0x000000, "black", '0'),
SPACE(0x20), SPACE(0x20, "space"),
UNKNOWN(0x7f), UNKNOWN(0x7f, "unknown"),
SGA_A(0x80), SGA_A(0x80, "dc_a"),
SGA_Z(0x99), SGA_Z(0x99, "dc_z"),
BUG(0x9a), BUG(0x9a, "bug"),
INVALID(0x9b), INVALID(0x9b, "invalid"),
DEMON(0x9c), DEMON(0x9c, "demon"),
IMP(0x9d), IMP(0x9d, "imp"),
HORNS(0x9e), HORNS(0x9e, "horns"),
BLKHEART(0x9f); 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" 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]"); + "\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; private final String format;
public final char code; public final char code;
public final String id;
public final char colorId;
public final int color; public final int color;
public final int shadow; public final int shadow;
@ -71,14 +73,16 @@ public enum TextColor {
return code < SHADOW.length ? SHADOW[code] : 0x000000; return code < SHADOW.length ? SHADOW[code] : 0x000000;
} }
private TextColor(int code) { private TextColor(int code, String id) {
this(code, 0x000000); 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.format = Character.toString(this.code = (char)code);
this.color = color; this.color = color;
this.shadow = Util.mixColor(Util.mixColor(this.color, 0x000000), 0x000000); this.shadow = Util.mixColor(Util.mixColor(this.color, 0x000000), 0x000000);
this.id = id;
this.colorId = colorId;
} }
public String toString() { public String toString() {

View file

@ -1,37 +1,12 @@
package common.util; package common.util;
public class DC32 { public class DC32 {
public static final byte[] ASCII = { // 0x1f -> AUX1 public static final byte[] DC32_TO_ASCII = {
0, ' ', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'G', // $00, $80 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 // $10, $90 '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 public static final byte[] ASCII_TO_DC32 = {
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 = {
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,
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, 0x01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

View file

@ -878,7 +878,7 @@ public final class Server implements IThreadListener, Executor {
BlockPos pos = origin; BlockPos pos = origin;
int radius = SVars.spawnRadius; int radius = SVars.spawnRadius;
if(radius > 0) { 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), 0,
ExtMath.clampi(world.rand.excl(-radius, radius), -World.MAX_SIZE + 1, World.MAX_SIZE - 1))); 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; newZ = ((double)pos.getZ()) + 0.5;
} }
else { else {
pos = world.getTopSolidOrLiquidBlock(new BlockPos(newX, 0, newZ)); pos = world.getHighestFreePos(new BlockPos(newX, 0, newZ));
newX = ((double)pos.getX()) + 0.5; newX = ((double)pos.getX()) + 0.5;
newY = (double)pos.getY(); newY = (double)pos.getY();
newZ = ((double)pos.getZ()) + 0.5; newZ = ((double)pos.getZ()) + 0.5;

View file

@ -79,7 +79,7 @@ public class BiomeTian extends GenBiome
{ {
int i = rand.chOffset(); int i = rand.chOffset();
int j = 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)));
} }
} }
} }

View file

@ -297,28 +297,28 @@ public abstract class GenBiome implements IBiome {
{ {
int j = rand.chOffset(); int j = rand.chOffset();
int k = 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) for (int i1 = 0; i1 < this.clayPerChunk; ++i1)
{ {
int l1 = rand.chOffset(); int l1 = rand.chOffset();
int i6 = 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) for (int j1 = 0; j1 < this.sandPerChunk; ++j1)
{ {
int i2 = rand.chOffset(); int i2 = rand.chOffset();
int j6 = 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) for (int i1 = 0; i1 < this.clayExtPerChunk; ++i1)
{ {
int l1 = rand.chOffset(); int l1 = rand.chOffset();
int i6 = 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; int k1 = this.treesPerChunk;

View file

@ -7,6 +7,7 @@ import java.util.Map;
import common.collect.Lists; import common.collect.Lists;
import common.collect.Maps; import common.collect.Maps;
import common.color.TextColor;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.CharValidator; import common.util.CharValidator;
import common.util.Vec3; import common.util.Vec3;
@ -22,6 +23,10 @@ public abstract class Command implements Executable {
private int parPos = 0; private int parPos = 0;
private boolean parReq = true; 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) { protected Command(String name) {
this.name = name; this.name = name;
} }

View file

@ -2,6 +2,7 @@ package server.command.commands;
import java.util.List; import java.util.List;
import common.color.TextColor;
import common.entity.Entity; import common.entity.Entity;
import common.util.BlockPos; import common.util.BlockPos;
import server.command.Command; import server.command.Command;
@ -21,7 +22,8 @@ public class CommandFind extends Command {
for(Entity entity : entities) { for(Entity entity : entities) {
if(entity.isEntityAlive()) { if(entity.isEntityAlive()) {
BlockPos pos = entity.getPosition(); 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++; done++;
} }
} }

View file

@ -177,7 +177,7 @@ public abstract class Spawner {
for(int n = 0; n < count; ++n) { for(int n = 0; n < count; ++n) {
boolean flag = false; boolean flag = false;
for(int m = 0; !flag && m < 4; ++m) { 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)) { if(canSpawnAt(EntityWaterNPC.class.isAssignableFrom(entry.type), world, pos)) {
EntityLiving entity; EntityLiving entity;
try { try {

View file

@ -2268,27 +2268,27 @@ public final class WorldServer extends AWorldServer {
return false; return false;
} }
public BlockPos getTopSolidOrLiquidBlock(BlockPos pos) { public BlockPos getHighestFreePos(BlockPos pos) {
ChunkServer chunk = this.getChunk(pos); ChunkServer chunk = this.getChunk(pos);
int h = chunk.getTopSegment(); int h = chunk.getTopSegment();
if(h == Integer.MIN_VALUE) if(h == Integer.MIN_VALUE)
return new BlockPos(pos.getX(), 0, pos.getZ()); return new BlockPos(pos.getX(), 0, pos.getZ());
BlockPos blockpos = new BlockPos(pos.getX(), h + 16, pos.getZ()); BlockPos free = new BlockPos(pos.getX(), h + 16, pos.getZ());
BlockPos blockpos1; BlockPos down;
h = chunk.getBottomSegment(); h = chunk.getBottomSegment();
if(blockpos.getY() - h > 512) if(free.getY() - h > 512)
h = blockpos.getY() - 512; h = free.getY() - 512;
for(; blockpos.getY() >= h; blockpos = blockpos1) { for(; free.getY() >= h; free = down) {
blockpos1 = blockpos.down(); down = free.down();
Material material = chunk.getBlock(blockpos1).getMaterial(); Material material = chunk.getBlock(down).getMaterial();
if(material.blocksMovement() && material != Material.LEAVES) { if(material.blocksMovement() && material != Material.LEAVES) {
break; break;
} }
} }
return blockpos; return free;
} }
public void removePlayerEntityDangerously(Entity entityIn) { public void removePlayerEntityDangerously(Entity entityIn) {

View file

@ -327,7 +327,7 @@ public class StructureScattered
if (p_74935_2_.isVecInside(blockpos$mutableblockpos)) 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; ++j;
} }
} }

View file

@ -1361,7 +1361,7 @@ public class StructureVillage
if (structureBoundingBoxIn.isVecInside(blockpos)) if (structureBoundingBoxIn.isVecInside(blockpos))
{ {
blockpos = worldIn.getTopSolidOrLiquidBlock(blockpos).down(); blockpos = worldIn.getHighestFreePos(blockpos).down();
worldIn.setState(blockpos, iblockstate, 2); worldIn.setState(blockpos, iblockstate, 2);
worldIn.setState(blockpos.down(), iblockstate1, 2); worldIn.setState(blockpos.down(), iblockstate1, 2);
} }
@ -1581,7 +1581,7 @@ public class StructureVillage
if (p_74889_2_.isVecInside(blockpos$mutableblockpos)) 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; ++j;
} }
} }