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

Reyzerbit

Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Reyzerbit

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

     

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

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

×
×
  • Create New...

Important Information

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