Merge remote-tracking branch 'origin/1.16' into 1.18
This commit is contained in:
commit
a1f867c26d
|
|
@ -1,15 +1,12 @@
|
||||||
package org.embeddedt.modernfix.forge.mixin.bugfix.recipe_book_type_desync;
|
package org.embeddedt.modernfix.forge.mixin.bugfix.recipe_book_type_desync;
|
||||||
|
|
||||||
import com.llamalad7.mixinextras.sugar.Local;
|
import com.llamalad7.mixinextras.sugar.Local;
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.multiplayer.ClientPacketListener;
|
|
||||||
import net.minecraft.network.Connection;
|
|
||||||
import net.minecraft.network.FriendlyByteBuf;
|
import net.minecraft.network.FriendlyByteBuf;
|
||||||
import net.minecraft.stats.RecipeBookSettings;
|
import net.minecraft.stats.RecipeBookSettings;
|
||||||
import net.minecraft.world.inventory.RecipeBookType;
|
import net.minecraft.world.inventory.RecipeBookType;
|
||||||
import net.minecraftforge.fml.network.NetworkHooks;
|
|
||||||
import org.embeddedt.modernfix.ModernFix;
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||||
|
import org.embeddedt.modernfix.forge.packet.NetworkUtils;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.injection.At;
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||||
|
|
@ -41,15 +38,9 @@ public class RecipeBookSettingsMixin {
|
||||||
}
|
}
|
||||||
@Redirect(method = "read(Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/stats/RecipeBookSettings;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;readBoolean()Z"))
|
@Redirect(method = "read(Lnet/minecraft/network/FriendlyByteBuf;)Lnet/minecraft/stats/RecipeBookSettings;", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/FriendlyByteBuf;readBoolean()Z"))
|
||||||
private static boolean useDefaultBooleanIfVanilla(FriendlyByteBuf buf, @Local(ordinal = 0) RecipeBookType type) {
|
private static boolean useDefaultBooleanIfVanilla(FriendlyByteBuf buf, @Local(ordinal = 0) RecipeBookType type) {
|
||||||
if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1)) {
|
if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1) && NetworkUtils.isCurrentlyVanilla) {
|
||||||
ClientPacketListener listener = Minecraft.getInstance().getConnection();
|
ModernFix.LOGGER.warn("Not reading recipe book data for type '{}' as we are using vanilla connection", type.name());
|
||||||
if(listener != null) {
|
return false; // skip actually reading buffer
|
||||||
Connection connection = listener.getConnection();
|
|
||||||
if(NetworkHooks.isVanillaConnection(connection)) {
|
|
||||||
ModernFix.LOGGER.warn("Not reading recipe book data for type '{}' as we are using vanilla connection", type.name());
|
|
||||||
return false; // skip actually reading buffer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return buf.readBoolean();
|
return buf.readBoolean();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package org.embeddedt.modernfix.forge.mixin.core;
|
||||||
|
|
||||||
|
import net.minecraft.network.Connection;
|
||||||
|
import net.minecraftforge.fml.network.NetworkHooks;
|
||||||
|
import org.embeddedt.modernfix.forge.packet.NetworkUtils;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(NetworkHooks.class)
|
||||||
|
public abstract class NetworkHooksMixin {
|
||||||
|
@Shadow public static boolean isVanillaConnection(Connection manager) {
|
||||||
|
throw new AssertionError();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "handleClientLoginSuccess", at = @At("RETURN"))
|
||||||
|
private static void setVanillaGlobalFlag(Connection manager, CallbackInfo ci) {
|
||||||
|
NetworkUtils.isCurrentlyVanilla = isVanillaConnection(manager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
package org.embeddedt.modernfix.forge.packet;
|
||||||
|
|
||||||
|
public class NetworkUtils {
|
||||||
|
public static boolean isCurrentlyVanilla;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user