Jump to content

[SOLVED]Mod dosen't work on server ? Packet recieving and sending?


Recommended Posts

Posted
Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityClientPlayerMP

  at com.koopamillion.item.Mitems.initializeItem(Mitems.java:140)

  at com.koopamillion.item.Mitems.mainRegistry(Mitems.java:27)

  at com.koopamillion.Main.MainRegistry.PreLoad(MainRegistry.java:50)

 

Mitems.initializeItem

is referencing a client-only class on line 140. If you want more help, post the

Mitems

class.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I did, the second spoiler.

 

Ah, I missed that.

 

It looks like line 140 is where you instantiate

EPick

. Post this class.

 

In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.

 

It's much easier to read code with proper formatting and syntax highlighting.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

	public void onUpdate(ItemStack Stack, World world, Entity entity, int par4, boolean par5)
{

	EntityPlayer Player = Minecraft.getMinecraft().thePlayer;

 

What did you expect this to do on a server?  Minecraft is a client side class only.  Did you completely miss the third parameter?

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.

Posted

When the if statement's conditional is

true

, you know that the

entity

argument (the entity updating the item) is an instance of

EntityPlayer

. This means that you can safely cast

entity

to

EntityPlayer

.

 

As Draco said, never use the

Minecraft

class in common code. It's client-only and will crash the dedicated server (as you've seen).

 

Always add the

@Override

annotation to override methods so you get a compilation error if the method doesn't actually override a super method. Your IDE can also auto-generate override methods with the correct signature and the annotation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

So do I literally, after doing the instanceof if statement, just replace Player with entity and remove the getMinecraft thingy. If so, how do I cast, sorry, my mod dosen't require much casting so I'm not familiar with it.

 

EDIT:

 

I changed the code to this. (Something is in // to save time)

 

https://gist.github.com/anonymous/d59fc12ec923e7d018c7

 

will this crash the server?

 

P.S: You said to never use the Minecraft thingy, my jetpack uses it, how do I replace it?

 

https://gist.github.com/anonymous/b6e65790f34ee3ae4bb5

Posted

For your jetpack, you could make a method in your Proxy classes to check if the jump key is pressed, returning false from your CommonProxy and

Minecraft.getMinecraft().keyBindJump.getIsKeyPressed()

in your ClientProxy; then in your jetpack code, check

if (MyMod.proxy.isJumpKeyPressed())

instead of what you have now.

 

Note that it will still be client-side only, which is fine for messing around with the player's motion but not for damaging the itemstack nor for changing the player's inventory.

 

Really what you should be doing is sending a packet from the client to the server when the jump key is pressed and released, storing its current state on the server for each player, and calculating most of your stuff on the server. Can't spawn particles from there, though :P

Posted

Thanks! It seemed to work (the jetpack) but, do you know if what I changed the ePick to is correct?

It's okay, but it could be written better by following Java naming conventions (e.g. camelCase variable names). Also, the last boolean parameter of #onUpdate is a flag telling you whether the item is held or not, so you could use that, and the slot index is given to you as well:

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isHeld)

It's amazing how much having properly named variables helps understand the code.

@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isHeld) {
if (isHeld && entity instanceof EntityPlayer && stack.getItemDamage() >= 255) {
	((EntityPlayer) entity).inventory.setInventorySlotContents(slot, new ItemStack(yourItemHere));
}
}

Posted

One last thing, I can log on to the server and do stuff, however, when I put on the jetpack on the server, this error comes on: (I am using a modpack thats why there are other mods)

 

 

[19:39:34] [server thread/INFO]: Koopamillion joined the game

[19:39:34] [server thread/INFO] [EnderCore]: Sending server configs to client for com.enderio.core.common.config.ConfigHandler

[19:39:34] [server thread/INFO] [Waila]: Player EntityPlayerMP['Koopamillion'/4327, l='world', x=108.44, y=62.00, z=9.34] connected. Sending ping

[19:39:34] [server thread/INFO] [mcjty.lib.varia.Logging]: SMP: Player logged in: Sync diminfo to clients

[19:39:34] [server thread/INFO] [mcjty.lib.varia.Logging]: Sync dimension info to clients!

[19:39:34] [server thread/INFO] [mcjty.lib.varia.Logging]: Send validation data to the client

[19:39:36] [server thread/INFO] [sTDOUT]: [mcjty.lib.preferences.PreferencesProperties:syncToClient:38]: syncToClient: style = STYLE_FLAT_GRADIENT

[19:39:36] [server thread/WARN]: Failed to handle packet for /82.27.112.38:51261

