Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.turtledove.necropolisofnostalgia.server.entity.Spiral_Draco;
- import com.turtledove.necropolisofnostalgia.server.entity.NecropolisEntity;
- import com.turtledove.necropolisofnostalgia.server.entity.NecropolisMultiPart;
- import com.turtledove.necropolisofnostalgia.server.ai.NecropolisPathNavigateGround;
- import com.turtledove.necropolisofnostalgia.server.ai.Spiral_DracoChargeTargetAI;
- import javax.annotation.Nullable;
- import net.minecraft.entity.*;
- import net.minecraft.entity.ai.*;
- import net.minecraft.entity.monster.EntityIronGolem;
- import net.minecraft.entity.monster.EntitySpider;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.SoundEvents;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.network.datasync.DataParameter;
- import net.minecraft.potion.PotionEffect;
- import net.minecraft.util.*;
- import net.minecraft.pathfinding.PathNavigate;
- import net.minecraft.util.DamageSource;
- import net.minecraft.world.World;
- import net.minecraft.network.datasync.EntityDataManager;
- import net.minecraft.network.datasync.DataSerializers;
- import net.minecraft.world.storage.loot.LootTableList;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import java.util.List;
- import net.ilexiconn.llibrary.server.entity.multipart.IMultipartEntity;
- public class EntitySpiral_Draco extends EntityCreature implements IMultipartEntity
- {
- private static final Logger LOGGER = LogManager.getLogger();
- /** An array containing all body parts */
- public NecropolisMultiPart[] spiral_dracoPartArray;
- /** The bounding box of the draco */
- public NecropolisMultiPart spiral_dracoPartFRLeg = new NecropolisMultiPart(this, 2F, -45, 0.0F, 1F, 4F, 0.5F);
- public NecropolisMultiPart spiral_dracoPartFLLeg = new NecropolisMultiPart(this, 2F, 45, 0.0F, 1F, 4F, 0.5F);
- public double[][] ringBuffer = new double[64][3];
- public int ringBufferIndex = -1;
- private boolean isModelDead;
- private static final DataParameter<Boolean> MODEL_DEAD = EntityDataManager.createKey(EntitySpiral_Draco.class, DataSerializers.BOOLEAN);
- public EntitySpiral_Draco(World worldIn)
- {
- super(worldIn);
- this.spiral_dracoPartArray = new NecropolisMultiPart[] {this.spiral_dracoPartFRLeg,this.spiral_dracoPartFLLeg};
- this.setHealth(this.getMaxHealth());
- this.setSize(0.25F, 0.25F);
- this.noClip = false;
- this.isImmuneToFire = true;
- this.ignoreFrustumCheck = true;
- }
- protected void initEntityAI()
- {
- this.tasks.addTask(2, new Spiral_DracoChargeTargetAI(this, EntityPlayer.class, 50.0F, 0.4F));
- this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
- }
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D);
- }
- protected void entityInit()
- {
- super.entityInit();
- }
- public void onUpdate()
- {
- super.onUpdate();
- updateParts();
- if (this.world.isRemote)
- {
- this.setHealth(this.getHealth());
- }
- if (this.getHealth() <= 0.0F)
- {
- float f12 = (this.rand.nextFloat() - 0.5F) * 8.0F;
- float f13 = (this.rand.nextFloat() - 0.5F) * 4.0F;
- float f15 = (this.rand.nextFloat() - 0.5F) * 8.0F;
- this.world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, this.posX + (double)f12, this.posY + 2.0D + (double)f13, this.posZ + (double)f15, 0.0D, 0.0D, 0.0D);
- }
- else
- {
- if (!this.world.isRemote && this.hurtTime == 0)
- {
- this.collideWithEntities(this.world.getEntitiesWithinAABBExcludingEntity(this, this.spiral_dracoPartFRLeg.getEntityBoundingBox().grow(1.0D)));
- this.collideWithEntities(this.world.getEntitiesWithinAABBExcludingEntity(this, this.spiral_dracoPartFLLeg.getEntityBoundingBox().grow(1.0D)));
- }
- }
- }
- public void updateParts()
- {
- if (spiral_dracoPartFRLeg != null)
- {
- spiral_dracoPartFRLeg.onUpdate();
- }
- if (spiral_dracoPartFLLeg != null)
- {
- spiral_dracoPartFLLeg.onUpdate();
- }
- }
- /**
- * Pushes all entities inside the list away from the enderdragon.
- */
- private void collideWithEntities(List<Entity> p_70970_1_)
- {
- double FR_leg_1 = (this.spiral_dracoPartFRLeg.getEntityBoundingBox().minX + this.spiral_dracoPartFRLeg.getEntityBoundingBox().maxX) / 2.0D;
- double FR_leg_2 = (this.spiral_dracoPartFRLeg.getEntityBoundingBox().minZ + this.spiral_dracoPartFRLeg.getEntityBoundingBox().maxZ) / 2.0D;
- double FL_leg_1 = (this.spiral_dracoPartFLLeg.getEntityBoundingBox().minX + this.spiral_dracoPartFLLeg.getEntityBoundingBox().maxX) / 2.0D;
- double FL_leg_2 = (this.spiral_dracoPartFLLeg.getEntityBoundingBox().minZ + this.spiral_dracoPartFLLeg.getEntityBoundingBox().maxZ) / 2.0D;
- for (Entity entity : p_70970_1_)
- {
- if (entity instanceof EntityLivingBase)
- {
- double d2 = entity.posX - FR_leg_1;
- double d3 = entity.posZ - FR_leg_2;
- double d4 = d2 * d2 + d3 * d3;
- entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
- entity.attackEntityFrom(DamageSource.causeMobDamage(this), 10.0F);
- }
- }
- for (Entity entity : p_70970_1_)
- {
- if (entity instanceof EntityLivingBase)
- {
- double d2 = entity.posX - FL_leg_1;
- double d3 = entity.posZ - FL_leg_2;
- double d4 = d2 * d2 + d3 * d3;
- entity.addVelocity(d2 / d4 * 4.0D, 0.20000000298023224D, d3 / d4 * 4.0D);
- entity.attackEntityFrom(DamageSource.causeMobDamage(this), 5.0F);
- }
- }
- }
- /**
- * Called when the entity is attacked.
- */
- public boolean attackEntityFrom(DamageSource source, float amount)
- {
- if (source.getTrueSource() instanceof EntityPlayer)
- {
- return super.attackEntityFrom(source, amount);
- }
- return false;
- }
- /**
- * Called by the /kill command.
- */
- public void onKillCommand()
- {
- this.setDead();
- }
- /**
- * (abstract) Protected helper method to write subclass entity data to NBT.
- */
- public void writeEntityToNBT(NBTTagCompound compound)
- {
- super.writeEntityToNBT(compound);
- }
- /**
- * (abstract) Protected helper method to read subclass entity data from NBT.
- */
- public void readEntityFromNBT(NBTTagCompound compound)
- {
- super.readEntityFromNBT(compound);
- }
- /**
- * Makes the entity despawn if requirements are reached
- */
- protected void despawnEntity()
- {
- }
- /**
- * Return the Entity parts making up this Entity (currently only for dragons)
- */
- public Entity[] getParts()
- {
- return this.spiral_dracoPartArray;
- }
- /**
- * Returns true if other Entities should be prevented from moving through this Entity.
- */
- public boolean canBeCollidedWith()
- {
- return false;
- }
- public World getWorld()
- {
- return this.world;
- }
- public SoundCategory getSoundCategory()
- {
- return SoundCategory.HOSTILE;
- }
- protected SoundEvent getAmbientSound()
- {
- return SoundEvents.ENTITY_ENDERDRAGON_AMBIENT;
- }
- protected SoundEvent getHurtSound(DamageSource damageSourceIn)
- {
- return SoundEvents.ENTITY_ENDERDRAGON_HURT;
- }
- /**
- * Returns the volume for the sounds this mob makes.
- */
- protected float getSoundVolume()
- {
- return 5.0F;
- }
- @Nullable
- protected ResourceLocation getLootTable()
- {
- return LootTableList.ENTITIES_ENDER_DRAGON;
- }
- public void notifyDataManagerChange(DataParameter<?> key)
- {
- super.notifyDataManagerChange(key);
- }
- /**
- * adds a PotionEffect to the entity
- */
- public void addPotionEffect(PotionEffect potioneffectIn)
- {
- }
- protected boolean canBeRidden(Entity entityIn)
- {
- return false;
- }
- /**
- * Returns false if this Entity is a boss, true otherwise.
- */
- public boolean isNonBoss()
- {
- return false;
- }
- public boolean isModelDead()
- {
- if (world.isRemote) {
- return this.isModelDead = Boolean.valueOf(this.dataManager.get(MODEL_DEAD).booleanValue());
- }
- return isModelDead;
- }
- public float getEyeHeight()
- {
- return 0.65F;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment