Boomerang type projectile

Started by KBEHAN on

Topic category: Help with modding (Java Edition)

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Boomerang type projectile
Sat, 12/31/2016 - 01:09 (edited)

Hey, it's me again here with another complex idea I need help with.

 

I want my entity throwable to have a boomerang type function.  So I kind of know the function of this.  I have code for damaging the entity.  But I need help with actual code for the rest of it.  here is my idea for the mechanic:

so,  entity throwable dissapears when it hits a block or entity is because of set dead.  what I need is to delete that part (I need it later though) and add in a motion, so in place of set dead when it hits a block or entity it has a motion. When it hits an entity or a block the motion will return/be backwards.  Then I need CollideWithPlayer that will 1. Set dead the entity and 2. give the player the item back. 

If anyone wants to help or has code or something please reply.  I am working in 1.7.10  version.

Edited by KBEHAN on Sat, 12/31/2016 - 01:09
Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:RE:1st no , it is must be
Mon, 01/16/2017 - 16:48

@#19.1

 

boolean hasCollided = false;
@Override
public void onUpdate() {
  if(hasCollided){
    super.onUpdate();
    inAirTicks++;
      if(inAirTicks > 60){
        setDead();
      }
  }
}

 

this does not work, I am not sure If I did it correctly though.

Last seen on 22:13, 3. Apr 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did you set the bool on
Mon, 01/16/2017 - 17:08

Did you set the bool on collision to true?

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Did you set the bool on
Mon, 01/16/2017 - 17:10

@#20

boolean hasCollided = true;
@Override
public void onUpdate() {
  if(hasCollided){
    super.onUpdate();
    inAirTicks++;
      if(inAirTicks > 60){
        setDead();
      }
  }
}

Last seen on 22:13, 3. Apr 2024
Joined Aug 2013
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I mean on collison with
Mon, 01/16/2017 - 17:21

I mean on collison with entity!

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hmm, So i have been trying
Tue, 01/24/2017 - 15:54

Hmm, So i have been trying for a 3 weeks now, trying to have it so when my projectile hits the player it setDead and gives the player an item.  I tried but could not get mop instance of entity player to work, so I am trying this:

 

private void returnToPlayer(boolean catched)
{
if (this.shootingEntity instanceof EntityPlayer)
{    
            EntityPlayer player = (EntityPlayer)this.shootingEntity;
            if (!player.inventory.addItemStackToInventory(this.inventory.get(mcreator_stevensShield.block)));
            {
                if(!this.worldObj.isRemote)
                    this.worldObj.spawnEntityInWorld(
                            new EntityItem(
                                    this.worldObj
                                    , (catched)? this.posX : this.shootingEntity.posX
                                    , (catched)? this.posY : this.shootingEntity.posY
                                    , (catched)? this.posZ : this.shootingEntity.posZ
                                    , this.inventory.get(mcreator_stevensShield.block)));
        }
    }
  }

 

but this is also wrong, can someone please point me in right direction?  I am really stuck on this.

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Hmm, So i have been trying
Tue, 01/24/2017 - 18:35

@#22

I am thinking that this code is not useable at all, I must use mop instance of entityplayer, but I am not sure how to have proper code for giving player item.

Last seen on 23:21, 14. Apr 2019
Joined Jul 2015
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:I mean on collison with
Sat, 01/28/2017 - 14:41

@#21

Hmm, I think maybe I need mop instance of EntityPlayer to make it so when projectile hits player it setDead and gives the player an item.