mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
parent
5413f9c98f
commit
b4c41adb7d
@ -480,7 +480,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
setOnFire(false);
|
||||
refreshHealth();
|
||||
|
||||
sendPacket(new RespawnPacket(getDimensionType().toString(), getDimensionType().getName().asString(),
|
||||
sendPacket(new RespawnPacket(getDimensionType().toString(), instance.getDimensionName(),
|
||||
0, gameMode, gameMode, false, levelFlat, true, deathLocation, portalCooldown));
|
||||
|
||||
PlayerRespawnEvent respawnEvent = new PlayerRespawnEvent(this);
|
||||
@ -689,7 +689,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
ChunkUtils.forChunksInRange(spawnPosition, MinecraftServer.getChunkViewDistance(), chunkRemover);
|
||||
}
|
||||
|
||||
if (dimensionChange) sendDimension(instance.getDimensionType());
|
||||
if (dimensionChange) sendDimension(instance.getDimensionType(), instance.getDimensionName());
|
||||
|
||||
super.setInstance(instance, spawnPosition);
|
||||
|
||||
@ -1038,7 +1038,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
final PlayerInfoRemovePacket removePlayerPacket = getRemovePlayerToList();
|
||||
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);
|
||||
|
||||
sendPacket(removePlayerPacket);
|
||||
@ -1422,11 +1422,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
*
|
||||
* @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()),
|
||||
"The dimension needs to be different than the current one!");
|
||||
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));
|
||||
refreshClientStateAfterRespawn();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ import net.minestom.server.thread.ThreadDispatcher;
|
||||
import net.minestom.server.timer.Schedulable;
|
||||
import net.minestom.server.timer.Scheduler;
|
||||
import net.minestom.server.utils.ArrayUtils;
|
||||
import net.minestom.server.utils.NamespaceID;
|
||||
import net.minestom.server.utils.PacketUtils;
|
||||
import net.minestom.server.utils.chunk.ChunkCache;
|
||||
import net.minestom.server.utils.chunk.ChunkSupplier;
|
||||
@ -68,6 +69,7 @@ public abstract class Instance implements Block.Getter, Block.Setter,
|
||||
private boolean registered;
|
||||
|
||||
private final DimensionType dimensionType;
|
||||
private final String dimensionName;
|
||||
|
||||
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
|
||||
*/
|
||||
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(),
|
||||
"The dimension " + dimensionType.getName() + " is not registered! Please use DimensionTypeManager#addDimension");
|
||||
this.uniqueId = uniqueId;
|
||||
this.dimensionType = dimensionType;
|
||||
this.dimensionName = dimensionName.asString();
|
||||
|
||||
this.worldBorder = new WorldBorder(this);
|
||||
|
||||
@ -362,6 +375,14 @@ public abstract class Instance implements Block.Getter, Block.Setter,
|
||||
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.
|
||||
*
|
||||
|
@ -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.EffectPacket;
|
||||
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.async.AsyncUtils;
|
||||
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
|
||||
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
|
||||
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);
|
||||
setChunkLoader(Objects.requireNonNullElse(loader, DEFAULT_LOADER));
|
||||
this.chunkLoader.loadInstance(this);
|
||||
}
|
||||
|
||||
public InstanceContainer(@NotNull UUID uniqueId, @NotNull DimensionType dimensionType) {
|
||||
this(uniqueId, dimensionType, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, @NotNull Block block) {
|
||||
Chunk chunk = getChunkAt(x, z);
|
||||
|
Loading…
Reference in New Issue
Block a user