split entity ai to server #2+

This commit is contained in:
Sen 2025-05-12 18:28:56 +02:00
parent 02c0bfcbf6
commit ad828ec6b4
27 changed files with 1160 additions and 1622 deletions

View file

@ -162,7 +162,6 @@ import common.util.Util;
import common.util.HitPosition.ObjectType;
import common.world.Chunk;
import common.world.LightType;
import common.world.Region;
import common.world.State;
import common.world.World;
import common.world.WorldClient;
@ -280,7 +279,7 @@ public class Client implements IThreadListener, IClient {
private final List<Message> chat = Lists.newArrayList();
private final List<Message> feed = Lists.newArrayList();
private final List<Message> hotbar = Lists.newArrayList();
private final File config = new File(System.getProperty("config.file", "game.cfg"));
private final File config = new File(System.getProperty("config.file", "client.cfg"));
private boolean primary;
private boolean secondary;
@ -1775,8 +1774,8 @@ public class Client implements IThreadListener, IClient {
String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX,
this.viewEntity.getEntityBoundingBox().minY, this.viewEntity.posZ) + "\n" +
String.format("Block: %d %d %d, R: '%s/%s'", blockpos.getX(), blockpos.getY(), blockpos.getZ(),
Region.getRegionFolder(blockpos.getX() >> 4, blockpos.getZ() >> 4),
Region.getRegionName(blockpos.getX() >> 4, blockpos.getZ() >> 4)) + "\n" +
Util.getRegionFolder(blockpos.getX() >> 4, blockpos.getZ() >> 4),
Util.getRegionName(blockpos.getX() >> 4, blockpos.getZ() >> 4)) + "\n" +
String.format("Chunk: %d %d %d + %d %d %d, FOV: %.1f °%s", blockpos.getX() >> 4, blockpos.getY() >> 4, blockpos.getZ() >> 4,
blockpos.getX() & 15, blockpos.getY() & 15, blockpos.getZ() & 15, this.zooming ?
(this.fov / this.zoomLevel) : this.fov, this.zooming ?
@ -2217,7 +2216,6 @@ public class Client implements IThreadListener, IClient {
Log.SYSTEM.info("Beende ...");
unload(false);
this.getSoundManager().unload();
Region.killIO();
this.renderGlobal.stopChunkBuilders();
if(audio.end())
Log.SOUND.info("Audiogerät geschlossen");

View file

@ -1,214 +0,0 @@
package client.gui;
import java.io.File;
import java.io.FileFilter;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import client.Client.FileMode;
import client.gui.element.ActButton;
import client.gui.element.ActButton.Mode;
import client.gui.element.GuiList;
import client.gui.element.ListEntry;
import client.gui.element.NavButton;
import client.renderer.Drawing;
import client.world.Converter;
import common.color.TextColor;
import common.dimension.Space;
import common.log.Log;
import common.world.Region;
import common.world.World;
import common.world.Region.FolderInfo;
import common.world.Region.SaveVersion;
public class GuiConvert extends GuiList<GuiConvert.SaveInfo> implements ActButton.Callback
{
protected class SaveInfo implements Comparable<SaveInfo>, ListEntry {
private final String file;
private final int dimensions;
private final int players;
private final long seed;
private final FolderInfo info;
public SaveInfo(String file, int dimensions, int players, long seed, FolderInfo info) {
this.file = file;
this.dimensions = dimensions;
this.players = players;
this.seed = seed;
this.info = info;
}
public String getFile() {
return this.file;
}
public int getDimensions() {
return this.dimensions;
}
public int getPlayers() {
return this.players;
}
public boolean mustConvert() {
return this.info.legacy != null;
}
public String getVersion() {
return this.info.legacy == null ? (this.info.version == null ? "<Unbekannt>" : this.info.version) : this.info.legacy.toString();
}
public boolean isIncompatible() {
return this.info.legacy == SaveVersion.RELEASE_1_13;
}
public long getLastPlayed() {
return this.info.lastPlayed;
}
public long getSeed() {
return this.seed;
}
public int compareTo(SaveInfo comp) {
return this.info.lastPlayed < comp.info.lastPlayed ? 1 : (this.info.lastPlayed > comp.info.lastPlayed ? -1 : this.file.compareTo(comp.file));
}
public void select(boolean isDoubleClick, int mouseX, int mouseY)
{
boolean use = !this.isIncompatible() && this.mustConvert();
GuiConvert.this.selectButton.enabled = use;
if (isDoubleClick && use)
{
GuiConvert.this.use(GuiConvert.this.selectButton, Mode.PRIMARY);
}
}
public void draw(int x, int y, int mouseXIn, int mouseYIn, boolean hover)
{
Drawing.drawText((this.isIncompatible() ? TextColor.DRED : "") + this.getFile() + (this.mustConvert() ? "" :
(TextColor.GRAY + " - " + TextColor.RESET + (this.getPlayers() > 0 ? this.getPlayers() + " Spieler" : "Keine Spieler"))),
x + 2, y, 0xffffffff);
Drawing.drawText((this.mustConvert() ? (this.isIncompatible() ? TextColor.CRIMSON : "") + this.getVersion() : (this.getDimensions() <= 0 ? "Keine Dimensionen" : this.getDimensions() + " Dimension" + (this.getDimensions() != 1 ? "en" : "") + " erschaffen"))
, x + 2, y + 18, 0xff808080);
Drawing.drawText(this.mustConvert() ? (this.isIncompatible() ? TextColor.CRIMSON + "Kann nicht konvertiert werden!" :
"Muss konvertiert werden!") : ( // "Kreativmodus: " + (info.isNoCreative() ? "Aus" : "An") +
"Zuletzt gespielt: " + DATE_FORMAT.format(new Date(this.getLastPlayed()))) + " " + TextColor.LGRAY + this.getVersion(), x + 2, y + 18 + 16, 0xff808080);
}
}
public static final GuiConvert INSTANCE = new GuiConvert();
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
private ActButton selectButton;
private File dir = null;
private GuiConvert()
{
}
private void load() {
this.elements.clear();
if(this.dir == null || !this.dir.exists() || !this.dir.isDirectory())
return;
try
{
File[] files = 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;
FolderInfo info = Region.loadWorldInfo(file);
if(info == null)
info = Converter.convertMapFormat(file, false);
if(info == null) {
this.elements.add(new SaveInfo(file.getName(), -1, -1,
0L, new FolderInfo(World.START_TIME, file.lastModified(), null, null)));
continue;
}
int dims = -1;
int players = -1;
if(info.legacy == null) {
dims = 0;
File[] folders = new File(new File(dir, file.getName()), "chunk").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.isDirectory() && !pathname.getName().equals(Space.INSTANCE.getDimensionName());
}
});
if(folders != null) {
for(File sub : folders) {
File[] dim = sub.listFiles();
if(dim != null && dim.length > 0)
dims++;
}
}
File[] plrs = new File(new File(dir, file.getName()), "players").listFiles(new FileFilter() {
public boolean accept(File pathname) {
return pathname.getName().endsWith(".nbt");
}
});
players = plrs == null ? 0 : plrs.length;
}
this.elements.add(new SaveInfo(file.getName(), dims, players,
0L, info));
}
Collections.sort(this.elements);
}
catch (Exception e)
{
Log.IO.error("Konnte Weltliste nicht laden", e);
this.elements.clear();
}
}
public void init(int width, int height)
{
super.init(width, height);
this.setDimensions(width, height, 32, height - 32);
this.load();
this.add(this.selectButton = new ActButton(width / 2 - 383, height - 28, 150, 24, this, "Konvertieren"));
this.add(new NavButton(width / 2 + 233, height - 28, 150, 24, GuiMenu.INSTANCE, "Abbrechen"));
this.add(new ActButton(4, 4, 200, 24, new ActButton.Callback() {
public void use(ActButton elem, ActButton.Mode action) {
if(GuiConvert.this.gm.world != null)
return;
GuiConvert.this.gm.showFileDialog(FileMode.DIRECTORY_LOAD, "Ordner wählen", GuiConvert.this.dir, new FileCallback() {
public void selected(File file) {
GuiConvert.this.dir = file;
GuiConvert.this.gm.displayGuiScreen(GuiConvert.this);
}
});
}
}, "Ordner wählen ..."));
this.selectButton.enabled = false;
}
public String getTitle() {
return "Welt auswählen";
}
public int getListWidth()
{
return 660;
}
public int getSlotHeight()
{
return 56;
}
public void use(ActButton button, Mode mode)
{
String dir = this.getSelected().getFile();
File folder = new File(this.dir, dir);
if(folder.isDirectory())
Converter.convertMapFormat(folder, true);
}
}

View file

@ -94,12 +94,11 @@ public class GuiMenu extends Gui {
}
}
});
this.add(new NavButton(0, 102, 196, 24, GuiConvert.INSTANCE, "Welt konvertieren"));
this.add(new ActButton(204, 102, 196, 24, new ActButton.Callback() {
this.add(new ActButton(0, 102, 400, 24, new ActButton.Callback() {
public void use(ActButton elem, ActButton.Mode action) {
GuiMenu.this.gm.interrupted = true;
}
}, "Spiel beenden"));
}, "Client schließen"));
this.shift();
this.add(new Label(4, /* this.gm.fb_y - 2 */ 0, 200, 20, TextColor.VIOLET + Config.VERSION, true));
this.splashLabel = this.add(new Label(0, 160, width, 24, ""));

File diff suppressed because it is too large Load diff