9
0
mirror of https://github.com/Xiao-MoMi/craft-engine.git synced 2025-12-25 18:09:27 +00:00

修复加载

This commit is contained in:
XiaoMoMi
2025-09-04 06:39:47 +08:00
parent 8b6c2c398a
commit 65b00161fb
6 changed files with 16 additions and 10 deletions

View File

@@ -496,6 +496,7 @@ public final class BlockGenerator {
}
}
}
public static class PerformBoneMealInterceptor {
public static final PerformBoneMealInterceptor INSTANCE = new PerformBoneMealInterceptor();

View File

@@ -1571,7 +1571,8 @@ public final class CoreReflections {
);
public static final Method method$BlockBehaviour$hasAnalogOutputSignal = requireNonNull(
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, boolean.class, new String[]{"hasAnalogOutputSignal", "c"}, clazz$BlockState)
ReflectionUtils.getDeclaredMethod(clazz$BlockBehaviour, boolean.class, new String[]{"hasAnalogOutputSignal",
VersionHelper.isOrAbove1_20_5() ? "c_" : "d_"}, clazz$BlockState)
);
public static final Method method$BlockBehaviour$getAnalogOutputSignal = requireNonNull(

View File

@@ -1057,7 +1057,6 @@ public final class NetworkReflections {
)
);
public static final Constructor<?> constructor$ClientboundMoveEntityPacket$PosRot = requireNonNull(
ReflectionUtils.getTheOnlyConstructor(clazz$ClientboundMoveEntityPacket$PosRot)
);

View File

@@ -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;
}

View File

@@ -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() {

View File

@@ -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;
}
}