Jump to content

Recommended Posts

Posted

 

Hi, could anyone help me with this problem?

I'm trying to register a simple command in my mod (server only)
and always from error

 

Main:
 

@Mod(modid = Version.MOD_ID, name = Version.NAME, version = Version.VERSION, acceptableRemoteVersions = "*", dependencies = "required-after:pixelmon")

public class NativeePixel {
  
	public PlayerStorage ps;
	public static World world;

	public static ArrayList lend = new ArrayList(Arrays.asList("Articuno", "Zapdos", "Moltres", "Mewtwo", "Mew",
			"Entei", "Raikou", "Suicune", "ho-oh", "Lugia", "Celebi", "regirock", "regice", "registeel", "latios",
			"latias", "Groudon", "Kyogre", "Rayquaza", "jirachi", "deoxys", "uxie", "azelf", "mesprit", "dialga",
			"palkia", "giratina", "cresselia", "darkrai", "manaphy", "phione", "heatran", "regigigas", "shaymin",
			"arceus", "victini", "cobalion", "terrakion", "virizion", "keldeo", "thundurus", "tornadus", "landorus",
			"zekrom", "reshiram", "kyurem", "genesect", "meloetta", "xerneas", "yveltal", "zygarde"));
	public static boolean isClient = true;
	@Mod.Instance("nativeepixelmon");
  
	public static NativeePixel instance;
	
	
	@Mod.EventHandler
	public void preinit(FMLPreInitializationEvent e) {
		
		FMLCommonHandler.instance().bus().register(new TickHandler());
		System.out.println("PreInitializationEvent.....");
		Configuration config = new Configuration(e.getSuggestedConfigurationFile());
		config.load();


	}

	@Mod.EventHandler
	public void init(FMLInitializationEvent e) {

		System.out.println("FMLInitializationEvent .....");
		isClient = e.getSide().isClient();

	}

	@Mod.EventHandler
	public void posinit(FMLPostInitializationEvent e) throws Exception {
		
		System.out.println("FMLPostInitializationEvent .....");


	}
	
	@Mod.EventHandler
	 public void serverLoad(FMLServerStartingEvent event)
	    {
	        System.out.println("=== FMLServerStartingEvent fired ===");
	        event.registerServerCommand(new CmdTest());
	    }

}

 

Class: 
 

public class CmdTest implements ICommand {


	@Override
	public int compareTo(Object arg0) {
		return 0;
	}

	@Override
	public String getCommandName() {
		return "nativee";
	}

	@Override
	public String getCommandUsage(ICommandSender sender) {
		return "/nativee";
	}

	@Override
	public List getCommandAliases() {
		List<String> aliases = new ArrayList();
		aliases.add("test2");
		aliases.add("test3");
		
		
		return aliases;
	}

	@Override
	public void processCommand(ICommandSender sender, String[] args) {
       if(sender instanceof EntityPlayer) {
    	   EntityPlayer p = (EntityPlayer) sender;
    	   System.out.println("aaaaaaaaaaaaaaaaaaaaaaaaaaaa");
    	   
       }

	}

	@Override
	public boolean canCommandSenderUseCommand(ICommandSender sender) {
		return true;
	}

	@Override
	public List addTabCompletionOptions(ICommandSender sender, String[] args) {
		return null;
	}

	@Override
	public boolean isUsernameIndex(String[] args, int ints) {
		return false;
	}

}

 

 

 

when I remove event.registerServerCommand(new CmdTest());  mod works

Posted

Class cmd:
 

import java.util.ArrayList;
import java.util.List;

import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText;

public class CmdTest extends CommandBase 
{

@Override
public String getCommandName() {
	return "nativee";
}
@Override
public String getCommandUsage(ICommandSender sender) {
	return "/nativee";
}
@Override
public void processCommand(ICommandSender sender, String[] args) {

	System.out.println("CMD TESTE");
	
}
}

New main: 
 

@Mod(modid = Version.MOD_ID, name = Version.NAME, version = Version.VERSION, acceptableRemoteVersions = "*", dependencies = "required-after:pixelmon")

public class NativeePixel {
  
	@Mod.Instance("nativeepixelmon")
	public static NativeePixel instance;
	  
	@Mod.EventHandler
	public void preinit(FMLPreInitializationEvent e) {
		MinecraftForge.EVENT_BUS.register(new TickHandler());
		System.out.println("PreInitializationEvent");
		Configuration config = new Configuration(e.getSuggestedConfigurationFile());
		config.load();
	}

	@Mod.EventHandler
	public void init(FMLInitializationEvent e) {
		System.out.println("FMLInitializationEvent....");	
	}

