Jump to content

[1.7.10] When running on dedicated server I get no such method error


Thornack

Recommended Posts

When I test my mod on a dedicated server and when I trigger the method that transforms the player into his party member I get a no such method error (this doesnt happen in LAN or when in singleplayer)

 

I have a getMob function, this function gets the entity that the player spawned from his party list by comparing the uuids the player knows with the uuids of entities from the world

//this function gives me a no such method error when I run the server and when player morphs
public static Entity getMob(World world, EntityPlayer player) {
	PlayerParty ppp = PlayerParty.get(player);
	for (Object object : world.getLoadedEntityList()) {
		if (object instanceof EntityPartyMember) {
			EntityPartyMember entity = (EntityPartyMember) object;
			long uuidMost = ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDMost");
			long uuidLeast =ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDLeast");
			if (entity.getUniqueID().getMostSignificantBits() == uuidMost && entity.getUniqueID().getLeastSignificantBits() == uuidLeast) {
			return entity;
			}
		}
	}
	System.out.println("DID NOT FIND ENTITY: Entity is Null");
	return null;
}

 

I have a morph function, this function swaps positions with the entity the player is transforming into and triggers a model/texture switch and will in the future switch their stats and all of that The way it works is as follows

 

 

    /** The morph method is called from the process method on server side only inside my PacketMorphBtnPressed and the PacketPWReturnBtnPressed classes

        * (where these packets are sent to notify server of GUI btn presses and are sent from Client to Server (the process method in these classes is Server side only))

*  The method takes a boolean as a parameter and it uses a helper method to get the spawned party member by its UUID, it passes the value

*  of the boolean to the setMorphedIntoPlayer method so that the party member entities' model can be updated depending on

*  the boolean's value and also uses this boolean to morph or un-morph the player (switch or switch back), it also swaps the positions of the party member with its owner       

        *  player to simulate a player swap.

*  @PARAM boolean shouldBeMorphed

*/

 

 

For some reason the helper method gives me a no such method exception when I run dedicated server and test. This method is located inside my BattlePlayerProperties class which is a IEEP class that adds additional stuff to the player

public void morph(boolean shouldBeMorphed){
	if(shouldBeMorphed){
	System.out.println("Morphing");
	} else{
	System.out.println("Returning");
	}
	EntityPartyMember morphPartyMember = (EntityPartyMember) WorldHelper.getMob(player.worldObj, player); //this line gives me a no such method error when I run the           server and test Im not sure why This is happening
	morphPartyMember.setMorphedIntoPlayer(shouldBeMorphed);
	double preMorphPosX = this.player.posX;
	double preMorphPosY = this.player.posY;
	double preMorphPosZ = this.player.posZ;
	this.player.setPositionAndUpdate(morphPartyMember.posX, morphPartyMember.posY, morphPartyMember.posZ);
	this.player.prevPosX = morphPartyMember.posX;
	this.player.prevPosY = morphPartyMember.posY;
	this.player.prevPosZ = morphPartyMember.posZ;
	morphPartyMember.setPosition(preMorphPosX, preMorphPosY, preMorphPosZ);
	morphPartyMember.prevPosX = preMorphPosX;
	morphPartyMember.prevPosY = preMorphPosY;
	morphPartyMember.prevPosZ = preMorphPosZ;

}

 

The consol error log (Please let me know if I have provided enough code/info about this error)

 

 

java.lang.NoSuchMethodError: net.minecraft.world.World.getLoadedEntityList()Ljava/util/List;

at custommod.battle.helper.WorldHelper.getMob(WorldHelper.java:145) ~[WorldHelper.class:?]

at custommod.player.properties.BattlePlayerProperties.morph(BattlePlayerProperties.java:172) ~[battlePlayerProperties.class:?]

at custommod.battle.network.PacketMorphBtnPressed.process(PacketMorphBtnPressed.java:36) ~[PacketMorphBtnPressed.class:?]

at custommod.battle.network.AbstractMessageOverlord.onMessage(AbstractMessageOverlord.java:77) ~[AbstractMessageOverlord.class:?]

at custommod.battle.network.AbstractMessageOverlord.onMessage(AbstractMessageOverlord.java:1) ~[AbstractMessageOverlord.class:?]

