Skip to content

Commit

Permalink
Initial support for 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
mircokroon committed May 16, 2024
1 parent 7d2e4ec commit 2cd11de
Show file tree
Hide file tree
Showing 41 changed files with 932 additions and 494 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<version>1.0.0.0</version>
<packaging>jar</packaging>
<properties>
<java.version>17</java.version>
<java.version.max>17</java.version.max>
<java.version>21</java.version>
<java.version.max>21</java.version.max>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/config/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public enum Version {
V1_19_3(761, 3218),
V1_20(763, 3463),
V1_20_2(764, 3578),
V1_20_3(765, 3698),
V1_20_4(765, 3698),
V1_20_6(766, 3839),
ANY(0, 0);

public final int dataVersion;
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/game/data/LevelData.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import static util.ExceptionHandling.attempt;

import config.Config;
import config.Option;
import config.Version;
import game.data.coordinates.Coordinate3D;
import game.data.coordinates.CoordinateDouble3D;
Expand Down Expand Up @@ -224,7 +223,7 @@ private void disableWorldGeneration(CompoundTag data) {
new NamedTag("biome", new StringTag("minecraft:the_void"))
)));

CompoundTag dimensions = new CompoundTag(worldManager.getDimensionCodec().getDimensions().stream().map(dimension -> {
CompoundTag dimensions = new CompoundTag(worldManager.getDimensionRegistry().getDimensions().stream().map(dimension -> {
CompoundTag dim = new CompoundTag();
dim.add("type", new StringTag(dimension.getType()));
dim.add("generator", generator);
Expand Down
26 changes: 18 additions & 8 deletions src/main/java/game/data/WorldManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import static util.ExceptionHandling.attempt;

import game.data.chunk.version.Chunk_1_17;
import game.data.dimension.DimensionType;
import gui.ChunkImageState;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -41,7 +43,7 @@
import game.data.coordinates.CoordinateDim2D;
import game.data.coordinates.CoordinateDouble3D;
import game.data.dimension.Dimension;
import game.data.dimension.DimensionCodec;
import game.data.dimension.DimensionRegistry;
import game.data.entity.EntityNames;
import game.data.entity.EntityRegistry;
import game.data.maps.MapRegistry;
Expand All @@ -53,7 +55,6 @@
import packets.DataTypeProvider;
import packets.builder.PacketBuilder;
import proxy.PacketInjector;
import se.llbit.nbt.CompoundTag;
import se.llbit.nbt.Tag;
import util.PathUtils;

Expand Down Expand Up @@ -81,14 +82,15 @@ public class WorldManager {
private ContainerManager containerManager;
private CommandBlockManager commandBlockManager;
private VillagerManager villagerManager;
private DimensionCodec dimensionCodec;
private DimensionRegistry dimensionCodec;
private final RenderDistanceExtender renderDistanceExtender;

private BiConsumer<CoordinateDouble3D, Double> playerPosListener;
private final CoordinateDouble3D playerPosition;
private boolean isBelowGround = false;
private double playerRotation = 0;
private Dimension dimension;
private DimensionType dimensionType;
private final EntityRegistry entityRegistry;
private final ChunkFactory chunkFactory;

Expand Down Expand Up @@ -160,6 +162,11 @@ public void setDimension(Dimension dimension) {
GuiManager.setDimension(this.dimension);
}

public void setDimensionType(DimensionType dimensionType) {
this.dimensionType = dimensionType;
Chunk_1_17.setWorldHeight(dimensionType.getDimensionMinHeight(), dimensionType.getDimensionMaxHeight());
}

private void saveAndUnloadChunks() {
if (saveService == null) {
return;
Expand Down Expand Up @@ -381,20 +388,23 @@ public void touchChunk(ChunkEntities c) {
regions.get(c.getLocation().chunkToDimRegion()).touch();
}

public DimensionCodec getDimensionCodec() {
public DimensionRegistry getDimensionRegistry() {
if (dimensionCodec == null) {
this.dimensionCodec = DimensionRegistry.empty();
}
return dimensionCodec;
}

/**
* Set the dimension codec, used to store information about the dimensions that this server supports.
* Set the dimension registry, used to store information about the dimensions that this server supports.
*/
public void setDimensionCodec(DimensionCodec codec) {
dimensionCodec = codec;
public void setDimensionRegistry(DimensionRegistry registry) {
dimensionCodec = registry;

// We can immediately try to write the dimension data to the proper directory.
try {
Path p = PathUtils.toPath(Config.getWorldOutputDir(), "datapacks", "downloaded", "data");
if (codec.write(p)) {
if (registry.write(p)) {

// we need to copy that pack.mcmeta file from so that Minecraft will recognise the datapack
Path packMeta = PathUtils.toPath(p.getParent().toString(), "pack.mcmeta");
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/game/data/chunk/ChunkSection.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package game.data.chunk;

import game.data.chunk.palette.GlobalPalette;
import game.data.chunk.palette.BlockRegistry;
import java.util.Arrays;

import org.apache.commons.lang3.mutable.MutableBoolean;
Expand Down Expand Up @@ -92,7 +92,7 @@ public byte getY() {
}

public int computeHeight(int x, int z, MutableBoolean foundAir) {
GlobalPalette globalPalette = GlobalPaletteProvider.getGlobalPalette(getDataVersion());
BlockRegistry globalPalette = GlobalPaletteProvider.getGlobalPalette(getDataVersion());

for (int y = 15; y >= 0 ; y--) {
int blockStateId = getNumericBlockStateAt(x, y, z);
Expand Down
Loading

0 comments on commit 2cd11de

Please sign in to comment.