Advertisement
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 javax.annotation.Nullable;
- import net.minecraft.entity.*;
- import net.minecraft.entity.item.EntityXPOrb;
- import net.minecraft.entity.monster.IMob;
- 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.util.math.MathHelper;
- import net.minecraft.util.math.Vec3d;
- import net.minecraft.world.EnumDifficulty;
- import net.minecraft.world.World;
- import net.minecraft.world.storage.loot.LootTableList;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import org.apache.logging.log4j.LogManager;
- import org.apache.logging.log4j.Logger;
- import java.util.List;
- public class EntitySpiral_Draco extends NecropolisEntity implements IEntityMultiPart, IMob
- {
- private static final Logger LOGGER = LogManager.getLogger();
- /** An array containing all body parts */
- public MultiPartEntityPart[] spiral_dracoPartArray;
- /** The head bounding box of the draco */
- //public MultiPartEntityPart spiral_dracoPartLHead = new MultiPartEntityPart(this, "Lhead", 6.0F, 6.0F);
- public MultiPartEntityPart spiral_dracoPartRLeg = new MultiPartEntityPart(this, "Chead", 6.0F, 6.0F);
- //public MultiPartEntityPart spiral_dracoPartRHead = new MultiPartEntityPart(this, "Rhead", 6.0F, 6.0F);
- private Vec3d targetLocation;
- public EntitySpiral_Draco(World worldIn)
- {
- super(worldIn);
- this.spiral_dracoPartArray = new MultiPartEntityPart[] {this.spiral_dracoPartRLeg};
- this.setHealth(this.getMaxHealth());
- this.setSize(16.0F, 14.0F);
- this.noClip = true;
- this.isImmuneToFire = true;
- this.targetLocation = null;
- this.setLocationAndAngles(this.posX,this.posY,this.posZ,0,0);
- this.ignoreFrustumCheck = true;
- }
- protected void applyEntityAttributes()
- {
- super.applyEntityAttributes();
- this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(200.0D);
- }
- protected void entityInit()
- {
- super.entityInit();
- }
- public void onUpdate()
- {
- super.onUpdate();
- 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
- {
- //this.spiral_dracoPartLHead.width = 1.0F;
- //this.spiral_dracoPartLHead.height = 1.0F;
- this.spiral_dracoPartRLeg.width = 1.0F;
- this.spiral_dracoPartRLeg.height = 4.0F;
- //this.spiral_dracoPartRHead.height = 1.0F;
- //this.spiral_dracoPartRHead.width = 1.0F;
- Vec3d[] avec3d = new Vec3d[this.spiral_dracoPartArray.length];
- for (int j = 0; j < this.spiral_dracoPartArray.length; ++j)
- {
- avec3d[j] = new Vec3d(this.spiral_dracoPartArray[j].posX, this.spiral_dracoPartArray[j].posY, this.spiral_dracoPartArray[j].posZ);
- }
- if (!this.world.isRemote && this.hurtTime == 0)
- {
- this.collideWithEntities(this.world.getEntitiesWithinAABBExcludingEntity(this, this.spiral_dracoPartRLeg.getEntityBoundingBox().grow(1.0D)));
- }
- this.spiral_dracoPartRLeg.onUpdate();
- this.spiral_dracoPartRLeg.setLocationAndAngles(this.posX + (double)(6.5F), this.posY + (double)(6.5F), this.posZ - (double)(6.5F), 0.0F, 0.0F);
- for (int k = 1; k < 2; ++k)
- {
- MultiPartEntityPart multipartentitypart = null;
- if (k == 0)
- {
- //multipartentitypart = this.spiral_dracoPartLHead;
- }
- if (k == 1)
- {
- multipartentitypart = this.spiral_dracoPartRLeg;
- }
- if (k == 2)
- {
- //multipartentitypart = this.spiral_dracoPartRHead;
- }
- multipartentitypart.onUpdate();
- multipartentitypart.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
- }
- for (int l = 0; l < this.spiral_dracoPartArray.length; ++l)
- {
- this.spiral_dracoPartArray[l].prevPosX = avec3d[l].x;
- this.spiral_dracoPartArray[l].prevPosY = avec3d[l].y;
- this.spiral_dracoPartArray[l].prevPosZ = avec3d[l].z;
- }
- }
- }
- /**
- * Pushes all entities inside the list away from the enderdragon.
- */
- private void collideWithEntities(List<Entity> p_70970_1_)
- {
- double d0 = (this.spiral_dracoPartRLeg.getEntityBoundingBox().minX + this.spiral_dracoPartRLeg.getEntityBoundingBox().maxX) / 2.0D;
- double d1 = (this.spiral_dracoPartRLeg.getEntityBoundingBox().minZ + this.spiral_dracoPartRLeg.getEntityBoundingBox().maxZ) / 2.0D;
- for (Entity entity : p_70970_1_)
- {
- if (entity instanceof EntityLivingBase)
- {
- System.out.print("Collided!");
- double d2 = entity.posX - d0;
- double d3 = entity.posZ - d1;
- 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);
- }
- }
- }
- public boolean attackEntityFromPart(MultiPartEntityPart dragonPart, DamageSource source, float damage)
- {
- if (dragonPart != this.spiral_dracoPartRLeg)
- {
- damage = damage / 4.0F + Math.min(damage, 1.0F);
- }
- if (damage < 0.01F)
- {
- return false;
- }
- else
- {
- if (source.getTrueSource() instanceof EntityPlayer || source.isExplosion())
- {
- float f = this.getHealth();
- this.attackDragonFrom(source, damage);
- }
- return true;
- }
- }
- /**
- * Called when the entity is attacked.
- */
- public boolean attackEntityFrom(DamageSource source, float amount)
- {
- if (source instanceof EntityDamageSource && ((EntityDamageSource)source).getIsThornsDamage())
- {
- this.attackEntityFromPart(this.spiral_dracoPartRLeg, source, amount);
- }
- return false;
- }
- /**
- * Provides a way to cause damage to an ender dragon.
- */
- protected boolean attackDragonFrom(DamageSource source, float amount)
- {
- return super.attackEntityFrom(source, amount);
- }
- /**
- * Called by the /kill command.
- */
- public void onKillCommand()
- {
- this.setDead();
- }
- private void dropExperience(int p_184668_1_)
- {
- while (p_184668_1_ > 0)
- {
- int i = EntityXPOrb.getXPSplit(p_184668_1_);
- p_184668_1_ -= i;
- this.world.spawnEntity(new EntityXPOrb(this.world, this.posX, this.posY, this.posZ, i));
- }
- }
- /**
- * (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 true;
- }
- 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;
- }
- @SideOnly(Side.CLIENT)
- public float getHeadPartYOffset(int p_184667_1_, double[] p_184667_2_, double[] p_184667_3_)
- {
- double d0;
- if (p_184667_1_ == 6)
- {
- d0 = 0.0D;
- }
- else
- {
- d0 = p_184667_3_[1] - p_184667_2_[1];
- }
- return (float)d0;
- }
- 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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement