Skip to content

Commit

Permalink
Renamed chunk type classes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 19, 2023
1 parent 4986c4b commit 83dbbff
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import java.util.zip.DataFormatException;
import java.util.zip.Inflater;

public class Chunk1_1Type extends Type<Chunk> {
public class ChunkType1_1 extends Type<Chunk> {

public Chunk1_1Type() {
public ChunkType1_1() {
super(Chunk.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
public class Types1_1 {

public static Type<BlockChangeRecord[]> BLOCK_CHANGE_RECORD_ARRAY = new BlockChangeRecordArrayType();
public static Type<Chunk> CHUNK = new Chunk1_1Type();
public static Type<Chunk> CHUNK = new ChunkType1_1();

}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;

import java.util.ArrayList;
Expand Down Expand Up @@ -459,7 +459,7 @@ public void register() {

if (!load) {
final Chunk chunk = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], null, new ArrayList<>());
wrapper.write(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class)), chunk);
wrapper.write(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class)), chunk);
} else {
wrapper.cancel();
}
Expand Down Expand Up @@ -496,7 +496,7 @@ public void register() {
}
}
}
wrapper.write(new Chunk1_7_6Type(clientWorld), chunk);
wrapper.write(new ChunkType1_7_6(clientWorld), chunk);
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import io.netty.buffer.ByteBuf;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6;

