Code question

Discussion in 'Community Talk' started by tyler489, May 16, 2016.

  1. tyler489

    tyler489 Well-Known Member

    Messages:
    1,873
    Likes Received:
    202
    Local Time:
    8:16 AM
    so i was looking into the galacticraft creeper boss code trying to figure out any way to damage it other than returning the tnt it shoots at u and i found this
    Code:
    	@Override
    	public boolean attackEntityFrom(DamageSource damageSource, float damage)
    	{
    		if (damageSource.getDamageType().equals("fireball"))
    		{
    			if (this.isEntityInvulnerable())
    			{
    				return false;
    			}
    			else if (super.attackEntityFrom(damageSource, damage))
    			{
    				Entity entity = damageSource.getEntity();
    
    				if (this.riddenByEntity != entity && this.ridingEntity != entity)
    				{
    					if (entity != this)
    					{
    						this.entityToAttack = entity;
    					}
    
    					return true;
    				}
    				else
    				{
    					return true;
    				}
    			}
    			else
    			{
    				return false;
    			}
    		}
    
    		return false;
    	}
    does this mean i can damage it with fireballs?
     
  2. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    9:16 AM
    Yes, fireballs deal damage to the guy apparently
     
  3. tyler489

    tyler489 Well-Known Member

    Messages:
    1,873
    Likes Received:
    202
    Local Time:
    8:16 AM
    im still trying to figure this part out
    Code:
    if (this.riddenByEntity != entity && this.ridingEntity != entity)
    				{
    					if (entity != this)
    					{
    						this.entityToAttack = entity;
    					}
    
    					return true;
    returning true makes him invunerable but it seems to be confusing
     
  4. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    9:16 AM
    there's static entity instantiated somewhere else, and it appears to be multiple mobs to make it, maybe that's why?
     
  5. Matryoshika

    Matryoshika Well-Known Member

    Messages:
    1,193
    Likes Received:
    606
    Local Time:
    3:16 PM
    incorrect;

    Code:
    Entity entity = damageSource.getEntity();
    The one who does the damage unto the creeper.

    Essentially, as far as I can see, if you are riding him, he will not aggro on you, even if hit (by you at least)
     
  6. chugga_fan

    chugga_fan ME 4M storage cell of knowledge, all the time

    Messages:
    5,861
    Likes Received:
    730
    Local Time:
    9:16 AM
    I never saw the source code, so i could only guess ;) but i was correct that it's instansiated somewhere else, but yhea that's right if you're looking at the source
     
  7. tyler489

    tyler489 Well-Known Member

    Messages:
    1,873
    Likes Received:
    202
    Local Time:
    8:16 AM
    hmm ok also found this list of slimelings foods
    gold ingot
    flint and steel
    baked potato
    stone sword
    gunpowder
    door
    emeralds
    cookedfish
    repeater
    boat
     
    Last edited: May 16, 2016
  8. Matryoshika

    Matryoshika Well-Known Member

    Messages:
    1,193
    Likes Received:
    606
    Local Time:
    3:16 PM
    ?? what?

    btw:
    Returning true in an attackEntityFrom method merely allows him to be hurt. You thought it is the other way around. Returning false means he is not hurt.
     
  9. tyler489

    tyler489 Well-Known Member

    Messages:
    1,873
    Likes Received:
    202
    Local Time:
    8:16 AM
    i was talking about isentityinvunerable method returning false

    the reason i was asking is i was trying to kill the boss on ozone (before the restart and crash)
    and the tnt attack ur suppost to hit back at him is disapearing. like desync it looks like i hit it it goes flying twords the creeper then reverses and exploads
     
  10. Matryoshika

    Matryoshika Well-Known Member

    Messages:
    1,193
    Likes Received:
    606
    Local Time:
    3:16 PM
    Ah, though you also got that wrong ;)
    It checks if he is already invulnerable, if so, any damage is negated. You need to find where that bool is set to true first, to find out how he becomes invulnerable.
     
  11. tyler489

    tyler489 Well-Known Member

    Messages:
    1,873
    Likes Received:
    202
    Local Time:
    8:16 AM
    this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
    this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
    so that makes him invunerable i guess

    Ozone is up but no one can join so i cant test
     
  12. SirWill

    SirWill Founder

    Messages:
    12,284
    Likes Received:
    3,708
    Local Time:
    3:16 PM
    Moved as it is no support request.
     
  13. DrummerBoyNo

    DrummerBoyNo Well-Known Member

    Messages:
    61
    Likes Received:
    6
    Local Time:
    8:16 AM
    Fire balls hurt as well as the boss is actually 4 entities the 3 heads and the legs. Prettmuch any weapon that has a effect like tnt should hurt him.
     

Share This Page