Jump to content

Recommended Posts

Posted (edited)

Hey folks!

So I have been working on a port of the classic mod Minecraft Comes Alive into modern forge versions as it hasn't been updated since 1.12.

Anyways, I am attempting to send a SimpleChannel message when a button is clicked in the GUI, in order to alert the server that the baby's name is being changed. Here's the error I am getting whenever I press the button:

---- Minecraft Crash Report ----
// Don't be sad, have a hug! <3

Time: 10/12/21 9:54 PM
Description: mouseClicked event handler

java.lang.ExceptionInInitializerError: null
	at com.reyzerbit.mca_reborn.client.gui.NameBabyScreen.lambda$init$0(NameBabyScreen.java:76) ~[main/:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.button.Button.onPress(Button.java:26) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.button.AbstractButton.onClick(AbstractButton.java:18) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.Widget.mouseClicked(Widget.java:136) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.INestedGuiEventHandler.mouseClicked(INestedGuiEventHandler.java:28) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$onPress$0(MouseHelper.java:87) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:427) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.onPress(MouseHelper.java:85) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:181) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHelper.lambda$setup$5(MouseHelper.java:180) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {}
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:89) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MainWindow.updateDisplay(MainWindow.java:305) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.runTick(Minecraft.java:996) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:607) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_291] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_291] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_291] {}
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_291] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {}
Caused by: java.lang.IllegalArgumentException: Registration of network channels is locked
	at net.minecraftforge.fml.network.NetworkRegistry.createInstance(NetworkRegistry.java:150) ~[forge:?] {re:classloading}
	at net.minecraftforge.fml.network.NetworkRegistry.newSimpleChannel(NetworkRegistry.java:117) ~[forge:?] {re:classloading}
	at com.reyzerbit.mca_reborn.network.Network.<clinit>(Network.java:41) ~[?:?] {re:classloading}
	... 30 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
	at com.reyzerbit.mca_reborn.client.gui.NameBabyScreen.lambda$init$0(NameBabyScreen.java:76) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.button.Button.onPress(Button.java:26) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.button.AbstractButton.onClick(AbstractButton.java:18) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.widget.Widget.mouseClicked(Widget.java:136) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.gui.INestedGuiEventHandler.mouseClicked(INestedGuiEventHandler.java:28) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$onPress$0(MouseHelper.java:87) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}
-- Affected screen --
Details:
	Screen name: com.reyzerbit.mca_reborn.client.gui.NameBabyScreen
Stacktrace:
	at net.minecraft.client.gui.screen.Screen.wrapScreenError(Screen.java:427) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.onPress(MouseHelper.java:85) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.MouseHelper.lambda$null$4(MouseHelper.java:181) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.util.concurrent.ThreadTaskExecutor.execute(ThreadTaskExecutor.java:86) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B}
	at net.minecraft.client.MouseHelper.lambda$setup$5(MouseHelper.java:180) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at org.lwjgl.glfw.GLFWMouseButtonCallbackI.callback(GLFWMouseButtonCallbackI.java:36) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
	at org.lwjgl.system.JNI.invokeV(Native Method) ~[lwjgl-3.2.2.jar:build 10] {}
	at org.lwjgl.glfw.GLFW.glfwPollEvents(GLFW.java:3101) ~[lwjgl-glfw-3.2.2.jar:build 10] {}
	at com.mojang.blaze3d.systems.RenderSystem.flipFrame(RenderSystem.java:89) ~[forge:?] {re:classloading,pl:runtimedistcleaner:A}


-- Affected level --
Details:
	All players: 1 total; [ClientPlayerEntity['Dev'/217, l='ClientLevel', x=159.15, y=82.16, z=-288.81]]
	Chunk stats: Client Chunk Cache: 841, 550
	Level dimension: minecraft:overworld
	Level spawn location: World: (144,67,-160), Chunk: (at 0,4,0 in 9,-10; contains blocks 144,0,-160 to 159,255,-145), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)
	Level time: 8909 game time, 8909 day time
	Server brand: forge
	Server type: Integrated singleplayer server
Stacktrace:
	at net.minecraft.client.world.ClientWorld.fillReportDetails(ClientWorld.java:447) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.fillReport(Minecraft.java:2029) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.Minecraft.run(Minecraft.java:623) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}
	at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_291] {}
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_291] {}
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_291] {}
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_291] {}
	at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {}
	at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {}
	at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.jar:?] {}


