char origins

This commit is contained in:
Sen 2025-03-28 14:30:37 +01:00
parent 3316c42ed8
commit e9ede99d84
14 changed files with 516 additions and 373 deletions

View file

@ -125,6 +125,7 @@ import game.world.Region;
import game.world.State;
import game.world.Vec3i;
import game.world.World;
import game.world.WorldPos;
import game.world.WorldServer;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
@ -2493,13 +2494,18 @@ public class Player extends NetHandler implements ICrafting, Executor
NetHandler.checkThread(packetIn, this, this.server);
CPacketAction.Action action = packetIn.getAction();
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR))
if(this.charEditor != (action == Action.SET_ALIGN || action == Action.SET_SPECIES || action == Action.SET_HEIGHT || action == Action.CLOSE_EDITOR)) // {
// if(this.local && action == Action.CLOSE_EDITOR)
// this.server.setDone();
return;
// }
switch (action)
{
case OPEN_EDITOR:
this.charEditor = true;
// if(this.local)
// this.server.resetProgress();
NBTTagCompound tag = this.server.swapPlayer(this, null, EntityHuman.class);
if(!this.characters.isEmpty() && this.selected >= 0)
this.characters.set(this.selected, tag);
@ -2507,13 +2513,24 @@ public class Player extends NetHandler implements ICrafting, Executor
this.sendPacket(new SPacketCharacterList(this.selected));
break;
case CLOSE_EDITOR:
case CLOSE_EDITOR: {
this.charEditor = false;
this.selected = this.characters.size();
this.characters.add(new NBTTagCompound());
this.entity.teleport(this.server.getRandomSpawnPosition());
WorldServer world = this.server.getWorld(packetIn.getAuxData());
world = world == null ? this.server.getSpace() : world;
WorldPos origin = new WorldPos(world.rand.range(-Config.originRadius, Config.originRadius), 64, world.rand.range(-Config.originRadius, Config.originRadius),
world.dimension.getDimensionId());
this.entity.setOrigin(origin);
Position pos = this.server.getRandomSpawnPosition(origin);
if(Config.preloadLocal && this.local && this.server.getPlayers().size() == 1)
this.server.preload(world, (int)pos.x, (int)pos.z);
this.entity.teleport(pos);
this.sendPacket(new SPacketCharacterList(this.selected, this.selected, new PlayerCharacter(this.entity.getCustomNameTag(), this.entity.getDescription(), this.entity.getAlignment(), this.entity.worldObj.dimension.getFormattedName(false), this.entity.getPosition(), EntityRegistry.getEntityName(EntityRegistry.getEntityString(this.entity)), this.entity.experienceLevel)));
// if(this.local)
// this.server.setDone();
break;
}
case SELECT_CHARACTER:
int index = packetIn.getAuxData();