Mirror von
https://github.com/ViaVersion/ViaBackwards.git
synchronisiert 2024-12-24 23:30:17 +01:00
Cancel null block entity nbt updates
Dieser Commit ist enthalten in:
Ursprung
04a970ef08
Commit
067c93a63a
@ -21,14 +21,12 @@ import com.viaversion.viabackwards.api.rewriters.TranslatableRewriter;
|
||||
import com.viaversion.viabackwards.protocol.protocol1_16_1to1_16_2.Protocol1_16_1To1_16_2;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockChangeRecord1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.Chunk;
|
||||
import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketRemapper;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntArrayTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.IntTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
||||
import com.viaversion.viaversion.libs.opennbt.tag.builtin.Tag;
|
||||
@ -98,13 +96,8 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
}
|
||||
|
||||
for (CompoundTag blockEntity : chunk.getBlockEntities()) {
|
||||
if (blockEntity == null) continue;
|
||||
|
||||
IntTag x = blockEntity.get("x");
|
||||
IntTag y = blockEntity.get("y");
|
||||
IntTag z = blockEntity.get("z");
|
||||
if (x != null && y != null && z != null) {
|
||||
handleBlockEntity(blockEntity, new Position(x.asInt(), y.asShort(), z.asInt()));
|
||||
if (blockEntity != null) {
|
||||
handleBlockEntity(blockEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -114,10 +107,10 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
protocol.registerClientbound(ClientboundPackets1_16_2.BLOCK_ENTITY_DATA, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION1_14);
|
||||
map(Type.UNSIGNED_BYTE);
|
||||
handler(wrapper -> {
|
||||
Position position = wrapper.passthrough(Type.POSITION1_14);
|
||||
wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
handleBlockEntity(wrapper.passthrough(Type.NBT), position);
|
||||
handleBlockEntity(wrapper.passthrough(Type.NBT));
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -161,7 +154,7 @@ public class BlockItemPackets1_16_2 extends com.viaversion.viabackwards.api.rewr
|
||||
});
|
||||
}
|
||||
|
||||
private void handleBlockEntity(CompoundTag tag, Position position) {
|
||||
private void handleBlockEntity(CompoundTag tag) {
|
||||
StringTag idTag = tag.get("id");
|
||||
if (idTag == null) return;
|
||||
if (idTag.getValue().equals("minecraft:skull")) {
|
||||
|
@ -89,6 +89,13 @@ public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_1
|
||||
map(Type.POSITION1_14);
|
||||
handler(wrapper -> {
|
||||
final int id = wrapper.read(Type.VAR_INT);
|
||||
final CompoundTag tag = wrapper.read(Type.NBT);
|
||||
if (tag == null) {
|
||||
// Cancel nbt-less updates (screw open commandblocks)
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
final int mappedId = BlockEntityIds.mappedId(id);
|
||||
if (mappedId == -1) {
|
||||
wrapper.cancel();
|
||||
@ -131,13 +138,13 @@ public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_1
|
||||
|
||||
final List<CompoundTag> blockEntityTags = new ArrayList<>(oldChunk.blockEntities().size());
|
||||
for (final BlockEntity blockEntity : oldChunk.blockEntities()) {
|
||||
final CompoundTag tag = blockEntity.tag() != null ? blockEntity.tag() : new CompoundTag();
|
||||
final String id = protocol.getMappingData().blockEntities().get(blockEntity.typeId());
|
||||
if (id == null) {
|
||||
// Shrug
|
||||
continue;
|
||||
}
|
||||
|
||||
final CompoundTag tag = blockEntity.tag() != null ? blockEntity.tag() : new CompoundTag();
|
||||
blockEntityTags.add(tag);
|
||||
tag.put("x", new IntTag((oldChunk.getX() << 4) + blockEntity.sectionX()));
|
||||
tag.put("y", new IntTag(blockEntity.y()));
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren