mirror of
https://github.com/ViaVersion/ViaBackwards.git
synced 2024-11-19 11:45:17 +01:00
21w37a works™️
Co-authored-by: Gerrygames <gecam59@gmail.com>
This commit is contained in:
parent
87ad6bd2b1
commit
deb11bf1a9
@ -28,6 +28,7 @@ import com.viaversion.viaversion.api.minecraft.entities.Entity1_17Types;
|
|||||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.ServerboundPackets1_17;
|
||||||
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.Protocol1_18To1_17_1;
|
||||||
import com.viaversion.viaversion.rewriter.TagRewriter;
|
import com.viaversion.viaversion.rewriter.TagRewriter;
|
||||||
|
|
||||||
public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_17_1, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> {
|
public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPackets1_17_1, ClientboundPackets1_17_1, ServerboundPackets1_17, ServerboundPackets1_17> {
|
||||||
@ -42,6 +43,8 @@ public final class Protocol1_17_1To1_18 extends BackwardsProtocol<ClientboundPac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
|
executeAsyncAfterLoaded(Protocol1_18To1_17_1.class, MAPPINGS::load);
|
||||||
|
|
||||||
entityRewriter.register();
|
entityRewriter.register();
|
||||||
itemRewriter.register();
|
itemRewriter.register();
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag;
|
|||||||
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
import com.viaversion.viaversion.protocols.protocol1_17_1to1_17.ClientboundPackets1_17_1;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
|
||||||
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
import com.viaversion.viaversion.protocols.protocol1_18to1_17_1.types.Chunk1_18Type;
|
||||||
|
import com.viaversion.viaversion.util.MathUtil;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.BitSet;
|
import java.util.BitSet;
|
||||||
@ -104,7 +105,10 @@ public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_1
|
|||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
final EntityTracker tracker = protocol.getEntityRewriter().tracker(wrapper.user());
|
||||||
final Chunk oldChunk = wrapper.read(new Chunk1_18Type(tracker.currentWorldSectionHeight()));
|
final Chunk1_18Type chunkType = new Chunk1_18Type(tracker.currentWorldSectionHeight(),
|
||||||
|
MathUtil.ceilLog2(protocol.getMappingData().getBlockStateMappings().size()),
|
||||||
|
MathUtil.ceilLog2(tracker.biomesSent()));
|
||||||
|
final Chunk oldChunk = wrapper.read(chunkType);
|
||||||
final int[] biomeData = new int[oldChunk.getSections().length * 64];
|
final int[] biomeData = new int[oldChunk.getSections().length * 64];
|
||||||
final ChunkSection[] sections = oldChunk.getSections();
|
final ChunkSection[] sections = oldChunk.getSections();
|
||||||
for (int i = 0; i < sections.length; i++) {
|
for (int i = 0; i < sections.length; i++) {
|
||||||
@ -127,7 +131,7 @@ public final class BlockItemPackets1_18 extends ItemRewriter<Protocol1_17_1To1_1
|
|||||||
|
|
||||||
final List<CompoundTag> blockEntityTags = new ArrayList<>(oldChunk.blockEntities().size());
|
final List<CompoundTag> blockEntityTags = new ArrayList<>(oldChunk.blockEntities().size());
|
||||||
for (final BlockEntity blockEntity : oldChunk.blockEntities()) {
|
for (final BlockEntity blockEntity : oldChunk.blockEntities()) {
|
||||||
final CompoundTag tag = blockEntity.tag();
|
final CompoundTag tag = blockEntity.tag() != null ? blockEntity.tag() : new CompoundTag();
|
||||||
final String id = protocol.getMappingData().blockEntities().get(blockEntity.typeId());
|
final String id = protocol.getMappingData().blockEntities().get(blockEntity.typeId());
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
// Shrug
|
// Shrug
|
||||||
|
@ -77,6 +77,9 @@ public final class EntityPackets1_18 extends EntityRewriter<Protocol1_17_1To1_18
|
|||||||
biomeCompound.put("depth", new FloatTag(0.125F));
|
biomeCompound.put("depth", new FloatTag(0.125F));
|
||||||
biomeCompound.put("scale", new FloatTag(0.05F));
|
biomeCompound.put("scale", new FloatTag(0.05F));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Track amount of biomes sent
|
||||||
|
tracker(wrapper.user()).setBiomesSent(biomes.size());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user