-- System Details --
Details:
	Minecraft Version: 1.16.5
	Minecraft Version ID: 1.16.5
	Operating System: Windows 10 (amd64) version 10.0
	Java Version: 1.8.0_291, Oracle Corporation
	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
	Memory: 1116041032 bytes (1064 MB) / 1884815360 bytes (1797 MB) up to 3803185152 bytes (3627 MB)
	CPUs: 6
	JVM Flags: 1 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump
	ModLauncher: 8.0.9+86+master.3cf110c
	ModLauncher launch target: fmluserdevclient
	ModLauncher naming: mcp
	ModLauncher services: 
		/mixin-0.8.2.jar mixin PLUGINSERVICE 
		/eventbus-4.0.0.jar eventbus PLUGINSERVICE 
		/forge-1.16.5-36.2.0_mapped_official_1.16.5-launcher.jar object_holder_definalize PLUGINSERVICE 
		/forge-1.16.5-36.2.0_mapped_official_1.16.5-launcher.jar runtime_enum_extender PLUGINSERVICE 
		/accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE 
		/forge-1.16.5-36.2.0_mapped_official_1.16.5-launcher.jar capability_inject_definalize PLUGINSERVICE 
		/forge-1.16.5-36.2.0_mapped_official_1.16.5-launcher.jar runtimedistcleaner PLUGINSERVICE 
		/mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE 
		/forge-1.16.5-36.2.0_mapped_official_1.16.5-launcher.jar fml TRANSFORMATIONSERVICE 
	FML: 36.2
	Forge: net.minecraftforge:36.2.0
	FML Language Providers: 
		[email protected]
		minecraft@1
	Mod List: 
		client-extra.jar                                  |Minecraft                     |minecraft                     |1.16.5              |DONE      |Manifest: a1:d4:5e:04:4f:d3:d6:e0:7b:37:97:cf:77:b0:de:ad:4a:47:ce:8c:96:49:5f:0a:cf:8c:ae:b2:6d:4b:8a:3f
		main                                              |Minecraft Comes Alive Reborn  |mca_reborn                    |1.0.0.0             |DONE      |Manifest: NOSIGNATURE
		forge-1.16.5-36.2.0_mapped_official_1.16.5-recomp.|Forge                         |forge                         |36.2.0              |DONE      |Manifest: NOSIGNATURE
	Crash Report UUID: c9300d70-fa23-423d-b75a-ae876bdd96ed
	Launched Version: MOD_DEV
	Backend library: LWJGL version 3.2.2 build 10
	Backend API: NVIDIA GeForce RTX 3060/PCIe/SSE2 GL version 4.6.0 NVIDIA 466.77, NVIDIA Corporation
	GL Caps: Using framebuffer using OpenGL 3.0
	Using VBOs: Yes
	Is Modded: Definitely; Client brand changed to 'forge'
	Type: Client (map_client.txt)
	Graphics mode: fancy
	Resource Packs: 
	Current Language: English (US)
	CPU: 6x Intel(R) Core(TM) i5-9400F CPU @ 2.90GHz

The GUI's init Override looks like this:

@Override
    public void init() {

        if (this.baby == null) this.onClose();
    	
    	this.minecraft.keyboardHandler.setSendRepeatsToGui(true);
        
        // Text Field
        babyNameTextField = new TextFieldWidget(font, width / 2 - 100, height / 2 - 60, 200, 20, new StringTextComponent("Enter name"));
        babyNameTextField.setMaxLength(32);
        babyNameTextField.setEditable(true);
        babyNameTextField.setFocus(true);
        children.add(babyNameTextField);
    	
    	// Done button
    	doneButton = addButton(new Button(width / 2 - 40, height / 2 - 10, 80, 20, new StringTextComponent(MCA.getLocalizer().localize("gui.button.done")), button -> {

			// This is the line throwing the error
            Network.INSTANCE.sendToServer(new BabyName(babyNameTextField.getValue().trim()));
            onClose();
        	
        }));
    	
    	// Random button
    	randomButton = addButton(new Button(width / 2 + 105, height / 2 - 60, 60, 20, new StringTextComponent(MCA.getLocalizer().localize("gui.button.random")), button -> {
    		
    		babyNameTextField.setValue(API.getRandomName(baby.getGender()));
    	
    	}));
        
    }

The message in question:

@AllArgsConstructor
    @Getter
    public static class BabyName {
    	
    	private String babyName;
		
		public static BabyName decode(PacketBuffer buffer) {
			
			return new BabyName(buffer.readUtf());
			
		}
		
		public static void encode(BabyName msg, PacketBuffer buffer) {
			
			buffer.writeUtf(msg.getBabyName());
			
		}
    	
    }

The Network class:

package com.reyzerbit.mca_reborn.network;

import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_CLIENT;
import static net.minecraftforge.fml.network.NetworkDirection.PLAY_TO_SERVER;

import java.util.Optional;

import com.reyzerbit.mca_reborn.common.MCA;
import com.reyzerbit.mca_reborn.network.MCAMessages.BabyName;
import com.reyzerbit.mca_reborn.network.MCAMessages.ButtonAction;
import com.reyzerbit.mca_reborn.network.MCAMessages.CallToPlayer;
import com.reyzerbit.mca_reborn.network.MCAMessages.CareerRequest;
import com.reyzerbit.mca_reborn.network.MCAMessages.CareerResponse;
import com.reyzerbit.mca_reborn.network.MCAMessages.GetFamily;
import com.reyzerbit.mca_reborn.network.MCAMessages.GetFamilyResponse;
import com.reyzerbit.mca_reborn.network.MCAMessages.InventoryRequest;
import com.reyzerbit.mca_reborn.network.MCAMessages.InventoryResponse;
import com.reyzerbit.mca_reborn.network.MCAMessages.ReviveVillager;
import com.reyzerbit.mca_reborn.network.MCAMessages.SavedVillagersRequest;
import com.reyzerbit.mca_reborn.network.MCAMessages.SavedVillagersResponse;
import com.reyzerbit.mca_reborn.network.MCAMessages.Say;
import com.reyzerbit.mca_reborn.network.MCAMessages.SetName;
import com.reyzerbit.mca_reborn.network.MCAMessages.SetProfession;
import com.reyzerbit.mca_reborn.network.MCAMessages.SetTexture;
import com.reyzerbit.mca_reborn.network.MCAMessages.SpawnParticles;

import net.minecraft.util.ResourceLocation;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.simple.SimpleChannel;

public class Network {

    private static int NETWORK_INDEX = 0;
	
