Jump to content

Throwable Entity that plants Sapling


Recommended Posts

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.




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))







                int i = par1MovingObjectPosition.blockX;

                int j = par1MovingObjectPosition.blockY;

                int k = par1MovingObjectPosition.blockZ;


                switch (par1MovingObjectPosition.sideHit)


                    case 0:



                    case 1:



                    case 2:



                    case 3:



                    case 4:



                    case 5:




                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);








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.

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.


  • Create New...

Important Information

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