mirror of
https://github.com/ACGaming/Spackenmobs
synced 2024-11-29 10:12:41 +01:00
Cleaner approach to creepers
This commit is contained in:
parent
b7b0baec7e
commit
62ba74ee14
13 changed files with 887 additions and 254 deletions
|
@ -1,12 +1,13 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.ai.EntityAIBakaMitaiCreeperSwell;
|
||||||
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityAreaEffectCloud;
|
import net.minecraft.entity.EntityAreaEffectCloud;
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.*;
|
import net.minecraft.entity.ai.*;
|
||||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
import net.minecraft.entity.monster.EntitySkeleton;
|
import net.minecraft.entity.monster.EntitySkeleton;
|
||||||
import net.minecraft.entity.passive.EntityOcelot;
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -31,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class EntityBakaMitaiCreeper extends EntityCreeper
|
public class EntityBakaMitaiCreeper extends EntityMob
|
||||||
{
|
{
|
||||||
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.VARINT);
|
||||||
private static final DataParameter<Boolean> POWERED = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.BOOLEAN);
|
private static final DataParameter<Boolean> POWERED = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.BOOLEAN);
|
||||||
|
@ -48,53 +49,34 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
this.setSize(0.6F, 1.7F);
|
this.setSize(0.6F, 1.7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void initEntityAI()
|
||||||
public boolean ableToCauseSkullDrop()
|
|
||||||
{
|
{
|
||||||
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
|
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||||
|
this.tasks.addTask(2, new EntityAIBakaMitaiCreeperSwell(this));
|
||||||
|
this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
|
||||||
|
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
|
||||||
|
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.8D));
|
||||||
|
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||||
|
this.tasks.addTask(6, new EntityAILookIdle(this));
|
||||||
|
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
|
||||||
|
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void applyEntityAttributes()
|
protected void applyEntityAttributes()
|
||||||
{
|
{
|
||||||
super.applyEntityAttributes();
|
super.applyEntityAttributes();
|
||||||
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
|
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public int getMaxFallHeight()
|
||||||
public boolean attackEntityAsMob(Entity entityIn)
|
|
||||||
{
|
{
|
||||||
return true;
|
return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void entityInit()
|
|
||||||
{
|
|
||||||
super.entityInit();
|
|
||||||
this.dataManager.register(STATE, -1);
|
|
||||||
this.dataManager.register(POWERED, false);
|
|
||||||
this.dataManager.register(IGNITED, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
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_BAKAMITAICREEPER_BLOW, getSoundCategory(), 1.0F, 1.0F);
|
|
||||||
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
|
|
||||||
this.setDead();
|
|
||||||
this.spawnLingeringCloud();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fall(float distance, float damageMultiplier)
|
public void fall(float distance, float damageMultiplier)
|
||||||
{
|
{
|
||||||
super.fall(distance, damageMultiplier);
|
super.fall(distance, damageMultiplier);
|
||||||
this.timeSinceIgnited = (int) (this.timeSinceIgnited + distance * 1.5F);
|
this.timeSinceIgnited = (int) ((float) this.timeSinceIgnited + distance * 1.5F);
|
||||||
|
|
||||||
if (this.timeSinceIgnited > this.fuseTime - 5)
|
if (this.timeSinceIgnited > this.fuseTime - 5)
|
||||||
{
|
{
|
||||||
|
@ -102,118 +84,49 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void entityInit()
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public float getCreeperFlashIntensity(float p_70831_1_)
|
|
||||||
{
|
{
|
||||||
return (this.lastActiveTime + (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (this.fuseTime - 2);
|
super.entityInit();
|
||||||
|
this.dataManager.register(STATE, -1);
|
||||||
|
this.dataManager.register(POWERED, Boolean.FALSE);
|
||||||
|
this.dataManager.register(IGNITED, Boolean.FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void writeEntityToNBT(NBTTagCompound compound)
|
||||||
public int getCreeperState()
|
|
||||||
{
|
{
|
||||||
return this.dataManager.get(STATE);
|
super.writeEntityToNBT(compound);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if ((Boolean) this.dataManager.get(POWERED))
|
||||||
public void setCreeperState(int state)
|
|
||||||
{
|
|
||||||
this.dataManager.set(STATE, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEvent getDeathSound()
|
|
||||||
{
|
|
||||||
return SoundEvents.ENTITY_CREEPER_DEATH;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
|
||||||
{
|
|
||||||
return SoundEvents.ENTITY_CREEPER_HURT;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
protected ResourceLocation getLootTable()
|
|
||||||
{
|
|
||||||
return LootTableList.ENTITIES_CREEPER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getMaxFallHeight()
|
|
||||||
{
|
|
||||||
return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean getPowered()
|
|
||||||
{
|
|
||||||
return this.dataManager.get(POWERED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean hasIgnited()
|
|
||||||
{
|
|
||||||
return this.dataManager.get(IGNITED);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void ignite()
|
|
||||||
{
|
|
||||||
this.dataManager.set(IGNITED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void incrementDroppedSkulls()
|
|
||||||
{
|
|
||||||
++this.droppedSkulls;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initEntityAI()
|
|
||||||
{
|
|
||||||
this.tasks.addTask(1, new EntityAISwimming(this));
|
|
||||||
this.tasks.addTask(2, new EntityAICreeperSwell(this));
|
|
||||||
this.tasks.addTask(3, new EntityAIAvoidEntity<>(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
|
|
||||||
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
|
|
||||||
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.8D));
|
|
||||||
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
|
||||||
this.tasks.addTask(6, new EntityAILookIdle(this));
|
|
||||||
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget<>(this, EntityPlayer.class, true));
|
|
||||||
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDeath(DamageSource cause)
|
|
||||||
{
|
|
||||||
super.onDeath(cause);
|
|
||||||
|
|
||||||
if (this.world.getGameRules().getBoolean("doMobLoot"))
|
|
||||||
{
|
{
|
||||||
if (cause.getTrueSource() instanceof EntitySkeleton)
|
compound.setBoolean("powered", true);
|
||||||
{
|
}
|
||||||
int i = Item.getIdFromItem(Items.RECORD_13);
|
|
||||||
int j = Item.getIdFromItem(Items.RECORD_WAIT);
|
compound.setShort("Fuse", (short) this.fuseTime);
|
||||||
int k = i + this.rand.nextInt(j - i + 1);
|
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
|
||||||
this.dropItem(Item.getItemById(k), 1);
|
compound.setBoolean("ignited", this.hasIgnited());
|
||||||
} else if (cause.getTrueSource() instanceof EntityBakaMitaiCreeper && cause.getTrueSource() != this && ((EntityBakaMitaiCreeper) cause.getTrueSource()).getPowered()
|
}
|
||||||
&& ((EntityBakaMitaiCreeper) cause.getTrueSource()).ableToCauseSkullDrop())
|
|
||||||
{
|
public void readEntityFromNBT(NBTTagCompound compound)
|
||||||
((EntityBakaMitaiCreeper) cause.getTrueSource()).incrementDroppedSkulls();
|
{
|
||||||
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
super.readEntityFromNBT(compound);
|
||||||
}
|
this.dataManager.set(POWERED, compound.getBoolean("powered"));
|
||||||
|
|
||||||
|
if (compound.hasKey("Fuse", 99))
|
||||||
|
{
|
||||||
|
this.fuseTime = compound.getShort("Fuse");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.hasKey("ExplosionRadius", 99))
|
||||||
|
{
|
||||||
|
this.explosionRadius = compound.getByte("ExplosionRadius");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.getBoolean("ignited"))
|
||||||
|
{
|
||||||
|
this.ignite();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStruckByLightning(EntityLightningBolt lightningBolt)
|
|
||||||
{
|
|
||||||
super.onStruckByLightning(lightningBolt);
|
|
||||||
this.dataManager.set(POWERED, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
if (this.isEntityAlive())
|
if (this.isEntityAlive())
|
||||||
|
@ -245,11 +158,77 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
this.explode();
|
this.explode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
||||||
|
{
|
||||||
|
return SoundEvents.ENTITY_CREEPER_HURT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getDeathSound()
|
||||||
|
{
|
||||||
|
return SoundEvents.ENTITY_CREEPER_DEATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeath(DamageSource cause)
|
||||||
|
{
|
||||||
|
super.onDeath(cause);
|
||||||
|
|
||||||
|
if (this.world.getGameRules().getBoolean("doMobLoot"))
|
||||||
|
{
|
||||||
|
if (cause.getTrueSource() instanceof EntitySkeleton)
|
||||||
|
{
|
||||||
|
int i = Item.getIdFromItem(Items.RECORD_13);
|
||||||
|
int j = Item.getIdFromItem(Items.RECORD_WAIT);
|
||||||
|
int k = i + this.rand.nextInt(j - i + 1);
|
||||||
|
this.dropItem(Item.getItemById(k), 1);
|
||||||
|
} else if (cause.getTrueSource() instanceof mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper && cause.getTrueSource() != this && ((mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper) cause.getTrueSource()).getPowered() && ((mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper) cause.getTrueSource()).ableToCauseSkullDrop())
|
||||||
|
{
|
||||||
|
((mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper) cause.getTrueSource()).incrementDroppedSkulls();
|
||||||
|
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean attackEntityAsMob(Entity entityIn)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPowered()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(POWERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public float getCreeperFlashIntensity(float p_70831_1_)
|
||||||
|
{
|
||||||
|
return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (float) (this.fuseTime - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected ResourceLocation getLootTable()
|
||||||
|
{
|
||||||
|
return LootTableList.ENTITIES_CREEPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreeperState()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreeperState(int state)
|
||||||
|
{
|
||||||
|
this.dataManager.set(STATE, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStruckByLightning(EntityLightningBolt lightningBolt)
|
||||||
|
{
|
||||||
|
super.onStruckByLightning(lightningBolt);
|
||||||
|
this.dataManager.set(POWERED, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
protected boolean processInteract(EntityPlayer player, EnumHand hand)
|
protected boolean processInteract(EntityPlayer player, EnumHand hand)
|
||||||
{
|
{
|
||||||
ItemStack itemstack = player.getHeldItem(hand);
|
ItemStack itemstack = player.getHeldItem(hand);
|
||||||
|
@ -270,25 +249,17 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
return super.processInteract(player, hand);
|
return super.processInteract(player, hand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void explode()
|
||||||
public void readEntityFromNBT(NBTTagCompound compound)
|
|
||||||
{
|
{
|
||||||
super.readEntityFromNBT(compound);
|
if (!this.world.isRemote)
|
||||||
this.dataManager.set(POWERED, compound.getBoolean("powered"));
|
|
||||||
|
|
||||||
if (compound.hasKey("Fuse", 99))
|
|
||||||
{
|
{
|
||||||
this.fuseTime = compound.getShort("Fuse");
|
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
||||||
}
|
float f = this.getPowered() ? 2.0F : 1.0F;
|
||||||
|
this.dead = true;
|
||||||
if (compound.hasKey("ExplosionRadius", 99))
|
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_BAKAMITAICREEPER_BLOW, getSoundCategory(), 2.0F, 1.0F);
|
||||||
{
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
|
||||||
this.explosionRadius = compound.getByte("ExplosionRadius");
|
this.setDead();
|
||||||
}
|
this.spawnLingeringCloud();
|
||||||
|
|
||||||
if (compound.getBoolean("ignited"))
|
|
||||||
{
|
|
||||||
this.ignite();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -303,7 +274,7 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||||
entityareaeffectcloud.setWaitTime(10);
|
entityareaeffectcloud.setWaitTime(10);
|
||||||
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
|
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
|
||||||
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
|
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
|
||||||
|
|
||||||
for (PotionEffect potioneffect : collection)
|
for (PotionEffect potioneffect : collection)
|
||||||
{
|
{
|
||||||
|
@ -314,18 +285,23 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasIgnited()
|
||||||
public void writeEntityToNBT(NBTTagCompound compound)
|
|
||||||
{
|
{
|
||||||
super.writeEntityToNBT(compound);
|
return this.dataManager.get(IGNITED);
|
||||||
|
}
|
||||||
|
|
||||||
if (this.dataManager.get(POWERED))
|
public void ignite()
|
||||||
{
|
{
|
||||||
compound.setBoolean("powered", true);
|
this.dataManager.set(IGNITED, Boolean.TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
compound.setShort("Fuse", (short) this.fuseTime);
|
public boolean ableToCauseSkullDrop()
|
||||||
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
|
{
|
||||||
compound.setBoolean("ignited", this.hasIgnited());
|
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementDroppedSkulls()
|
||||||
|
{
|
||||||
|
++this.droppedSkulls;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,47 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.ai.EntityAIIslamistSwell;
|
||||||
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityAreaEffectCloud;
|
||||||
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
|
import net.minecraft.entity.ai.*;
|
||||||
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||||
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
|
import net.minecraft.entity.monster.EntitySkeleton;
|
||||||
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.datasync.DataParameter;
|
||||||
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.storage.loot.LootTableList;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class EntityIslamist extends EntityCreeper
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class EntityIslamist extends EntityMob
|
||||||
{
|
{
|
||||||
private final int fuseTime = 30;
|
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntityIslamist.class, DataSerializers.VARINT);
|
||||||
private final int explosionRadius = 6;
|
private static final DataParameter<Boolean> POWERED = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntityIslamist.class, DataSerializers.BOOLEAN);
|
||||||
|
private static final DataParameter<Boolean> IGNITED = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntityIslamist.class, DataSerializers.BOOLEAN);
|
||||||
private int lastActiveTime;
|
private int lastActiveTime;
|
||||||
private int timeSinceIgnited;
|
private int timeSinceIgnited;
|
||||||
|
private int fuseTime = 30;
|
||||||
|
private int explosionRadius = 6;
|
||||||
|
private int droppedSkulls;
|
||||||
|
|
||||||
public EntityIslamist(World worldIn)
|
public EntityIslamist(World worldIn)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +49,84 @@ public class EntityIslamist extends EntityCreeper
|
||||||
this.setSize(0.6F, 1.7F);
|
this.setSize(0.6F, 1.7F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void initEntityAI()
|
||||||
|
{
|
||||||
|
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||||
|
this.tasks.addTask(2, new EntityAIIslamistSwell(this));
|
||||||
|
this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
|
||||||
|
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
|
||||||
|
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.8D));
|
||||||
|
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||||
|
this.tasks.addTask(6, new EntityAILookIdle(this));
|
||||||
|
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
|
||||||
|
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyEntityAttributes()
|
||||||
|
{
|
||||||
|
super.applyEntityAttributes();
|
||||||
|
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxFallHeight()
|
||||||
|
{
|
||||||
|
return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fall(float distance, float damageMultiplier)
|
||||||
|
{
|
||||||
|
super.fall(distance, damageMultiplier);
|
||||||
|
this.timeSinceIgnited = (int) ((float) this.timeSinceIgnited + distance * 1.5F);
|
||||||
|
|
||||||
|
if (this.timeSinceIgnited > this.fuseTime - 5)
|
||||||
|
{
|
||||||
|
this.timeSinceIgnited = this.fuseTime - 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void entityInit()
|
||||||
|
{
|
||||||
|
super.entityInit();
|
||||||
|
this.dataManager.register(STATE, -1);
|
||||||
|
this.dataManager.register(POWERED, Boolean.FALSE);
|
||||||
|
this.dataManager.register(IGNITED, Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeEntityToNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.writeEntityToNBT(compound);
|
||||||
|
|
||||||
|
if (this.dataManager.get(POWERED))
|
||||||
|
{
|
||||||
|
compound.setBoolean("powered", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
compound.setShort("Fuse", (short) this.fuseTime);
|
||||||
|
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
|
||||||
|
compound.setBoolean("ignited", this.hasIgnited());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readEntityFromNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.readEntityFromNBT(compound);
|
||||||
|
this.dataManager.set(POWERED, compound.getBoolean("powered"));
|
||||||
|
|
||||||
|
if (compound.hasKey("Fuse", 99))
|
||||||
|
{
|
||||||
|
this.fuseTime = compound.getShort("Fuse");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.hasKey("ExplosionRadius", 99))
|
||||||
|
{
|
||||||
|
this.explosionRadius = compound.getByte("ExplosionRadius");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.getBoolean("ignited"))
|
||||||
|
{
|
||||||
|
this.ignite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
if (this.isEntityAlive())
|
if (this.isEntityAlive())
|
||||||
|
@ -51,10 +158,97 @@ public class EntityIslamist extends EntityCreeper
|
||||||
this.explode();
|
this.explode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
||||||
|
{
|
||||||
|
return ModSoundEvents.ENTITY_ISLAMIST_HURT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getDeathSound()
|
||||||
|
{
|
||||||
|
return ModSoundEvents.ENTITY_ISLAMIST_AMBIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeath(DamageSource cause)
|
||||||
|
{
|
||||||
|
super.onDeath(cause);
|
||||||
|
|
||||||
|
if (this.world.getGameRules().getBoolean("doMobLoot"))
|
||||||
|
{
|
||||||
|
if (cause.getTrueSource() instanceof EntitySkeleton)
|
||||||
|
{
|
||||||
|
int i = Item.getIdFromItem(Items.RECORD_13);
|
||||||
|
int j = Item.getIdFromItem(Items.RECORD_WAIT);
|
||||||
|
int k = i + this.rand.nextInt(j - i + 1);
|
||||||
|
this.dropItem(Item.getItemById(k), 1);
|
||||||
|
} else if (cause.getTrueSource() instanceof mod.acgaming.spackenmobs.entities.EntityIslamist && cause.getTrueSource() != this && ((mod.acgaming.spackenmobs.entities.EntityIslamist) cause.getTrueSource()).getPowered() && ((mod.acgaming.spackenmobs.entities.EntityIslamist) cause.getTrueSource()).ableToCauseSkullDrop())
|
||||||
|
{
|
||||||
|
((mod.acgaming.spackenmobs.entities.EntityIslamist) cause.getTrueSource()).incrementDroppedSkulls();
|
||||||
|
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean attackEntityAsMob(Entity entityIn)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPowered()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(POWERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public float getCreeperFlashIntensity(float p_70831_1_)
|
||||||
|
{
|
||||||
|
return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (float) (this.fuseTime - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected ResourceLocation getLootTable()
|
||||||
|
{
|
||||||
|
return LootTableList.ENTITIES_CREEPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreeperState()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreeperState(int state)
|
||||||
|
{
|
||||||
|
this.dataManager.set(STATE, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStruckByLightning(EntityLightningBolt lightningBolt)
|
||||||
|
{
|
||||||
|
super.onStruckByLightning(lightningBolt);
|
||||||
|
this.dataManager.set(POWERED, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean processInteract(EntityPlayer player, EnumHand hand)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = player.getHeldItem(hand);
|
||||||
|
|
||||||
|
if (itemstack.getItem() == Items.FLINT_AND_STEEL)
|
||||||
|
{
|
||||||
|
this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
|
||||||
|
player.swingArm(hand);
|
||||||
|
|
||||||
|
if (!this.world.isRemote)
|
||||||
|
{
|
||||||
|
this.ignite();
|
||||||
|
itemstack.damageItem(1, player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.processInteract(player, hand);
|
||||||
|
}
|
||||||
|
|
||||||
private void explode()
|
private void explode()
|
||||||
{
|
{
|
||||||
if (!this.world.isRemote)
|
if (!this.world.isRemote)
|
||||||
|
@ -62,22 +256,52 @@ public class EntityIslamist extends EntityCreeper
|
||||||
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
||||||
float f = this.getPowered() ? 2.0F : 1.0F;
|
float f = this.getPowered() ? 2.0F : 1.0F;
|
||||||
this.dead = true;
|
this.dead = true;
|
||||||
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_ISLAMIST_BLOW, getSoundCategory(), 1.0F,
|
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_ISLAMIST_BLOW, getSoundCategory(), 1.0F, 1.0F);
|
||||||
1.0F);
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
|
||||||
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
|
|
||||||
this.setDead();
|
this.setDead();
|
||||||
|
this.spawnLingeringCloud();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void spawnLingeringCloud()
|
||||||
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
|
||||||
{
|
{
|
||||||
return ModSoundEvents.ENTITY_ISLAMIST_HURT;
|
Collection<PotionEffect> collection = this.getActivePotionEffects();
|
||||||
|
|
||||||
|
if (!collection.isEmpty())
|
||||||
|
{
|
||||||
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
|
||||||
|
entityareaeffectcloud.setRadius(2.5F);
|
||||||
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||||
|
entityareaeffectcloud.setWaitTime(10);
|
||||||
|
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
|
||||||
|
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
|
||||||
|
|
||||||
|
for (PotionEffect potioneffect : collection)
|
||||||
|
{
|
||||||
|
entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.world.spawnEntity(entityareaeffectcloud);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasIgnited()
|
||||||
protected SoundEvent getAmbientSound()
|
|
||||||
{
|
{
|
||||||
return ModSoundEvents.ENTITY_ISLAMIST_AMBIENT;
|
return this.dataManager.get(IGNITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ignite()
|
||||||
|
{
|
||||||
|
this.dataManager.set(IGNITED, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ableToCauseSkullDrop()
|
||||||
|
{
|
||||||
|
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementDroppedSkulls()
|
||||||
|
{
|
||||||
|
++this.droppedSkulls;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities;
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import mod.acgaming.spackenmobs.entities.ai.EntityAIDance;
|
||||||
|
import mod.acgaming.spackenmobs.entities.ai.EntityAIEatDroppedFish;
|
||||||
import mod.acgaming.spackenmobs.misc.ModConfigs;
|
import mod.acgaming.spackenmobs.misc.ModConfigs;
|
||||||
import mod.acgaming.spackenmobs.misc.ModItems;
|
import mod.acgaming.spackenmobs.misc.ModItems;
|
||||||
import mod.acgaming.spackenmobs.misc.ModLootTableList;
|
import mod.acgaming.spackenmobs.misc.ModLootTableList;
|
||||||
|
@ -37,11 +39,11 @@ public class EntityJens extends EntityAnimal
|
||||||
private static final DataParameter<Integer> DIGEST_TIME = EntityDataManager.createKey(EntityJens.class, DataSerializers.VARINT);
|
private static final DataParameter<Integer> DIGEST_TIME = EntityDataManager.createKey(EntityJens.class, DataSerializers.VARINT);
|
||||||
private static final Set<Item> TEMPTATION_ITEMS = Sets.newHashSet(ModItems.RAM, Items.FISH);
|
private static final Set<Item> TEMPTATION_ITEMS = Sets.newHashSet(ModItems.RAM, Items.FISH);
|
||||||
private static final Set<Item> FISH_ITEMS = Sets.newHashSet(Items.FISH);
|
private static final Set<Item> FISH_ITEMS = Sets.newHashSet(Items.FISH);
|
||||||
|
public boolean digesting;
|
||||||
|
public int digestTime;
|
||||||
private boolean boosting;
|
private boolean boosting;
|
||||||
private int boostTime;
|
private int boostTime;
|
||||||
private int totalBoostTime;
|
private int totalBoostTime;
|
||||||
public boolean digesting;
|
|
||||||
public int digestTime;
|
|
||||||
|
|
||||||
public EntityJens(World worldIn)
|
public EntityJens(World worldIn)
|
||||||
{
|
{
|
||||||
|
@ -87,10 +89,9 @@ public class EntityJens extends EntityAnimal
|
||||||
if (!(entity instanceof EntityPlayer))
|
if (!(entity instanceof EntityPlayer))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
EntityPlayer entityplayer = (EntityPlayer)entity;
|
EntityPlayer entityplayer = (EntityPlayer) entity;
|
||||||
return entityplayer.getHeldItemMainhand().getItem() == ModItems.RAM_ON_A_STICK || entityplayer.getHeldItemOffhand().getItem() == ModItems.RAM_ON_A_STICK;
|
return entityplayer.getHeldItemMainhand().getItem() == ModItems.RAM_ON_A_STICK || entityplayer.getHeldItemOffhand().getItem() == ModItems.RAM_ON_A_STICK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,26 +169,22 @@ public class EntityJens extends EntityAnimal
|
||||||
itemstack.shrink(1);
|
itemstack.shrink(1);
|
||||||
digestFish();
|
digestFish();
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (itemstack.getItem() == Items.NAME_TAG)
|
||||||
else if (itemstack.getItem() == Items.NAME_TAG)
|
|
||||||
{
|
{
|
||||||
itemstack.interactWithEntity(player, this, hand);
|
itemstack.interactWithEntity(player, this, hand);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (!this.isBeingRidden())
|
||||||
else if (!this.isBeingRidden())
|
|
||||||
{
|
{
|
||||||
if (!this.world.isRemote)
|
if (!this.world.isRemote)
|
||||||
{
|
{
|
||||||
player.startRiding(this);
|
player.startRiding(this);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -234,17 +231,16 @@ public class EntityJens extends EntityAnimal
|
||||||
|
|
||||||
if (this.canPassengerSteer())
|
if (this.canPassengerSteer())
|
||||||
{
|
{
|
||||||
float f = (float)this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() * 0.225F;
|
float f = (float) this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).getAttributeValue() * 0.225F;
|
||||||
|
|
||||||
if (this.boosting)
|
if (this.boosting)
|
||||||
{
|
{
|
||||||
f += f * 1.15F * MathHelper.sin((float)this.boostTime / (float)this.totalBoostTime * (float)Math.PI);
|
f += f * 1.15F * MathHelper.sin((float) this.boostTime / (float) this.totalBoostTime * (float) Math.PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setAIMoveSpeed(f);
|
this.setAIMoveSpeed(f);
|
||||||
super.travel(0.0F, 0.0F, 1.0F);
|
super.travel(0.0F, 0.0F, 1.0F);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.motionX = 0.0D;
|
this.motionX = 0.0D;
|
||||||
this.motionY = 0.0D;
|
this.motionY = 0.0D;
|
||||||
|
@ -263,8 +259,7 @@ public class EntityJens extends EntityAnimal
|
||||||
|
|
||||||
this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
|
this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
|
||||||
this.limbSwing += this.limbSwingAmount;
|
this.limbSwing += this.limbSwingAmount;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.stepHeight = 0.5F;
|
this.stepHeight = 0.5F;
|
||||||
this.jumpMovementFactor = 0.02F;
|
this.jumpMovementFactor = 0.02F;
|
||||||
|
@ -277,8 +272,7 @@ public class EntityJens extends EntityAnimal
|
||||||
if (this.boosting)
|
if (this.boosting)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
this.boosting = true;
|
this.boosting = true;
|
||||||
this.boostTime = 0;
|
this.boostTime = 0;
|
||||||
|
|
|
@ -1,27 +1,133 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.ai.EntityAISmavaCreeperSwell;
|
||||||
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
import mod.acgaming.spackenmobs.misc.ModSoundEvents;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityAreaEffectCloud;
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
import net.minecraft.entity.ai.*;
|
||||||
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||||
|
import net.minecraft.entity.monster.EntityMob;
|
||||||
|
import net.minecraft.entity.monster.EntitySkeleton;
|
||||||
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Items;
|
||||||
|
import net.minecraft.init.SoundEvents;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.datasync.DataParameter;
|
||||||
|
import net.minecraft.network.datasync.DataSerializers;
|
||||||
|
import net.minecraft.network.datasync.EntityDataManager;
|
||||||
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.util.EnumHand;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.SoundEvent;
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.storage.loot.LootTableList;
|
||||||
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
public class EntitySmavaCreeper extends EntityCreeper
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class EntitySmavaCreeper extends EntityMob
|
||||||
{
|
{
|
||||||
private final int fuseTime = 20;
|
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntitySmavaCreeper.class, DataSerializers.VARINT);
|
||||||
private final int explosionRadius = 6;
|
private static final DataParameter<Boolean> POWERED = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntitySmavaCreeper.class, DataSerializers.BOOLEAN);
|
||||||
|
private static final DataParameter<Boolean> IGNITED = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntitySmavaCreeper.class, DataSerializers.BOOLEAN);
|
||||||
private int lastActiveTime;
|
private int lastActiveTime;
|
||||||
private int timeSinceIgnited;
|
private int timeSinceIgnited;
|
||||||
|
private int fuseTime = 20;
|
||||||
|
private int explosionRadius = 6;
|
||||||
|
private int droppedSkulls;
|
||||||
|
|
||||||
public EntitySmavaCreeper(World worldIn)
|
public EntitySmavaCreeper(World worldIn)
|
||||||
{
|
{
|
||||||
super(worldIn);
|
super(worldIn);
|
||||||
setSize(0.6F, 1.7F);
|
this.setSize(0.6F, 1.7F);
|
||||||
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
|
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initEntityAI()
|
||||||
|
{
|
||||||
|
this.tasks.addTask(1, new EntityAISwimming(this));
|
||||||
|
this.tasks.addTask(2, new EntityAISmavaCreeperSwell(this));
|
||||||
|
this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityOcelot.class, 6.0F, 1.0D, 1.2D));
|
||||||
|
this.tasks.addTask(4, new EntityAIAttackMelee(this, 1.0D, false));
|
||||||
|
this.tasks.addTask(5, new EntityAIWanderAvoidWater(this, 0.8D));
|
||||||
|
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||||
|
this.tasks.addTask(6, new EntityAILookIdle(this));
|
||||||
|
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
|
||||||
|
this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyEntityAttributes()
|
||||||
|
{
|
||||||
|
super.applyEntityAttributes();
|
||||||
|
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxFallHeight()
|
||||||
|
{
|
||||||
|
return this.getAttackTarget() == null ? 3 : 3 + (int) (this.getHealth() - 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fall(float distance, float damageMultiplier)
|
||||||
|
{
|
||||||
|
super.fall(distance, damageMultiplier);
|
||||||
|
this.timeSinceIgnited = (int) ((float) this.timeSinceIgnited + distance * 1.5F);
|
||||||
|
|
||||||
|
if (this.timeSinceIgnited > this.fuseTime - 5)
|
||||||
|
{
|
||||||
|
this.timeSinceIgnited = this.fuseTime - 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void entityInit()
|
||||||
|
{
|
||||||
|
super.entityInit();
|
||||||
|
this.dataManager.register(STATE, -1);
|
||||||
|
this.dataManager.register(POWERED, Boolean.FALSE);
|
||||||
|
this.dataManager.register(IGNITED, Boolean.FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeEntityToNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.writeEntityToNBT(compound);
|
||||||
|
|
||||||
|
if (this.dataManager.get(POWERED))
|
||||||
|
{
|
||||||
|
compound.setBoolean("powered", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
compound.setShort("Fuse", (short) this.fuseTime);
|
||||||
|
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
|
||||||
|
compound.setBoolean("ignited", this.hasIgnited());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readEntityFromNBT(NBTTagCompound compound)
|
||||||
|
{
|
||||||
|
super.readEntityFromNBT(compound);
|
||||||
|
this.dataManager.set(POWERED, compound.getBoolean("powered"));
|
||||||
|
|
||||||
|
if (compound.hasKey("Fuse", 99))
|
||||||
|
{
|
||||||
|
this.fuseTime = compound.getShort("Fuse");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.hasKey("ExplosionRadius", 99))
|
||||||
|
{
|
||||||
|
this.explosionRadius = compound.getByte("ExplosionRadius");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compound.getBoolean("ignited"))
|
||||||
|
{
|
||||||
|
this.ignite();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
{
|
{
|
||||||
if (this.isEntityAlive())
|
if (this.isEntityAlive())
|
||||||
|
@ -53,10 +159,102 @@ public class EntitySmavaCreeper extends EntityCreeper
|
||||||
this.explode();
|
this.explode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onUpdate();
|
super.onUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getAmbientSound()
|
||||||
|
{
|
||||||
|
return ModSoundEvents.ENTITY_SMAVACREEPER_AMBIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
||||||
|
{
|
||||||
|
return ModSoundEvents.ENTITY_SMAVACREEPER_HURT;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SoundEvent getDeathSound()
|
||||||
|
{
|
||||||
|
return SoundEvents.ENTITY_CREEPER_DEATH;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDeath(DamageSource cause)
|
||||||
|
{
|
||||||
|
super.onDeath(cause);
|
||||||
|
|
||||||
|
if (this.world.getGameRules().getBoolean("doMobLoot"))
|
||||||
|
{
|
||||||
|
if (cause.getTrueSource() instanceof EntitySkeleton)
|
||||||
|
{
|
||||||
|
int i = Item.getIdFromItem(Items.RECORD_13);
|
||||||
|
int j = Item.getIdFromItem(Items.RECORD_WAIT);
|
||||||
|
int k = i + this.rand.nextInt(j - i + 1);
|
||||||
|
this.dropItem(Item.getItemById(k), 1);
|
||||||
|
} else if (cause.getTrueSource() instanceof mod.acgaming.spackenmobs.entities.EntitySmavaCreeper && cause.getTrueSource() != this && ((mod.acgaming.spackenmobs.entities.EntitySmavaCreeper) cause.getTrueSource()).getPowered() && ((mod.acgaming.spackenmobs.entities.EntitySmavaCreeper) cause.getTrueSource()).ableToCauseSkullDrop())
|
||||||
|
{
|
||||||
|
((mod.acgaming.spackenmobs.entities.EntitySmavaCreeper) cause.getTrueSource()).incrementDroppedSkulls();
|
||||||
|
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean attackEntityAsMob(Entity entityIn)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getPowered()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(POWERED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public float getCreeperFlashIntensity(float p_70831_1_)
|
||||||
|
{
|
||||||
|
return ((float) this.lastActiveTime + (float) (this.timeSinceIgnited - this.lastActiveTime) * p_70831_1_) / (float) (this.fuseTime - 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
protected ResourceLocation getLootTable()
|
||||||
|
{
|
||||||
|
return LootTableList.ENTITIES_CREEPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreeperState()
|
||||||
|
{
|
||||||
|
return this.dataManager.get(STATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreeperState(int state)
|
||||||
|
{
|
||||||
|
this.dataManager.set(STATE, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStruckByLightning(EntityLightningBolt lightningBolt)
|
||||||
|
{
|
||||||
|
super.onStruckByLightning(lightningBolt);
|
||||||
|
this.dataManager.set(POWERED, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean processInteract(EntityPlayer player, EnumHand hand)
|
||||||
|
{
|
||||||
|
ItemStack itemstack = player.getHeldItem(hand);
|
||||||
|
|
||||||
|
if (itemstack.getItem() == Items.FLINT_AND_STEEL)
|
||||||
|
{
|
||||||
|
this.world.playSound(player, this.posX, this.posY, this.posZ, SoundEvents.ITEM_FLINTANDSTEEL_USE, this.getSoundCategory(), 1.0F, this.rand.nextFloat() * 0.4F + 0.8F);
|
||||||
|
player.swingArm(hand);
|
||||||
|
|
||||||
|
if (!this.world.isRemote)
|
||||||
|
{
|
||||||
|
this.ignite();
|
||||||
|
itemstack.damageItem(1, player);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.processInteract(player, hand);
|
||||||
|
}
|
||||||
|
|
||||||
private void explode()
|
private void explode()
|
||||||
{
|
{
|
||||||
if (!this.world.isRemote)
|
if (!this.world.isRemote)
|
||||||
|
@ -64,22 +262,52 @@ public class EntitySmavaCreeper extends EntityCreeper
|
||||||
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
boolean flag = net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.world, this);
|
||||||
float f = this.getPowered() ? 2.0F : 1.0F;
|
float f = this.getPowered() ? 2.0F : 1.0F;
|
||||||
this.dead = true;
|
this.dead = true;
|
||||||
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_SMAVACREEPER_BLOW, getSoundCategory(), 5.0F,
|
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_SMAVACREEPER_BLOW, getSoundCategory(), 5.0F, 1.0F);
|
||||||
1.0F);
|
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
|
||||||
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
|
|
||||||
this.setDead();
|
this.setDead();
|
||||||
|
this.spawnLingeringCloud();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private void spawnLingeringCloud()
|
||||||
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
|
|
||||||
{
|
{
|
||||||
return ModSoundEvents.ENTITY_SMAVACREEPER_HURT;
|
Collection<PotionEffect> collection = this.getActivePotionEffects();
|
||||||
|
|
||||||
|
if (!collection.isEmpty())
|
||||||
|
{
|
||||||
|
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ);
|
||||||
|
entityareaeffectcloud.setRadius(2.5F);
|
||||||
|
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||||
|
entityareaeffectcloud.setWaitTime(10);
|
||||||
|
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
|
||||||
|
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
|
||||||
|
|
||||||
|
for (PotionEffect potioneffect : collection)
|
||||||
|
{
|
||||||
|
entityareaeffectcloud.addEffect(new PotionEffect(potioneffect));
|
||||||
|
}
|
||||||
|
|
||||||
|
this.world.spawnEntity(entityareaeffectcloud);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public boolean hasIgnited()
|
||||||
protected SoundEvent getAmbientSound()
|
|
||||||
{
|
{
|
||||||
return ModSoundEvents.ENTITY_SMAVACREEPER_AMBIENT;
|
return this.dataManager.get(IGNITED);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ignite()
|
||||||
|
{
|
||||||
|
this.dataManager.set(IGNITED, Boolean.TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean ableToCauseSkullDrop()
|
||||||
|
{
|
||||||
|
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void incrementDroppedSkulls()
|
||||||
|
{
|
||||||
|
++this.droppedSkulls;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package mod.acgaming.spackenmobs.entities.ai;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
|
|
||||||
|
public class EntityAIBakaMitaiCreeperSwell extends EntityAIBase
|
||||||
|
{
|
||||||
|
EntityBakaMitaiCreeper swellingCreeper;
|
||||||
|
EntityLivingBase creeperAttackTarget;
|
||||||
|
|
||||||
|
public EntityAIBakaMitaiCreeperSwell(EntityBakaMitaiCreeper entitycreeperIn)
|
||||||
|
{
|
||||||
|
this.swellingCreeper = entitycreeperIn;
|
||||||
|
this.setMutexBits(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldExecute()
|
||||||
|
{
|
||||||
|
EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget();
|
||||||
|
return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSq(entitylivingbase) < 9.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startExecuting()
|
||||||
|
{
|
||||||
|
this.swellingCreeper.getNavigator().clearPath();
|
||||||
|
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTask()
|
||||||
|
{
|
||||||
|
this.creeperAttackTarget = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTask()
|
||||||
|
{
|
||||||
|
if (this.creeperAttackTarget == null)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (this.swellingCreeper.getDistanceSq(this.creeperAttackTarget) > 49.0D)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget))
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities.ai;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.EntityJens;
|
||||||
import net.minecraft.block.BlockJukebox;
|
import net.minecraft.block.BlockJukebox;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
|
@ -43,8 +44,7 @@ public class EntityAIDance extends EntityAIBase
|
||||||
{
|
{
|
||||||
for (int z = -this.searchRadius; z <= this.searchRadius; z++)
|
for (int z = -this.searchRadius; z <= this.searchRadius; z++)
|
||||||
{
|
{
|
||||||
if (this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getBlock() == Blocks.JUKEBOX
|
if (this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getBlock() == Blocks.JUKEBOX && this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getValue(BlockJukebox.HAS_RECORD))
|
||||||
&& this.jens.world.getBlockState(this.jens.getPosition().add(x, y, z)).getValue(BlockJukebox.HAS_RECORD))
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ public class EntityAIDance extends EntityAIBase
|
||||||
this.jens.setSneaking(false);
|
this.jens.setSneaking(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.lastDanceMoveTime = this.jens.world.rand.nextInt(10) + 5;
|
this.lastDanceMoveTime = this.jens.world.rand.nextInt(20) + 10;
|
||||||
}
|
}
|
||||||
this.lastDanceMoveTime--;
|
this.lastDanceMoveTime--;
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
package mod.acgaming.spackenmobs.entities;
|
package mod.acgaming.spackenmobs.entities.ai;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.EntityJens;
|
||||||
import net.minecraft.entity.ai.EntityAIBase;
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
|
@ -0,0 +1,51 @@
|
||||||
|
package mod.acgaming.spackenmobs.entities.ai;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.EntityIslamist;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
|
|
||||||
|
public class EntityAIIslamistSwell extends EntityAIBase
|
||||||
|
{
|
||||||
|
EntityIslamist swellingCreeper;
|
||||||
|
EntityLivingBase creeperAttackTarget;
|
||||||
|
|
||||||
|
public EntityAIIslamistSwell(EntityIslamist entitycreeperIn)
|
||||||
|
{
|
||||||
|
this.swellingCreeper = entitycreeperIn;
|
||||||
|
this.setMutexBits(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldExecute()
|
||||||
|
{
|
||||||
|
EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget();
|
||||||
|
return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSq(entitylivingbase) < 9.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startExecuting()
|
||||||
|
{
|
||||||
|
this.swellingCreeper.getNavigator().clearPath();
|
||||||
|
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTask()
|
||||||
|
{
|
||||||
|
this.creeperAttackTarget = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTask()
|
||||||
|
{
|
||||||
|
if (this.creeperAttackTarget == null)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (this.swellingCreeper.getDistanceSq(this.creeperAttackTarget) > 49.0D)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget))
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package mod.acgaming.spackenmobs.entities.ai;
|
||||||
|
|
||||||
|
import mod.acgaming.spackenmobs.entities.EntitySmavaCreeper;
|
||||||
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
import net.minecraft.entity.ai.EntityAIBase;
|
||||||
|
|
||||||
|
public class EntityAISmavaCreeperSwell extends EntityAIBase
|
||||||
|
{
|
||||||
|
EntitySmavaCreeper swellingCreeper;
|
||||||
|
EntityLivingBase creeperAttackTarget;
|
||||||
|
|
||||||
|
public EntityAISmavaCreeperSwell(EntitySmavaCreeper entitycreeperIn)
|
||||||
|
{
|
||||||
|
this.swellingCreeper = entitycreeperIn;
|
||||||
|
this.setMutexBits(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldExecute()
|
||||||
|
{
|
||||||
|
EntityLivingBase entitylivingbase = this.swellingCreeper.getAttackTarget();
|
||||||
|
return this.swellingCreeper.getCreeperState() > 0 || entitylivingbase != null && this.swellingCreeper.getDistanceSq(entitylivingbase) < 9.0D;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startExecuting()
|
||||||
|
{
|
||||||
|
this.swellingCreeper.getNavigator().clearPath();
|
||||||
|
this.creeperAttackTarget = this.swellingCreeper.getAttackTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resetTask()
|
||||||
|
{
|
||||||
|
this.creeperAttackTarget = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTask()
|
||||||
|
{
|
||||||
|
if (this.creeperAttackTarget == null)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (this.swellingCreeper.getDistanceSq(this.creeperAttackTarget) > 49.0D)
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else if (!this.swellingCreeper.getEntitySenses().canSee(this.creeperAttackTarget))
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(-1);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
this.swellingCreeper.setCreeperState(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,15 +9,16 @@ public class ModEntities
|
||||||
public static void initModels()
|
public static void initModels()
|
||||||
{
|
{
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityApoRed.class, RenderApoRed.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityApoRed.class, RenderApoRed.FACTORY);
|
||||||
|
RenderingRegistry.registerEntityRenderingHandler(EntityBakaMitaiCreeper.class, RenderBakaMitaiCreeper.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityDrachenlord.class, RenderDrachenlord.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityDrachenlord.class, RenderDrachenlord.FACTORY);
|
||||||
|
RenderingRegistry.registerEntityRenderingHandler(EntityFriedrichLiechtenstein.class, RenderFriedrichLiechtenstein.FACTORY);
|
||||||
|
RenderingRegistry.registerEntityRenderingHandler(EntityHolzstammhuhn.class, RenderHolzstammhuhn.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityIslamist.class, RenderIslamist.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityIslamist.class, RenderIslamist.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityJens.class, RenderJens.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityJens.class, RenderJens.FACTORY);
|
||||||
|
RenderingRegistry.registerEntityRenderingHandler(EntityMZTEWolf.class, RenderMZTEWolf.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityMarcellDAvis.class, RenderMarcellDAvis.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityMarcellDAvis.class, RenderMarcellDAvis.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityMrBean.class, RenderMrBean.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntityMrBean.class, RenderMrBean.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntitySchalker.class, RenderSchalker.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntitySchalker.class, RenderSchalker.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntitySmavaCreeper.class, RenderSmavaCreeper.FACTORY);
|
RenderingRegistry.registerEntityRenderingHandler(EntitySmavaCreeper.class, RenderSmavaCreeper.FACTORY);
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityMZTEWolf.class, RenderMZTEWolf.FACTORY);
|
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityHolzstammhuhn.class, RenderHolzstammhuhn.FACTORY);
|
|
||||||
RenderingRegistry.registerEntityRenderingHandler(EntityFriedrichLiechtenstein.class, RenderFriedrichLiechtenstein.FACTORY);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,12 +1,11 @@
|
||||||
package mod.acgaming.spackenmobs.render;
|
package mod.acgaming.spackenmobs.render;
|
||||||
|
|
||||||
import mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper;
|
import mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper;
|
||||||
|
import net.minecraft.client.model.ModelCreeper;
|
||||||
import net.minecraft.client.renderer.GlStateManager;
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderCreeper;
|
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge;
|
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||||
|
@ -14,17 +13,17 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderBakaMitaiCreeper extends RenderCreeper
|
public class RenderBakaMitaiCreeper extends RenderLiving<EntityBakaMitaiCreeper>
|
||||||
{
|
{
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private static final ResourceLocation CREEPER_TEXTURE = new ResourceLocation("textures/entity/creeper/creeper.png");
|
private static final ResourceLocation CREEPER_TEXTURE = new ResourceLocation("textures/entity/creeper/creeper.png");
|
||||||
|
|
||||||
public RenderBakaMitaiCreeper(RenderManager renderManagerIn)
|
public RenderBakaMitaiCreeper(RenderManager renderManagerIn)
|
||||||
{
|
{
|
||||||
super(renderManagerIn);
|
super(renderManagerIn, new ModelCreeper(), 0.5F);
|
||||||
this.addLayer(new LayerCreeperCharge(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected int getColorMultiplier(EntityBakaMitaiCreeper entitylivingbaseIn, float lightBrightness, float partialTickTime)
|
protected int getColorMultiplier(EntityBakaMitaiCreeper entitylivingbaseIn, float lightBrightness, float partialTickTime)
|
||||||
{
|
{
|
||||||
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
@ -41,11 +40,12 @@ public class RenderBakaMitaiCreeper extends RenderCreeper
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(EntityCreeper entity)
|
protected ResourceLocation getEntityTexture(EntityBakaMitaiCreeper entity)
|
||||||
{
|
{
|
||||||
return CREEPER_TEXTURE;
|
return CREEPER_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void preRenderCallback(EntityBakaMitaiCreeper entitylivingbaseIn, float partialTickTime)
|
protected void preRenderCallback(EntityBakaMitaiCreeper entitylivingbaseIn, float partialTickTime)
|
||||||
{
|
{
|
||||||
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
|
|
@ -1,35 +1,63 @@
|
||||||
package mod.acgaming.spackenmobs.render;
|
package mod.acgaming.spackenmobs.render;
|
||||||
|
|
||||||
import mod.acgaming.spackenmobs.entities.EntityIslamist;
|
import mod.acgaming.spackenmobs.entities.EntityIslamist;
|
||||||
|
import net.minecraft.client.model.ModelCreeper;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderCreeper;
|
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge;
|
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderIslamist extends RenderCreeper
|
public class RenderIslamist extends RenderLiving<EntityIslamist>
|
||||||
{
|
{
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private static final ResourceLocation ISLAMIST_TEXTURE = new ResourceLocation(
|
private static final ResourceLocation ISLAMIST_TEXTURE = new ResourceLocation("spackenmobs:textures/entities/islamist.png");
|
||||||
"spackenmobs:textures/entities/islamist.png");
|
|
||||||
|
|
||||||
public RenderIslamist(RenderManager renderManagerIn)
|
public RenderIslamist(RenderManager renderManagerIn)
|
||||||
{
|
{
|
||||||
super(renderManagerIn);
|
super(renderManagerIn, new ModelCreeper(), 0.5F);
|
||||||
this.addLayer(new LayerCreeperCharge(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(EntityCreeper entity)
|
protected int getColorMultiplier(EntityIslamist entitylivingbaseIn, float lightBrightness, float partialTickTime)
|
||||||
|
{
|
||||||
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
|
||||||
|
if ((int) (f * 10.0F) % 2 == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
int i = (int) (f * 0.2F * 255.0F);
|
||||||
|
i = MathHelper.clamp(i, 0, 255);
|
||||||
|
return i << 24 | 822083583;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ResourceLocation getEntityTexture(EntityIslamist entity)
|
||||||
{
|
{
|
||||||
return ISLAMIST_TEXTURE;
|
return ISLAMIST_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRenderCallback(EntityIslamist entitylivingbaseIn, float partialTickTime)
|
||||||
|
{
|
||||||
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F;
|
||||||
|
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
||||||
|
f = f * f;
|
||||||
|
f = f * f;
|
||||||
|
float f2 = (1.0F + f * 0.4F) * f1;
|
||||||
|
float f3 = (1.0F + f * 0.1F) / f1;
|
||||||
|
GlStateManager.scale(f2, f3, f2);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Factory implements IRenderFactory<EntityIslamist>
|
public static class Factory implements IRenderFactory<EntityIslamist>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,35 +1,63 @@
|
||||||
package mod.acgaming.spackenmobs.render;
|
package mod.acgaming.spackenmobs.render;
|
||||||
|
|
||||||
import mod.acgaming.spackenmobs.entities.EntitySmavaCreeper;
|
import mod.acgaming.spackenmobs.entities.EntitySmavaCreeper;
|
||||||
|
import net.minecraft.client.model.ModelCreeper;
|
||||||
|
import net.minecraft.client.renderer.GlStateManager;
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
import net.minecraft.client.renderer.entity.Render;
|
||||||
import net.minecraft.client.renderer.entity.RenderCreeper;
|
import net.minecraft.client.renderer.entity.RenderLiving;
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
import net.minecraft.client.renderer.entity.layers.LayerCreeperCharge;
|
|
||||||
import net.minecraft.entity.monster.EntityCreeper;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderSmavaCreeper extends RenderCreeper
|
public class RenderSmavaCreeper extends RenderLiving<EntitySmavaCreeper>
|
||||||
{
|
{
|
||||||
public static final Factory FACTORY = new Factory();
|
public static final Factory FACTORY = new Factory();
|
||||||
private static final ResourceLocation SMAVA_TEXTURE = new ResourceLocation(
|
private static final ResourceLocation SMAVA_TEXTURE = new ResourceLocation("spackenmobs:textures/entities/smava_creeper.png");
|
||||||
"spackenmobs:textures/entities/smava_creeper.png");
|
|
||||||
|
|
||||||
public RenderSmavaCreeper(RenderManager renderManagerIn)
|
public RenderSmavaCreeper(RenderManager renderManagerIn)
|
||||||
{
|
{
|
||||||
super(renderManagerIn);
|
super(renderManagerIn, new ModelCreeper(), 0.5F);
|
||||||
this.addLayer(new LayerCreeperCharge(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResourceLocation getEntityTexture(EntityCreeper entity)
|
protected int getColorMultiplier(EntitySmavaCreeper entitylivingbaseIn, float lightBrightness, float partialTickTime)
|
||||||
|
{
|
||||||
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
|
||||||
|
if ((int) (f * 10.0F) % 2 == 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
int i = (int) (f * 0.2F * 255.0F);
|
||||||
|
i = MathHelper.clamp(i, 0, 255);
|
||||||
|
return i << 24 | 822083583;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ResourceLocation getEntityTexture(EntitySmavaCreeper entity)
|
||||||
{
|
{
|
||||||
return SMAVA_TEXTURE;
|
return SMAVA_TEXTURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void preRenderCallback(EntitySmavaCreeper entitylivingbaseIn, float partialTickTime)
|
||||||
|
{
|
||||||
|
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
|
||||||
|
float f1 = 1.0F + MathHelper.sin(f * 100.0F) * f * 0.01F;
|
||||||
|
f = MathHelper.clamp(f, 0.0F, 1.0F);
|
||||||
|
f = f * f;
|
||||||
|
f = f * f;
|
||||||
|
float f2 = (1.0F + f * 0.4F) * f1;
|
||||||
|
float f3 = (1.0F + f * 0.1F) / f1;
|
||||||
|
GlStateManager.scale(f2, f3, f2);
|
||||||
|
}
|
||||||
|
|
||||||
public static class Factory implements IRenderFactory<EntitySmavaCreeper>
|
public static class Factory implements IRenderFactory<EntitySmavaCreeper>
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue