Jump to content

Recommended Posts

Posted

Hello, I've been trying to make this working for several hours and it's getting frustrating :/ I'm trying to register an event in @Init (tried @PreInit too) method, but it's never firing. I can register the event in load() or the mod constructor, but it only works in the client, if I put the mod on the server, it throws an error.

 

Source code:

 

package cz.chylex.minimod.HeavyAnvils;

import java.util.HashSet;

import java.util.Iterator;

import java.util.Set;

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.item.EntityFallingSand;

import net.minecraft.server.MinecraftServer;

import net.minecraft.src.BaseMod;

import net.minecraft.src.ModLoader;

import net.minecraftforge.common.MinecraftForge;

import net.minecraftforge.event.ForgeSubscribe;

import net.minecraftforge.event.entity.EntityJoinWorldEvent;

import cpw.mods.fml.common.Mod;

import cpw.mods.fml.common.Mod.Init;

import cpw.mods.fml.common.Mod.Instance;

import cpw.mods.fml.common.SidedProxy;

import cpw.mods.fml.common.event.FMLInitializationEvent;

import cpw.mods.fml.common.network.NetworkMod;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

@Mod(modid="chylex_HeavyAnvils", name="Heavy Anvils", version="1.0")

@NetworkMod(clientSideRequired=false, serverSideRequired=false)

public class mod_HeavyAnvils extends BaseMod{

@Instance("chylex_HeavyAnvils")

public static mod_HeavyAnvils instance;

 

private Set<EntityFallingSand> anvils = new HashSet<EntityFallingSand>();

 

@Init

public void initialize(FMLInitializationEvent event){ // <-- never fires

System.out.println("test");

MinecraftForge.EVENT_BUS.register(this);

}

 

@Override

public String getName(){

return "MM Heavy Anvils";

}

 

@Override

public String getVersion(){

return "1.0";

}

 

@Override

public void load(){

//MinecraftForge.EVENT_BUS.register(this); <-- this works in client, server throws error

ModLoader.setInGameHook(this,true,true);

}

 

@SideOnly(Side.CLIENT)

@Override

public boolean onTickInGame(float time, Minecraft minecraftInstance){

onTick();

return true;

}

 

@SideOnly(Side.SERVER)

@Override

public boolean onTickInGame(MinecraftServer minecraftServer){

onTick();

return true;

}

 

private void onTick(){

for(Iterator<EntityFallingSand> iter=anvils.iterator(); iter.hasNext();){

EntityFallingSand e=iter.next();

if (e.onGround){

int x=(int)Math.floor(e.posX),y=(int)Math.floor(e.posY-1),z=(int)Math.floor(e.posZ);

int block=e.worldObj.getBlockId(x,y,z);

if (block==Block.glass.blockID||block==Block.thinGlass.blockID||block==Block.glowStone.blockID){

e.worldObj.setBlock(x,y,z,0);

}

iter.remove();

}

}

}

 

@ForgeSubscribe

public void onEntityJoinWorld(EntityJoinWorldEvent e){

if (!e.world.isRemote&&e.entity instanceof EntityFallingSand){

EntityFallingSand fs=(EntityFallingSand)e.entity;

if (fs.blockID==Block.anvil.blockID)anvils.add(fs);

}

}

}

 

 

 

The "test" message never shows up, and the event isn't registered. If I register it inside the constructor or load(), client works flawlessly, but this error shows up on the server (started it inside Eclipse, but the same error is thrown if I run the server from .jar and put the mod inside mods folder):

 

2013-04-12 15:14:11 [iNFO] [ForgeModLoader] Forge Mod Loader version 5.1.8.611 for Minecraft 1.5.1 loading

2013-04-12 15:14:11 [iNFO] [ForgeModLoader] Java is Java HotSpot 64-Bit Server VM, version 1.7.0_02, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre7

2013-04-12 15:14:11 [iNFO] [ForgeModLoader] Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation

2013-04-12 15:14:11 [iNFO] [sTDOUT] 229 recipes

2013-04-12 15:14:11 [iNFO] [sTDOUT] 27 achievements

2013-04-12 15:14:12 [iNFO] [Minecraft-Server] Starting minecraft server version 1.5.1

2013-04-12 15:14:12 [iNFO] [MinecraftForge] Attempting early MinecraftForge initialization

2013-04-12 15:14:12 [iNFO] [sTDOUT] MinecraftForge v7.7.1.611 Initialized

2013-04-12 15:14:12 [iNFO] [ForgeModLoader] MinecraftForge v7.7.1.611 Initialized

2013-04-12 15:14:12 [iNFO] [sTDOUT] Replaced 85 ore recipies

2013-04-12 15:14:12 [iNFO] [MinecraftForge] Completed early MinecraftForge initialization

2013-04-12 15:14:12 [iNFO] [ForgeModLoader] Reading custom logging properties from D:\MCP\MCP7_151_minimods_forge\mcp\jars\config\logging.properties

2013-04-12 15:14:12 [OFF] [ForgeModLoader] Logging level for ForgeModLoader logging is set to ALL

2013-04-12 15:14:12 [iNFO] [ForgeModLoader] Searching D:\MCP\MCP7_151_minimods_forge\mcp\jars\mods for mods

2013-04-12 15:14:13 [iNFO] [ForgeModLoader] Forge Mod Loader has identified 4 mods to load

2013-04-12 15:14:13 [iNFO] [mcp] Activating mod mcp

2013-04-12 15:14:13 [iNFO] [FML] Activating mod FML

2013-04-12 15:14:13 [iNFO] [Forge] Activating mod Forge

2013-04-12 15:14:13 [iNFO] [mod_HeavyAnvils] Activating mod mod_HeavyAnvils

2013-04-12 15:14:13 [iNFO] [ForgeModLoader] Configured a dormant chunk cache size of 0

2013-04-12 15:14:13 [iNFO] [Minecraft-Server] Loading properties

2013-04-12 15:14:13 [iNFO] [Minecraft-Server] Default game type: SURVIVAL

2013-04-12 15:14:13 [iNFO] [Minecraft-Server] Generating keypair

2013-04-12 15:14:13 [iNFO] [Minecraft-Server] Starting Minecraft server on *:25565

2013-04-12 15:14:13 [WARNING] [Minecraft-Server] **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE!

2013-04-12 15:14:13 [WARNING] [Minecraft-Server] The server will make no attempt to authenticate usernames. Beware.

2013-04-12 15:14:13 [WARNING] [Minecraft-Server] While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose.

2013-04-12 15:14:13 [WARNING] [Minecraft-Server] To change this, set "online-mode" to "true" in the server.properties file.

2013-04-12 15:14:13 [iNFO] [sTDERR] java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/NetClientHandler

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.Class.getDeclaredMethods0(Native Method)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.Class.privateGetDeclaredMethods(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.Class.privateGetPublicMethods(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.Class.privateGetPublicMethods(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.Class.getMethods(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at net.minecraftforge.event.EventBus.register(EventBus.java:28)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cz.chylex.minimod.HeavyAnvils.mod_HeavyAnvils.load(mod_HeavyAnvils.java:49)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.modloader.ModLoaderModContainer.init(ModLoaderModContainer.java:537)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.reflect.Method.invoke(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

2013-04-12 15:14:13 [iNFO] [sTDERR] at com.google.common.eventbus.EventBus.post(EventBus.java:267)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.Loader.initializeMods(Loader.java:689)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:93)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:357)

2013-04-12 15:14:13 [iNFO] [sTDERR] at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:140)

2013-04-12 15:14:13 [iNFO] [sTDERR] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:429)

2013-04-12 15:14:13 [iNFO] [sTDERR] at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

2013-04-12 15:14:13 [iNFO] [sTDERR] Caused by: java.lang.ClassNotFoundException: net.minecraft.client.multiplayer.NetClientHandler

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:211)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.ClassLoader.loadClass(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] at java.lang.ClassLoader.loadClass(Unknown Source)

2013-04-12 15:14:13 [iNFO] [sTDERR] ... 34 more

2013-04-12 15:14:13 [iNFO] [sTDERR] Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/multiplayer/NetClientHandler for invalid side SERVER

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:292)

2013-04-12 15:14:13 [iNFO] [sTDERR] at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:199)

2013-04-12 15:14:13 [iNFO] [sTDERR] ... 36 more

2013-04-12 15:14:13 [sEVERE] [Minecraft-Server] Encountered an unexpected exception NoClassDefFoundError

java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/NetClientHandler

at java.lang.Class.getDeclaredMethods0(Native Method)

at java.lang.Class.privateGetDeclaredMethods(Unknown Source)

at java.lang.Class.privateGetPublicMethods(Unknown Source)

at java.lang.Class.privateGetPublicMethods(Unknown Source)

at java.lang.Class.getMethods(Unknown Source)

at net.minecraftforge.event.EventBus.register(EventBus.java:28)

at cz.chylex.minimod.HeavyAnvils.mod_HeavyAnvils.load(mod_HeavyAnvils.java:49)

at cpw.mods.fml.common.modloader.ModLoaderModContainer.init(ModLoaderModContainer.java:537)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:165)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)

at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)

at com.google.common.eventbus.EventBus.post(EventBus.java:267)

at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:98)

at cpw.mods.fml.common.Loader.initializeMods(Loader.java:689)

