Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Issue with custom GUI


Reyzerbit
 Share

Recommended Posts

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: 
		javafml@36.2
		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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

 

Link to comment
Share on other sites

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • in mcp mappings it's PlayerEntity#sendPlayerAbilities yes
    • there is no player#onUpdateAbilities and what do you mean with tick event phase and logical side? like this? if(event.phase == TickEvent.Phase.END) { if(event.side.isServer() && ModKeys.abilityTransformKey.isKeyDown()) { player.noClip = true; } }  
    • Create needs to update for the new forge version, check if the mod is up to date or downgrade forge to 39.0.44
    • check the TickEvent Phase and the LogicalSide, also call Player#onUpdateAbilities
    • So I was playing with Create mod, flywheel, JEI, optifine, traveller's backpack and xaero's minimap, my game crashed so I rebooted it and there was a chunk missing from the world, so again, I rebooted the world, it didn't work so I tried to forceload chunks. After that, it crashed again and then everytime I've tried to open said world, Forge has crashed and given me this crash report. Hope someone can help, Oskar.   ---- Minecraft Crash Report ---- // Hi. I'm Minecraft, and I'm a crashaholic. Time: 28/01/2022, 16:56 Description: Exception in server tick loop java.lang.NoSuchMethodError: 'net.minecraft.nbt.CompoundTag net.minecraft.world.level.block.entity.BlockEntity.save(net.minecraft.nbt.CompoundTag)'     at com.simibubi.create.foundation.tileEntity.SyncedTileEntity.save(SyncedTileEntity.java:26) ~[create-mc1.18.1_v0.4a.jar%2353!/:mc1.18.1_v0.4a] {re:classloading}     at com.simibubi.create.foundation.tileEntity.SyncedTileEntity.writeClient(SyncedTileEntity.java:61) ~[create-mc1.18.1_v0.4a.jar%2353!/:mc1.18.1_v0.4a] {re:classloading}     at com.simibubi.create.foundation.tileEntity.SyncedTileEntity.m_5995_(SyncedTileEntity.java:33) ~[create-mc1.18.1_v0.4a.jar%2353!/:mc1.18.1_v0.4a] {re:classloading}     at net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData$BlockEntityInfo.m_195691_(ClientboundLevelChunkPacketData.java:153) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData.<init>(ClientboundLevelChunkPacketData.java:44) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket.<init>(ClientboundLevelChunkWithLightPacket.java:24) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.level.ChunkMap.m_183760_(ChunkMap.java:1459) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.level.ChunkMap.m_183754_(ChunkMap.java:1009) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.level.ChunkMap.m_140192_(ChunkMap.java:1195) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.level.ChunkMap.m_140199_(ChunkMap.java:1360) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.level.ServerChunkCache.m_8463_(ServerChunkCache.java:458) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.level.ServerLevel$EntityCallbacks.m_141985_(ServerLevel.java:1551) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.level.ServerLevel$EntityCallbacks.m_141985_(ServerLevel.java:1534) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.world.level.entity.PersistentEntitySectionManager.m_157575_(PersistentEntitySectionManager.java:135) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.world.level.entity.PersistentEntitySectionManager.addEntityWithoutEvent(PersistentEntitySectionManager.java:98) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.world.level.entity.PersistentEntitySectionManager.addNewEntityWithoutEvent(PersistentEntitySectionManager.java:76) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.level.ServerLevel.m_8853_(ServerLevel.java:827) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.level.ServerLevel.m_8834_(ServerLevel.java:771) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.players.PlayerList.m_11261_(PlayerList.java:190) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:fml:xaerominimap:xaero_playerlist_sendworldinfo}     at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_143699_(ServerLoginPacketListenerImpl.java:138) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_10055_(ServerLoginPacketListenerImpl.java:125) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.network.ServerLoginPacketListenerImpl.m_10050_(ServerLoginPacketListenerImpl.java:69) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.network.Connection.m_129483_(Connection.java:229) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.network.ServerConnectionListener.m_9721_(ServerConnectionListener.java:142) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_5703_(MinecraftServer.java:882) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:808) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.client.server.IntegratedServer.m_5705_(IntegratedServer.java:120) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,xf:OptiFine:default}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:668) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.m_177918_(MinecraftServer.java:258) ~[client-1.18.1-20211210.034407-srg.jar%2359!/:?] {re:classloading,pl:accesstransformer:B}     at java.lang.Thread.run(Thread.java:833) [?:?] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details:     Minecraft Version: 1.18.1     Minecraft Version ID: 1.18.1     Operating System: Windows 10 (amd64) version 10.0     Java Version: 17.0.1, Microsoft     Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Microsoft     Memory: 1094049504 bytes (1043 MiB) / 2147483648 bytes (2048 MiB) up to 2147483648 bytes (2048 MiB)     CPUs: 12     Processor Vendor: GenuineIntel     Processor Name: Intel(R) Core(TM) i5-10600K CPU @ 4.10GHz     Identifier: Intel64 Family 6 Model 165 Stepping 5     Microarchitecture: unknown     Frequency (GHz): 4.10     Number of physical packages: 1     Number of physical CPUs: 6     Number of logical CPUs: 12     Graphics card #0 name: NVIDIA GeForce GTX 970     Graphics card #0 vendor: NVIDIA (0x10de)     Graphics card #0 VRAM (MB): 4095.00     Graphics card #0 deviceId: 0x13c2     Graphics card #0 versionInfo: DriverVersion=30.0.14.9676     Memory slot #0 capacity (MB): 8192.00     Memory slot #0 clockSpeed (GHz): 2.13     Memory slot #0 type: DDR4     Memory slot #1 capacity (MB): 8192.00     Memory slot #1 clockSpeed (GHz): 2.13     Memory slot #1 type: DDR4     Virtual memory max (MB): 32639.30     Virtual memory used (MB): 17961.01     Swap memory total (MB): 16319.65     Swap memory used (MB): 268.15     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     Server Running: true     Player Count: 1 / 8; [ServerPlayer['OskarYeet'/131, l='ServerLevel[The Yeet Hangout]', x=-347.89, y=71.26, z=42.36]]     Data Packs: vanilla, mod:wthit, mod:forge, mod:flywheel (incompatible), mod:create, mod:xaerominimap, mod:travelersbackpack, mod:jei     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'; Server brand changed to 'forge'     OptiFine Version: OptiFine_1.18.1_HD_U_H5_pre4     OptiFine Build: 20211221-182052     Render Distance Chunks: 16     Mipmaps: 4     Anisotropic Filtering: 1     Antialiasing: 0     Multitexture: false     Shaders: (internal)     OpenGlVersion: 3.2.0 NVIDIA 496.76     OpenGlRenderer: NVIDIA GeForce GTX 970/PCIe/SSE2     OpenGlVendor: NVIDIA Corporation     CpuCount: 12     ModLauncher: 9.1.0+9.1.0+main.6690ee51     ModLauncher launch target: forgeclient     ModLauncher naming: srg     ModLauncher services:           mixin PLUGINSERVICE           eventbus PLUGINSERVICE           object_holder_definalize PLUGINSERVICE           runtime_enum_extender PLUGINSERVICE           capability_token_subclass PLUGINSERVICE           accesstransformer PLUGINSERVICE           runtimedistcleaner PLUGINSERVICE           mixin TRANSFORMATIONSERVICE           OptiFine TRANSFORMATIONSERVICE           fml TRANSFORMATIONSERVICE      FML Language Providers:          minecraft@1.0         javafml@null     Mod List:          client-1.18.1-20211210.034407-srg.jar             |Minecraft                     |minecraft                     |1.18.1              |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         wthit-forge-4.4.0.jar                             |wthit                         |wthit                         |4.4.0               |DONE      |Manifest: NOSIGNATURE         forge-1.18.1-39.0.59-universal.jar                |Forge                         |forge                         |39.0.59             |DONE      |Manifest: 84:ce:76:e8:45:35:e4:0e:63:86:df:47:59:80:0f:67:6c:c1:5f:6e:5f:4d:b3:54:47:1a:9f:7f:ed:5e:f2:90         flywheel-forge-1.18-0.4.1.jar                     |Flywheel                      |flywheel                      |1.18-0.4.1          |DONE      |Manifest: NOSIGNATURE         create-mc1.18.1_v0.4a.jar                         |Create                        |create                        |0.4a                |DONE      |Manifest: NOSIGNATURE         Xaeros_Minimap_22.1.0_Forge_1.18.jar              |Xaero's Minimap               |xaerominimap                  |22.1.0              |DONE      |Manifest: NOSIGNATURE         TravelersBackpack-1.18.1-7.0.1.jar                |Traveler's Backpack           |travelersbackpack             |7.0.1               |DONE      |Manifest: NOSIGNATURE         jei-1.18.1-9.2.3.78.jar                           |Just Enough Items             |jei                           |9.2.3.78            |DONE      |Manifest: NOSIGNATURE     Crash Report UUID: 14aa60c3-969a-4197-a9c9-902eab937477     FML: 39.0     Forge: net.minecraftforge:39.0.59
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.