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

Your message is being sent to the server, so you need to register it with Side.SERVER, not Side.CLIENT.

ย 

You put the movement code (and also the stack-damaging code) in the message handler's onMessage method, but I suggest you also keep your code that updates the client-side player motion - it will make the controls more responsive feeling.

  • Author

BTW - Thanks for not just giving up on me, it's much appreciated! :D

ย 

Ok, I'm very very very close :D!

ย 

EDIT: The server crashes even though I've done all the messages :'( It says:

ย 

If you can please could you post the code I need to do because these messages are so confusing....

ย 

ย 

net.minecraft.util.ReportedException: Ticking player

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:384) ~[EntityPlayerMP.class:?]

at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) ~[NetHandlerPlayServer.class:?]

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) ~[C03PacketPlayer.class:?]

at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:111) ~[C03PacketPlayer.class:?]

at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) ~[NetworkManager.class:?]

at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]

at net.minecraft.server.dedicated.DedicatedServer.updateTimeLightAndEntities(DedicatedServer.java:349) [DedicatedServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft

at com.koopamillion.Main.ServerProxy.keyBindJump(ServerProxy.java:40) ~[serverProxy.class:?]

at com.koopamillion.item.jetpack.onArmorTick(jetpack.java:38) ~[jetpack.class:?]

at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:355) ~[inventoryPlayer.class:?]

at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:610) ~[EntityPlayer.class:?]

at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816) ~[EntityLivingBase.class:?]

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327) ~[EntityPlayer.class:?]

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) ~[EntityPlayerMP.class:?]

... 10 more

Caused by: java.lang.ClassNotFoundException: net.minecraft.client.Minecraft

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) ~[launchwrapper-1.11.jar:?]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_73]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_73]

at com.koopamillion.Main.ServerProxy.keyBindJump(ServerProxy.java:40) ~[serverProxy.class:?]

at com.koopamillion.item.jetpack.onArmorTick(jetpack.java:38) ~[jetpack.class:?]

at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:355) ~[inventoryPlayer.class:?]

at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:610) ~[EntityPlayer.class:?]

at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816) ~[EntityLivingBase.class:?]

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327) ~[EntityPlayer.class:?]

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) ~[EntityPlayerMP.class:?]

... 10 more

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

at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:50) ~[forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) ~[launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ~[launchwrapper-1.11.jar:?]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_73]

at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_73]

at com.koopamillion.Main.ServerProxy.keyBindJump(ServerProxy.java:40) ~[serverProxy.class:?]

at com.koopamillion.item.jetpack.onArmorTick(jetpack.java:38) ~[jetpack.class:?]

at net.minecraft.entity.player.InventoryPlayer.decrementAnimations(InventoryPlayer.java:355) ~[inventoryPlayer.class:?]

at net.minecraft.entity.player.EntityPlayer.onLivingUpdate(EntityPlayer.java:610) ~[EntityPlayer.class:?]

at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:1816) ~[EntityLivingBase.class:?]

at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:327) ~[EntityPlayer.class:?]

at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) ~[EntityPlayerMP.class:?]

... 10 more

ย 

ย 

My proxy code and jetpack code:

ย 

ย 

@Override

