Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Good evening everybody,

 

I am using a keybinding in my mod and I wanted to test on the server, but the server crash all the time.

 

My code:

 

KeyBinding class

 

 

public class RedKeyBinding{

public static int switchKey = Keyboard.KEY_H;

@SideOnly(Side.CLIENT)
public KeyBinding invert = new KeyBinding("Switch", switchKey, RedModInfo.ModName);

public RedKeyBinding(){
	ClientRegistry.registerKeyBinding(invert);
}

@SubscribeEvent
public void KeyInputEvent(KeyInputEvent event){

	Item[] items = new Item[]{RedTools.redSword, RedTools.redSwordCharged, RedTools.redPickaxe, RedTools.redPickaxeCharged, RedTools.redAxe, RedTools.redAxeCharged};

	if(invert.isPressed()){
		InventoryPlayer inventory = Minecraft.getMinecraft().thePlayer.inventory;
		InventoryPlayer inventoryMP = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(Minecraft.getMinecraft().thePlayer.getDisplayName()).inventory;

		for(int i = 0; i < items.length && inventory.getCurrentItem() != null; i += 2){
			if(inventory.getCurrentItem().getUnlocalizedName().equals(new ItemStack(items[i]).getUnlocalizedName())){
				inventory.setInventorySlotContents(inventory.currentItem, new ItemStack(items[i + 1], 1, inventory.getCurrentItem().getItemDamage()));
				inventoryMP.setInventorySlotContents(inventoryMP.currentItem, new ItemStack(items[i + 1], 1, inventory.getCurrentItem().getItemDamage()));
			}
			else if(inventory.getCurrentItem().getUnlocalizedName().equals(new ItemStack(items[i + 1]).getUnlocalizedName())){
				inventory.setInventorySlotContents(inventory.currentItem, new ItemStack(items[i], 1, inventory.getCurrentItem().getItemDamage()));
				inventoryMP.setInventorySlotContents(inventoryMP.currentItem, new ItemStack(items[i], 1, inventory.getCurrentItem().getItemDamage()));
			}
		}
	}
}
}

 

 

 

KeyHandler class

 

 

public class RedKeyHandler {

public static void init(){
	EventBus eventBus = FMLCommonHandler.instance().bus();
	eventBus.register(new RedKeyBinding());
	eventBus.register(new RedKeyHandler());
}
}

 

 

 

Crashreport

 

 

---- Minecraft Crash Report ----
// Don't be sad, have a hug! <3

Time: 07.03.14 20:34
Description: Exception in server tick loop

cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/minecraft/client/settings/KeyBinding
at cpw.mods.fml.common.LoadController.transition(LoadController.java:163)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:497)
at cpw.mods.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:78)
at cpw.mods.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:296)
at net.minecraft.server.dedicated.DedicatedServer.startServer(DedicatedServer.java:115)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:414)
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:706)
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/settings/KeyBinding
at at.minecraft.korti.invertredstonetools.utils.RedKeyBinding.<init>(RedKeyBinding.java:29)
at at.minecraft.korti.invertredstonetools.utils.RedKeyHandler.init(RedKeyHandler.java:12)
at at.minecraft.korti.invertredstonetools.RedstoneTools.preInit(RedstoneTools.java:33)
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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536)
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:47)
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.sendEventToModContainer(LoadController.java:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
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:47)
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:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:495)
... 5 more
Caused by: java.lang.ClassNotFoundException: net.minecraft.client.settings.KeyBinding
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:188)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 35 more
Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/settings/KeyBinding for invalid side SERVER
at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50)
at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:276)
at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:174)
... 37 more


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 7 (amd64) version 6.1
Java Version: 1.7.0_51, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 917219752 bytes (874 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.125.1039 Minecraft Forge 10.12.0.1039 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{7.2.125.1039} [Forge Mod Loader] (forgeBin-1.7.2-10.12.0.1039.jar) Unloaded->Constructed->Pre-initialized
Forge{10.12.0.1039} [Minecraft Forge] (forgeBin-1.7.2-10.12.0.1039.jar) Unloaded->Constructed->Pre-initialized
invertredstonetools{Alpha 0.1.1} [invert Redstone Tools] (bin) Unloaded->Constructed->Errored
Profiler Position: N/A (disabled)
Is Modded: Definitely; Server brand changed to 'fml,forge'
Type: Dedicated Server (map_server.txt)

 

 

 

Sorry for my bad english and a good weekend :D

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.