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