mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +01:00
hollow-cube/dimension-names
This commit is contained in:
parent
388dbf71b9
commit
7493b640b7
@ -480,7 +480,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
setOnFire(false);
|
setOnFire(false);
|
||||||
refreshHealth();
|
refreshHealth();
|
||||||
|
|
||||||
sendPacket(new RespawnPacket(getDimensionType().toString(), getDimensionType().getName().asString(),
|
sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
|
||||||
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
|
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
|
||||||
|
|
||||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
|
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
|
||||||
@ -689,7 +689,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
ChunkUtils.forChunksInRange(spawnPosition, MinecraftServer.getChunkViewDistance(), chunkRemover);
|
ChunkUtils.forChunksInRange(spawnPosition, MinecraftServer.getChunkViewDistance(), chunkRemover);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dimensionChange) sendDimension(instance.getDimensionType());
|
if (dimensionChange) sendDimension(instance.getDimensionType(), instance.getDimensionName());
|
||||||
|
|
||||||
super.setInstance(instance, spawnPosition);
|
super.setInstance(instance, spawnPosition);
|
||||||
|
|
||||||
@ -1032,7 +1032,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
final PlayerInfoRemovePacket removePlayerPacket = getRemovePlayerToList();
|
final PlayerInfoRemovePacket removePlayerPacket = getRemovePlayerToList();
|
||||||
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
|
final PlayerInfoUpdatePacket addPlayerPacket = getAddPlayerToList();
|
||||||
|
|
||||||
RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), getDimensionType().getName().asString(),
|
RespawnPacket respawnPacket = new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
|
||||||
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown);
|
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown);
|
||||||
|
|
||||||
sendPacket(removePlayerPacket);
|
sendPacket(removePlayerPacket);
|
||||||
@ -1416,11 +1416,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
*
|
*
|
||||||
* @param dimensionType the new player dimension
|
* @param dimensionType the new player dimension
|
||||||
*/
|
*/
|
||||||
protected void sendDimension(@NotNull DimensionType dimensionType) {
|
protected void sendDimension(@NotNull DimensionType dimensionType, @NotNull String dimensionName) {
|
||||||
Check.argCondition(dimensionType.equals(getDimensionType()),
|
Check.argCondition(dimensionType.equals(getDimensionType()),
|
||||||
"The dimension needs to be different than the current one!");
|
"The dimension needs to be different than the current one!");
|
||||||
this.dimensionType = dimensionType;
|
this.dimensionType = dimensionType;
|
||||||
sendPacket(new RespawnPacket(dimensionType.toString(), getDimensionType().getName().asString(),
|
sendPacket(new RespawnPacket(dimensionType.toString(), dimensionName,
|
||||||
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
|
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
|
||||||
refreshClientStateAfterRespawn();
|
refreshClientStateAfterRespawn();
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import net.minestom.server.thread.ThreadDispatcher;
|
|||||||
import net.minestom.server.timer.Schedulable;
|
import net.minestom.server.timer.Schedulable;
|
||||||
import net.minestom.server.timer.Scheduler;
|
import net.minestom.server.timer.Scheduler;
|
||||||
import net.minestom.server.utils.ArrayUtils;
|
import net.minestom.server.utils.ArrayUtils;
|
||||||
|
import net.minestom.server.utils.NamespaceID;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
import net.minestom.server.utils.PacketUtils;
|
||||||
import net.minestom.server.utils.chunk.ChunkCache;
|
import net.minestom.server.utils.chunk.ChunkCache;
|
||||||
import net.minestom.server.utils.chunk.ChunkSupplier;
|
import net.minestom.server.utils.chunk.ChunkSupplier;
|
||||||
@ -68,6 +69,7 @@ public abstract class Instance implements Block.Getter, Block.Setter,
|
|||||||
private boolean registered;
|
private boolean registered;
|
||||||
|
|
||||||
private final DimensionType dimensionType;
|
private final DimensionType dimensionType;
|
||||||
|
private final String dimensionName;
|
||||||
|
|
||||||
private final WorldBorder worldBorder;
|
private final WorldBorder worldBorder;
|
||||||
|
|
||||||
@ -111,10 +113,21 @@ public abstract class Instance implements Block.Getter, Block.Setter,
|
|||||||
* @param dimensionType the {@link DimensionType} of the instance
|
* @param dimensionType the {@link DimensionType} of the instance
|
||||||
*/
|
*/
|
||||||
public Instance(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType) {
|
public Instance(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType) {
|
||||||
|
this(uniqueId, dimensionType, dimensionType.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
*
|
||||||
|
* @param uniqueId the {@link UUID} of the instance
|
||||||
|
* @param dimensionType the {@link DimensionType} of the instance
|
||||||
|
*/
|
||||||
|
public Instance(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType, @NotNull NamespaceID dimensionName) {
|
||||||
Check.argCondition(!dimensionType.isRegistered(),
|
Check.argCondition(!dimensionType.isRegistered(),
|
||||||
"The dimension " + dimensionType.getName() + " is not registered! Please use DimensionTypeManager#addDimension");
|
"The dimension " + dimensionType.getName() + " is not registered! Please use DimensionTypeManager#addDimension");
|
||||||
this.uniqueId = uniqueId;
|
this.uniqueId = uniqueId;
|
||||||
this.dimensionType = dimensionType;
|
this.dimensionType = dimensionType;
|
||||||
|
this.dimensionName = dimensionName.asString();
|
||||||
|
|
||||||
this.worldBorder = new WorldBorder(this);
|
this.worldBorder = new WorldBorder(this);
|
||||||
|
|
||||||
@ -362,6 +375,14 @@ public abstract class Instance implements Block.Getter, Block.Setter,
|
|||||||
return dimensionType;
|
return dimensionType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the instance dimension name.
|
||||||
|
* @return the dimension name of the instance
|
||||||
|
*/
|
||||||
|
public @NotNull String getDimensionName() {
|
||||||
|
return dimensionName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the age of this instance in tick.
|
* Gets the age of this instance in tick.
|
||||||
*
|
*
|
||||||
|
@ -20,6 +20,7 @@ import net.minestom.server.network.packet.server.play.BlockChangePacket;
|
|||||||
import net.minestom.server.network.packet.server.play.BlockEntityDataPacket;
|
import net.minestom.server.network.packet.server.play.BlockEntityDataPacket;
|
||||||
import net.minestom.server.network.packet.server.play.EffectPacket;
|
import net.minestom.server.network.packet.server.play.EffectPacket;
|
||||||
import net.minestom.server.network.packet.server.play.UnloadChunkPacket;
|
import net.minestom.server.network.packet.server.play.UnloadChunkPacket;
|
||||||
|
import net.minestom.server.utils.NamespaceID;
|
||||||
import net.minestom.server.utils.PacketUtils;
|
import net.minestom.server.utils.PacketUtils;
|
||||||
import net.minestom.server.utils.async.AsyncUtils;
|
import net.minestom.server.utils.async.AsyncUtils;
|
||||||
import net.minestom.server.utils.block.BlockUtils;
|
import net.minestom.server.utils.block.BlockUtils;
|
||||||
@ -77,18 +78,27 @@ public class InstanceContainer extends Instance {
|
|||||||
protected InstanceContainer srcInstance; // only present if this instance has been created using a copy
|
protected InstanceContainer srcInstance; // only present if this instance has been created using a copy
|
||||||
private long lastBlockChangeTime; // Time at which the last block change happened (#setBlock)
|
private long lastBlockChangeTime; // Time at which the last block change happened (#setBlock)
|
||||||
|
|
||||||
|
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType) {
|
||||||
|
this(uniqueId, dimensionType, null, dimensionType.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType, @NotNull NamespaceID dimensionName) {
|
||||||
|
this(uniqueId, dimensionType, null, dimensionName);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiStatus.Experimental
|
@ApiStatus.Experimental
|
||||||
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType, @Nullable IChunkLoader loader) {
|
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType, @Nullable IChunkLoader loader) {
|
||||||
super(uniqueId, dimensionType);
|
this(uniqueId, dimensionType, loader, dimensionType.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType, @Nullable IChunkLoader loader, @NotNull NamespaceID dimensionName) {
|
||||||
|
super(uniqueId, dimensionType, dimensionName);
|
||||||
setChunkSupplier(DynamicChunk::new);
|
setChunkSupplier(DynamicChunk::new);
|
||||||
setChunkLoader(Objects.requireNonNullElse(loader, DEFAULT_LOADER));
|
setChunkLoader(Objects.requireNonNullElse(loader, DEFAULT_LOADER));
|
||||||
this.chunkLoader.loadInstance(this);
|
this.chunkLoader.loadInstance(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType) {
|
|
||||||
this(uniqueId, dimensionType, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setBlock(int x, int y, int z, @NotNull Block block) {
|
public void setBlock(int x, int y, int z, @NotNull Block block) {
|
||||||
Chunk chunk = getChunkAt(x, z);
|
Chunk chunk = getChunkAt(x, z);
|
||||||
|
Loading…
Reference in New Issue
Block a user