3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Store environment instead of clientlevel in chunk types

Dieser Commit ist enthalten in:
Nassim Jahnke 2023-10-20 16:56:53 +10:00
Ursprung 7edde72416
Commit 54c04a62e0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
7 geänderte Dateien mit 32 neuen und 126 gelöschten Zeilen

Datei anzeigen

@ -1,42 +0,0 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.type.types.chunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.type.Type;
public abstract class BaseChunkBulkType extends Type<Chunk[]> {
protected BaseChunkBulkType() {
super(Chunk[].class);
}
protected BaseChunkBulkType(String typeName) {
super(typeName, Chunk[].class);
}
@Override
public Class<? extends Type> getBaseClass() {
return BaseChunkBulkType.class;
}
}

Datei anzeigen

@ -1,42 +0,0 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2023 ViaVersion and contributors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.viaversion.viaversion.api.type.types.chunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
import com.viaversion.viaversion.api.type.Type;
public abstract class BaseChunkType extends Type<Chunk> {
protected BaseChunkType() {
super(Chunk.class);
}
protected BaseChunkType(String typeName) {
super(typeName, Chunk.class);
}
@Override
public Class<? extends Type> getBaseClass() {
return BaseChunkType.class;
}
}

Datei anzeigen

@ -121,5 +121,4 @@ public class BulkChunkType1_8 extends Type<Chunk[]> {
return this.data; return this.data;
} }
} }
} }

Datei anzeigen

@ -24,7 +24,6 @@ package com.viaversion.viaversion.api.type.types.chunk;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -38,13 +37,13 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
public class ChunkType1_13 extends PartialType<Chunk, ClientWorld> { public class ChunkType1_13 extends PartialType<Chunk, Environment> {
private static final ChunkType1_13 WITH_SKYLIGHT = new ChunkType1_13(new ClientWorld(Environment.NORMAL)); private static final ChunkType1_13 WITH_SKYLIGHT = new ChunkType1_13(Environment.NORMAL);
private static final ChunkType1_13 WITHOUT_SKYLIGHT = new ChunkType1_13(new ClientWorld(Environment.NETHER)); private static final ChunkType1_13 WITHOUT_SKYLIGHT = new ChunkType1_13(Environment.NETHER);
public ChunkType1_13(ClientWorld clientWorld) { public ChunkType1_13(Environment environment) {
super(clientWorld, Chunk.class); super(environment, Chunk.class);
} }
public static ChunkType1_13 forEnvironment(Environment environment) { public static ChunkType1_13 forEnvironment(Environment environment) {
@ -52,7 +51,7 @@ public class ChunkType1_13 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public Chunk read(ByteBuf input, ClientWorld world) throws Exception { public Chunk read(ByteBuf input, Environment environment) throws Exception {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
@ -68,7 +67,7 @@ public class ChunkType1_13 extends PartialType<Chunk, ClientWorld> {
ChunkSection section = Types1_13.CHUNK_SECTION.read(data); ChunkSection section = Types1_13.CHUNK_SECTION.read(data);
sections[i] = section; sections[i] = section;
section.getLight().readBlockLight(data); section.getLight().readBlockLight(data);
if (world.getEnvironment() == Environment.NORMAL) { if (environment == Environment.NORMAL) {
section.getLight().readSkyLight(data); section.getLight().readSkyLight(data);
} }
} }
@ -98,7 +97,7 @@ public class ChunkType1_13 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { public void write(ByteBuf output, Environment environment, Chunk chunk) throws Exception {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
@ -134,9 +133,4 @@ public class ChunkType1_13 extends PartialType<Chunk, ClientWorld> {
// Write Block Entities // Write Block Entities
Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); Type.NAMED_COMPOUND_TAG_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0]));
} }
@Override
public Class<? extends Type> getBaseClass() {
return BaseChunkType.class;
}
} }

Datei anzeigen

