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