at cpw.mods.fml.server.FMLServerHandler.finishServerLoading(FMLServerHandler.java:93)

at cpw.mods.fml.common.FMLCommonHandler.onServerStarted(FMLCommonHandler.java:357)

at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:140)

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:429)

at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.multiplayer.NetClientHandler

at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:211)

at java.lang.ClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

... 34 more

Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/multiplayer/NetClientHandler for invalid side SERVER

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50)

at cpw.mods.fml.relauncher.RelaunchClassLoader.runTransformers(RelaunchClassLoader.java:292)

at cpw.mods.fml.relauncher.RelaunchClassLoader.findClass(RelaunchClassLoader.java:199)

... 36 more

2013-04-12 15:14:13 [sEVERE] [Minecraft-Server] This crash report has been saved to: D:\MCP\MCP7_151_minimods_forge\mcp\jars\.\crash-reports\crash-2013-04-12_15.14.13-server.txt

 

 

 

I have no idea why it's trying to load the NetClientHandler class on the server, just because I'm trying to register an event, can't find any references to that class in my mod, I'm simply clueless. I have the latest Forge version for 1.5.1 (just to be 100% sure, I redownloaded it about 30 minutes ago). Thanks for help :)

Posted
public class mod_HeavyAnvils extends BaseMod

 

seriously?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

public class mod_HeavyAnvils extends BaseMod

 

seriously?

 

Oops, somehow I automatically assumed it was supposed to work like that, didn't realize it's just for ModLoader compatibility... Explains many weird things I've encountered, anyways it works now, thanks a lot :)

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

    • Reach Out To Rapid Digital: What sapp Info: +1 41 4 80 7 14 85 Email INFO: rap iddi gita lrecov ery @ exe cs. com Hello, my name is Jayson, and I’m 35 years old from the United Kingdom. My family and I recently endured an incredibly challenging experience that I wouldn’t wish on anyone. We became victims of a cryptocurrency investment fraud scheme that saw us lose a staggering $807,000 in USDT and Bitcoins. The fraudsters had created a convincing facade, and we were lured into investing, only to discover later that the platform was a complete scam. We were left devastated, not just financially, but emotionally, as we had trusted these people and believed in the legitimacy of the investment. After the initial shock wore off, we desperately searched for ways to recover the lost funds. It seemed like an impossible task, and we felt as though there was no hope. That’s when, by sheer luck, we stumbled across a post about Rapid Digital Recovery, a cryptocurrency and funds recovery organization with a proven track record in cybersecurity and fraud recovery. We decided to reach out to them, and from the first interaction, we were impressed with their professionalism and transparency. They explained the recovery process in detail and reassured us that they had the skills and expertise to track down the perpetrators and recover our funds. This gave us a renewed sense of hope, something we hadn’t felt in months. What truly stood out during our experience with Rapid Digital Recovery was their dedication to the recovery process. The team went above and beyond, using sophisticated tracking tools and cyber forensics to gather critical information. Within a matter of weeks, they had successfully located the funds and traced the scam back to the fraudsters responsible. They worked with the authorities to ensure the criminals were held accountable for their actions. To our relief, the team at Rapid Digital Recovery was able to recover every single penny we had lost. The funds were returned in full, and the sense of closure we felt was invaluable. We couldn’t have imagined such a positive outcome in the early stages of our recovery journey, and we are deeply grateful for the work they did. If you ever find yourself in a similar situation, I highly recommend contacting Rapid Digital Recovery. Their expertise, transparency, and dedication to their clients make them the go-to choice for anyone seeking to recover lost cryptocurrency or funds. They truly gave us back our financial future.  
    • This is my first time modding anything, so maybe just skill issue. I'm using Forge 54.0.12 and Temurin 21.0.5+11-LTS I wanted to create a custom keybind and to check whether it works I'd like to send a chat message. I tried using Minecraft.getInstance().player.sendSystemMessage(Component.literal("test")); but IntelliJ couldnt resolve sendSystemMessage(...). Since I saw people using it in earlier versions, I tried the same thing with 1.20.6(- 50.1.0), where it works fine, now I can't figure out if this is intentional and whether there are other options for sending chat messages. On that note, is there more documentation than https://docs.minecraftforge.net/en/1.21.x/? It seems very incomplete compared to something like the Oracle Java docs
    • Hi, i'm having this error and I wanna fix it. we try: -Reload drivers -Eliminate .minecraft -Eliminate Java -Restart launcher -Verify if minecraft is using gpu -Mods  in .minecraft is empty -Install the latest and recomended version of forge idk what i have to do, help me pls. the lastest log is: https://mclo.gs/WAMao8x  
    • Read the FAQ, Rule #2. (https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/)  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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