Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 00:22:51 +01:00
Transform block 36 for 1.9.2 reading, and also use PartialType.
Dieser Commit ist enthalten in:
Ursprung
b50d0075ca
Commit
b48fc17ead
@ -4,25 +4,29 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import org.bukkit.World;
|
||||
import org.spacehq.opennbt.tag.builtin.CompoundTag;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.type.PartialType;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.minecraft.BaseChunkType;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.BitSet;
|
||||
|
||||
public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
private final ClientWorld clientWorld;
|
||||
public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
|
||||
|
||||
public Chunk1_9_1_2Type(ClientWorld clientWorld) {
|
||||
super("1.9.1/2 Chunk");
|
||||
this.clientWorld = clientWorld;
|
||||
super(clientWorld, Chunk.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Chunk read(ByteBuf input) throws Exception {
|
||||
public Chunk read(ByteBuf input, ClientWorld world) throws Exception {
|
||||
boolean replacePistons = world.getUser().get(ProtocolInfo.class).getPipeline().contains(Protocol1_10To1_9_3_4.class) && ViaVersion.getConfig().isReplacePistons();
|
||||
int replacementId = ViaVersion.getConfig().getPistonReplacementId();
|
||||
|
||||
int chunkX = input.readInt();
|
||||
int chunkZ = input.readInt();
|
||||
|
||||
@ -46,9 +50,14 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
sections[i] = section;
|
||||
section.readBlocks(input);
|
||||
section.readBlockLight(input);
|
||||
if(clientWorld.getEnvironment() == World.Environment.NORMAL) {
|
||||
if (world.getEnvironment() == World.Environment.NORMAL) {
|
||||
section.readSkyLight(input);
|
||||
}
|
||||
if (replacePistons) {
|
||||
if (section.getPalette().contains(36)) {
|
||||
section.getPalette().set(section.getPalette().indexOf(36), replacementId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
byte[] biomeData = groundUp ? new byte[256] : null;
|
||||
@ -60,7 +69,7 @@ public class Chunk1_9_1_2Type extends BaseChunkType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ByteBuf output, Chunk input) throws Exception {
|
||||
public void write(ByteBuf output, ClientWorld world, Chunk input) throws Exception {
|
||||
Chunk chunk = input;
|
||||
|
||||
output.writeInt(chunk.getX());
|
||||
|
@ -3,6 +3,7 @@ package us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import lombok.Getter;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.ChunkSection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.NibbleArray;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
@ -21,7 +22,7 @@ public class ChunkSection1_9_1_2 implements ChunkSection {
|
||||
/**
|
||||
* Length of the block data array.
|
||||
*/
|
||||
|
||||
@Getter
|
||||
private final List<Integer> palette = Lists.newArrayList();
|
||||
private final int[] blocks;
|
||||
private final NibbleArray blockLight;
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren