use of com.teamwizardry.wizardry.api.entity.fairy.FairyData in project Wizardry by TeamWizardry.
the class ItemJar method addInformation.
@Override
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
if (stack.getItemDamage() == 2) {
FairyData fairy = FairyData.deserialize(NBTHelper.getCompound(stack, "fairy"));
if (fairy == null)
return;
IManaCapability cap = fairy.handler;
double mana = ManaManager.getMana(cap) / ManaManager.getMaxMana(cap);
boolean dulled = fairy.isDepressed;
if (dulled) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.dulled.info").trim());
} else if (mana > 0.25 && mana < 0.5) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.barely_excited.info").trim());
} else if (mana >= 0.5 && mana < 0.75) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.moderately_excited.info").trim());
} else if (mana > 0.75 && mana < 1) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.very_excited.info").trim());
} else if (mana >= 1) {
tooltip.add(I18n.translateToLocal("item.wizardry.fairy_jar.overloaded.info").trim());
} else
super.addInformation(stack, worldIn, tooltip, flagIn);
} else
super.addInformation(stack, worldIn, tooltip, flagIn);
}
use of com.teamwizardry.wizardry.api.entity.fairy.FairyData in project Wizardry by TeamWizardry.
the class EntityFairy method entityInit.
@Override
protected void entityInit() {
super.entityInit();
this.getDataManager().register(DATA_FAIRY, new FairyData().serializeNBT());
this.getDataManager().register(DATA_LOOK_TARGET, new NBTTagCompound());
this.getDataManager().register(DATA_HELD_ITEM, ItemStack.EMPTY);
this.getDataManager().register(DATA_CHAINED_FAIRY, Optional.absent());
}
use of com.teamwizardry.wizardry.api.entity.fairy.FairyData in project Wizardry by TeamWizardry.
the class EntityFairy method onDeath.
@Override
public void onDeath(@Nonnull DamageSource cause) {
if (getIsInvulnerable())
return;
if (!world.isRemote) {
FairyData dataFairy = getDataFairy();
if (dataFairy == null)
return;
if (dataFairy.isDepressed) {
ItemStack stack = new ItemStack(ModItems.FAIRY_ITEM);
NBTHelper.setTag(stack, "fairy", dataFairy.serializeNBT());
world.removeEntity(this);
EntityItem entityItem = new EntityItem(world);
entityItem.setPosition(posX, posY, posZ);
entityItem.setItem(stack);
entityItem.setPickupDelay(20);
entityItem.setNoDespawn();
world.spawnEntity(entityItem);
return;
}
super.onDeath(cause);
if (getHealth() <= 0)
PacketHandler.NETWORK.sendToAllAround(new PacketExplode(getPositionVector().add(0, 0.25, 0), dataFairy.primaryColor, dataFairy.secondaryColor, 0.5, 0.5, RandUtil.nextInt(100, 200), 75, 25, true), new NetworkRegistry.TargetPoint(world.provider.getDimension(), posX, posY, posZ, 256));
}
}
use of com.teamwizardry.wizardry.api.entity.fairy.FairyData in project Wizardry by TeamWizardry.
the class EntityFairy method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
setNoGravity(true);
fallDistance = 0;
FairyData dataFairy = getDataFairy();
float size = dataFairy != null && dataFairy.wasTamperedWith ? 0.2f : 1f;
setScale(size);
// if (isAIDisabled()) return;
if (isDead)
return;
if (dataFairy != null && dataFairy.isDepressed) {
Vec3d lookTarget = getLookTarget();
if (lookTarget != null && !moving)
getLookHelper().setLookPosition(lookTarget.x, lookTarget.y, lookTarget.z, 20, 20);
if (!tasks.taskEntries.isEmpty()) {
ArrayList<EntityAITasks.EntityAITaskEntry> tempTasks = new ArrayList<>(tasks.taskEntries);
for (EntityAITasks.EntityAITaskEntry taskEntry : tempTasks) {
tasks.removeTask(taskEntry.action);
}
}
if (!targetTasks.taskEntries.isEmpty()) {
ArrayList<EntityAITasks.EntityAITaskEntry> tempTargetTasks = new ArrayList<>(targetTasks.taskEntries);
for (EntityAITasks.EntityAITaskEntry taskEntry : tempTargetTasks) {
targetTasks.removeTask(taskEntry.action);
}
}
}
ProjectileHelper.rotateTowardsMovement(this, 0.5F);
if (!world.isRemote && !isStunned())
fairyTaskController.tick(this);
if (dataFairy != null && getNavigator().noPath())
if (!dataFairy.isDepressed) {
getMoveHelper().setMoveTo(posX + RandUtil.nextDouble(-32, 32), posY + RandUtil.nextDouble(-32, 32), posZ + RandUtil.nextDouble(-32, 32), 2);
} else if (moving && !isStunned()) {
if (currentTarget == null)
return;
double v = getPositionVector().distanceTo(currentTarget);
if (v <= 0.5) {
setPosition(currentTarget.x, currentTarget.y, currentTarget.z);
motionX = 0;
motionY = 0;
motionZ = 0;
this.targetDeltaX = 0.0D;
this.targetDeltaY = 0.0D;
this.targetDeltaZ = 0.0D;
moving = false;
currentTarget = null;
return;
}
if (!world.isRemote) {
this.targetDeltaX = MathHelper.clamp(this.targetDeltaX * 1.025D, -1.0D, 1.0D);
this.targetDeltaY = MathHelper.clamp(this.targetDeltaY * 1.025D, -1.0D, 1.0D);
this.targetDeltaZ = MathHelper.clamp(this.targetDeltaZ * 1.025D, -1.0D, 1.0D);
this.motionX += (this.targetDeltaX - this.motionX) * 0.2D;
this.motionY += (this.targetDeltaY - this.motionY) * 0.2D;
this.motionZ += (this.targetDeltaZ - this.motionZ) * 0.2D;
}
this.setPosition(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
if (this.currentTarget != null) {
if (this.steps > 0) {
--this.steps;
if (this.steps == 0) {
this.selectNextMoveDirection(this.direction == null ? null : this.direction.getAxis());
}
}
if (this.direction != null) {
BlockPos blockpos = new BlockPos(this);
EnumFacing.Axis enumfacing$axis = this.direction.getAxis();
if (this.world.isBlockNormalCube(blockpos.offset(this.direction), false)) {
this.selectNextMoveDirection(enumfacing$axis);
} else {
BlockPos blockpos1 = new BlockPos(this.currentTarget);
if (enumfacing$axis == EnumFacing.Axis.X && blockpos.getX() == blockpos1.getX() || enumfacing$axis == EnumFacing.Axis.Z && blockpos.getZ() == blockpos1.getZ() || enumfacing$axis == EnumFacing.Axis.Y && blockpos.getY() == blockpos1.getY()) {
this.selectNextMoveDirection(enumfacing$axis);
}
}
}
}
}
}
Aggregations