public void onArmorTick(World world, EntityPlayer player, ItemStack stack){

if(stack.getItem() == Mitems.jetpack && MainRegistry.proxy.keyBindJump()){

JetpackMessage.sendToServer(new JetpackMessage(1));

/*int yaw = (int)player.rotationYaw;

ย 

ย  ย  ย  ย  if (yaw<0)ย  ย  ย  ย  ย  ย 

ย  ย  ย  ย  ย  yaw+=360;ย 

ย 

ย  ย  ย  ย  yaw+=22;ย  ย 

ย  ย  ย  ย  yaw%=360;ย 

ย 

ย  ย  ย  ย  int facing = yaw/45;ย  //ย  360degrees divided by 45 == 8 zones

ย  ย  ย 

ย 

ย  ย  if(facing == 0){

ย  ย  player.motionZ = 0.5;

ย  ย  }

ย  ย  if(facing == 1){

ย  ย  player.motionZ = 0.5;

ย  ย  player.motionX = -0.5;

ย  ย  }

ย  ย  if(facing == 2){

ย  ย  player.motionX = -0.5;

ย  ย  }

ย  ย  if(facing == 3){

ย  ย  player.motionX = -0.5;

ย  ย  player.motionZ = -0.5;

ย  ย  }

ย  ย  if(facing == 4){

ย  ย  player.motionZ = -0.5;

ย  ย  }

ย  ย  if(facing == 5){

ย  ย  player.motionZ = -0.5;

ย  ย  player.motionX = 0.5;

ย  ย  }

ย  ย  if(facing == 6){

ย  ย 

ย  ย  player.motionX = 0.5;

ย  ย  }

ย  ย  if(facing == 7){

ย  ย  player.motionZ = 0.5;

ย  ย  player.motionX = 0.5;

ย  ย  }

ย  ย  world.spawnParticle("flame", player.posX + 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

world.spawnParticle("flame", player.posX - 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

world.spawnParticle("largesmoke", player.posX + 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

world.spawnParticle("largesmoke", player.posX - 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

world.spawnParticle("lava", player.posX + 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

world.spawnParticle("lava", player.posX - 0.2, player.posY - 0.6, player.posZ - 0.2, 0, -0.3, 0);

ย 

player.motionY = 0.5;*/

Mitems.jetpack.setDamage(stack, Mitems.jetpack.getDamage(stack) + 1);

ย 

}

ย 

ย 

Proxy:

ย 

public boolean keyBindJump(){

return Minecraft.getMinecraft().gameSettings.keyBindJump.getIsKeyPressed();

}

ย 

ย 

Please can you help because I've setup messages and it's not working :(

ย 

THE CLIENT DOSENT CRASH.

ย 

But when you said the update code, what code do you mean?

ย 

ย 

  • Author

I really don't get this...ย  ???

ย 

New code:

ย 

Crashes... I think it's because it's returning null but I did a null != check. So I'm not sure... Plus even if I fix this event I think it will still bug out because Im using minecraft.getMinecraft... How do I fix this! Thanks in advance!

ย 

This is my jetpack event code: (I did register it with that fmlcommonhandler.register.bus thingy)

ย 

ย 

package com.koopamillion.Main;

ย 

import com.koopamillion.item.Mitems;

ย 

import cpw.mods.fml.common.eventhandler.SubscribeEvent;

import cpw.mods.fml.common.gameevent.TickEvent;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

ย 

public class JetpackEvent {

ย 

@SubscribeEvent

public void onClientTick(TickEvent.ClientTickEvent e){

if(e.phase == TickEvent.Phase.START) {

EntityPlayer player = Minecraft.getMinecraft().thePlayer;

ItemStack stack = player.getCurrentArmor(1);

if((stack != null && stack.getItem() == Mitems.jetpack && MainRegistry.proxy.keyBindJump())){

JetpackMessage.sendToServer(new JetpackMessage(1));

}else{

System.out.println(stack);

}}

ย 

}

}

ย 

ย 

ย 

Crash report:

ย 

ย 

[12:39:08] [Client thread/FATAL]: Unreported exception thrown!

java.lang.NullPointerException

at com.koopamillion.Main.JetpackEvent.onClientTick(JetpackEvent.java:17) ~[JetpackEvent.class:?]

at cpw.mods.fml.common.eventhandler.ASMEventHandler_13_JetpackEvent_onClientTick_ClientTickEvent.invoke(.dynamic) ~[?:?]

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?]

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) ~[EventBus.class:?]

at cpw.mods.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:325) ~[FMLCommonHandler.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1678) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?]

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]

at GradleStart.main(Unknown Source) [start/:?]

[12:39:08] [Client thread/INFO] [sTDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: ---- Minecraft Crash Report ----

// Oh - I know what I did wrong!

ย 

Time: 29/03/16 12:39

Description: Unexpected error

ย 

java.lang.NullPointerException: Unexpected error

at com.koopamillion.Main.JetpackEvent.onClientTick(JetpackEvent.java:17)

at cpw.mods.fml.common.eventhandler.ASMEventHandler_13_JetpackEvent_onClientTick_ClientTickEvent.invoke(.dynamic)

at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54)

