feat: updated to 1.21.4
This commit is contained in:
parent
317bce17c2
commit
f59736deef
@ -1,7 +1,7 @@
|
||||
dependencies {
|
||||
api project(":resource-compiler")
|
||||
|
||||
api 'net.minestom:minestom-snapshots:bb7acc2e77'
|
||||
api 'net.minestom:minestom-snapshots:1_21_4-6490538291'
|
||||
|
||||
api 'org.slf4j:slf4j-api:2.0.16'
|
||||
api 'org.apache.logging.log4j:log4j-slf4j2-impl:2.24.0'
|
||||
|
||||
@ -23,7 +23,7 @@ public class BlankSlotItem {
|
||||
public synchronized static ItemStack getItem() {
|
||||
if (stack == null) {
|
||||
stack = ItemStack.builder(Material.PAPER)
|
||||
.customModelData(1)
|
||||
.itemModel("minecraft:air")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@ -29,30 +29,27 @@ public class FlatWorldModule {
|
||||
|
||||
var factory = WorldFactory.custom(dimension, new IChunkLoader() {
|
||||
@Override
|
||||
public @NotNull CompletableFuture<@Nullable Chunk> loadChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
var chunk = new DynamicChunk(instance, chunkX, chunkZ);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y <= 10; y++) {
|
||||
var block = switch (y) {
|
||||
case 10 -> Block.GRASS_BLOCK;
|
||||
case 9, 8, 7 -> Block.DIRT;
|
||||
case 0 -> Block.BEDROCK;
|
||||
default -> Block.STONE;
|
||||
};
|
||||
chunk.setBlock(x, y, z, block);
|
||||
}
|
||||
public @NotNull Chunk loadChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||
|
||||
var chunk = new DynamicChunk(instance, chunkX, chunkZ);
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
for (int y = 0; y <= 10; y++) {
|
||||
var block = switch (y) {
|
||||
case 10 -> Block.GRASS_BLOCK;
|
||||
case 9, 8, 7 -> Block.DIRT;
|
||||
case 0 -> Block.BEDROCK;
|
||||
default -> Block.STONE;
|
||||
};
|
||||
chunk.setBlock(x, y, z, block);
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
});
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Void> saveChunk(@NotNull Chunk chunk) {
|
||||
return new CompletableFuture<>();
|
||||
}
|
||||
public void saveChunk(@NotNull Chunk chunk) {}
|
||||
});
|
||||
|
||||
init(gameMode, factory.createWorldSync(), new Pos(0, 11, 0));
|
||||
|
||||
@ -179,6 +179,7 @@ public class DialogueRenderer extends Inventory {
|
||||
player.sendMessage(Component.text("[ERROR] " + ex.getMessage(), NamedTextColor.RED));
|
||||
|
||||
log.error(ex.getMessage(), ex);
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +255,7 @@ public class DialogueRenderer extends Inventory {
|
||||
itemBackup = null;
|
||||
}
|
||||
|
||||
player.closeInventory();
|
||||
if (!closedByPlayer) player.closeInventory();
|
||||
|
||||
player.eventNode().removeListener(onCloseListener);
|
||||
onCloseListener = null;
|
||||
|
||||
@ -45,7 +45,7 @@ public class World {
|
||||
public synchronized void unload() {
|
||||
if (!instance.isRegistered()) return;
|
||||
|
||||
log.info("Unloading world {} ({})", instance.getUniqueId(), instance.getChunkLoader().getClass().getSimpleName());
|
||||
log.info("Unloading world {} ({})", instance.getUuid(), instance.getChunkLoader().getClass().getSimpleName());
|
||||
|
||||
for (var player: instance.getPlayers()) {
|
||||
if (player.isOnline()) player.kick("World forced to unload");
|
||||
|
||||
@ -18,14 +18,14 @@ public abstract class WorldFactory {
|
||||
public final CompletableFuture<World> createWorld() {
|
||||
return CompletableFuture.supplyAsync(this::loadWorld)
|
||||
.thenApply(world -> {
|
||||
log.info("Created world {} ({})", world.getInstance().getUniqueId(), world.getInstance().getChunkLoader().getClass().getSimpleName());
|
||||
log.info("Created world {} ({})", world.getInstance().getUuid(), world.getInstance().getChunkLoader().getClass().getSimpleName());
|
||||
return world;
|
||||
});
|
||||
}
|
||||
|
||||
public final World createWorldSync() {
|
||||
var world = loadWorld();
|
||||
log.info("Created new world {} ({})", world.getInstance().getUniqueId(), world.getInstance().getChunkLoader().getClass().getSimpleName());
|
||||
log.info("Created new world {} ({})", world.getInstance().getUuid(), world.getInstance().getChunkLoader().getClass().getSimpleName());
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@ import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.IChunkLoader;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import ru.dragonestia.msb3.api.world.chunk.OutOfBoundsChunk;
|
||||
import ru.dragonestia.msb3.api.world.chunk.SharedChunk;
|
||||
import ru.dragonestia.msb3.api.world.loader.anvil.AnvilRegionLoader;
|
||||
@ -14,7 +13,6 @@ import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Log4j2
|
||||
public class PreloadedAnvilChunkLoader implements IChunkLoader {
|
||||
@ -26,24 +24,17 @@ public class PreloadedAnvilChunkLoader implements IChunkLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<@Nullable Chunk> loadChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||
return CompletableFuture.supplyAsync(() -> {
|
||||
var sourceChunkData = source.provideChunk(chunkX, chunkZ);
|
||||
if (sourceChunkData.isEmpty()) {
|
||||
return new OutOfBoundsChunk.Dynamic(instance, chunkX, chunkZ);
|
||||
}
|
||||
return new SharedChunk(instance, chunkX, chunkZ, sourceChunkData.get());
|
||||
});
|
||||
public @NotNull Chunk loadChunk(@NotNull Instance instance, int chunkX, int chunkZ) {
|
||||
var sourceChunkData = source.provideChunk(chunkX, chunkZ);
|
||||
if (sourceChunkData.isEmpty()) {
|
||||
return new OutOfBoundsChunk.Dynamic(instance, chunkX, chunkZ);
|
||||
}
|
||||
return new SharedChunk(instance, chunkX, chunkZ, sourceChunkData.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull CompletableFuture<Void> saveChunk(@NotNull Chunk chunk) {
|
||||
if (chunk instanceof SharedChunk sharedChunk) {
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
// TODO...
|
||||
});
|
||||
}
|
||||
return CompletableFuture.completedFuture(null);
|
||||
public void saveChunk(@NotNull Chunk chunk) {
|
||||
// TODO...
|
||||
}
|
||||
|
||||
public static class Source {
|
||||
|
||||
@ -9,6 +9,7 @@ import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.Section;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.BlockHandler;
|
||||
import net.minestom.server.instance.palette.Palettes;
|
||||
import net.minestom.server.registry.DynamicRegistry;
|
||||
import net.minestom.server.utils.ArrayUtils;
|
||||
import net.minestom.server.utils.MathUtils;
|
||||
@ -127,7 +128,7 @@ public class AnvilRegionLoader {
|
||||
|
||||
int bitsPerEntry = packedIndices.length * 64 / biomeIndices.length;
|
||||
if (bitsPerEntry > 3) bitsPerEntry = MathUtils.bitsToRepresent(convertedBiomePalette.length);
|
||||
ArrayUtils.unpack(biomeIndices, packedIndices, bitsPerEntry);
|
||||
Palettes.unpack(biomeIndices, packedIndices, bitsPerEntry);
|
||||
|
||||
section.biomePalette().setAll((x, y, z) -> {
|
||||
final int index = x + z * 4 + y * 16;
|
||||
@ -147,7 +148,7 @@ public class AnvilRegionLoader {
|
||||
final long[] packedStates = blockStatesTag.getLongArray("data");
|
||||
Check.stateCondition(packedStates.length == 0, "Missing packed states data");
|
||||
int[] blockStateIndices = new int[Chunk.CHUNK_SECTION_SIZE * Chunk.CHUNK_SECTION_SIZE * Chunk.CHUNK_SECTION_SIZE];
|
||||
ArrayUtils.unpack(blockStateIndices, packedStates, packedStates.length * 64 / blockStateIndices.length);
|
||||
Palettes.unpack(blockStateIndices, packedStates, packedStates.length * 64 / blockStateIndices.length);
|
||||
|
||||
for (int y = 0; y < Chunk.CHUNK_SECTION_SIZE; y++) {
|
||||
for (int z = 0; z < Chunk.CHUNK_SECTION_SIZE; z++) {
|
||||
|
||||
@ -5,6 +5,7 @@ import it.unimi.dsi.fastutil.booleans.BooleanList;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import net.kyori.adventure.nbt.*;
|
||||
import net.minestom.server.coordinate.CoordConversion;
|
||||
import net.minestom.server.utils.chunk.ChunkUtils;
|
||||
import net.minestom.server.utils.validate.Check;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -89,7 +90,7 @@ public class RegionFile implements AutoCloseable {
|
||||
}
|
||||
|
||||
private int getChunkIndex(int chunkX, int chunkZ) {
|
||||
return (ChunkUtils.toRegionLocal(chunkZ) << 5) | ChunkUtils.toRegionLocal(chunkX);
|
||||
return (CoordConversion.chunkToRegionLocal(chunkZ) << 5) | CoordConversion.chunkToRegionLocal(chunkX);
|
||||
}
|
||||
|
||||
private void readHeader() throws IOException {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
rootProject.name = 'msb3'
|
||||
|
||||
include 'resource-compiler', 'api', 'editor'
|
||||
include 'resource-compiler', 'api', 'editor', 'tarkov'
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user