mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2026-01-03 14:22:25 +00:00
修复加载
This commit is contained in:
@@ -100,7 +100,7 @@ public abstract class BlockBehavior {
|
||||
return false;
|
||||
}
|
||||
|
||||
//BlockState state Level level BlockPos pos
|
||||
//BlockState state, Level level, BlockPos pos
|
||||
public int getAnalogOutputSignal(Object thisBlock, Object[] args) throws Exception {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,8 @@ public class Dependencies {
|
||||
"adventure-nbt",
|
||||
List.of(Relocation.of("option", "net{}kyori{}option"),
|
||||
Relocation.of("examination", "net{}kyori{}examination"),
|
||||
Relocation.of("adventure", "net{}kyori{}adventure"))
|
||||
Relocation.of("adventure", "net{}kyori{}adventure")),
|
||||
true
|
||||
) {
|
||||
@Override
|
||||
public String getVersion() {
|
||||
|
||||
@@ -12,11 +12,7 @@ import net.momirealms.sparrow.nbt.ListTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.*;
|
||||
|
||||
public class CEChunk {
|
||||
public final CEWorld world;
|
||||
@@ -26,7 +22,7 @@ public class CEChunk {
|
||||
public final Map<BlockPos, BlockEntity> blockEntities;
|
||||
private volatile boolean dirty;
|
||||
private volatile boolean loaded;
|
||||
protected final Map<BlockPos, ReplaceableTickingBlockEntity> tickingBlockEntitiesByPos = new ConcurrentHashMap<>();
|
||||
protected final Map<BlockPos, ReplaceableTickingBlockEntity> tickingBlockEntitiesByPos = new HashMap<>();
|
||||
|
||||
public CEChunk(CEWorld world, ChunkPos chunkPos) {
|
||||
this.world = world;
|
||||
@@ -71,6 +67,13 @@ public class CEChunk {
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllBlockEntities() {
|
||||
this.blockEntities.values().forEach(e -> e.setValid(false));
|
||||
this.blockEntities.clear();
|
||||
this.tickingBlockEntitiesByPos.values().forEach((ticker) -> ticker.setTicker(DummyTickingBlockEntity.INSTANCE));
|
||||
this.tickingBlockEntitiesByPos.clear();
|
||||
}
|
||||
|
||||
public <T extends BlockEntity> void replaceOrCreateTickingBlockEntity(T blockEntity) {
|
||||
ImmutableBlockState blockState = blockEntity.blockState();
|
||||
BlockEntityTicker<T> ticker = blockState.createBlockEntityTicker(this.world, blockEntity.type());
|
||||
@@ -250,6 +253,7 @@ public class CEChunk {
|
||||
public void unload() {
|
||||
if (!this.loaded) return;
|
||||
this.world.removeLoadedChunk(this);
|
||||
this.clearAllBlockEntities();
|
||||
this.loaded = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user