at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:37) ~[simpleChannelHandlerWrapper.class:?]

at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:17) ~[simpleChannelHandlerWrapper.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[simpleChannelInboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:101) ~[simpleChannelInboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:101) ~[simpleChannelInboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:101) ~[simpleChannelInboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:101) ~[simpleChannelInboundHandler.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[MessageToMessageDecoder.class:?]

at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]

at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]

at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]

at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]

at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.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:?]

[19:06:49] [server thread/INFO]: Player437 lost connection: TextComponent{text='A fatal error has occured, this connection is terminated', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null}}

[19:06:49] [server thread/INFO]: Player437 left the game

 

 

 

Link to comment
Share on other sites

Now I understand that my getMob function is taxing, I havent been able to find a way around using it which sucks. If anyone has any ideas as to how to achieve that I would gladly appreciate any input.

 

As Always Thanks for reading the post :)

Link to comment
Share on other sites

World#getLoadedEntityList() is for client side only, and you're trying to call it on server side.

I'm not the best person with determining Sided things, but I do know that client only means it cannot be run on a dedicated server. You should use your proxy to make sure that it is the client side, and not the server. I've had to do that with several things.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

I changed it by adding the following to client proxy

public static List getLoadedEntityList(World world){
	return world.getLoadedEntityList();
}

 

and then

 

public static Entity getMob(World world, EntityPlayer player) {
	PlayerParty ppp = PlayerParty.get(player);
	for (Object object : ClientProxy.getLoadedEntityList()) {
		if (object instanceof EntityPartyMember) {
			EntityPartyMember entity = (EntityPartyMember) object;
			long uuidMost = ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDMost");
			long uuidLeast =ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDLeast");
			if (entity.getUniqueID().getMostSignificantBits() == uuidMost && entity.getUniqueID().getLeastSignificantBits() == uuidLeast) {
			return entity;
			}
		}
	}
	System.out.println("DID NOT FIND ENTITY: Entity is Null");
	return null;
}

 

but I still get a crash this time it is a java.lang.NoClassDefFoundError: net/minecraft/client/entity/EntityClientPlayerMP but this is from the server thread nothing is printed to consol.

at custommod.battle.helper.WorldHelper.getMob(WorldHelper.java:145) ~[WorldHelper.class:?]

Link to comment
Share on other sites

Does anyone know of a better way to get an entity by its UUID when you are on the server?

Oh, if that's what you're doing, the function already exists.

Use World.getPlayerEntityByUUID(); It's not restricted to either side. That way, you don't have to loop through all the entities.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

Im not looking to get the Player by UUID I want a spawned entity for which the player has a UUID. My Player has a list of party members all of which he knows UUID's for all the time. I want to get the entity from the UUID the player knows when the entity is in the world. I want this done on server side Also World.getPlayerEntityByUUID() isnt a method in 1.7.10 I dont think (I only found World # getPlayerEntityByName())

Link to comment
Share on other sites

Im not looking to get the Player by UUID I want a spawned entity for which the player has a UUID. My Player has a list of party members all of which he knows UUID's for all the time. I want to get the entity from the UUID the player knows when the entity is in the world. I want this done on server side

That function will still work for that. It is not limited to the client entity player, it searches through every single instance of an EntityPlayer in the world, by using the list World.playerEntities. This means that if you are on a server, it checks every single player that is currently logged into that world, and returns them if they match the UUID.

 

Edit: I just noticed you said that the function does not exist in 1.7.10. Does the field World.entityPlayers exist?

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

Im not looking for Players though. I am looking for EntityCustomMob not EntityPlayer.

Is this what you are looking for?

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2136028-get-entity-by-uuid?comment=6

If I helped please press the Thank You button.

 

Check out my mods at http://www.curse.com/users/The_Fireplace/projects

Link to comment
Share on other sites

Im not looking for Players though. I am looking for EntityCustomMob not EntityPlayer.

It seems just the accessor method is client only. Have you tried using World.loadedEntityList directly?

 

i.e.:

 

