Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-11-20 06:50:10 +01:00
Merge branch 'master' into dev
Dieser Commit ist enthalten in:
Commit
45cece245c
@ -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)) {
|
||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||
CompoundTag tag = null;
|
||||
if (tags.containsKey(pos)) {
|
||||
tag = tags.get(pos);
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
if (!hasBlockEntityHandler(btype)) continue;
|
||||
|
||||
Pos pos = new Pos(x, (y + (i << 4)), z);
|
||||
|
||||
// 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)));
|
||||
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);
|
||||
|
||||
|
@ -47,10 +47,10 @@ public class BlockItemPackets1_13 extends BlockItemRewriter<Protocol1_12_2To1_13
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int p = 0; p < section.getPalette().size(); p++) {
|
||||
int old = section.getPalette().get(p);
|
||||
for (int p = 0; p < section.getPaletteSize(); p++) {
|
||||
int old = section.getPaletteEntry(p);
|
||||
if (old != 0) {
|
||||
section.getPalette().set(p, toNewId(old));
|
||||
section.setPaletteEntry(p, toNewId(old));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,13 @@ import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.BlockColors;
|
||||
import nl.matsv.viabackwards.protocol.protocol1_12to1_11_1.data.MapColorMapping;
|
||||
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;
|
||||
@ -209,7 +209,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);
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ public class WorldPackets {
|
||||
|
||||
for (ChunkSection section : chunk.getSections()) {
|
||||
if (section != null) {
|
||||
for (int i = 0; i < section.getPalette().size(); i++) {
|
||||
section.getPalette().set(
|
||||
for (int i = 0; i < section.getPaletteSize(); i++) {
|
||||
section.setPaletteEntry(
|
||||
i,
|
||||
Protocol1_13To1_13_1.getNewBlockStateId(section.getPalette().get(i))
|
||||
Protocol1_13To1_13_1.getNewBlockStateId(section.getPaletteEntry(i))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -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.6.0</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren