Skip to content

Commit

Permalink
Updated Via API usage
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Oct 19, 2023
1 parent 9aaae4c commit 9fcc8a1
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ raknet_transport_version=1.0.0.CR1-SNAPSHOT
classic4j_version=2.0.1

# viaversion (and required) libs
viaversion_version=4.9.0-23w41a-SNAPSHOT
viabackwards_version=4.9.0-23w41a-SNAPSHOT
viaversion_version=4.9.0-23w42a-SNAPSHOT
viabackwards_version=4.9.0-23w42a-SNAPSHOT

vialoader_version=2.2.11-SNAPSHOT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_17;
import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag;
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.Tag;
import com.viaversion.viaversion.protocols.protocol1_17to1_16_4.types.Chunk1_17Type;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.raphimc.vialoader.util.VersionEnum;
import net.raphimc.vialegacy.protocols.classic.protocola1_0_15toc0_28_30.model.ClassicLevel;
Expand Down Expand Up @@ -73,8 +73,8 @@ public static PacketHandler handleChunkData(final PacketHandler parentHandler) {

if (ProtocolHack.getTargetVersion(wrapper.user().getChannel()).isOlderThanOrEqualTo(VersionEnum.c0_28toc0_30)) {
wrapper.resetReader();
final Chunk chunk = wrapper.read(new Chunk1_17Type(16));
wrapper.write(new Chunk1_17Type(chunk.getSections().length), chunk);
final Chunk chunk = wrapper.read(new ChunkType1_17(16));
wrapper.write(new ChunkType1_17(chunk.getSections().length), chunk);

final ClassicWorldHeightProvider heightProvider = Via.getManager().getProviders().get(ClassicWorldHeightProvider.class);
if (chunk.getSections().length < heightProvider.getMaxChunkSectionCount(wrapper.user())) { // Increase available sections to match new world height
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Fixes https://github.com/ViaVersion/ViaFabricPlus/issues/209
*/
@Pseudo
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor")
@Mixin(targets = "org.anti_ad.mc.ipnext.event.AutoRefillHandler$ItemSlotMonitor", remap = false)
public class MixinAutoRefillHandler_ItemSlotMonitor {

@Shadow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion;

import com.viaversion.viaversion.api.type.types.minecraft.NamedCompoundTagType;
import com.viaversion.viaversion.api.type.types.misc.NamedCompoundTagType;
import com.viaversion.viaversion.libs.opennbt.tag.limiter.TagLimiter;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.viaversion.protocol1_9_1to1_9;

import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_9_1;
import com.viaversion.viaversion.protocols.protocol1_9_1to1_9.Protocol1_9_1To1_9;
import com.viaversion.viaversion.protocols.protocol1_9_1to1_9.types.Chunk1_9_1_2Type;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -34,7 +34,7 @@ public class MixinProtocol1_9_1To1_9 extends AbstractProtocol<ClientboundPackets
@Inject(method = "registerPackets", at = @At("RETURN"))
public void clearInputBuffer(CallbackInfo ci) {
registerClientbound(ClientboundPackets1_9.CHUNK_DATA, wrapper -> {
wrapper.passthrough(new Chunk1_9_1_2Type(wrapper.user().get(ClientWorld.class)));
wrapper.passthrough(new ChunkType1_9_1(wrapper.user().get(ClientWorld.class)));
wrapper.clearInputBuffer();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.minecraft.chunks.*;
import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_8;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -28,15 +28,15 @@
import java.util.ArrayList;
import java.util.logging.Level;

@Mixin(value = Chunk1_8Type.class, remap = false)
public abstract class MixinChunk1_8Type {
@Mixin(value = ChunkType1_8.class, remap = false)
public abstract class MixinChunkType1_8 {

@Shadow
public static Chunk deserialize(int chunkX, int chunkZ, boolean fullChunk, boolean skyLight, int bitmask, byte[] data) {
return null;
}

@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Lcom/viaversion/viaversion/protocols/protocol1_9_3to1_9_1_2/storage/ClientWorld;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/protocols/protocol1_9to1_8/types/Chunk1_8Type;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
@Redirect(method = "read(Lio/netty/buffer/ByteBuf;Lcom/viaversion/viaversion/api/minecraft/ClientWorld;)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;", at = @At(value = "INVOKE", target = "Lcom/viaversion/viaversion/api/type/types/chunk/ChunkType1_8;deserialize(IIZZI[B)Lcom/viaversion/viaversion/api/minecraft/chunks/Chunk;"))
private Chunk fixAegis(int chunkX, int chunkZ, boolean fullChunk, boolean skyLight, int bitmask, byte[] data) {
try {
return deserialize(chunkX, chunkZ, fullChunk, skyLight, bitmask, data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class PackFormatsMappings {
private final static Map<Integer, GameVersion> protocolMap = new HashMap<>();

public static void load() {
registerVersion(VersionEnum.r1_20_3, 19, "23w42a");
registerVersion(VersionEnum.r1_20_2, 18, "1.20.2");
registerVersion(VersionEnum.r1_20tor1_20_1, 15, "1.20.1"); // 1.20 and 1.20.1 are the same, why care...
registerVersion(VersionEnum.r1_19_4, 13, "1.19.4");
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/viafabricplus.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"fixes.viaversion.protocol1_19_3to1_19_1.MixinProtocol1_19_3To1_19_1",
"fixes.viaversion.protocol1_19to1_18_2.MixinWorldPackets",
"fixes.viaversion.protocol1_9_1to1_9.MixinProtocol1_9_1To1_9",
"fixes.viaversion.protocol1_9to1_8.MixinChunk1_8Type",
"fixes.viaversion.protocol1_9to1_8.MixinChunkType1_8",
"fixes.viaversion.protocol1_9to1_8.MixinCommandBlockProvider",
"fixes.viaversion.protocol1_9to1_8.MixinEntityPackets_6_1",
"fixes.viaversion.protocol1_9to1_8.MixinEntityTracker1_9",
Expand Down

0 comments on commit 9fcc8a1

Please sign in to comment.