MinecraftForge icon indicating copy to clipboard operation
MinecraftForge copied to clipboard

[1.19.x] Vanilla clients can join modded server

Open tmvkrpxl0 opened this issue 2 years ago • 6 comments

Minecraft Version: 1.19.2

Forge Version: 43.1.33

Logs: https://gist.github.com/tmvkrpxl0/c5cd8ad9d3ccb5d4c5e1ac7d2ccf776c It has log from both vanilla client and modded lan server

Steps to Reproduce:

  1. Start modded server with mods that adds blocks/items, either userdev LAN, userdev Server, or dedicated Server
  2. Launch vanilla client
  3. Join it and observe it can

Description of issue: Vanilla clients are able to join modded server, without getting kicked. image In this image, left is modded client running Lan server looking at vanilla client player right is vanilla client, unable to process chunk with custom block as it's unknown.

tmvkrpxl0 avatar Oct 07 '22 05:10 tmvkrpxl0

I've been able to reproduce this bug using a very simple test mod on both userdev server and dedicated server (didn't test userdev LAN). Below are my logs. Vanilla_1 was the log when testing on dedicated server, Vanilla_2 on userdev server.

dedicated_server.log vanilla_client_2.log userdev_dedicated_server.log vanilla_client_1.log

My test mod consisted of a single class file as follows:

@Mod(TestMod.MOD_ID)
public class TestMod
{

	public static final String MOD_ID = "testmod";
	
	public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID);
	public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);

	public static final RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test_block", () -> new Block(BlockBehaviour.Properties.of(Material.STONE)));
	public static final RegistryObject<Item> TEST_BLOCK_ITEM = ITEMS.register("test_block", () -> new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
	
	public TestMod()
	{
		
		IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
		BLOCKS.register(modEventBus);
		ITEMS.register(modEventBus);
		
	}
	
}

StanCEmpire avatar Oct 07 '22 13:10 StanCEmpire

Isn't there a way for the mod to reject the vanilla client? IIRC, the reason forge does not reject it is because its valid for a client to join a server with server only mods, but its up to the mods to declare whether they require both sides or not.

KnightMiner avatar Oct 07 '22 15:10 KnightMiner

Even so, it doesn't make sense for a Forge server to accept connection from a client which is missing common registry items (blocks, items, etc.) because this creates all sorts of problems (such as ghost blocks and server/client desync). Does the forge server not do a registry check before accepting connection?

StanCEmpire avatar Oct 07 '22 19:10 StanCEmpire

Isn't there a way for the mod to reject the vanilla client? IIRC, the reason forge does not reject it is because its valid for a client to join a server with server only mods, but its up to the mods to declare whether they require both sides or not.

Yes, but clients with forge installed but no mods get rejected, and same should go for vanilla clients

tmvkrpxl0 avatar Oct 08 '22 03:10 tmvkrpxl0

In theory you are both correct, and incorrect. As there are times where moded content is hidden behind logical/gameplay mechanics which allow vanilla clients to work just fine. But yes we could add a sanity check with a config option to bypass it. The problem is that we need to do an audit and figure out what we'd cant to classify as a non-vanilla compatible registry change...

LexManos avatar Oct 08 '22 03:10 LexManos

One possibility for a registry addition on the server that is compatible with vanilla clients would be a modded entity that spawns a vanilla client-side entity in its packet, so it's not even as simple as 'no registry additions'.

I think a simple easily discoverable way for mods to declare themselves incompatible, possibly set by default in the MDK (or defaulting to a third state that just does very simple registry comparisons, but allowing mods to override it to say they are compatible) would be best.

Random832 avatar Oct 08 '22 04:10 Random832