public static Entity getMob(World world, EntityPlayer player) {
	PlayerParty ppp = PlayerParty.get(player);
	for (Object object : world.loadedEntityList) {
		if (object instanceof EntityPartyMember) {
			EntityPartyMember entity = (EntityPartyMember) object;
			long uuidMost = ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDMost");
			long uuidLeast =ppp.getEntityPartyMemberNBTFromSlot(ppp.getSpawnedSlot()).getLong("UUIDLeast");
			if (entity.getUniqueID().getMostSignificantBits() == uuidMost && entity.getUniqueID().getLeastSignificantBits() == uuidLeast) {
			return entity;
			}
		}
	}
	System.out.println("DID NOT FIND ENTITY: Entity is Null");
	return null;

That may work, I'm not 100% sure if loadedEntityList is set to public in 1.7.10

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

 
/** A list of all Entities in all currently-loaded chunks */
    public List loadedEntityList = new ArrayList();

Ya it is public I think ill try that and letcha know if it works. I do want to eventually figure out a better way of getting my entity while on server side

 

EDIT: Yes that worked thanks alot!

Link to comment
Share on other sites

Im not looking for Players though. I am looking for EntityCustomMob not EntityPlayer.

Is this what you are looking for?

http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2136028-get-entity-by-uuid?comment=6

 

That is exactly what I am doing currently and it now works on dedicated server and on single player too. However I want a more efficient way of getting my entity since using that method you are scanning through all entities and if there is 5000+ on a server this is taxing. very inefficient.

Link to comment
Share on other sites

That is exactly what I am doing currently and it now works on dedicated server and on single player too. However I want a more efficient way of getting my entity since using that method you are scanning through all entities and if there is 5000+ on a server this is taxing. very inefficient.

Since they are not actually players, have you tried just using World.getEntityById()? Every time an entity is created, it is assigned an id that stays the same until it dies. You might could use that. Instead of saving the UUID, you can just save the regular ID. I'm not sure if entity IDs persist over world saves, though. I never really tested that.

 

Edit:

Looking at the code, I don't think they are saved. So, logging out and logging back in would reload all entities with new IDs. If you want them to be remembered over world saves, just keep using what you were.

With all due respect, sir: I do, what I do, the way I do it. ~ MacGyver

Link to comment
Share on other sites

That is exactly what I am doing currently and it now works on dedicated server and on single player too. However I want a more efficient way of getting my entity since using that method you are scanning through all entities and if there is 5000+ on a server this is taxing. very inefficient.

Since they are not actually players, have you tried just using World.getEntityById()? Every time an entity is created, it is assigned an id that stays the same until it dies. You might could use that. Instead of saving the UUID, you can just save the regular ID. I'm not sure if entity IDs persist over world saves, though. I never really tested that.

 

Edit:

Looking at the code, I don't think they are saved. So, logging out and logging back in would reload all entities with new IDs. If you want them to be remembered over world saves, just keep using what you were.

 

Ya it is unfortunate that they dont persist otherwise I would use that. Ill be thinking of ways to improve this cause it isnt good atm scanning all Entities in all loaded chunks is a bad idea I think. Even though my method is called once in forever pretty much even if the player spams the morph/unmorph buttons, I still want a more efficient way of getting the entity cause if 5000 players decide to spam then there may be issues. Its just inefficient and Ill bet there is a better way. For now unless I get any ideas ill be working on other stuff. Again if anyone comes up with a better solution please post, I see this get entity by UUID issue alot in the forums and it seems no one's found anything thats really good and efficient I dont think.

Link to comment
Share on other sites

Thorny - I alredy told you, comparing even 10000 UUIDs is NOTHING if done per-call.

 

Computers are capable of computing shitload of data, don't worry about something like this.

 

As to better solutions - I've also alredy told you - only way to do it faster is to make smart caching of direct entity references.

Again there is no point.

Best thing to do is simpl cut down everything irrelevant. Pseudo:

 

optional: check smart cache - one I mentioned, first see if you can grab entity on instant, if not, go further.

for loop on world.entities

if (entity instanceof YourEntity) // checking instanceof is like x+y, cmon man!

now you compare UUIDs

1.7.10 is no longer supported by forge, you are on your own.

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



×
×
  • Create New...

Important Information

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