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:What is hard about writing
Sun, 01/15/2017 - 20:37

@#13

oh, it is boolean. for some reason I keep thinking of int!

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:What is hard about writing
Sun, 01/15/2017 - 20:42

:@#13

:compileApiJava UP-TO-DATE
>:processApiResources UP-TO-DATE
>:apiClasses UP-TO-DATE
>:sourceMainJava
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:153: error: variable hasCollided might not have been initialized
>:compileJava FAILED
>     >            ^
    if>BUILD FAILED
(hasCollided){
>Note: /Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_sugilitesFlail.java uses unchecked or unsafe operations.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
you must initialize it. In
Sun, 01/15/2017 - 20:46

you must initialize it. In constructor or directly in the declaration asign to it a value , to be more exact - false

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:you must initialize it. In
Sun, 01/15/2017 - 20:52

@#14

hmm, now my entity does not move at all

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Did you kept the code that
Sun, 01/15/2017 - 21:21

Did you kept the code that you had in onUpdate() before?

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 kept the code that
Sun, 01/15/2017 - 23:30

@#15

well this is my code:

 

public static class Entityshield extends EntityThrowable{

/** How many ticks the arrow has been in the air. */
    public int inAirTicks;
    
public Entityshield(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public Entityshield(World par1World, EntityLivingBase par2EntityLivingBase)
{
super(par1World, par2EntityLivingBase);
}
public Entityshield(World par1World)
{
super(par1World);
}

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

Wich onUpdate code are you talking about?  is it this one:

 

@Override
    public void onUpdate() {
        if (--distance < -LIFESPAN && !worldObj.isRemote) {
            worldObj.spawnEntityInWorld(new EntityItem(worldObj, posX, posY, posZ, getshield()));
            setDead();
            }
        }

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:you must initialize it. In
Mon, 01/16/2017 - 12:32

@#14

I did a test, and it seems that if the code has this:@Override
    public void onUpdate() {

 

the projectile doesn't move.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hm no. Call a super method.
Mon, 01/16/2017 - 12:37

Hm no. Call a super method.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:Hm no. Call a super method.
Mon, 01/16/2017 - 13:43

@#16

so I need to add something like this?

super.OnUpdate();

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
With lowercase "O"
Mon, 01/16/2017 - 13:47

With lowercase "O"

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
super.onUpdate();
Mon, 01/16/2017 - 13:52

super.onUpdate();

and this goes on line on top of

inAirTicks++;

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
RE:With lowercase "O"
Mon, 01/16/2017 - 13:57

@#17

this is full code by the way

@Override
    public void onUpdate() {
         boolean hasCollided = false;
         if(hasCollided){
    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:
1st no , it is must be
Mon, 01/16/2017 - 14:24

1st no , it is must be compeltly first thing in the void , also why do you declare the boolean in the void? Do you know that if you do this , it will every tick set the value to false and also it will not be accesable from rest of code?

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

User statistics:

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

@#19

oh, boolean should can be put under where i put int for inAirTicks?