Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EntityEarthSpike extends AvatarEntity {
- private float damageMult;
- /**
- * @param world
- */
- public EntityEarthSpike(World world) {
- super(world);
- setSize(1, 1);
- this.damageMult = 1.6F;
- }
- public void setDamageMult(float mult) {
- this.damageMult = mult;
- }
- @Override
- protected void readEntityFromNBT(NBTTagCompound nbt) {
- super.readEntityFromNBT(nbt);
- }
- @Override
- protected void writeEntityToNBT(NBTTagCompound nbt) {
- super.writeEntityToNBT(nbt);
- setDead();
- }
- @Override
- public void onEntityUpdate() {
- super.onEntityUpdate();
- setVelocity(Vector.ZERO);
- if (ticksExisted >= 15) {
- this.setDead();
- }
- // amount of entities which were successfully attacked
- int attacked = 0;
- // Push collided entities back
- if (!world.isRemote) {
- List<Entity> collided = world.getEntitiesInAABBexcluding(this, getEntityBoundingBox(),
- entity -> entity != getOwner());
- if (!collided.isEmpty()) {
- for (Entity entity : collided) {
- if (attackEntity(entity)) {
- attacked++;
- }
- }
- }
- }
- if (!world.isRemote && getOwner() != null) {
- BendingData data = BendingData.get(getOwner());
- if (data != null) {
- data.getAbilityData("earthspike").addXp(SKILLS_CONFIG.earthspikeHit * attacked);
- }
- }
- }
- private boolean attackEntity(Entity entity) {
- if (!(entity instanceof EntityItem && entity.ticksExisted <=
- 10) && canCollideWith(entity)) {
- Vector push = velocity().withY(.8).times(STATS_CONFIG.ravineSettings.push);
- entity.addVelocity(push.x(), push.y(), push.z());
- AvatarUtils.afterVelocityAdded(entity);
- DamageSource ds = AvatarDamageSource.causeRavineDamage(entity, getOwner());
- float damage = STATS_CONFIG.ravineSettings.damage * damageMult;
- return entity.attackEntityFrom(ds, damage);
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement