2
1
Fork 1
mirror of https://github.com/ACGaming/Spackenmobs synced 2024-05-19 11:54:25 +02:00

Cleaner approach to creepers

This commit is contained in:
ACGaming 2020-10-17 13:57:39 +02:00
parent b7b0baec7e
commit 62ba74ee14
13 changed files with 887 additions and 254 deletions

View file

@ -1,12 +1,13 @@
package mod.acgaming.spackenmobs.entities;
import mod.acgaming.spackenmobs.entities.ai.EntityAIBakaMitaiCreeperSwell;
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.ai.*;
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.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
@ -31,7 +32,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import javax.annotation.Nullable;
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<Boolean> POWERED = EntityDataManager.createKey(EntityBakaMitaiCreeper.class, DataSerializers.BOOLEAN);
@ -48,53 +49,34 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
this.setSize(0.6F, 1.7F);
}
@Override
public boolean ableToCauseSkullDrop()
protected void initEntityAI()
{
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()
{
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.25D);
}
@Override
public boolean attackEntityAsMob(Entity entityIn)
public int getMaxFallHeight()
{
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)
{
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)
{
@ -102,118 +84,49 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
}
}
@Override
@SideOnly(Side.CLIENT)
public float getCreeperFlashIntensity(float p_70831_1_)
protected void entityInit()
{
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 int getCreeperState()
public void writeEntityToNBT(NBTTagCompound compound)
{
return this.dataManager.get(STATE);
}
super.writeEntityToNBT(compound);
@Override
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 ((Boolean) this.dataManager.get(POWERED))
{
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 EntityBakaMitaiCreeper && cause.getTrueSource() != this && ((EntityBakaMitaiCreeper) cause.getTrueSource()).getPowered()
&& ((EntityBakaMitaiCreeper) cause.getTrueSource()).ableToCauseSkullDrop())
{
((EntityBakaMitaiCreeper) cause.getTrueSource()).incrementDroppedSkulls();
this.entityDropItem(new ItemStack(Items.SKULL, 1, 4), 0.0F);
}
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 onStruckByLightning(EntityLightningBolt lightningBolt)
{
super.onStruckByLightning(lightningBolt);
this.dataManager.set(POWERED, true);
}
@Override
public void onUpdate()
{
if (this.isEntityAlive())
@ -245,11 +158,77 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
this.explode();
}
}
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)
{
ItemStack itemstack = player.getHeldItem(hand);
@ -270,25 +249,17 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
return super.processInteract(player, hand);
}
@Override
public void readEntityFromNBT(NBTTagCompound compound)
private void explode()
{
super.readEntityFromNBT(compound);
this.dataManager.set(POWERED, compound.getBoolean("powered"));
if (compound.hasKey("Fuse", 99))
if (!this.world.isRemote)
{
this.fuseTime = compound.getShort("Fuse");
}
if (compound.hasKey("ExplosionRadius", 99))
{
this.explosionRadius = compound.getByte("ExplosionRadius");
}
if (compound.getBoolean("ignited"))
{
this.ignite();
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(), 2.0F, 1.0F);
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
this.setDead();
this.spawnLingeringCloud();
}
}
@ -303,7 +274,7 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
entityareaeffectcloud.setRadiusOnUse(-0.5F);
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setDuration(entityareaeffectcloud.getDuration() / 2);
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / entityareaeffectcloud.getDuration());
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
for (PotionEffect potioneffect : collection)
{
@ -314,18 +285,23 @@ public class EntityBakaMitaiCreeper extends EntityCreeper
}
}
@Override
public void writeEntityToNBT(NBTTagCompound compound)
public boolean hasIgnited()
{
super.writeEntityToNBT(compound);
return this.dataManager.get(IGNITED);
}
if (this.dataManager.get(POWERED))
{
compound.setBoolean("powered", true);
}
public void ignite()
{
this.dataManager.set(IGNITED, Boolean.TRUE);
}
compound.setShort("Fuse", (short) this.fuseTime);
compound.setByte("ExplosionRadius", (byte) this.explosionRadius);
compound.setBoolean("ignited", this.hasIgnited());
public boolean ableToCauseSkullDrop()
{
return this.droppedSkulls < 1 && this.world.getGameRules().getBoolean("doMobLoot");
}
public void incrementDroppedSkulls()
{
++this.droppedSkulls;
}
}

View file