public class Chunk1_2_4Type extends Chunk1_7_6Type {
public class ChunkType1_2_4 extends ChunkType1_7_6 {

private static final ClientWorld OVERWORLD = new ClientWorld(null);

static {
OVERWORLD.setEnvironment(Environment.NORMAL.id());
}

public Chunk1_2_4Type() {
public ChunkType1_2_4() {
super(OVERWORLD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public class Types1_2_4 {
public static final Type<Item[]> ITEM_ARRAY = new ItemArrayType<>(ITEM);
public static final Type<Item[]> COMPRESSED_NBT_ITEM_ARRAY = new ItemArrayType<>(COMPRESSED_NBT_ITEM);

public static final Type<Chunk> CHUNK = new Chunk1_2_4Type();
public static final Type<Chunk> CHUNK = new ChunkType1_2_4();

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import net.raphimc.vialegacy.api.remapper.LegacyItemRewriter;
import net.raphimc.vialegacy.api.splitter.PreNettySplitter;
import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.rewriter.ItemRewriter;
import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.ChunkBulk1_4_4Type;
import net.raphimc.vialegacy.protocols.release.protocol1_4_6_7to1_4_4_5.types.ChunkBulkType1_4_4;
import net.raphimc.vialegacy.protocols.release.protocol1_5_0_1to1_4_6_7.ClientboundPackets1_4_6;
import net.raphimc.vialegacy.protocols.release.protocol1_6_1to1_5_2.ServerboundPackets1_5_2;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.MetaType1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.types.Types1_6_4;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;

public class Protocol1_4_6_7to1_4_4_5 extends StatelessProtocol<ClientboundPackets1_4_4, ClientboundPackets1_4_6, ServerboundPackets1_5_2, ServerboundPackets1_5_2> {
Expand Down Expand Up @@ -129,7 +129,7 @@ public void register() {
public void register() {
handler(wrapper -> {
final ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
wrapper.write(new ChunkBulk1_7_6Type(clientWorld), wrapper.read(new ChunkBulk1_4_4Type(clientWorld)));
wrapper.write(new ChunkBulkType1_7_6(clientWorld), wrapper.read(new ChunkBulkType1_4_4(clientWorld)));
});
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import io.netty.buffer.ByteBuf;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6;

public class ChunkBulk1_4_4Type extends ChunkBulk1_7_6Type {
public class ChunkBulkType1_4_4 extends ChunkBulkType1_7_6 {

public ChunkBulk1_4_4Type(ClientWorld clientWorld) {
public ChunkBulkType1_4_4(ClientWorld clientWorld) {
super(clientWorld);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.model.GameProfile;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.MetaType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;

Expand Down Expand Up @@ -421,7 +421,7 @@ public void register() {
@Override
public void register() {
handler(wrapper -> {
final Chunk chunk = wrapper.passthrough(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class)));
final Chunk chunk = wrapper.passthrough(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class)));
wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk);
});
}
Expand Down Expand Up @@ -486,7 +486,7 @@ public void register() {
@Override
public void register() {
handler(wrapper -> {
final Chunk[] chunks = wrapper.passthrough(new ChunkBulk1_7_6Type(wrapper.user().get(ClientWorld.class)));
final Chunk[] chunks = wrapper.passthrough(new ChunkBulkType1_7_6(wrapper.user().get(ClientWorld.class)));
for (Chunk chunk : chunks) {
wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.ItemRewriter;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.rewriter.TranslationRewriter;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.storage.*;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Chunk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulk1_7_6Type;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.ChunkBulkType1_7_6;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.types.Types1_7_6;

import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -633,7 +633,7 @@ public void register() {
@Override
public void register() {
handler(wrapper -> {
final Chunk chunk = wrapper.read(new Chunk1_7_6Type(wrapper.user().get(ClientWorld.class)));
final Chunk chunk = wrapper.read(new ChunkType1_7_6(wrapper.user().get(ClientWorld.class)));
wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk);
wrapper.write(new Chunk1_8Type(wrapper.user().get(ClientWorld.class)), chunk);
});
Expand Down Expand Up @@ -696,7 +696,7 @@ public void register() {
@Override
public void register() {
handler(wrapper -> {
final Chunk[] chunks = wrapper.read(new ChunkBulk1_7_6Type(wrapper.user().get(ClientWorld.class)));
final Chunk[] chunks = wrapper.read(new ChunkBulkType1_7_6(wrapper.user().get(ClientWorld.class)));
for (Chunk chunk : chunks) {
wrapper.user().get(ChunkTracker.class).trackAndRemap(chunk);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import net.lenni0451.mcstructs.snbt.SNbtSerializer;
import net.lenni0451.mcstructs.snbt.exceptions.SNbtSerializeException;
import net.raphimc.vialegacy.ViaLegacy;
import net.raphimc.vialegacy.protocols.release.protocol1_7_6_10to1_7_2_5.ClientboundPackets1_7_2;
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.Protocol1_8to1_7_6_10;
import net.raphimc.vialegacy.util.NbtConverter;

Expand Down Expand Up @@ -358,10 +359,10 @@ public class ChatItemRewriter {
ID_TO_NAME.put(2267, "record_wait");
}

private final ComponentRewriter SHOW_ITEM;
private final ComponentRewriter<ClientboundPackets1_7_2> SHOW_ITEM;

public ChatItemRewriter(final Protocol1_8to1_7_6_10 protocol) {
this.SHOW_ITEM = new ComponentRewriter(protocol) {
this.SHOW_ITEM = new ComponentRewriter<ClientboundPackets1_7_2>(protocol) {
@Override
protected void handleHoverEvent(JsonObject hoverEvent) {
super.handleHoverEvent(hoverEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
import java.util.zip.Deflater;
import java.util.zip.Inflater;

public class ChunkBulk1_7_6Type extends PartialType<Chunk[], ClientWorld> {
public class ChunkBulkType1_7_6 extends PartialType<Chunk[], ClientWorld> {

public ChunkBulk1_7_6Type(final ClientWorld clientWorld) {
public ChunkBulkType1_7_6(final ClientWorld clientWorld) {
super(clientWorld, Chunk[].class);
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public Chunk[] read(ByteBuf byteBuf, ClientWorld clientWorld) throws Exception {
additionalBitMask[i] = byteBuf.readShort();
}

final byte[] uncompressedData = new byte[Chunk1_7_6Type.getSize((short) 0xFFFF, (short) 0xFFFF, true, hasSkyLight) * chunkCount];
final byte[] uncompressedData = new byte[ChunkType1_7_6.getSize((short) 0xFFFF, (short) 0xFFFF, true, hasSkyLight) * chunkCount];
final Inflater inflater = new Inflater();
try {
inflater.setInput(data, 0, compressedSize);
Expand All @@ -96,9 +96,9 @@ public Chunk[] read(ByteBuf byteBuf, ClientWorld clientWorld) throws Exception {
final Chunk[] chunks = new Chunk[chunkCount];
int dataPosition = 0;
for (int i = 0; i < chunkCount; i++) {
final byte[] chunkData = new byte[Chunk1_7_6Type.getSize(primaryBitMask[i], additionalBitMask[i], true, hasSkyLight)];
final byte[] chunkData = new byte[ChunkType1_7_6.getSize(primaryBitMask[i], additionalBitMask[i], true, hasSkyLight)];
System.arraycopy(uncompressedData, dataPosition, chunkData, 0, chunkData.length);
chunks[i] = Chunk1_7_6Type.deserialize(chunkX[i], chunkZ[i], true, hasSkyLight, primaryBitMask[i], additionalBitMask[i], chunkData);
chunks[i] = ChunkType1_7_6.deserialize(chunkX[i], chunkZ[i], true, hasSkyLight, primaryBitMask[i], additionalBitMask[i], chunkData);
dataPosition += chunkData.length;
}

Expand All @@ -116,7 +116,7 @@ public void write(ByteBuf byteBuf, ClientWorld clientWorld, Chunk[] chunks) thro

for (int i = 0; i < chunkCount; i++) {
final Chunk chunk = chunks[i];
final Pair<byte[], Short> chunkData = Chunk1_7_6Type.serialize(chunk);
final Pair<byte[], Short> chunkData = ChunkType1_7_6.serialize(chunk);
output.write(chunkData.key());
chunkX[i] = chunk.getX();
chunkZ[i] = chunk.getZ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import java.util.zip.Deflater;
import java.util.zip.Inflater;

public class Chunk1_7_6Type extends PartialType<Chunk, ClientWorld> {
public class ChunkType1_7_6 extends PartialType<Chunk, ClientWorld> {

public Chunk1_7_6Type(final ClientWorld clientWorld) {
public ChunkType1_7_6(final ClientWorld clientWorld) {
super(clientWorld, Chunk.class);
}

Expand Down

0 comments on commit 83dbbff

Please sign in to comment.