mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-12-22 16:57:40 +01:00
Update VV usage
This commit is contained in:
parent
7f85d074af
commit
8a9d4bd971
@ -177,7 +177,7 @@ public class BlockItemPackets1_11 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
@ -153,7 +153,7 @@ public class BlockItemPackets1_12 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_12.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment()); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
@ -258,8 +258,8 @@ public class BlockItemPackets1_13 extends com.viaversion.viabackwards.api.rewrit
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType1_9_3 type_old = new ChunkType1_9_3(clientWorld);
|
||||
ChunkType1_13 type = new ChunkType1_13(clientWorld);
|
||||
ChunkType1_9_3 type_old = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment());
|
||||
ChunkType1_13 type = ChunkType1_13.forEnvironment(clientWorld.getEnvironment());
|
||||
Chunk chunk = wrapper.read(type);
|
||||
|
||||
// Handle Block Entities before block rewrite
|
||||
|
@ -170,10 +170,10 @@ public class Protocol1_13_2To1_14 extends BackwardsProtocol<ClientboundPackets1_
|
||||
user.addEntityTracker(this.getClass(), new EntityTrackerBase(user, EntityTypes1_14.PLAYER));
|
||||
|
||||
if (!user.has(ChunkLightStorage.class)) {
|
||||
user.put(new ChunkLightStorage(user));
|
||||
user.put(new ChunkLightStorage());
|
||||
}
|
||||
|
||||
user.put(new DifficultyStorage(user));
|
||||
user.put(new DifficultyStorage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -366,8 +366,8 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_14.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.read(new ChunkType1_14());
|
||||
wrapper.write(new ChunkType1_13(clientWorld), chunk);
|
||||
Chunk chunk = wrapper.read(ChunkType1_14.TYPE);
|
||||
wrapper.write(ChunkType1_13.forEnvironment(clientWorld.getEnvironment()), chunk);
|
||||
|
||||
ChunkLightStorage.ChunkLight chunkLight = wrapper.user().get(ChunkLightStorage.class).getStoredLight(chunk.getX(), chunk.getZ());
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
@ -382,10 +382,10 @@ public class BlockItemPackets1_14 extends com.viaversion.viabackwards.api.rewrit
|
||||
sectionLight.setSkyLight(ChunkLightStorage.FULL_LIGHT);
|
||||
}
|
||||
} else {
|
||||
byte[] blockLight = chunkLight.getBlockLight()[i];
|
||||
byte[] blockLight = chunkLight.blockLight()[i];
|
||||
sectionLight.setBlockLight(blockLight != null ? blockLight : ChunkLightStorage.FULL_LIGHT);
|
||||
if (clientWorld.getEnvironment() == Environment.NORMAL) {
|
||||
byte[] skyLight = chunkLight.getSkyLight()[i];
|
||||
byte[] skyLight = chunkLight.skyLight()[i];
|
||||
sectionLight.setSkyLight(skyLight != null ? skyLight : ChunkLightStorage.FULL_LIGHT);
|
||||
}
|
||||
}
|
||||
|
@ -17,15 +17,14 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChunkLightStorage extends StoredObject {
|
||||
public class ChunkLightStorage implements StorableObject {
|
||||
public static final byte[] FULL_LIGHT = new byte[2048];
|
||||
public static final byte[] EMPTY_LIGHT = new byte[2048];
|
||||
private static Constructor<?> fastUtilLongObjectHashMap;
|
||||
@ -41,10 +40,6 @@ public class ChunkLightStorage extends StoredObject {
|
||||
}
|
||||
}
|
||||
|
||||
public ChunkLightStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public void setStoredLight(byte[][] skyLight, byte[][] blockLight, int x, int z) {
|
||||
storedLight.put(getChunkSectionIndex(x, z), new ChunkLight(skyLight, blockLight));
|
||||
}
|
||||
@ -85,11 +80,11 @@ public class ChunkLightStorage extends StoredObject {
|
||||
this.blockLight = blockLight;
|
||||
}
|
||||
|
||||
public byte[][] getSkyLight() {
|
||||
public byte[][] skyLight() {
|
||||
return skyLight;
|
||||
}
|
||||
|
||||
public byte[][] getBlockLight() {
|
||||
public byte[][] blockLight() {
|
||||
return blockLight;
|
||||
}
|
||||
}
|
||||
|
@ -17,16 +17,11 @@
|
||||
*/
|
||||
package com.viaversion.viabackwards.protocol.protocol1_13_2to1_14.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.StoredObject;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
|
||||
public class DifficultyStorage extends StoredObject {
|
||||
public class DifficultyStorage implements StorableObject {
|
||||
private byte difficulty;
|
||||
|
||||
public DifficultyStorage(UserConnection user) {
|
||||
super(user);
|
||||
}
|
||||
|
||||
public byte getDifficulty() {
|
||||
return difficulty;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class WorldPackets1_13_1 {
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_13.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
Chunk chunk = wrapper.passthrough(new ChunkType1_13(clientWorld));
|
||||
Chunk chunk = wrapper.passthrough(ChunkType1_13.forEnvironment(clientWorld.getEnvironment()));
|
||||
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section == null) {
|
||||
|
@ -61,8 +61,8 @@ public class BlockItemPackets1_15 extends com.viaversion.viabackwards.api.rewrit
|
||||
blockRewriter.registerMultiBlockChange(ClientboundPackets1_15.MULTI_BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_15.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new ChunkType1_15());
|
||||
wrapper.write(new ChunkType1_14(), chunk);
|
||||
Chunk chunk = wrapper.read(ChunkType1_15.TYPE);
|
||||
wrapper.write(ChunkType1_14.TYPE, chunk);
|
||||
|
||||
if (chunk.isFullChunk()) {
|
||||
int[] biomeData = chunk.getBiomeData();
|
||||
|
@ -142,8 +142,8 @@ public class BlockItemPackets1_16 extends com.viaversion.viabackwards.api.rewrit
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new ChunkType1_16());
|
||||
wrapper.write(new ChunkType1_15(), chunk);
|
||||
Chunk chunk = wrapper.read(ChunkType1_16.TYPE);
|
||||
wrapper.write(ChunkType1_15.TYPE, chunk);
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
ChunkSection section = chunk.getSections()[i];
|
||||
|
@ -75,8 +75,8 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
blockRewriter.registerBlockChange(ClientboundPackets1_16_2.BLOCK_CHANGE);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.CHUNK_DATA, wrapper -> {
|
||||
Chunk chunk = wrapper.read(new ChunkType1_16_2());
|
||||
wrapper.write(new ChunkType1_16(), chunk);
|
||||
Chunk chunk = wrapper.read(ChunkType1_16_2.TYPE);
|
||||
wrapper.write(ChunkType1_16.TYPE, chunk);
|
||||
|
||||
chunk.setIgnoreOldLightData(true);
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
|
@ -325,7 +325,7 @@ public final class BlockItemPackets1_17 extends ItemRewriter<ClientboundPackets1
|
||||
int currentWorldSectionHeight = tracker.currentWorldSectionHeight();
|
||||
|
||||
Chunk chunk = wrapper.read(new ChunkType1_17(currentWorldSectionHeight));
|
||||
wrapper.write(new ChunkType1_16_2(), chunk);
|
||||
wrapper.write(ChunkType1_16_2.TYPE, chunk);
|
||||
|
||||
// Cut sections
|
||||
int startFromSection = Math.max(0, -(tracker.currentMinY() >> 4));
|
||||
|
@ -72,8 +72,8 @@ public class Protocol1_9_1_2To1_9_3_4 extends AbstractProtocol<ClientboundPacket
|
||||
registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType1_9_3 newType = new ChunkType1_9_3(clientWorld);
|
||||
ChunkType1_9_1 oldType = new ChunkType1_9_1(clientWorld); // Get the old type to not write Block Entities
|
||||
ChunkType1_9_3 newType = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment());
|
||||
ChunkType1_9_1 oldType = ChunkType1_9_1.forEnvironment(clientWorld.getEnvironment()); // Get the old type to not write Block Entities
|
||||
|
||||
Chunk chunk = wrapper.read(newType);
|
||||
wrapper.write(oldType, chunk);
|
||||
|
@ -78,7 +78,7 @@ public class BlockItemPackets1_10 extends LegacyBlockItemRewriter<ClientboundPac
|
||||
protocol.registerClientbound(ClientboundPackets1_9_3.CHUNK_DATA, wrapper -> {
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
ChunkType1_9_3 type = new ChunkType1_9_3(clientWorld);
|
||||
ChunkType1_9_3 type = ChunkType1_9_3.forEnvironment(clientWorld.getEnvironment());
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
Loading…
Reference in New Issue
Block a user