net.minecraft.util.ReportedException: Ticking player

        at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:349) ~[mw.class:?]

        at net.minecraft.network.NetHandlerPlayServer.func_147347_a(NetHandlerPlayServer.java:303) ~[nh.class:?]

        at net.minecraft.network.play.client.C03PacketPlayer.func_148833_a(SourceFile:137) ~[jd.class:?]

        at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.func_148833_a(SourceFile:20) ~[jf.class:?]

        at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:212) ~[ej.class:?]

        at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:165) [nc.class:?]

        at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:659) [MinecraftServer.class:?]

        at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:334) [lt.class:?]

        at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:547) [MinecraftServer.class:?]

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

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

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

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

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

        at net.minecraft.entity.player.InventoryPlayer.func_70429_k(InventoryPlayer.java:319) ~[yx.class:?]

        at net.minecraft.entity.player.EntityPlayer.func_70636_d(EntityPlayer.java:538) ~[yz.class:?]

        at net.minecraft.entity.EntityLivingBase.func_70071_h_(EntityLivingBase.java:1611) ~[sv.class:?]

        at net.minecraft.entity.player.EntityPlayer.func_70071_h_(EntityPlayer.java:288) ~[yz.class:?]

        at net.minecraft.entity.player.EntityPlayerMP.func_71127_g(EntityPlayerMP.java:295) ~[mw.class:?]

        ... 10 more

[19:39:36] [server thread/INFO]: Koopamillion lost connection: TextComponent{text='Internal server error', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null}}

[19:39:36] [server thread/INFO]: Koopamillion left the game

 

 

Posted

Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/Minecraft
        at com.koopamillion.Main.ServerProxy.keyBindJump(ServerProxy.java:36) ~[serverProxy.class:?]

Same error as before, basically: don't use Minecraft class on the server! Your ServerProxy CANNOT access client-side only classes.

 

If you want to handle things on the server, you need to send a packet when the key is pressed and do whatever you need to do while handling that packet.

Posted

Sorry, but how do I approach sending and handling a packet? I've heard of s35packet in tileentity.

You won't be sending a vanilla packet, so you'll need to setup your own SimpleNetworkWrapper instance and create both an IMessage and an IMessageHandler for each specific type of action / data you want to send.

 

Keep in mind that a 'packet' is simply bits of data that is sent from one side to the other, allowing the different sides (client and server) to communicate with each other. Sometimes, a single bit is enough data, other times you need to send lots.

 

In your case, you could get by with a packet that doesn't send any data at all other than the packet ID (which is written and read automatically), e.g. PacketToggleJumpKey, whenever it is received server.jumpKeyState = !server.jumpKeyState, but you'd probably want to send the actual state (true or false).

Posted

Before you start writing your network code:

 

Don't use a single class for both the MessageHandler and the Message, you'll inevitably get the fields mixed up.

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.

Posted

Where abouts do I put the onKeyPressed? I've set up the IMessage and whatnot. Should I put it on onArmorTick so that it checks every tick? I'm really not getting these messages :'(

 

I've done this (It gives a crash):

Please can someone help because I really don't fix this is possible....? Thanks!

 

Crash report:

 

https://gist.github.com/anonymous/aac1dce291021eccf470

 

MainRegistry:

 

https://gist.github.com/anonymous/65177c244948f5a325ed

 

Message handler:

 

https://gist.github.com/anonymous/ad453cbe13f3b9f92c2a

 

Message Class:

 

https://gist.github.com/anonymous/b346dd147aedde0ef271

 

Jetpack:

 

https://gist.github.com/anonymous/76242c7b70515824361a

Posted

Neither your IMessageHandler attempt (which doesn't even implement that interface... -.-) nor your IMessage class are properly done. As for your crash, you didn't register any messages. Will you please just follow a network tutorial from start to finish?

 

@Draco Why does everyone think/say that? If done well, there won't be any chance at all of mixing anything up. See for example here, a message for which looks like this. As you can see, the IMessageHandler is completely generalized and reused for every message, allowing the IMessage to be totally self-contained. Makes for way nicer code, imo.

Posted
@Draco Why does everyone think/say that? If done well, there won't be any chance at all of mixing anything up.

 

"If done well" is the key phrase here.

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.

Posted

EDIT:

 

I have my key sensor, send to server and receive, anyway, it just says memory leak, top offenders my mod: 100.

 

Also where would I put the code to make the player move?

 

I'm using snw. My code:

 

Thanks!

 

Handler:

https://gist.github.com/anonymous/3b51310aa295b8fd8c3e

Message:

https://gist.github.com/anonymous/95f092beab1d3fd04466

MainRegistry:

https://gist.github.com/anonymous/6a442216ed510d724334

Jetpack (key sensor):

https://gist.github.com/anonymous/bfcd6131c6343a64e55e

 

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



×
×
  • Create New...

Important Information

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