Jump to content

Packet Issue[1.8.9]


JelloMOO

Recommended Posts

	public static class Handler implements IMessageHandler<MessageEntityMove, IMessage>
    {
        @Override
	public IMessage onMessage(final MessageEntityMove message,
	MessageContext ctx)
        { 
            IThreadListener mainThread = (IThreadListener) ctx.getServerHandler().playerEntity.worldObj;
            
		final EntityPlayerMP thePlayer = (EntityPlayerMP) YouLoyal.proxy.
		getPlayerEntityFromContext(ctx);
		final Entity theEntity = thePlayer.worldObj.
		getEntityByID(message.entityId);
            mainThread.addScheduledTask(new Runnable()
            {
			@Override
			public void run()
                {

 

This code is taken from a simple packet i made.

 

See what I'm trying to do is pick up a chicken and hold it in my hand. I use a packet to send the chicken's ID to the server so that I can mount the chicken on a bat that i'm constantly teleporting to the player's hand. However, after a while, the server loses the entity, and the chicken goes back to the position it's in before I picked it up. I checked the coords for the bat and the chicken, and I found that the bat isnt the problem.

The server will say that the chicken is in it's last position before it teleported back to its original position. So I'm seeing that the server lost the chicken's entity ID.

 

Would this be attributed to a problem with the piece of the packet I showed above?

 

If not, what would be causing this issue, and how do I fix it?

Link to comment
Share on other sites

	public static class Handler implements IMessageHandler<MessageEntityMove, IMessage>
    {
        @Override
	public IMessage onMessage(final MessageEntityMove message,
	MessageContext ctx)
        { 
            IThreadListener mainThread = (IThreadListener) ctx.getServerHandler().playerEntity.worldObj;
            
		final EntityPlayerMP thePlayer = (EntityPlayerMP) YouLoyal.proxy.
		getPlayerEntityFromContext(ctx);
		final Entity theEntity = thePlayer.worldObj.
		getEntityByID(message.entityId);
            mainThread.addScheduledTask(new Runnable()
            {
			@Override
			public void run()
                {

 

This code is taken from a simple packet i made.

 

See what I'm trying to do is pick up a chicken and hold it in my hand. I use a packet to send the chicken's ID to the server so that I can mount the chicken on a bat that i'm constantly teleporting to the player's hand. However, after a while, the server loses the entity, and the chicken goes back to the position it's in before I picked it up. I checked the coords for the bat and the chicken, and I found that the bat isnt the problem.

The server will say that the chicken is in it's last position before it teleported back to its original position. So I'm seeing that the server lost the chicken's entity ID.

 

Would this be attributed to a problem with the piece of the packet I showed above?

 

If not, what would be causing this issue, and how do I fix it?

Link to comment
Share on other sites

I mount the entity in another class, inside of a

    @SideOnly(Side.CLIENT)
    @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void onEvent(MouseEvent event)

 

event.

 

using this

 

.network.sendToServer(new MessageEntityPacket(ent.getEntityId()));

 

I successfully get the entity's ID and send it to the server, but only temporarily. It seems like it forgets after a while and teleports the entity back.

Link to comment
Share on other sites

I mount the entity in another class, inside of a

    @SideOnly(Side.CLIENT)
    @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
    public void onEvent(MouseEvent event)

 

event.

 

using this

 

.network.sendToServer(new MessageEntityPacket(ent.getEntityId()));

 

I successfully get the entity's ID and send it to the server, but only temporarily. It seems like it forgets after a while and teleports the entity back.

Link to comment
Share on other sites

What does this mean?

 

It means that you never picked it up on client?

 

Proper way:

Client:

1. Right click.

2. Ray trace for entity.

3. If entity was found and is in range (e.g 3 blocks), check if chicken.

4. Send packet containing ray traced chicken ID.

Server:

1. Receive packet, PASS NEW RUNNABLE TO SERVER THREAD: (next steps in runnable)

2. Get EntityPlayerMP from Context, get EntityLivingBase from entityId received.

3. Safety recheck - test if found EntityLivingBase is in proper distance, then check if it is actually EntityChicken.

4. Found instance of EntityChicken save as WeakReference on server side @Capability or IEntityExtendedProperties assigned to player who sent packet.

5. Use EntityTracker to update all players tracking player who picked up chicken with packet.

* Packet will containt entityId of: player who picked up chicken, chicken picked up.

Client: (all receivers)

1. Receive packet, PASS NEW RUNNABLE TO CLIENT THREAD: (next steps in runnable)

2. Set client side @Capability or IEntityExtendedProperties of RECEIVED (from packet's player's entityId) EntityPlayer to have reference to EntityChicken from entityId chicken received.

3. Additionally - since it may happen that new EntityPlayer will come up to you while you are alredy holding chicken - you need to notify them:

* Use PlayerEvent.StartTracking to update event.player about event.target (target is the EntityPlayer that would be holding chicken the moment someone else starts seeing him).

Both:

1. Now - use PlayerTickEvent (START or END) to move chicken on BOTH SIDES in such way it always fits player's Y coord and rotation (this is pure math).

 

This all will give you side-backed smooth movements of held Chicken on all clients seeing given player.

 

Note: It is also possible to totally perform all chicken movements from server, but idk how well that will do with smoothness. In that case you can remove all blue steps.

 

P.S: This is all theorycraft that will work (where I am not sure about blue part). I didn't have fun in field of moving entities for some time, so maybe server-only will work just as smooth as one could expect. Now when I think about it - it even should. For all I care yo ucould be even updating client side entities with RenderTickEvents lol (totally viable).

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

Link to comment
Share on other sites

What does this mean?

 

It means that you never picked it up on client?

 

Proper way:

Client:

1. Right click.

2. Ray trace for entity.

3. If entity was found and is in range (e.g 3 blocks), check if chicken.

4. Send packet containing ray traced chicken ID.

Server:

1. Receive packet, PASS NEW RUNNABLE TO SERVER THREAD: (next steps in runnable)

2. Get EntityPlayerMP from Context, get EntityLivingBase from entityId received.

3. Safety recheck - test if found EntityLivingBase is in proper distance, then check if it is actually EntityChicken.

4. Found instance of EntityChicken save as WeakReference on server side @Capability or IEntityExtendedProperties assigned to player who sent packet.

5. Use EntityTracker to update all players tracking player who picked up chicken with packet.

* Packet will containt entityId of: player who picked up chicken, chicken picked up.

Client: (all receivers)

1. Receive packet, PASS NEW RUNNABLE TO CLIENT THREAD: (next steps in runnable)

2. Set client side @Capability or IEntityExtendedProperties of RECEIVED (from packet's player's entityId) EntityPlayer to have reference to EntityChicken from entityId chicken received.

3. Additionally - since it may happen that new EntityPlayer will come up to you while you are alredy holding chicken - you need to notify them:

* Use PlayerEvent.StartTracking to update event.player about event.target (target is the EntityPlayer that would be holding chicken the moment someone else starts seeing him).

Both:

1. Now - use PlayerTickEvent (START or END) to move chicken on BOTH SIDES in such way it always fits player's Y coord and rotation (this is pure math).

 

This all will give you side-backed smooth movements of held Chicken on all clients seeing given player.

 

Note: It is also possible to totally perform all chicken movements from server, but idk how well that will do with smoothness. In that case you can remove all blue steps.

 

P.S: This is all theorycraft that will work (where I am not sure about blue part). I didn't have fun in field of moving entities for some time, so maybe server-only will work just as smooth as one could expect. Now when I think about it - it even should. For all I care yo ucould be even updating client side entities with RenderTickEvents lol (totally viable).

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

Link to comment
Share on other sites

	public static class Handler implements IMessageHandler<MessageEntityMove, IMessage>
    {
        @Override
	public IMessage onMessage(final MessageEntityMove message,
	final MessageContext ctx)
        { 
		// Know it will be on the server so make it thread-safe
            IThreadListener mainThread = (IThreadListener) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client
            

            mainThread.addScheduledTask(new Runnable()
            {
    			final EntityPlayerMP thePlayer = (EntityPlayerMP) blessup.proxy.
    					getPlayerEntityFromContext(ctx);
    			final Entity theEntity = thePlayer.worldObj.getEntityByID(message.entityId);
    			final WeakReference<Entity> ent1 = new WeakReference<Entity>(theEntity);

 

So I did this.

 

It didn't quite fix my issue unfortunately.

 

What am I doing wrong?

 

EDIT:

 

Using the weak reference really gave me the entity position and I found that the problem was in how I was mounting the entity on the bat. I didnt mount it in the packet like I should have.

 

So now the entity is truly mounted.

 

 

There seems to be some server lag. Is that normal with this? I'll do some more testing and report back here before setting this to solved.

Link to comment
Share on other sites

	public static class Handler implements IMessageHandler<MessageEntityMove, IMessage>
    {
        @Override
	public IMessage onMessage(final MessageEntityMove message,
	final MessageContext ctx)
        { 
		// Know it will be on the server so make it thread-safe
            IThreadListener mainThread = (IThreadListener) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client
            

            mainThread.addScheduledTask(new Runnable()
            {
    			final EntityPlayerMP thePlayer = (EntityPlayerMP) blessup.proxy.
    					getPlayerEntityFromContext(ctx);
    			final Entity theEntity = thePlayer.worldObj.getEntityByID(message.entityId);
    			final WeakReference<Entity> ent1 = new WeakReference<Entity>(theEntity);

 

So I did this.

 

It didn't quite fix my issue unfortunately.

 

What am I doing wrong?

 

EDIT:

 

Using the weak reference really gave me the entity position and I found that the problem was in how I was mounting the entity on the bat. I didnt mount it in the packet like I should have.

 

So now the entity is truly mounted.

 

 

There seems to be some server lag. Is that normal with this? I'll do some more testing and report back here before setting this to solved.

Link to comment
Share on other sites

Alright, new issue.

 

When I put down the chicken, it creates a copy of the chicken, making two chickens, and they walk in sync with each other.

 

What on earth is happening?

 

It appears that when I kill the chickens, the original will die, but the copy will stay.

 

However, this is where it gets creepy.

The copy doesn't stay alive.

 

You know when you kill an animal and it turns over and it's color becomes red right before it disappears?

 

Well, the chicken copy does that, except it doesn't disappear. It stays there.

Forever.

 

Seriously, what dimension did I just walk into?

Whats happening?

Link to comment
Share on other sites

Alright, new issue.

 

When I put down the chicken, it creates a copy of the chicken, making two chickens, and they walk in sync with each other.

 

What on earth is happening?

 

It appears that when I kill the chickens, the original will die, but the copy will stay.

 

However, this is where it gets creepy.

The copy doesn't stay alive.

 

You know when you kill an animal and it turns over and it's color becomes red right before it disappears?

 

Well, the chicken copy does that, except it doesn't disappear. It stays there.

Forever.

 

Seriously, what dimension did I just walk into?

Whats happening?

Link to comment
Share on other sites

Dude, what are you doing? What are you doing with that WeakReference? Is needs to be saved INSIDE PLAYER. My prev post explains step by step what you should do.

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

Link to comment
Share on other sites

Dude, what are you doing? What are you doing with that WeakReference? Is needs to be saved INSIDE PLAYER. My prev post explains step by step what you should do.

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

Link to comment
Share on other sites

You need the reference inside the capability not the packet handler.

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

You need the reference inside the capability not the packet handler.

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

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

    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
    • Let me try and help you with love spells, traditional healing, native healing, fortune telling, witchcraft, psychic readings, black magic, voodoo, herbalist healing, or any other service your may desire within the realm of african native healing, the spirits and the ancestors. I am a sangoma and healer. I could help you to connect with the ancestors , interpret dreams, diagnose illness through divination with bones, and help you heal both physical and spiritual illness. We facilitate the deepening of your relationship to the spirit world and the ancestors. Working in partnership with one\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’s ancestors is a gift representing a close link with the spirit realm as a mediator between the worlds.*   Witchdoctors, or sorcerers, are often purveyors of mutis and charms that cause harm to people. we believe that we are here for only one purpose, to heal through love and compassion.*   African people share a common understanding of the importance of ancestors in daily life. When they have lost touch with their ancestors, illness may result or bad luck. Then a traditional healer, or sangoma, is sought out who may prescribe herbs, changes in lifestyle, a career change, or changes in relationships. The client may also be told to perform a ceremony or purification ritual to appease the ancestors.*   Let us solve your problems using powerful African traditional methods. We believe that our ancestors and spirits give us enlightenment, wisdom, divine guidance, enabling us to overcome obstacles holding your life back. Our knowledge has been passed down through centuries, being refined along the way from generation to generation. We believe in the occult, the paranormal, the spirit world, the mystic world.*   The services here are based on the African Tradition Value system/religion,where we believe the ancestors and spirits play a very important role in society. The ancestors and spirits give guidance and counsel in society. They could enable us to see into the future and give solutions to the problems affecting us. We use rituals, divination, spells, chants and prayers to enable us tackle the task before us.*   I have experience in helping and guiding many people from all over the world. My psychic abilities may help you answer and resolve many unanswered questions
  • Topics

×
×
  • Create New...

Important Information

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