Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Fix warning message for unsupported experimental data. Closes #105
Browse files Browse the repository at this point in the history
  • Loading branch information
Earthcomputer committed Oct 11, 2020
1 parent ddf7e06 commit 4e49016
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/net/earthcomputer/multiconnect/impl/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.entity.data.TrackedDataHandler;
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
import net.minecraft.item.Item;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtOps;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.Packet;
import net.minecraft.tag.Tag;
import net.minecraft.text.TranslatableText;
Expand Down Expand Up @@ -207,9 +207,9 @@ public static <T> void translateDynamicRegistries(TransformerByteBuf buf, Codec<
return;
}
if (!allowablePredicate.test(oldRegistries)) {
ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
if (networkHandler != null) {
networkHandler.getConnection().disconnect(new TranslatableText("multiconnect.unsupportedExperimentalCodec"));
ClientConnection connection = buf.getConnection();
if (connection != null) {
connection.disconnect(new TranslatableText("multiconnect.unsupportedExperimentalCodec"));
}
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public final class TransformerByteBuf extends PacketByteBuf {
private final TranslatorRegistry translatorRegistry;

private boolean transformationEnabled = false;
private Deque<StackFrame> stack = new ArrayDeque<>();
private final Deque<StackFrame> stack = new ArrayDeque<>();
private boolean forceSuper = false;

public TransformerByteBuf(ByteBuf delegate, ChannelHandlerContext context) {
Expand All @@ -50,6 +50,10 @@ public TransformerByteBuf(ByteBuf delegate, ChannelHandlerContext context, Trans
this.translatorRegistry = translatorRegistry;
}

public ClientConnection getConnection() {
return context.channel().pipeline().get(ClientConnection.class);
}

@SuppressWarnings("unchecked")
public TransformerByteBuf readTopLevelType(Class<?> type) {
transformationEnabled = true;
Expand Down

0 comments on commit 4e49016

Please sign in to comment.