|
1 | 1 | package org.embeddedt.modernfix.forge.mixin.bugfix.recipe_book_type_desync; |
2 | 2 |
|
3 | 3 | import com.llamalad7.mixinextras.sugar.Local; |
4 | | -import net.minecraft.client.Minecraft; |
5 | | -import net.minecraft.client.multiplayer.ClientPacketListener; |
6 | | -import net.minecraft.network.Connection; |
7 | 4 | import net.minecraft.network.FriendlyByteBuf; |
8 | 5 | import net.minecraft.stats.RecipeBookSettings; |
9 | 6 | import net.minecraft.world.inventory.RecipeBookType; |
10 | | -import net.minecraftforge.fml.network.NetworkHooks; |
11 | 7 | import org.embeddedt.modernfix.ModernFix; |
12 | 8 | import org.embeddedt.modernfix.annotation.ClientOnlyMixin; |
| 9 | +import org.embeddedt.modernfix.forge.packet.NetworkUtils; |
13 | 10 | import org.spongepowered.asm.mixin.Mixin; |
14 | 11 | import org.spongepowered.asm.mixin.injection.At; |
15 | 12 | import org.spongepowered.asm.mixin.injection.Redirect; |
@@ -41,15 +38,9 @@ public class RecipeBookSettingsMixin { |
41 | 38 | } |
42 | 39 | @Redirect(method = "read(Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/stats/RecipeBookSettings;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;readBoolean()Z")) |
43 | 40 | private static boolean useDefaultBooleanIfVanilla(FriendlyByteBuf buf, @Local(ordinal = 0) RecipeBookType type) { |
44 | | - if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1)) { |
45 | | - ClientPacketListener listener = Minecraft.getInstance().getConnection(); |
46 | | - if(listener != null) { |
47 | | - Connection connection = listener.getConnection(); |
48 | | - if(NetworkHooks.isVanillaConnection(connection)) { |
49 | | - ModernFix.LOGGER.warn("Not reading recipe book data for type '{}' as we are using vanilla connection", type.name()); |
50 | | - return false; // skip actually reading buffer |
51 | | - } |
52 | | - } |
| 41 | + if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1) && NetworkUtils.isCurrentlyVanilla) { |
| 42 | + ModernFix.LOGGER.warn("Not reading recipe book data for type '{}' as we are using vanilla connection", type.name()); |
| 43 | + return false; // skip actually reading buffer |
53 | 44 | } |
54 | 45 | return buf.readBoolean(); |
55 | 46 | } |
|
0 commit comments