	@Mod.EventHandler
	public void posinit(FMLPostInitializationEvent e) {

		System.out.println("FMLPostInitializationEvent INICIADO Do NativeeYT.....");
		MinecraftForge.EVENT_BUS.register(new apis());

	}

	@Mod.EventHandler
	public void serverLoad(FMLServerStartingEvent event) {
		System.out.println("=== FMLServerStartingEvent fired ===");
       event.registerServerCommand(new CmdTest());
	}
}

console erro: 
 

[12:02:28] [Server thread/INFO]: === FMLServerStartingEvent fired ===
[12:02:28] [Server thread/ERROR]: Fatal errors were detected during the transition from SERVER_ABOUT_TO_START to SERVER_STARTING. Loading cannot continue
[12:02:28] [Server thread/ERROR]: 
	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
	UCHIJAAA	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
	UCHIJAAA	FML{7.10.99.99} [Forge Mod Loader] (Thermos1614.jar) 
	UCHIJAAA	Forge{10.13.4.1614} [Minecraft Forge] (Thermos1614.jar) 
	UCHIJAAA	kimagine{0.2} [KImagine] (minecraft.jar) 
	UCHIJAAA	pixelmon{3.5.0} [Pixelmon] (Pixelmon-1.7.10-3.5.1-universal.jar) 
	UCHIJAAE	nativeepixelmon{1.0} [Nativee Pixelmon] (Test.jar) 
[12:02:28] [Server thread/ERROR]: The following problems were captured during this phase
[12:02:28] [Server thread/ERROR]: Caught exception from nativeepixelmon
java.lang.AbstractMethodError
	at net.minecraft.command.CommandHandler.registerCommand(CommandHandler.java:154) ~[z.class:?]
	at net.minecraft.command.CommandHandler.func_71560_a(CommandHandler.java:143) ~[z.class:?]
	at cpw.mods.fml.common.event.FMLServerStartingEvent.registerServerCommand(FMLServerStartingEvent.java:45) ~[FMLServerStartingEvent.class:1.7.10-1614.58]
	at nativeepixel.NativeePixel.serverLoad(NativeePixel.java:186) ~[NativeePixel.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:1.7.10-1614.58]
	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[server-1.7.10.jar:?]
	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:1.7.10-1614.58]
	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:1.7.10-1614.58]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[server-1.7.10.jar:?]
	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:1.7.10-1614.58]
	at cpw.mods.fml.common.Loader.serverStarting(Loader.java:789) [Loader.class:1.7.10-1614.58]
	at cpw.mods.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:283) [FMLCommonHandler.class:1.7.10-1614.58]
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:368) [lt.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:643) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
[12:02:28] [Server thread/ERROR]: A fatal exception occurred during the server starting event
cpw.mods.fml.common.LoaderException: java.lang.AbstractMethodError

	at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) ~[LoadController.class:1.7.10-1614.58]
	at cpw.mods.fml.common.Loader.serverStarting(Loader.java:790) [Loader.class:1.7.10-1614.58]
	at cpw.mods.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:283) [FMLCommonHandler.class:1.7.10-1614.58]
	at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:368) [lt.class:?]
	at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:643) [MinecraftServer.class:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_151]
Caused by: java.lang.AbstractMethodError
	at net.minecraft.command.CommandHandler.registerCommand(CommandHandler.java:154) ~[z.class:?]
	at net.minecraft.command.CommandHandler.func_71560_a(CommandHandler.java:143) ~[z.class:?]
	at cpw.mods.fml.common.event.FMLServerStartingEvent.registerServerCommand(FMLServerStartingEvent.java:45) ~[FMLServerStartingEvent.class:1.7.10-1614.58]
	at nativeepixel.NativeePixel.serverLoad(NativeePixel.java:186) ~[NativeePixel.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) ~[FMLModContainer.class:1.7.10-1614.58]
	at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) ~[?:?]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[server-1.7.10.jar:?]
	at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[LoadController.class:1.7.10-1614.58]
	at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[LoadController.class:1.7.10-1614.58]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
	at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[server-1.7.10.jar:?]
	at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[server-1.7.10.jar:?]
	at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) ~[LoadController.class:1.7.10-1614.58]
	at cpw.mods.fml.common.Loader.serverStarting(Loader.java:789) ~[Loader.class:1.7.10-1614.58]
	... 4 more
[12:02:28] [Server thread/INFO]: Applying holder lookups
[12:02:28] [Server thread/INFO]: Holder lookups applied
[12:02:28] [Server thread/INFO]: The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded.
[12:02:28] [Server thread/INFO]: The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded.

 

  • Guest locked this topic
Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
  • Topics

×
×
  • Create New...

Important Information

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