Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-27 00:22:53 +01:00
ViaVersion 2.0.0 compatibility
Dieser Commit ist enthalten in:
Ursprung
d484545bef
Commit
7296017ab8
@ -138,10 +138,18 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
if (!(tag.contains("x") && tag.contains("y") && tag.contains("z")))
|
||||
continue;
|
||||
Pos pos = new Pos(
|
||||
(int) tag.get("x").getValue() % 16,
|
||||
(int) tag.get("x").getValue() & 0xF,
|
||||
(int) tag.get("y").getValue(),
|
||||
(int) tag.get("z").getValue() % 16);
|
||||
(int) tag.get("z").getValue() & 0xF);
|
||||
tags.put(pos, tag);
|
||||
|
||||
// Handle given Block Entities
|
||||
ChunkSection section = chunk.getSections()[pos.getY() >> 4];
|
||||
if (section == null) continue;
|
||||
int block = section.getFlatBlock(pos.getX(), pos.getY() & 0xF, pos.getZ());
|
||||
int btype = block >> 4;
|
||||
if (!hasBlockEntityHandler(btype)) continue;
|
||||
replacementData.get(btype).getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
}
|
||||
|
||||
for (int i = 0; i < chunk.getSections().length; i++) {
|
||||
@ -149,32 +157,45 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
|
||||
if (section == null)
|
||||
continue;
|
||||
|
||||
boolean hasBlockEntityHandler = false;
|
||||
|
||||
// Map blocks
|
||||
for (int j = 0; j < section.getPaletteSize(); j++) {
|
||||
int block = section.getPaletteEntry(j);
|
||||
int btype = block >> 4;
|
||||
int meta = block & 0xF;
|
||||
|
||||
if (containsBlock(btype)) {
|
||||
Block b = handleBlock(btype, meta);
|
||||
section.setPaletteEntry(j, (b.getId() << 4) | (b.getData() & 0xF));
|
||||
}
|
||||
|
||||
hasBlockEntityHandler = hasBlockEntityHandler || hasBlockEntityHandler(btype);
|
||||
}
|
||||
|
||||
if (!hasBlockEntityHandler) continue;
|
||||
|
||||
// We need to handle a Block Entity :(
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int block = section.getBlock(x, y, z);
|
||||
int block = section.getFlatBlock(x, y, z);
|
||||
int btype = block >> 4;
|
||||
int meta = block & 15;
|
||||
|
||||
if (containsBlock(btype)) {
|
||||
Block b = handleBlock(btype, meta); // Type / data
|
||||
section.setBlock(x, y, z, b.getId(), b.getData());
|
||||
}
|
||||
// Entity Tags
|
||||
if (hasBlockEntityHandler(btype)) {
|
||||
if (!hasBlockEntityHandler(btype)) continue;
|
||||
|
||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||
CompoundTag tag = null;
|
||||
if (tags.containsKey(pos)) {
|
||||
tag = tags.get(pos);
|
||||
} else {
|
||||
tag = new CompoundTag("");
|
||||
|
||||
// Already handled above
|
||||
if (tags.containsKey(pos)) continue;
|
||||
|
||||
CompoundTag tag = new CompoundTag("");
|
||||
tag.put(new IntTag("x", x + (chunk.getX() << 4)));
|
||||
tag.put(new IntTag("y", y + (i << 4)));
|
||||
tag.put(new IntTag("z", z + (chunk.getZ() << 4)));
|
||||
chunk.getBlockEntities().add(tag);
|
||||
}
|
||||
replacementData.get(btype).getBlockEntityHandler().handleOrNewCompoundTag(block, tag);
|
||||
}
|
||||
chunk.getBlockEntities().add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,13 @@ import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@ -226,7 +226,7 @@ public class BlockItemPackets1_11 extends BlockItemRewriter<Protocol1_10To1_11>
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.10 Chunk type since nothing changed.
|
||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
|
||||
|
@ -15,13 +15,13 @@ import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.Protocol1_11_1To1_12;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
@ -171,7 +171,7 @@ public class BlockItemPackets1_12 extends BlockItemRewriter<Protocol1_11_1To1_12
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld); // Use the 1.9.4 Chunk type since nothing changed.
|
||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_9_4to1_10.Protocol1_9_4To1_10;
|
||||
import nl.matsv.viabackwards.utils.Block;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.minecraft.chunks.Chunk;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.remapper.PacketHandler;
|
||||
import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.packets.State;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.chunks.Chunk1_9_3_4;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.types.Chunk1_9_3_4Type;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
|
||||
@ -166,7 +166,7 @@ public class BlockItemPackets1_10 extends BlockItemRewriter<Protocol1_9_4To1_10>
|
||||
ClientWorld clientWorld = wrapper.user().get(ClientWorld.class);
|
||||
|
||||
Chunk1_9_3_4Type type = new Chunk1_9_3_4Type(clientWorld);
|
||||
Chunk1_9_3_4 chunk = (Chunk1_9_3_4) wrapper.passthrough(type);
|
||||
Chunk chunk = wrapper.passthrough(type);
|
||||
|
||||
handleChunk(chunk);
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -65,7 +65,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>1.4.1</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren