mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 20:22:28 +00:00
Workaround for modded attributes on vanilla entities logging warnings on vanilla clients
Switch to a handler-based approach per packet class, simplify patch, add some docs Add license header and docs Switch to a network handler based approach Switch to a network handler based approach revert build gradle change Simplify Packet patch Add license header to IForgePacket Revert ForgeHooks changes Less hacky and more generic way to filter packets for vanilla connections _Actually_ Order SAS. It's early Order SAS simplify vanilla connection check Remove unneeded import change
This commit is contained in:
1 parent
5a7facc20f
commit
acd18455c2
5 files changed
+124
-3
No files matched your search
@@ -27,7 +27,8 @@ public enum ConnectionType
|
||||
|
||||
private final Function<String, Integer> versionExtractor;
|
||||
|
||||
ConnectionType(Function<String, Integer> versionExtractor) {
|
||||
ConnectionType(Function<String, Integer> versionExtractor)
|
||||
{
|
||||
this.versionExtractor = versionExtractor;
|
||||
}
|
||||
|
||||
@@ -36,7 +37,14 @@ public enum ConnectionType
|
||||
return vers.startsWith(FMLNetworkConstants.FMLNETMARKER) ? MODDED : VANILLA;
|
||||
}
|
||||
|
||||
public int getFMLVersionNumber(final String fmlVersion) {
|
||||
public int getFMLVersionNumber(final String fmlVersion)
|
||||
{
|
||||
return versionExtractor.apply(fmlVersion);
|
||||
}
|
||||
|
||||
public boolean isVanilla()
|
||||
{
|
||||
return this == VANILLA;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,6 +27,8 @@ import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.tags.ITagCollection;
|
||||
import net.minecraft.tags.ITagCollectionSupplier;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
@@ -62,7 +64,17 @@ public class NetworkHooks
|
||||
|
||||
public static ConnectionType getConnectionType(final Supplier<NetworkManager> connection)
|
||||
{
|
||||
return ConnectionType.forVersionFlag(connection.get().channel().attr(FMLNetworkConstants.FML_NETVERSION).get());
|
||||
return getConnectionType(connection.get().channel());
|
||||
}
|
||||
|
||||
public static ConnectionType getConnectionType(ChannelHandlerContext context)
|
||||
{
|
||||
return getConnectionType(context.channel());
|
||||
}
|
||||
|
||||
private static ConnectionType getConnectionType(Channel channel)
|
||||
{
|
||||
return ConnectionType.forVersionFlag(channel.attr(FMLNetworkConstants.FML_NETVERSION).get());
|
||||
}
|
||||
|
||||
public static IPacket<?> getEntitySpawningPacket(Entity entity)
|
||||
|
||||
@@ -68,6 +68,7 @@ import net.minecraftforge.fml.loading.moddiscovery.ModFile;
|
||||
import net.minecraftforge.fml.packs.ModFileResourcePack;
|
||||
import net.minecraftforge.fml.packs.ResourcePackLoader;
|
||||
import net.minecraftforge.forgespi.language.IModInfo;
|
||||
import net.minecraftforge.network.VanillaConnectionNetworkFilter;
|
||||
import net.minecraftforge.registries.GameData;
|
||||
|
||||
public class ServerLifecycleHooks
|
||||
@@ -168,6 +169,7 @@ public class ServerLifecycleHooks
|
||||
if (packet.getRequestedState() == ProtocolType.STATUS) return true;
|
||||
|
||||
NetworkHooks.registerServerLoginChannel(manager, packet);
|
||||
VanillaConnectionNetworkFilter.injectIfNecessary(manager);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user