Jump to content

Recommended Posts

Posted

This one I basically have working already. The Sapling is placed where it lands, but it would probably be better if I had it actually get planted and on the right block. Right now it gets placed on any block and on any side of the block. Not sure how to do a check for this within the Throwable Entity class.

  Actually, what I really wanted this to do originally was to act as bonemeal wherever it landed, Throwable Bonemeal. But I know that one is a bit more complicated so I settled on a sapling planter.

 

Entity:

 

protected void onImpact(MovingObjectPosition par1MovingObjectPosition)

    {

    if (!this.worldObj.isRemote)

        {

            /* if (par1MovingObjectPosition.entityHit != null)

            {

                if (!par1MovingObjectPosition.entityHit.isImmuneToFire()) //&& par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F))

                {

                    par1MovingObjectPosition.entityHit.setFire(5);

                }*/

            }

            else

            {

                int i = par1MovingObjectPosition.blockX;

                int j = par1MovingObjectPosition.blockY;

                int k = par1MovingObjectPosition.blockZ;

 

                switch (par1MovingObjectPosition.sideHit)

                {

                    case 0:

                        --j;

                        break;

                    case 1:

                        ++j;

                        break;

                    case 2:

                        --k;

                        break;

                    case 3:

                        ++k;

                        break;

                    case 4:

                        --i;

                        break;

                    case 5:

                        ++i;

                }

 

                if (this.worldObj.isAirBlock(i, j, k))

                {

               

                AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);

                    this.worldObj.setBlock(i, j, k, Block.sapling.blockID);

               

                }

            }

 

            this.setDead();

        }

 

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.