at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138)

at cpw.mods.fml.common.FMLCommonHandler.onPreClientTick(FMLCommonHandler.java:325)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:1678)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)

at net.minecraft.client.Minecraft.run(Minecraft.java:962)

at net.minecraft.client.main.Main.main(Main.java:164)

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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

ย 

ย 

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

---

ย 

ย 

ย 

  • Author

OK, I've got it sending a message, thanks guys! But... Unfortunately I can't make the players motion change...

ย 

I've done sendToServer(bla bla) NOT sendTo(bla bla)

ย 

However, it's the onMessage that answers it, not the on server message, therefore I don't have a player parameter and can't make the player move... This is the handler:

ย 

ย 

package com.koopamillion.Main;

ย 

import cpw.mods.fml.common.network.simpleimpl.IMessage;

import cpw.mods.fml.common.network.simpleimpl.MessageContext;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

ย 

public class JetpackHandler extends AbstractServerMessageHandler<JetpackMessage>{

ย 

ย 

ย 

ย 

ย 

@Override

public IMessage handleServerMessage(EntityPlayer player, JetpackMessage message, MessageContext ctx) {

ย 

player.motionY = 0.5;

System.out.println(message.i);

ย 

return null;

}

ย 

ย 

@Override

public IMessage onMessage(JetpackMessage message, MessageContext ctx) {

ย 

ย 

System.out.println(message.i);

return null;

}

public void fly(EntityPlayer player, ItemStack stack){

player.motionY = 0.5;

}

}

ย 

ย 

ย 

The message:

ย 

ย 

package com.koopamillion.Main;

ย 

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

import cpw.mods.fml.common.network.simpleimpl.IMessage;

import io.netty.buffer.ByteBuf;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.EntityPlayerMP;

ย 

ย 

public class JetpackMessage implements IMessage{

ย 

public static int i;

ย 

public JetpackMessage() {}

ย 

ย  ย  public JetpackMessage(int i) {

ย  ย  ย  ย  this.i = i;

ย  ย  }

@Override

public void fromBytes(ByteBuf buf) {

ย 

i = buf.readInt();

}

ย 

@Override

public void toBytes(ByteBuf buf) {

buf.writeInt(i);

ย 

}

public static final void sendToServer(IMessage message) {

MainRegistry.network.sendToServer(message);

}

public static final void sendToServe(IMessage message, EntityPlayer player) {

MainRegistry.network.sendTo(message, (EntityPlayerMP) player);

}

ย 

ย 

}

ย 

ย 

ย 

And the jetpack event just does mainregistry.network.sendToServer(new JetpackMessage(1)).

ย 

So, how do I make it move the player.. Thanks in advance :)

ย 

Well...in

onMessage

you're not doing anything to make the player move.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.ย  If you think this is the case, JUST REPORT ME.ย  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

ย 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

ย 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Okay, but It dosen't do anything to the player... (But it is getting the correct player as I tested it with give experience)

ย 

My code on jetpack handler:

ย 

ย 

package com.koopamillion.Main;

ย 

import cpw.mods.fml.common.network.simpleimpl.IMessage;

import cpw.mods.fml.common.network.simpleimpl.MessageContext;

import net.minecraft.client.Minecraft;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

ย 

public class JetpackHandler extends AbstractServerMessageHandler<JetpackMessage>{

ย 

ย 

ย 

ย 

ย 

@Override

public IMessage handleServerMessage(EntityPlayer player, JetpackMessage message, MessageContext ctx) {

ย 

player.motionY = 0.5;

System.out.println(message.i);

ย 

return null;

}

ย 

ย 

@Override

public IMessage onMessage(JetpackMessage message, MessageContext ctx) {

ย 

ย 

this.fly(ctx.getServerHandler().playerEntity);

System.out.println(message.i);

return null;

}

public void fly(EntityPlayer player){

player.motionY = 0.5;

}

}

ย 

Thanks!ย 

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.