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

Sending Entity information to the Client


CreativeMD
 Share

Recommended Posts

Hi,

I made a Throwing Knife with different kinds of materials. The material is depedent on the itemID and every material differently. But when i render it the int itemID is 0.

But it shouldn't.

Is there a way of sending this int to the client?

 

public EntityThrow(World par1World, EntityLiving par2EntityLiving, float par3, ItemMaterial Material, int ID)
    {
    	super(par1World);
    	this.damage = Material.efficiency/1.5;
    	this.renderDistanceWeight = 10.0D;
        this.shootingEntity = par2EntityLiving;

        if (par2EntityLiving instanceof EntityPlayer)
        {
            this.canBePickedUp = 1;
        }
        
        this.itemID = ID;

        this.setSize(0.5F, 0.5F);
        this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.rotationPitch);
        this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
        this.posY -= 0.10000000149011612D;
        this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
        this.setPosition(this.posX, this.posY, this.posZ);
        this.yOffset = 0.0F;
        this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
        this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, par3 * 1.5F, 1.0F);
    }

Link to comment
Share on other sites

You may also need to create custom packets as well depending on what you want to do with the entity once you've created it.

Do what diesieben07 said and add the implements IEntityAdditionalSpawnData and the two methods required to read and write spawn data.

 

You basically just write in an order which pieces of data you want to load on the spawn and then read in the same order like

 

writeInt

writeInt

writeUTF

 

you need to read it the same order

 

readInt

readInt

readUTF

There's no place like ~/

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



×
×
  • Create New...

Important Information

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