Jump to content

[SOLVED] FMLInitializationEvent not firing


chylex

Recommended Posts

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 :)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :)

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Wait guys, I still don't don't understand... I shall send my code -- Define the function to decrease hunger local function decreaseHunger(player)     local currentHunger = player.getHunger()          -- Check if hunger is not already zero     if currentHunger > 0 then         player.setHunger(currentHunger - 1)     end end -- Register event to decrease hunger over time script.registerEvent(EntityPlayer, function(player)     while true do         -- Decrease hunger every few seconds         decreaseHunger(player)         script.sleep(1000) -- Sleep for 1 second     end end)     Any help appriecated. It's been a while since I learnt Javascript or whatever Minecraft is made with... ... ... ... Nicknotname Hungerinpeaceful xx
    • good days  i get this error: java.lang.ClassCastException: class net.minecraft.client.player.LocalPlayer cannot be cast to class net.minecraftforge.common.extensions.IForgeServerPlayer (net.minecraft.client.player.LocalPlayer is in module minecraft@1.20.4 of loader 'TRANSFORMER' @3e8b3b79; net.minecraftforge.common.extensions.IForgeServerPlayer is in module forge@49.0.26 of loader 'TRANSFORMER' @3e8b3b79)     at mercmod.blocks.classes.panel_whit_entity_inside.use(panel_whit_entity_inside.java:576) ~[main/:?] {re:classloading}     at net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase.use(BlockBehaviour.java:826) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading}     at net.minecraft.client.multiplayer.MultiPlayerGameMode.performUseItemOn(MultiPlayerGameMode.java:324) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.multiplayer.MultiPlayerGameMode.lambda$useItemOn$4(MultiPlayerGameMode.java:292) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.multiplayer.MultiPlayerGameMode.startPrediction(MultiPlayerGameMode.java:251) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.multiplayer.MultiPlayerGameMode.useItemOn(MultiPlayerGameMode.java:291) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.startUseItem(Minecraft.java:1799) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.handleKeybinds(Minecraft.java:2083) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.tick(Minecraft.java:1902) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.runTick(Minecraft.java:1216) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.Minecraft.run(Minecraft.java:801) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A}     at net.minecraft.client.main.Main.main(Main.java:234) ~[forge-1.20.4-49.0.26_mapped_official_1.20.4-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} ------------------------------------------------------------------------------------------------------------------   context:  im updating the briefcase from mi mod an i need to make a gui whit this image that gonna be launched from a block and from a item soo im using kapenjoe tutorials  ---------------------------------------------------------------------------------------- The problem is that tutorial is for 1.20.1 and im using 1.20.4 and i really dont get how to call and open the gui from the block nor from the item i made this based on post i made short ago everything seems find but when right click the block to open the gui it crash the game  @Override public InteractionResult use(BlockState blkstate, Level warudo, BlockPos pos, Player pe, InteractionHand hand, BlockHitResult hitresult) {     if(warudo.isClientSide()){         BlockEntity blkentity = warudo.getBlockEntity(pos);         if(blkentity instanceof Panel_BlockEntity){             //   ↓↓↓  open the menu from the block              IForgeServerPlayer ifpe = (IForgeServerPlayer)pe; //<--- this is wrong  "class net.minecraft.client.player.LocalPlayer cannot be cast to class net.minecraftforge.common.extensions.IForgeServerPlayer"             ifpe.openMenu( (Panel_BlockEntity) blkentity, pos ); //<-- i need an example of how open a gui in 1.20.4         }     } return InteractionResult.sidedSuccess(warudo.isClientSide()); } Theres nothing highlighted in red in the code like everything where right an possible but dont works  ####################################################################################################### i need to see an example, just the piece of code for the use() method of the block whit the block entity for 1.20.4  and the same  but for the item     @Override     public @NotNull InteractionResultHolder<ItemStack> use(@NotNull Level warudo, @NotNull Player pe, @NotNull InteractionHand interactionHand)     {         if (!warudo.isClientSide())         {             ItemStack heldItem = pe.getItemInHand(interactionHand);                          if (heldItem.getCapability(ForgeCapabilities.ITEM_HANDLER).isPresent())             {                 //   ↓↓↓  open the menu from the item                 NetworkHooks.openScreen((ServerPlayer) pe, this);             }         }         return super.use(warudo, pe, interactionHand);     }   thanks for your attention           
    • It depends on the data you want to save, but generally speaking you should use some custom Player Capabilities, attach to the Player and use them to store/retrieve any kind of data you want. You can find how to make them work for 1.20.x in the documentation here: https://docs.minecraftforge.net/en/latest/datastorage/capabilities/
  • Topics

×
×
  • Create New...

Important Information

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