mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 01:47:54 +01:00
Rename some internal-only methods
This commit is contained in:
parent
55626738e2
commit
705f419f9d
@ -1316,7 +1316,7 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission
|
||||
Check.notNull(newChunk, "The entity " + getEntityId() + " tried to move in an unloaded chunk at " + x + ";" + z);
|
||||
|
||||
if (lastChunk != newChunk) {
|
||||
instance.switchEntityChunk(this, lastChunk, newChunk);
|
||||
instance.UNSAFE_switchEntityChunk(this, lastChunk, newChunk);
|
||||
if (this instanceof Player) {
|
||||
// Refresh player view
|
||||
final Player player = (Player) this;
|
||||
|
@ -1,11 +1,6 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.UpdateManager;
|
||||
import net.minestom.server.adventure.audience.PacketGroupingAudience;
|
||||
@ -40,6 +35,7 @@ import net.minestom.server.utils.time.TimeUnit;
|
||||
import net.minestom.server.utils.time.UpdateOption;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import net.minestom.server.world.DimensionType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -859,6 +855,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
*
|
||||
* @param entity the entity to add
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public void UNSAFE_addEntity(@NotNull Entity entity) {
|
||||
final Instance lastInstance = entity.getInstance();
|
||||
if (lastInstance != null && lastInstance != this) {
|
||||
@ -890,7 +887,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
// Load the chunk if not already (or throw an error if auto chunk load is disabled)
|
||||
loadOptionalChunk(entityPosition, chunk -> {
|
||||
Check.notNull(chunk, "You tried to spawn an entity in an unloaded chunk, " + entityPosition);
|
||||
addEntityToChunk(entity, chunk);
|
||||
UNSAFE_addEntityToChunk(entity, chunk);
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -902,6 +899,7 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
*
|
||||
* @param entity the entity to remove
|
||||
*/
|
||||
@ApiStatus.Internal
|
||||
public void UNSAFE_removeEntity(@NotNull Entity entity) {
|
||||
final Instance entityInstance = entity.getInstance();
|
||||
if (entityInstance != this)
|
||||
@ -915,21 +913,22 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
// Remove the entity from cache
|
||||
final Chunk chunk = getChunkAt(entity.getPosition());
|
||||
Check.notNull(chunk, "Tried to interact with an unloaded chunk.");
|
||||
removeEntityFromChunk(entity, chunk);
|
||||
UNSAFE_removeEntityFromChunk(entity, chunk);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronized method to execute {@link #removeEntityFromChunk(Entity, Chunk)}
|
||||
* and {@link #addEntityToChunk(Entity, Chunk)} simultaneously.
|
||||
* Synchronized method to execute {@link #UNSAFE_removeEntityFromChunk(Entity, Chunk)}
|
||||
* and {@link #UNSAFE_addEntityToChunk(Entity, Chunk)} simultaneously.
|
||||
*
|
||||
* @param entity the entity to change its chunk
|
||||
* @param lastChunk the last entity chunk
|
||||
* @param newChunk the new entity chunk
|
||||
*/
|
||||
public synchronized void switchEntityChunk(@NotNull Entity entity, @NotNull Chunk lastChunk, @NotNull Chunk newChunk) {
|
||||
removeEntityFromChunk(entity, lastChunk);
|
||||
addEntityToChunk(entity, newChunk);
|
||||
@ApiStatus.Internal
|
||||
public synchronized void UNSAFE_switchEntityChunk(@NotNull Entity entity, @NotNull Chunk lastChunk, @NotNull Chunk newChunk) {
|
||||
UNSAFE_removeEntityFromChunk(entity, lastChunk);
|
||||
UNSAFE_addEntityToChunk(entity, newChunk);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -940,7 +939,8 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
* @param entity the entity to add
|
||||
* @param chunk the chunk where the entity will be added
|
||||
*/
|
||||
public void addEntityToChunk(@NotNull Entity entity, @NotNull Chunk chunk) {
|
||||
@ApiStatus.Internal
|
||||
public void UNSAFE_addEntityToChunk(@NotNull Entity entity, @NotNull Chunk chunk) {
|
||||
Check.notNull(chunk,
|
||||
"The chunk " + chunk + " is not loaded, you can make it automatic by using Instance#enableAutoChunkLoad(true)");
|
||||
Check.argCondition(!chunk.isLoaded(), "Chunk " + chunk + " has been unloaded previously");
|
||||
@ -968,7 +968,8 @@ public abstract class Instance implements BlockModifier, EventHandler, DataConta
|
||||
* @param entity the entity to remove
|
||||
* @param chunk the chunk where the entity will be removed
|
||||
*/
|
||||
public void removeEntityFromChunk(@NotNull Entity entity, @NotNull Chunk chunk) {
|
||||
@ApiStatus.Internal
|
||||
public void UNSAFE_removeEntityFromChunk(@NotNull Entity entity, @NotNull Chunk chunk) {
|
||||
synchronized (entitiesLock) {
|
||||
final long chunkIndex = ChunkUtils.getChunkIndex(chunk.getChunkX(), chunk.getChunkZ());
|
||||
Set<Entity> entities = getEntitiesInChunk(chunkIndex);
|
||||
|
Loading…
Reference in New Issue
Block a user