Jump to content

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


Koopamillion

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

	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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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));
}
}

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

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.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Here is a tutorial from this same forum that I tried and kinda made work. Take into account that you will have to manage the offset (like rotation, and the offset relative to things like the main hand, offhand etc) by yourself and that can get very troublesome at times.  
    • I have done this now but have got the error:   'food(net.minecraft.world.food.FoodProperties)' in 'net.minecraft.world.item.Item.Properties' cannot be applied to                '(net.minecraftforge.registries.RegistryObject<net.minecraft.world.item.Item>)' public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register( "lemon_juice", () -> new Item( new HoneyBottleItem.Properties().stacksTo(1).food( (new FoodProperties.Builder()) .nutrition(3) .saturationMod(0.25F) .effect(() -> new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 1500), 0.01f ) .build() ) )); The code above is from the ModFoods class, the one below from the ModItems class. public static final RegistryObject<Item> LEMON_JUICE = ITEMS.register("lemon_juice", () -> new Item(new Item.Properties().food(ModFoods.LEMON_JUICE)));   I shall keep going between them to try and figure out the cause. I am sorry if this is too much for you to help with, though I thank you greatly for your patience and all the effort you have put in to help me.
    • I have been following these exact tutorials for quite a while, I must agree that they are amazing and easy to follow. I have registered the item in the ModFoods class, I tried to do it in ModItems (Where all the items should be registered) but got errors, I think I may need to revert this and figure it out from there. Once again, thank you for your help! 👍 Just looking back, I have noticed in your code you added ITEMS.register, which I am guessing means that they are being registered in ModFoods, I shall go through the process of trial and error to figure this out.
    • ♈+2349027025197ஜ Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join a brotherhood for protection and wealth here’s is your opportunity, but you should know there’s no ritual without repercussions but with the right guidance and support from this great temple your destiny is certain to be changed for the better and equally protected depending if you’re destined for greatness Call now for enquiry +2349027025197☎+2349027025197₩™ I want to join ILLUMINATI occult without human sacrificeGREATORLDRADO BROTHERHOOD OCCULT , Is The Club of the Riches and Famous; is the world oldest and largest fraternity made up of 3 Millions Members. We are one Family under one father who is the Supreme Being. In Greatorldrado BROTHERHOOD we believe that we were born in paradise and no member should struggle in this world. Hence all our new members are given Money Rewards once they join in order to upgrade their lifestyle.; interested viewers should contact us; on. +2349027025197 ۝ஐℰ+2349027025197 ₩Greatorldrado BROTHERHOOD OCCULT IS A SACRED FRATERNITY WITH A GRAND LODGE TEMPLE SITUATED IN G.R.A PHASE 1 PORT HARCOURT NIGERIA, OUR NUMBER ONE OBLIGATION IS TO MAKE EVERY INITIATE MEMBER HERE RICH AND FAMOUS IN OTHER RISE THE POWERS OF GUARDIANS OF AGE+. +2349027025197   SEARCHING ON HOW TO JOIN THE Greatorldrado BROTHERHOOD MONEY RITUAL OCCULT IS NOT THE PROBLEM BUT MAKE SURE YOU'VE THOUGHT ABOUT IT VERY WELL BEFORE REACHING US HERE BECAUSE NOT EVERYONE HAS THE HEART TO DO WHAT IT TAKES TO BECOME ONE OF US HERE, BUT IF YOU THINK YOU'RE SERIOUS MINDED AND READY TO RUN THE SPIRITUAL RACE OF LIFE IN OTHER TO ACQUIRE ALL YOU NEED HERE ON EARTH CONTACT SPIRITUAL GRANDMASTER NOW FOR INQUIRY +2349027025197   +2349027025197 Are you a pastor, business man or woman, politician, civil engineer, civil servant, security officer, entrepreneur, Job seeker, poor or rich Seeking how to join
  • Topics

×
×
  • Create New...

Important Information

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