Update to NeoForge 20.4.70-beta
This commit is contained in:
parent
d6fc939f41
commit
dcee8b4169
|
|
@ -2,7 +2,9 @@ package org.embeddedt.modernfix.packet;
|
|||
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
|
||||
|
|
@ -10,7 +12,8 @@ import java.lang.reflect.Field;
|
|||
import java.lang.reflect.Modifier;
|
||||
import java.util.*;
|
||||
|
||||
public class EntityIDSyncPacket {
|
||||
public class EntityIDSyncPacket implements CustomPacketPayload {
|
||||
public static final ResourceLocation ID = new ResourceLocation(ModernFix.MODID, "entity_id_sync");
|
||||
private Map<Class<? extends Entity>, List<Pair<String, Integer>>> map;
|
||||
|
||||
public EntityIDSyncPacket(Map<Class<? extends Entity>, List<Pair<String, Integer>>> map) {
|
||||
|
|
@ -21,11 +24,8 @@ public class EntityIDSyncPacket {
|
|||
return this.map;
|
||||
}
|
||||
|
||||
public EntityIDSyncPacket() {
|
||||
this.map = new HashMap<>();
|
||||
}
|
||||
|
||||
public void serialize(FriendlyByteBuf buf) {
|
||||
@Override
|
||||
public void write(FriendlyByteBuf buf) {
|
||||
buf.writeVarInt(map.keySet().size());
|
||||
for(Map.Entry<Class<? extends Entity>, List<Pair<String, Integer>>> entry : map.entrySet()) {
|
||||
buf.writeUtf(entry.getKey().getName());
|
||||
|
|
@ -38,8 +38,8 @@ public class EntityIDSyncPacket {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static EntityIDSyncPacket deserialize(FriendlyByteBuf buf) {
|
||||
EntityIDSyncPacket self = new EntityIDSyncPacket();
|
||||
public EntityIDSyncPacket(FriendlyByteBuf buf) {
|
||||
EntityIDSyncPacket self = this;
|
||||
int numEntityClasses = buf.readVarInt();
|
||||
for(int i = 0; i < numEntityClasses; i++) {
|
||||
String clzName = buf.readUtf();
|
||||
|
|
@ -73,6 +73,10 @@ public class EntityIDSyncPacket {
|
|||
ModernFix.LOGGER.error("Error deserializing packet", e);
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation id() {
|
||||
return ID;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.google.common.collect.Multimap;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.client.searchtree.SearchRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
|
@ -39,7 +40,7 @@ public interface ModernFixPlatformHooks {
|
|||
|
||||
Path getGameDirectory();
|
||||
|
||||
void sendPacket(ServerPlayer player, Object packet);
|
||||
void sendPacket(ServerPlayer player, CustomPacketPayload packet);
|
||||
|
||||
Multimap<String, String> getCustomModOptions();
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import net.fabricmc.loader.api.metadata.CustomValue;
|
|||
import net.fabricmc.loader.api.metadata.ModMetadata;
|
||||
import net.minecraft.client.searchtree.SearchRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
|
|
@ -72,7 +73,7 @@ public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
|
|||
return FabricLoader.getInstance().getGameDir();
|
||||
}
|
||||
|
||||
public void sendPacket(ServerPlayer player, Object packet) {
|
||||
public void sendPacket(ServerPlayer player, CustomPacketPayload packet) {
|
||||
//PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), packet);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ mixinextras_version=0.3.2
|
|||
mod_id=modernfix
|
||||
minecraft_version=1.20.4
|
||||
enabled_platforms=fabric,neoforge
|
||||
forge_version=20.4.22-beta
|
||||
forge_version=20.4.70-beta
|
||||
# parchment_version=2023.07.09
|
||||
refined_storage_version=4392788
|
||||
jei_version=16.0.0.28
|
||||
|
|
|
|||
|
|
@ -1,15 +1,9 @@
|
|||
package org.embeddedt.modernfix.neoforge.mixin.bugfix.recipe_book_type_desync;
|
||||
|
||||
import com.llamalad7.mixinextras.sugar.Local;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.stats.RecipeBookSettings;
|
||||
import net.minecraft.world.inventory.RecipeBookType;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.embeddedt.modernfix.neoforge.packet.NetworkUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
|
@ -36,12 +30,14 @@ public class RecipeBookSettingsMixin {
|
|||
}
|
||||
mfix$maxVanillaOrdinal = ord;
|
||||
}
|
||||
/*
|
||||
@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) {
|
||||
if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1) && NetworkUtils.isCurrentlyVanilla) {
|
||||
if(type.ordinal() >= (mfix$maxVanillaOrdinal + 1)) {
|
||||
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();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package org.embeddedt.modernfix.neoforge.mixin.core;
|
||||
|
||||
import net.minecraft.server.Bootstrap;
|
||||
import net.neoforged.neoforge.network.NetworkConstants;
|
||||
import org.embeddedt.modernfix.util.TimeFormatter;
|
||||
import org.slf4j.Logger;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
|
|
@ -25,10 +24,4 @@ public class BootstrapMixin {
|
|||
LOGGER.info("ModernFix reached bootstrap stage ({} after launch)", TimeFormatter.formatNanos(ManagementFactory.getRuntimeMXBean().getUptime() * 1000L * 1000L));
|
||||
}
|
||||
}
|
||||
|
||||
/* for https://github.com/MinecraftForge/MinecraftForge/issues/9505 */
|
||||
@Inject(method = "bootStrap", at = @At("RETURN"))
|
||||
private static void doClassloadHack(CallbackInfo ci) {
|
||||
NetworkConstants.init();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
package org.embeddedt.modernfix.neoforge.mixin.core;
|
||||
|
||||
import net.minecraft.network.Connection;
|
||||
import net.neoforged.neoforge.network.NetworkHooks;
|
||||
import org.embeddedt.modernfix.neoforge.packet.NetworkUtils;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
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 {
|
||||
@Inject(method = "handleClientLoginSuccess", at = @At("RETURN"), remap = false)
|
||||
private static void setVanillaGlobalFlag(Connection manager, CallbackInfo ci) {
|
||||
NetworkUtils.isCurrentlyVanilla = NetworkHooks.isVanillaConnection(manager);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
package org.embeddedt.modernfix.neoforge.packet;
|
||||
|
||||
public class NetworkUtils {
|
||||
public static boolean isCurrentlyVanilla;
|
||||
}
|
||||
|
|
@ -1,33 +1,24 @@
|
|||
package org.embeddedt.modernfix.neoforge.packet;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.neoforged.api.distmarker.Dist;
|
||||
import net.neoforged.fml.DistExecutor;
|
||||
import net.neoforged.neoforge.network.NetworkEvent;
|
||||
import net.neoforged.neoforge.network.NetworkRegistry;
|
||||
import net.neoforged.neoforge.network.simple.SimpleChannel;
|
||||
import net.neoforged.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.neoforged.neoforge.network.event.RegisterPayloadHandlerEvent;
|
||||
import net.neoforged.neoforge.network.handling.PlayPayloadContext;
|
||||
import net.neoforged.neoforge.network.registration.IPayloadRegistrar;
|
||||
import org.embeddedt.modernfix.ModernFix;
|
||||
import org.embeddedt.modernfix.ModernFixClient;
|
||||
import org.embeddedt.modernfix.packet.EntityIDSyncPacket;
|
||||
|
||||
public class PacketHandler {
|
||||
private static final String PROTOCOL_VERSION = "1";
|
||||
public static final SimpleChannel INSTANCE = NetworkRegistry.newSimpleChannel(
|
||||
new ResourceLocation(ModernFix.MODID, "main"),
|
||||
() -> PROTOCOL_VERSION,
|
||||
NetworkRegistry.acceptMissingOr(PROTOCOL_VERSION),
|
||||
NetworkRegistry.acceptMissingOr(PROTOCOL_VERSION)
|
||||
);
|
||||
private static void registerPackets(final RegisterPayloadHandlerEvent event) {
|
||||
final IPayloadRegistrar registrar = event.registrar(ModernFix.MODID).optional();
|
||||
registrar.play(EntityIDSyncPacket.ID, EntityIDSyncPacket::new, PacketHandler::handleSyncPacket);
|
||||
}
|
||||
|
||||
public static void register() {
|
||||
int id = 1;
|
||||
INSTANCE.registerMessage(id++, EntityIDSyncPacket.class, EntityIDSyncPacket::serialize, EntityIDSyncPacket::deserialize, PacketHandler::handleSyncPacket);
|
||||
FMLJavaModLoadingContext.get().getModEventBus().addListener(PacketHandler::registerPackets);
|
||||
}
|
||||
|
||||
private static void handleSyncPacket(EntityIDSyncPacket packet, NetworkEvent.Context contextSupplier) {
|
||||
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
|
||||
contextSupplier.enqueueWork(() -> ModernFixClient.handleEntityIDSync(packet));
|
||||
contextSupplier.setPacketHandled(true);
|
||||
});
|
||||
private static void handleSyncPacket(EntityIDSyncPacket packet, PlayPayloadContext context) {
|
||||
context.workHandler().execute(() -> ModernFixClient.handleEntityIDSync(packet));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.google.common.collect.Multimap;
|
|||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.minecraft.client.searchtree.SearchRegistry;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
|
|
@ -87,8 +88,8 @@ public class ModernFixPlatformHooksImpl implements ModernFixPlatformHooks {
|
|||
return FMLPaths.GAMEDIR.get();
|
||||
}
|
||||
|
||||
public void sendPacket(ServerPlayer player, Object packet) {
|
||||
PacketHandler.INSTANCE.send(PacketDistributor.PLAYER.with(() -> player), packet);
|
||||
public void sendPacket(ServerPlayer player, CustomPacketPayload packet) {
|
||||
PacketDistributor.PLAYER.with(player).send(packet);
|
||||
}
|
||||
|
||||
public void injectPlatformSpecificHacks() {
|
||||
|
|
|
|||
|
|
@ -45,9 +45,9 @@ Egregious, yet effective performance improvements for modern Minecraft
|
|||
# the modid of the dependency
|
||||
modId = "neoforge" #mandatory
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory = true #mandatory
|
||||
type = "required" #mandatory
|
||||
# The version range of the dependency
|
||||
versionRange = "[20.4.22-beta,)" #mandatory
|
||||
versionRange = "[20.4.70-beta,)" #mandatory
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering = "NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
|
|
@ -55,14 +55,14 @@ side = "BOTH"
|
|||
# Here's another dependency
|
||||
[[dependencies.modernfix]]
|
||||
modId = "minecraft"
|
||||
mandatory = true
|
||||
type = "required"
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange = "[1.20, 1.21)"
|
||||
ordering = "NONE"
|
||||
side = "BOTH"
|
||||
[[dependencies.modernfix]]
|
||||
modId = "jei"
|
||||
mandatory = false
|
||||
type = "optional"
|
||||
# This version range declares a minimum of the current minecraft version up to but not including the next major version
|
||||
versionRange = "[13,)"
|
||||
ordering = "BEFORE"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user