Jump to content

Recommended Posts

Posted

I am having some issues with the server updating the client as to its position.

 

 

My full project can be view here: https://github.com/allout58/SpaceCraft

 

 

Here is the code file for the entity in question:

EntityRocket.java

package allout58.mods.SpaceCraft.Rockets.Entity;


import java.util.Random;



import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import allout58.mods.SpaceCraft.Rockets.Rocket;


public class EntityRocket extends Entity
{
    Rocket rocketLogic;


    public EntityRocket(World world)
    {
        super(world);
        // this.preventEntitySpawning = true;
    }


    public EntityRocket(World par1World, Rocket rLogic, double x, double y, double z)
    {
        this(par1World);
        this.setPosition(x, y, z);
        rocketLogic = rLogic;
        rocketLogic.Launch();
    }


    @Override
    protected void readEntityFromNBT(NBTTagCompound nbttagcompound)
    {
         rocketLogic = new Rocket();
         rocketLogic.readFromNBT(nbttagcompound);
    }


    @Override
    protected void writeEntityToNBT(NBTTagCompound nbttagcompound)
    {
         rocketLogic.writeToNBT(nbttagcompound);
    }


    @Override
    public void onUpdate()
    {
        super.onUpdate();
        if (ticksExisted > 500) this.kill();
        if (rocketLogic == null) return;
        if (!worldObj.isRemote)
        {
            rocketLogic.tick();
            this.motionX = rocketLogic.velX;
            this.motionY = rocketLogic.velY;
            this.motionZ = rocketLogic.velZ;
        }
        setPosition(posX + motionX, posY + motionY, posZ + motionZ);
        if (worldObj.isRemote)
        {
            Random rand = new Random();
            for (int i = 0; i < (rocketLogic.Size.ordinal() + 1) * (2 - Minecraft.getMinecraft().gameSettings.particleSetting); i++)
            {
                worldObj.spawnParticle("flame", this.posX + rand.nextDouble() * (rand.nextBoolean() ? -1 : 1), this.posY - rand.nextDouble(), this.posZ + rand.nextDouble() * (rand.nextBoolean() ? -1 : 1), rand.nextInt(35) / 100 * (rand.nextBoolean() ? -1 : 1), -rand.nextDouble(), rand.nextInt(35) / 100 * (rand.nextBoolean() ? -1 : 1));
            }
        }
        System.out.println("Rocket entity-" + (worldObj.isRemote ? "Client" : "Server") + " x:" + posX + " y:" + posY + " z:" + posZ);


    }


    @Override
    protected void entityInit()
    {


    }
}

 

 

FYI, the class Rocket updates "velY" on "tick()". See the github for the full file.

 

 

Here is some of the output:

2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Server x:-594.5 y:246.40848585690674 z:-165.5
2013-09-02 23:24:43 [iNFO] [sTDOUT] Rocket entity-Client x:-594.5 y:231.5 z:-165.5

 

 

Thanks for any help you can give!

allout58

Posted

Is it your y spazzing out?

I think it's solved by doing yOffset = yOffset/3

I haven't tried it since 1.4 but it might still work :P

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Posted

thebest108: the y is the only one I am changing, but I set the motionX, motionY and motionZ to constants > 0 and client still wasn't moving. I can get the client to move, but not with the server.

 

 

GotoLink: yes, but after running a world.isRemote check. How else am I going to get the particle settings? The particles can only be spawned client side.

 

 

The particles are the real reason I want both client and server side. If I make sure that only the serverside entity is spawned, everything works fine but I can't spawn particles, and I really want particles...

allout58

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

    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
    • Yes, Attapoll offers a $20 Sign-up bonus for new users using a code (AOVCQ). Enter the Attapoll Referral Code “AOVCQ” and submit. Yes, Attapoll offers $20 Referral Code {AOVCQ} For New Customers. If you are who wish to join Attapoll, then you should use this exclusive Attapoll referral code $20 Signup Bonus Use this Code (AOVCQ) and get $20 Welcome Bonus. You can get a $20 Signup bonus use this referral code {AOVCQ}. You can get a $20 Attpoll Referral Code {AOVCQ}. This Attapoll $20 Referral code is specifically for existing customers and can be redeemed to receive a $20. Enter $20 Attapoll Referral Code {AOVCQ} at checkout. Enjoy $20Welcome Bonus. Use the best Attapoll referral code $20 (AOVCQ) to get up to $20 first time survey as a new user. Complete the survey and get $20 credited on your Attapoll account. Plus, refer your friend to earn 10% commission on their earning If you're on the hunt for a little extra cash or some cool rewards without too much hassle, you've landed in the right place. Today, we're diving into the world of Attapoll referral codes, a nifty way to boost your earnings while taking surveys. Use this Attapoll Referral Link or code {{AOVCQ}} to get a $20 sign up bonus.
  • Topics

×
×
  • Create New...

Important Information

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