2020-08-09 17:46:58 +02:00
|
|
|
package mod.acgaming.spackenmobs.entities;
|
2020-08-23 10:30:02 +02:00
|
|
|
|
2020-08-14 19:24:29 +02:00
|
|
|
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
2020-08-09 17:46:58 +02:00
|
|
|
import net.minecraft.entity.monster.EntityCreeper;
|
|
|
|
import net.minecraft.util.DamageSource;
|
|
|
|
import net.minecraft.util.SoundEvent;
|
|
|
|
import net.minecraft.world.World;
|
2020-08-27 20:12:55 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
public class EntityIslamist extends EntityCreeper
|
|
|
|
{
|
|
|
|
private final int fuseTime = 30;
|
|
|
|
private final int explosionRadius = 6;
|
2020-08-30 14:23:10 +02:00
|
|
|
private int lastActiveTime;
|
|
|
|
private int timeSinceIgnited;
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
public EntityIslamist(World worldIn)
|
|
|
|
{
|
|
|
|
super(worldIn);
|
|
|
|
this.setSize(0.6F, 1.7F);
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
@Override
|
|
|
|
public void onUpdate()
|
|
|
|
{
|
|
|
|
if (this.isEntityAlive())
|
|
|
|
{
|
|
|
|
this.lastActiveTime = this.timeSinceIgnited;
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
if (this.hasIgnited())
|
|
|
|
{
|
|
|
|
this.setCreeperState(1);
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
int i = this.getCreeperState();
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
if (i > 0 && this.timeSinceIgnited == 0)
|
|
|
|
{
|
|
|
|
this.playSound(ModSoundEvents.ENTITY_ISLAMIST_FUSE, 1.0F, 0.5F);
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
this.timeSinceIgnited += i;
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
if (this.timeSinceIgnited < 0)
|
|
|
|
{
|
|
|
|
this.timeSinceIgnited = 0;
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
if (this.timeSinceIgnited >= this.fuseTime)
|
|
|
|
{
|
|
|
|
this.timeSinceIgnited = this.fuseTime;
|
|
|
|
this.explode();
|
|
|
|
}
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
super.onUpdate();
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
private void explode()
|
|
|
|
{
|
|
|
|
if (!this.world.isRemote)
|
|
|
|
{
|
|
|
|
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
|
|
|
float f = this.getPowered() ? 2.0F : 1.0F;
|
|
|
|
this.dead = true;
|
|
|
|
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_ISLAMIST_BLOW, getSoundCategory(), 1.0F,
|
|
|
|
1.0F);
|
|
|
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
|
|
|
|
this.setDead();
|
|
|
|
}
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
@Override
|
|
|
|
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
|
|
|
{
|
|
|
|
return ModSoundEvents.ENTITY_ISLAMIST_HURT;
|
|
|
|
}
|
2020-08-29 17:36:56 +02:00
|
|
|
|
2020-08-29 20:42:50 +02:00
|
|
|
@Override
|
|
|
|
protected SoundEvent getAmbientSound()
|
|
|
|
{
|
|
|
|
return ModSoundEvents.ENTITY_ISLAMIST_AMBIENT;
|
|
|
|
}
|
2020-08-09 17:46:58 +02:00
|
|
|
}
|