@ -1,17 +1,47 @@
package mod.acgaming.spackenmobs.entities;
import mod.acgaming.spackenmobs.entities.ai.EntityAIIslamistSwell;
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.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
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 final int explosionRadius = 6;
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntityIslamist.class, DataSerializers.VARINT);
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 timeSinceIgnited;
private int fuseTime = 30;
private int explosionRadius = 6;
private int droppedSkulls;
public EntityIslamist(World worldIn)
{
@ -19,7 +49,84 @@ public class EntityIslamist extends EntityCreeper
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()
{
if (this.isEntityAlive())
@ -51,10 +158,97 @@ public class EntityIslamist extends EntityCreeper
this.explode();
}
}
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()
{
if (!this.world.isRemote)
@ -62,22 +256,52 @@ public class EntityIslamist extends EntityCreeper
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.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_ISLAMIST_BLOW, getSoundCategory(), 1.0F, 1.0F);
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
this.setDead();
this.spawnLingeringCloud();
}
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
private void spawnLingeringCloud()
{
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
protected SoundEvent getAmbientSound()
public boolean hasIgnited()
{
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;
}
}

View file

@ -1,6 +1,8 @@
package mod.acgaming.spackenmobs.entities;
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.ModItems;
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 Set<Item> TEMPTATION_ITEMS = Sets.newHashSet(ModItems.RAM, Items.FISH);
private static final Set<Item> FISH_ITEMS = Sets.newHashSet(Items.FISH);
public boolean digesting;
public int digestTime;
private boolean boosting;
private int boostTime;
private int totalBoostTime;
public boolean digesting;
public int digestTime;
public EntityJens(World worldIn)
{
@ -87,10 +89,9 @@ public class EntityJens extends EntityAnimal
if (!(entity instanceof EntityPlayer))
{
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;
}
}
@ -168,26 +169,22 @@ public class EntityJens extends EntityAnimal
itemstack.shrink(1);
digestFish();
return true;
}
else if (itemstack.getItem() == Items.NAME_TAG)
} else if (itemstack.getItem() == Items.NAME_TAG)
{
itemstack.interactWithEntity(player, this, hand);
return true;
}
else if (!this.isBeingRidden())
} else if (!this.isBeingRidden())
{
if (!this.world.isRemote)
{
player.startRiding(this);
}
return true;
}
else
} else
{
return false;
}
}
else
} else
{
return true;
}
@ -234,17 +231,16 @@ public class EntityJens extends EntityAnimal
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)
{
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);
super.travel(0.0F, 0.0F, 1.0F);
}
else
} else
{
this.motionX = 0.0D;
this.motionY = 0.0D;
@ -263,8 +259,7 @@ public class EntityJens extends EntityAnimal
this.limbSwingAmount += (f1 - this.limbSwingAmount) * 0.4F;
this.limbSwing += this.limbSwingAmount;
}
else
} else
{
this.stepHeight = 0.5F;
this.jumpMovementFactor = 0.02F;
@ -277,8 +272,7 @@ public class EntityJens extends EntityAnimal
if (this.boosting)
{
return false;
}
else
} else
{
this.boosting = true;
this.boostTime = 0;

View file

@ -1,27 +1,133 @@
package mod.acgaming.spackenmobs.entities;
import mod.acgaming.spackenmobs.entities.ai.EntityAISmavaCreeperSwell;
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.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.EnumHand;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
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 final int explosionRadius = 6;
private static final DataParameter<Integer> STATE = EntityDataManager.createKey(mod.acgaming.spackenmobs.entities.EntitySmavaCreeper.class, DataSerializers.VARINT);
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 timeSinceIgnited;
private int fuseTime = 20;
private int explosionRadius = 6;
private int droppedSkulls;
public EntitySmavaCreeper(World worldIn)
{
super(worldIn);
setSize(0.6F, 1.7F);
getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.5D);
this.setSize(0.6F, 1.7F);
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()
{
if (this.isEntityAlive())
@ -53,10 +159,102 @@ public class EntitySmavaCreeper extends EntityCreeper
this.explode();
}
}
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()
{
if (!this.world.isRemote)
@ -64,22 +262,52 @@ public class EntitySmavaCreeper extends EntityCreeper
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_SMAVACREEPER_BLOW, getSoundCategory(), 5.0F,
1.0F);
this.world.createExplosion(this, this.posX, this.posY, this.posZ, this.explosionRadius * f, flag);
this.world.playSound(null, getPosition(), ModSoundEvents.ENTITY_SMAVACREEPER_BLOW, getSoundCategory(), 5.0F, 1.0F);
this.world.createExplosion(this, this.posX, this.posY, this.posZ, (float) this.explosionRadius * f, flag);
this.setDead();
this.spawnLingeringCloud();
}
}
@Override
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
private void spawnLingeringCloud()
{
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
protected SoundEvent getAmbientSound()
public boolean hasIgnited()
{
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;
}
}

View file

@ -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);
}
}
}

View file

@ -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.entity.ai.EntityAIBase;
import net.minecraft.init.Blocks;
@ -43,8 +44,7 @@ public class EntityAIDance extends EntityAIBase
{
for (int z = -this.searchRadius; z <= this.searchRadius; z++)
{
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))
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))
return true;
}
}
@ -79,8 +79,8 @@ public class EntityAIDance extends EntityAIBase
this.jens.setSneaking(false);
break;
}
this.lastDanceMoveTime = this.jens.world.rand.nextInt(10) + 5;
this.lastDanceMoveTime = this.jens.world.rand.nextInt(20) + 10;
}
this.lastDanceMoveTime--;
}
}
}

View file

@ -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.item.EntityItem;
import net.minecraft.item.ItemStack;

View file

@ -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);
}
}
}

View file

@ -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);
}
}
}

View file

@ -9,15 +9,16 @@ public class ModEntities
public static void initModels()
{
RenderingRegistry.registerEntityRenderingHandler(EntityApoRed.class, RenderApoRed.FACTORY);
RenderingRegistry.registerEntityRenderingHandler(EntityBakaMitaiCreeper.class, RenderBakaMitaiCreeper.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(EntityJens.class, RenderJens.FACTORY);
RenderingRegistry.registerEntityRenderingHandler(EntityMZTEWolf.class, RenderMZTEWolf.FACTORY);
RenderingRegistry.registerEntityRenderingHandler(EntityMarcellDAvis.class, RenderMarcellDAvis.FACTORY);
RenderingRegistry.registerEntityRenderingHandler(EntityMrBean.class, RenderMrBean.FACTORY);
RenderingRegistry.registerEntityRenderingHandler(EntitySchalker.class, RenderSchalker.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);
}
}

View file

@ -1,12 +1,11 @@
package mod.acgaming.spackenmobs.render;
import mod.acgaming.spackenmobs.entities.EntityBakaMitaiCreeper;
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.RenderCreeper;
import net.minecraft.client.renderer.entity.RenderLiving;
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.math.MathHelper;
import net.minecraftforge.fml.client.registry.IRenderFactory;
@ -14,17 +13,17 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderBakaMitaiCreeper extends RenderCreeper
public class RenderBakaMitaiCreeper extends RenderLiving<EntityBakaMitaiCreeper>
{
public static final Factory FACTORY = new Factory();
private static final ResourceLocation CREEPER_TEXTURE = new ResourceLocation("textures/entity/creeper/creeper.png");
public RenderBakaMitaiCreeper(RenderManager renderManagerIn)
{
super(renderManagerIn);
this.addLayer(new LayerCreeperCharge(this));
super(renderManagerIn, new ModelCreeper(), 0.5F);
}
@Override
protected int getColorMultiplier(EntityBakaMitaiCreeper entitylivingbaseIn, float lightBrightness, float partialTickTime)
{
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);
@ -41,11 +40,12 @@ public class RenderBakaMitaiCreeper extends RenderCreeper
}
@Override
protected ResourceLocation getEntityTexture(EntityCreeper entity)
protected ResourceLocation getEntityTexture(EntityBakaMitaiCreeper entity)
{
return CREEPER_TEXTURE;
}
@Override
protected void preRenderCallback(EntityBakaMitaiCreeper entitylivingbaseIn, float partialTickTime)
{
float f = entitylivingbaseIn.getCreeperFlashIntensity(partialTickTime);

View file

@ -1,35 +1,63 @@
package mod.acgaming.spackenmobs.render;
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.RenderCreeper;
import net.minecraft.client.renderer.entity.RenderLiving;
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.math.MathHelper;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderIslamist extends RenderCreeper
public class RenderIslamist extends RenderLiving<EntityIslamist>
{
public static final Factory FACTORY = new Factory();
private static final ResourceLocation ISLAMIST_TEXTURE = new ResourceLocation(
"spackenmobs:textures/entities/islamist.png");
private static final ResourceLocation ISLAMIST_TEXTURE = new ResourceLocation("spackenmobs:textures/entities/islamist.png");
public RenderIslamist(RenderManager renderManagerIn)
{
super(renderManagerIn);
this.addLayer(new LayerCreeperCharge(this));
super(renderManagerIn, new ModelCreeper(), 0.5F);
}
@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;
}
@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>
{
@Override

View file

@ -1,35 +1,63 @@
package mod.acgaming.spackenmobs.render;
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.RenderCreeper;
import net.minecraft.client.renderer.entity.RenderLiving;
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.math.MathHelper;
import net.minecraftforge.fml.client.registry.IRenderFactory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderSmavaCreeper extends RenderCreeper
public class RenderSmavaCreeper extends RenderLiving<EntitySmavaCreeper>
{
public static final Factory FACTORY = new Factory();
private static final ResourceLocation SMAVA_TEXTURE = new ResourceLocation(
"spackenmobs:textures/entities/smava_creeper.png");
private static final ResourceLocation SMAVA_TEXTURE = new ResourceLocation("spackenmobs:textures/entities/smava_creeper.png");
public RenderSmavaCreeper(RenderManager renderManagerIn)
{
super(renderManagerIn);
this.addLayer(new LayerCreeperCharge(this));
super(renderManagerIn, new ModelCreeper(), 0.5F);
}
@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;
}
@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>
{
@Override