Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Koopamillion
 Share

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

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • one mod you are using, overwrites the gold armor texture but there is an issue in the texture name. Unfortunately I can't tell you which mod exactly cause the crash 
    • How so? A couple of trigonometric functions can't possibly affect performance.
    • Minecraft Version-1.16.5 Forge Version-36.2.0   Crash Log-  https://gist.github.com/keepinitreal247/05669330de1d11fba00d1cbe565f35b1 Debug Log-https://gist.github.com/keepinitreal247/af4304598bd4192be840e8c111af2c81
    • When I try to open forge with java it says unable to install java but I can open java itself just fine. I've tried deleting and redownloading both forge and java but nothing changed. I also tried opening it from my files and from my desktop but it still gave me the same message. I don't think I'm doing anything wrong, I just click on forge and pressed open with java and java opens but only to give me the message saying " unable to install java there are errors in the following switches".   (this is just a picture of what i got from google not my exact message)
    • This is the capability inject and provider for one of my capabilities. All of them are coded the exact same way. public class CapabilityDamageTypes { @CapabilityInject(IDamageTypes.class) public static Capability<IDamageTypes> DAMAGE_TYPES_CAPABILITY = null; public static void register() { CapabilityManager.INSTANCE.register(IDamageTypes.class, new Storage(), new Factory()); } private static class Storage implements Capability.IStorage<IDamageTypes> { @Nullable @Override public INBT writeNBT(Capability<IDamageTypes> capability, IDamageTypes instance, Direction side) { CompoundNBT tag = new CompoundNBT(); tag.putFloat("slash", instance.getSlashDamage()); tag.putFloat("impact", instance.getImpactDamage()); tag.putFloat("puncture", instance.getPunctureDamage()); tag.putFloat("fire", instance.getFireDamage()); tag.putFloat("lightning", instance.getLightningDamage()); tag.putFloat("ice", instance.getIceDamage()); tag.putFloat("dark", instance.getDarkDamage()); tag.putFloat("holy", instance.getHolyDamage()); tag.putFloat("magic", instance.getMagicDamage()); tag.putString("mobDamageType", instance.getMobDamageType()); return tag; } @Override public void readNBT(Capability<IDamageTypes> capability, IDamageTypes instance, Direction side, INBT nbt) { float slash = ((CompoundNBT) nbt).getFloat("slash"); float impact = ((CompoundNBT) nbt).getFloat("impact"); float puncture = ((CompoundNBT) nbt).getFloat("puncture"); float fire = ((CompoundNBT) nbt).getFloat("fire"); float lightning = ((CompoundNBT) nbt).getFloat("lightning"); float ice = ((CompoundNBT) nbt).getFloat("ice"); float dark = ((CompoundNBT) nbt).getFloat("dark"); float holy = ((CompoundNBT) nbt).getFloat("holy"); float magic = ((CompoundNBT) nbt).getFloat("magic"); String mobDamageType = ((CompoundNBT) nbt).getString("mobDamageType"); instance.setSlashDamage(slash); instance.setImpactDamage(impact); instance.setPunctureDamage(puncture); instance.setFireDamage(fire); instance.setLightningDamage(lightning); instance.setIceDamage(ice); instance.setDarkDamage(dark); instance.setHolyDamage(holy); instance.setMagicDamage(magic); instance.setMobDamageType(mobDamageType); } } private static class Factory implements Callable<IDamageTypes> { @Override public IDamageTypes call() throws Exception { return new DamageTypes(0, 0, 0, 0, 0, 0, 0, 0, 0, "IMPACT"); } } } package com.cwjn.hardstuckintegration.Capabilities.DamageTypes; import net.minecraft.nbt.CompoundNBT; import net.minecraft.util.Direction; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.capabilities.ICapabilitySerializable; import net.minecraftforge.common.util.LazyOptional; import javax.annotation.Nonnull; import javax.annotation.Nullable; public class DamageTypesProvider implements ICapabilitySerializable<CompoundNBT> { //private final DamageTypes damage = new DamageTypes(); //private final LazyOptional<IDamageTypes> damageOptional = LazyOptional.of(() -> damage); private DamageTypes damage; private LazyOptional<IDamageTypes> damageOptional; public void invalidate() { damageOptional.invalidate(); } public DamageTypesProvider(float I, float P, float S, float F, float L, float IC, float D, float H, float M, String mobDamageType) { damage = new DamageTypes(I, P, S, F, L, IC, D, H, M, mobDamageType); damageOptional = LazyOptional.of(() -> damage); } @Nonnull @Override public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable Direction side) { return cap == CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY ? damageOptional.cast() : LazyOptional.empty(); } @Override public CompoundNBT serializeNBT() { if (CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY == null) { return new CompoundNBT(); } else { return (CompoundNBT) CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY.writeNBT(damage, null); } } @Override public void deserializeNBT(CompoundNBT nbt) { if (CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY != null) { CapabilityDamageTypes.DAMAGE_TYPES_CAPABILITY.readNBT(damage, null, nbt); } } }  
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.