	private static final String PROTOCOL_VERSION = "1";
    public static final SimpleChannel INSTANCE;
    static {
    	
    	INSTANCE = NetworkRegistry.newSimpleChannel(new ResourceLocation(MCA.MODID, "mca_network_channel"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals);
    	
    }
    
    @SubscribeEvent
    public static void onCommonSetupEvent(FMLCommonSetupEvent event) {
    	
    	// Beneath each message register is the original code for backwards reference

    	// Client -> Server
    	INSTANCE.registerMessage(NETWORK_INDEX++, ButtonAction.class, ButtonAction::encode, ButtonAction::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(0, ButtonActionHandler.class, ButtonAction.class, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, BabyName.class, BabyName::encode, BabyName::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(BabyNameHandler.class, BabyName.class, 2, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, CareerRequest.class, CareerRequest::encode, CareerRequest::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(CareerRequestHandler.class, CareerRequest.class, 4, Side.SERVER);
    	
    	INSTANCE.registerMessage(NETWORK_INDEX++, InventoryRequest.class, InventoryRequest::encode, InventoryRequest::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(InventoryRequestHandler.class, InventoryRequest.class, 5, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, SavedVillagersRequest.class, SavedVillagersRequest::encode, SavedVillagersRequest::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(SavedVillagersRequestHandler.class, SavedVillagersRequest.class, 7, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, ReviveVillager.class, ReviveVillager::encode, ReviveVillager::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(ReviveVillagerHandler.class, ReviveVillager.class, 9, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, SetName.class, SetName::encode, SetName::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(SetNameHandler.class, SetName.class, 10, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, GetFamily.class, GetFamily::encode, GetFamily::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(GetFamilyHandler.class, GetFamily.class, 12, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, CallToPlayer.class, CallToPlayer::encode, CallToPlayer::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(CallToPlayerHandler.class, CallToPlayer.class, 14, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, SetTexture.class, SetTexture::encode, SetTexture::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(SetTextureHandler.class, SetTexture.class, 15, Side.SERVER);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, SetProfession.class, SetProfession::encode, SetProfession::decode, MessageHandler.Server::handle, Optional.of(PLAY_TO_SERVER));
        //INSTANCE.registerMessage(SetProfessionHandler.class, SetProfession.class, 16, Side.SERVER);
        
        // Server -> Client
    	INSTANCE.registerMessage(NETWORK_INDEX++, SpawnParticles.class, SpawnParticles::encode, SpawnParticles::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(SpawnParticlesHandler.class, SpawnParticles.class, 11, Side.CLIENT);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, Say.class, Say::encode, Say::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(SayHandler.class, Say.class, 1, Side.CLIENT);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, CareerResponse.class, CareerResponse::encode, CareerResponse::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(CareerResponseHandler.class, CareerResponse.class, 3, Side.CLIENT);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, InventoryResponse.class, InventoryResponse::encode, InventoryResponse::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(InventoryResponseHandler.class, InventoryResponse.class, 6, Side.CLIENT);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, SavedVillagersResponse.class, SavedVillagersResponse::encode, SavedVillagersResponse::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(SavedVillagersResponseHandler.class, SavedVillagersResponse.class, 8, Side.CLIENT);
        
    	INSTANCE.registerMessage(NETWORK_INDEX++, GetFamilyResponse.class, GetFamilyResponse::encode, GetFamilyResponse::decode, MessageHandler.Client::handle, Optional.of(PLAY_TO_CLIENT));
        //INSTANCE.registerMessage(GetFamilyResponseHandler.class, GetFamilyResponse.class, 13, Side.CLIENT);
        
    }

}

Message Handler, which is called on message recieved:

public static void handle(BabyName msg, Supplier<NetworkEvent.Context> context) {
  
  context.get().enqueueWork(() -> ServerHandler.processMessage(msg, context.get().getSender()));
  
  context.get().setPacketHandled(true);
		    
}

And finally: the specific handler itself:

protected static void processMessage(BabyName msg, ServerPlayerEntity player) {

	ItemStack stack = player.inventory.getSelected();

	if (stack.getItem() instanceof Baby) {

		CompoundNBT nbt = stack.serializeNBT();
		nbt.putString("name", msg.getBabyName());
		stack.deserializeNBT(nbt);

	}

	return;
		
}

I'm trying to figure out what is wrong with this. I can't seem to figure out what's going wrong, and I've been trying things and googling help for almost 3 days now.

 

Any advice would be appreciated!

 

Thanks!

 

-Rey

Edited by Reyzerbit
Clarity
Posted
19 minutes ago, ImNotJahan said:

I'm not sure what he meant but could you show what code the 76th line of NameBabyScreen is

Yup! It's actually the line 

 Network.INSTANCE.sendToServer(new BabyName(babyNameTextField.getValue().trim()));

from the Overrided init. I'll edit it with a comment so you can see.

Posted (edited)
2 hours ago, Reyzerbit said:

What do you mean?

I mean the info I gave you in this post is wrong, since I edit the post and I remove the wrong info

Edited by Luis_ST
Posted
11 hours ago, diesieben07 said:

How do you register the onCommonSetupEvent event handler? I am guessing you aren't, so it is never called.

I knew I forgot something! This was the issue haha. I always forget to add the listener, for some reason my brain always wants to assume that the @EventSubscriber annotation is enough.

 

Thank you!

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • hello i am wanting to know if anyone can help me with this crash happened when i tried to go to bed on server https://pastebin.com/CezfAbAh
    • I accidentally posted this in the ForgeGradle subforum, super sorry. I meant to post it in the regular modders forum. Hopefully it can still reach the right people!
    • I've been trying to make an addon mod for create, but setting up dependencies and trying to add the mod into my mod environment has proven a little difficult for me. Ive been searching this forum and I've seen problems that were close to mine but not exactly mine, searching the error output just yields  people having trouble with their own modid, not an addons. The error while loading Minecraft,  "mods.toml missing metadata of modid create" and  "The Mod File C:Users\user1\data\<mod>\build\resources\main has mods that were not found" My build.gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'org.parchmentmc.librarian.forgegradle' version '1.+' } version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: 'parchment', version: '2023.09.03-1.20.1' copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' property 'mixin.env.remapRefMap', 'true' property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg" mods { "${mod_id}" { source sourceSets.main } } } client { // ... mods { other_mod { // ... } // Configures the 'example' mod create { // Add a source set to a mod's sources source sourceSets.main // Merges this configuration and specifies whether to overwrite existing properties merge mods.other_mod, true } } } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } // This run config launches GameTestServer and runs all registered gametests, then exits. // By default, the server will crash when no gametests are provided. // The gametest system is also enabled by default for other run configs under the /test command. gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { // example of overriding the workingDirectory set in configureEach above workingDirectory project.file('run-data') // Specify the modid for data generation, where to output the resulting resource, and where to look for existing resources. args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } // Include resources generated by data generators. sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { maven { url = 'https://maven.tterrag.com/' } } dependencies { // Specify the version of Minecraft to use. // Any artifact can be supplied so long as it has a "userdev" classifier artifact and is a compatible patcher artifact. // The "userdev" classifier will be requested and setup by ForgeGradle. // If the group id is "net.minecraft" and the artifact id is one of ["client", "server", "joined"], // then special handling is done to allow a setup of a vanilla dependency without the use of an external repository. minecraft "net.minecraftforge:forge:1.20.1-47.3.22" implementation fg.deobf("com.simibubi.create:create-${create_minecraft_version}:${create_version}:slim") { transitive = false } implementation fg.deobf("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}") // Example mod dependency with JEI - using fg.deobf() ensures the dependency is remapped to your development mappings // The JEI API is declared for compile time use, while the full JEI artifact is used at runtime // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-common-api:${jei_version}") // compileOnly fg.deobf("mezz.jei:jei-${mc_version}-forge-api:${jei_version}") // runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}-forge:${jei_version}") // Example mod dependency using a mod jar from ./libs with a flat dir repository // This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar // The group id is ignored when searching -- in this case, it is "blank" // implementation fg.deobf("blank:coolmod-${mc_version}:${coolmod_version}") // For more info: // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } // This block of code expands all declared replace properties in the specified resource targets. // A missing property will result in an error. Properties are expanded using ${} Groovy notation. // When "copyIdeResources" is enabled, this will also run before the game launches in IDE environments. // See https://docs.gradle.org/current/dsl/org.gradle.language.jvm.tasks.ProcessResources.html tasks.named('processResources', ProcessResources).configure { var replaceProperties = [ minecraft_version: minecraft_version, minecraft_version_range: minecraft_version_range, forge_version: forge_version, forge_version_range: forge_version_range, loader_version_range: loader_version_range, mod_id: mod_id, mod_name: mod_name, mod_license: mod_license, mod_version: mod_version, mod_authors: mod_authors, mod_description: mod_description, ] inputs.properties replaceProperties filesMatching(['META-INF/mods.toml', 'pack.mcmeta']) { expand replaceProperties + [project: project] } } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") ]) } // This is the preferred method to reobfuscate your jar file finalizedBy 'reobfJar' } // However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing: // tasks.named('publish').configure { // dependsOn 'reobfJar' // } // Example configuration to allow publishing using the maven-publish plugin publishing { publications { register('mavenJava', MavenPublication) { artifact jar } } } tasks.withType(JavaCompile).configureEach { options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation } -And my mods.toml file  modLoader="javafml" #mandatory loaderVersion="[47,)" license="MIT" [[mods]] modId="mechmod" version="0.0.1" displayName="Create: Mechs" authors="Affe" [[dependencies.mechmod]] modId="create" mandatory=true versionRange="[0,)" ordering="NONE" side="BOTH" [[dependencies.mechmod]] modId="forge" mandatory=true versionRange="[47.1.3,)" ordering="NONE" side="BOTH" [[dependencies.mechmod]] modId="minecraft" mandatory=true versionRange="[1.20,1.21)" ordering="NONE" side="BOTH" [[dependencies.mechmod]] modId="flywheel" mandatory=true versionRange="[0.6.11,0.6.12)" ordering="AFTER" side="CLIENT" I thought I had implemented the code from the "depending on create" section from their github correctly. But I assume I haven't implemented something that is needed. But I don't know what or where. I can also provide any file you think will help with your diagnosis. Any help would be appreciated, cheers!   
    • Yo i might be a lil bit late but on 1.20.6 you can call BuiltInRegistries.ITEMS.getTagOrEmpty(*required tag*) to get an iterable of item holders, this might be possible on 1.18.2 as well. Then you get the items using for(Holder<Item> holder: iterable) or the .forEach(Consumer<Holder<Item>>) method, or convert the iterable to array/list/collection. When you get the holders, use the .get() method to get the items
    • I'm troubleshooting some mods that I want for a single player world in 1.21.4 and I was having trouble with a resource library config crashing my game so I tried another mod and the library config for that was causing crashes as well. I've updated java and forge recently. Both of these dependency mods have caused Exit Code: -1 but I'm using the crash report for the mod that I was originally wanting to use. https://pastebin.com/82FZPwS2
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.