@ -22,7 +22,6 @@
*/ */
package com.viaversion.viaversion.api.type.types.chunk; package com.viaversion.viaversion.api.type.types.chunk;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -34,13 +33,13 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled; import io.netty.buffer.Unpooled;
import java.util.ArrayList; import java.util.ArrayList;
public class ChunkType1_8 extends PartialType<Chunk, ClientWorld> { public class ChunkType1_8 extends PartialType<Chunk, Environment> {
private static final ChunkType1_8 WITH_SKYLIGHT = new ChunkType1_8(new ClientWorld(Environment.NORMAL)); private static final ChunkType1_8 WITH_SKYLIGHT = new ChunkType1_8(Environment.NORMAL);
private static final ChunkType1_8 WITHOUT_SKYLIGHT = new ChunkType1_8(new ClientWorld(Environment.NETHER)); private static final ChunkType1_8 WITHOUT_SKYLIGHT = new ChunkType1_8(Environment.NETHER);
public ChunkType1_8(ClientWorld clientWorld) { public ChunkType1_8(Environment environment) {
super(clientWorld, Chunk.class); super(environment, Chunk.class);
} }
public static ChunkType1_8 forEnvironment(Environment environment) { public static ChunkType1_8 forEnvironment(Environment environment) {
@ -48,7 +47,7 @@ public class ChunkType1_8 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public Chunk read(ByteBuf input, ClientWorld world) throws Exception { public Chunk read(ByteBuf input, Environment environment) throws Exception {
final int chunkX = input.readInt(); final int chunkX = input.readInt();
final int chunkZ = input.readInt(); final int chunkZ = input.readInt();
final boolean fullChunk = input.readBoolean(); final boolean fullChunk = input.readBoolean();
@ -62,11 +61,11 @@ public class ChunkType1_8 extends PartialType<Chunk, ClientWorld> {
return new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], null, new ArrayList<>()); return new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], null, new ArrayList<>());
} }
return deserialize(chunkX, chunkZ, fullChunk, world.getEnvironment() == Environment.NORMAL, bitmask, data); return deserialize(chunkX, chunkZ, fullChunk, environment == Environment.NORMAL, bitmask, data);
} }
@Override @Override
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { public void write(ByteBuf output, Environment environment, Chunk chunk) throws Exception {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isFullChunk()); output.writeBoolean(chunk.isFullChunk());

Datei anzeigen

@ -22,7 +22,6 @@
*/ */
package com.viaversion.viaversion.api.type.types.chunk; package com.viaversion.viaversion.api.type.types.chunk;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -34,13 +33,13 @@ import io.netty.buffer.ByteBuf;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.BitSet; import java.util.BitSet;
public class ChunkType1_9_1 extends PartialType<Chunk, ClientWorld> { public class ChunkType1_9_1 extends PartialType<Chunk, Environment> {
private static final ChunkType1_9_1 WITH_SKYLIGHT = new ChunkType1_9_1(new ClientWorld(Environment.NORMAL)); private static final ChunkType1_9_1 WITH_SKYLIGHT = new ChunkType1_9_1(Environment.NORMAL);
private static final ChunkType1_9_1 WITHOUT_SKYLIGHT = new ChunkType1_9_1(new ClientWorld(Environment.NETHER)); private static final ChunkType1_9_1 WITHOUT_SKYLIGHT = new ChunkType1_9_1(Environment.NETHER);
public ChunkType1_9_1(ClientWorld clientWorld) { public ChunkType1_9_1(Environment environment) {
super(clientWorld, Chunk.class); super(environment, Chunk.class);
} }
public static ChunkType1_9_1 forEnvironment(Environment environment) { public static ChunkType1_9_1 forEnvironment(Environment environment) {
@ -48,7 +47,7 @@ public class ChunkType1_9_1 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public Chunk read(ByteBuf input, ClientWorld world) throws Exception { public Chunk read(ByteBuf input, Environment environment) throws Exception {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
@ -72,7 +71,7 @@ public class ChunkType1_9_1 extends PartialType<Chunk, ClientWorld> {
ChunkSection section = Types1_9.CHUNK_SECTION.read(input); ChunkSection section = Types1_9.CHUNK_SECTION.read(input);
sections[i] = section; sections[i] = section;
section.getLight().readBlockLight(input); section.getLight().readBlockLight(input);
if (world.getEnvironment() == Environment.NORMAL) { if (environment == Environment.NORMAL) {
section.getLight().readSkyLight(input); section.getLight().readSkyLight(input);
} }
} }
@ -88,7 +87,7 @@ public class ChunkType1_9_1 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { public void write(ByteBuf output, Environment environment, Chunk chunk) throws Exception {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());

Datei anzeigen

@ -24,7 +24,6 @@ package com.viaversion.viaversion.api.type.types.chunk;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.Environment;
import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk; import com.viaversion.viaversion.api.minecraft.chunks.BaseChunk;
import com.viaversion.viaversion.api.minecraft.chunks.Chunk; import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
@ -37,13 +36,13 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class ChunkType1_9_3 extends PartialType<Chunk, ClientWorld> { public class ChunkType1_9_3 extends PartialType<Chunk, Environment> {
private static final ChunkType1_9_3 WITH_SKYLIGHT = new ChunkType1_9_3(new ClientWorld(Environment.NORMAL)); private static final ChunkType1_9_3 WITH_SKYLIGHT = new ChunkType1_9_3(Environment.NORMAL);
private static final ChunkType1_9_3 WITHOUT_SKYLIGHT = new ChunkType1_9_3(new ClientWorld(Environment.NETHER)); private static final ChunkType1_9_3 WITHOUT_SKYLIGHT = new ChunkType1_9_3(Environment.NETHER);
public ChunkType1_9_3(ClientWorld clientWorld) { public ChunkType1_9_3(Environment environment) {
super(clientWorld, Chunk.class); super(environment, Chunk.class);
} }
public static ChunkType1_9_3 forEnvironment(Environment environment) { public static ChunkType1_9_3 forEnvironment(Environment environment) {
@ -51,7 +50,7 @@ public class ChunkType1_9_3 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public Chunk read(ByteBuf input, ClientWorld world) throws Exception { public Chunk read(ByteBuf input, Environment environment) throws Exception {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
@ -67,7 +66,7 @@ public class ChunkType1_9_3 extends PartialType<Chunk, ClientWorld> {
ChunkSection section = Types1_9.CHUNK_SECTION.read(input); ChunkSection section = Types1_9.CHUNK_SECTION.read(input);
sections[i] = section; sections[i] = section;
section.getLight().readBlockLight(input); section.getLight().readBlockLight(input);
if (world.getEnvironment() == Environment.NORMAL) { if (environment == Environment.NORMAL) {
section.getLight().readSkyLight(input); section.getLight().readSkyLight(input);
} }
} }
@ -93,7 +92,7 @@ public class ChunkType1_9_3 extends PartialType<Chunk, ClientWorld> {
} }
@Override @Override
public void write(ByteBuf output, ClientWorld world, Chunk chunk) throws Exception { public void write(ByteBuf output, Environment environment, Chunk chunk) throws Exception {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());