use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class EntityAirGuardian method onUpdate.
@SuppressWarnings("incomplete-switch")
@Override
public void onUpdate() {
if (firstTick) {
this.tasks.addTask(0, new EntityAIGuardSpawnLocation(this, 0.5F, 5, 16, new AMVector3(this)));
this.firstTick = false;
}
this.orbitRotation += 2f;
this.orbitRotation %= 360;
switch(currentAction) {
case IDLE:
break;
case SPINNING:
this.spinRotation = (this.spinRotation - 40) % 360;
if (this.worldObj.isRemote) {
for (int i = 0; i < AMCore.config.getGFXLevel(); ++i) {
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "wind", posX + worldObj.rand.nextDouble() * 4 - 2, posY, posZ + worldObj.rand.nextDouble() * 4 - 2);
if (particle != null) {
if (ticksInCurrentAction < BossActions.SPINNING.getMaxActionTime() - 10) {
particle.AddParticleController(new ParticleApproachEntity(particle, this, 0.2f, 0.5f, 1, true));
particle.AddParticleController(new ParticleFloatUpward(particle, 0.01f, 0.2f, 2, true));
} else {
particle.AddParticleController(new ParticleFloatUpward(particle, 0.1f, 1, 1, false));
}
particle.setMaxAge(30);
}
}
}
break;
}
if (this.motionY < 0) {
this.motionY *= 0.8999999f;
}
if (this.posY < 150) {
if (worldObj.isRemote) {
for (int i = 0; i < 25; ++i) {
AMParticle wind = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, "wind", posX, posY, posZ);
if (wind != null) {
wind.setIgnoreMaxAge(false);
wind.setMaxAge(10 + rand.nextInt(10));
wind.setDontRequireControllers();
wind.addRandomOffset(1, 1, 1);
// wind.AddParticleController(new PaticleFleePoint(wind, new AMVector3(this), rand.nextInt() * 0.1f + 0.01f, 10, 1, false));
}
}
} else {
if (this.posY < 145)
this.setDead();
}
}
super.onUpdate();
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityFlickerHabitat method writeOutList.
private void writeOutList(NBTTagCompound compound) {
NBTTagList outputList = new NBTTagList();
for (int priority : outList.keySet()) {
// create a compound for the priority
NBTTagCompound priorityCompound = new NBTTagCompound();
// attach the priority to the compound
priorityCompound.setInteger("priority", priority);
// get the list of locations for this priority
ArrayList<AMVector3> priorityList = outList.get(priority);
if (priorityList == null)
continue;
// create a tag list to store the vectors in
NBTTagList vectors = new NBTTagList();
// spin through the list
for (AMVector3 vec : priorityList) {
// create a compound to hold the individual vector
NBTTagCompound vectorItem = new NBTTagCompound();
// write the vector to the newly created compound
vec.writeToNBT(vectorItem);
// attach the vector tag to the vectors list
vectors.appendTag(vectorItem);
}
// attach the vectors to the priority compound
priorityCompound.setTag("vectors", vectors);
// attach the priority compound to the final output list
outputList.appendTag(priorityCompound);
}
// store the final output list in the parent compound
compound.setTag("outList", outputList);
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityFlickerHabitat method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound nbttagcompound) {
super.readFromNBT(nbttagcompound);
initLocationLists();
// read in list
if (nbttagcompound.hasKey("InList")) {
NBTTagList inItems = nbttagcompound.getTagList("InList", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < inItems.tagCount(); ++i) {
NBTTagCompound inItem = (NBTTagCompound) inItems.getCompoundTagAt(i);
if (inItem == null) {
continue;
}
float x = 0;
float y = 0;
float z = 0;
boolean success = true;
if (inItem.hasKey("x")) {
x = inItem.getFloat("x");
} else {
success = false;
}
if (success && inItem.hasKey("y")) {
y = inItem.getFloat("y");
} else {
success = false;
}
if (success && inItem.hasKey("z")) {
z = inItem.getFloat("z");
} else {
success = false;
}
if (success) {
inList.add(new AMVector3(x, y, z));
}
}
// end for(int i = 0; i < inItems.tagCount(); ++i)
}
// end if(nbttagcompound.hasKey("InList"))
readOutList(nbttagcompound);
if (nbttagcompound.hasKey("upgrade")) {
isUpgrade = nbttagcompound.getBoolean("upgrade");
}
if (nbttagcompound.hasKey("flickerJar")) {
NBTTagCompound jar = nbttagcompound.getCompoundTag("flickerJar");
flickerJar = ItemStack.loadItemStackFromNBT(jar);
if (!this.isUpgrade) {
setOperatorBasedOnFlicker();
}
}
if (this.isUpgrade) {
int flag = nbttagcompound.getInteger("mainHabitatDirection");
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
if (direction.flag == flag) {
this.mainHabitatDirection = direction;
break;
}
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityFlickerHabitat method readOutList.
private void readOutList(NBTTagCompound compound) {
// valid compound?
if (!compound.hasKey("outList"))
return;
// get the tag list for the output data
NBTTagList outputList = compound.getTagList("outList", Constants.NBT.TAG_COMPOUND);
// spin through em
for (int i = 0; i < outputList.tagCount(); ++i) {
// get the current compound tag - this should contain a priority level and a list of vectors
NBTTagCompound priorityCompound = outputList.getCompoundTagAt(i);
// create the list to hold the output locations
ArrayList<AMVector3> locationsInPriority = new ArrayList<AMVector3>();
// does the current compound tag contain the values we're looking for?
if (!priorityCompound.hasKey("priority") || !priorityCompound.hasKey("vectors")) {
LogHelper.warn("Malformed save data for flicker item transport controller - cannot process records.");
continue;
}
// get the priority from the compound
int priority = priorityCompound.getInteger("priority");
// get the list of vectors from the compound
NBTTagList vectors = priorityCompound.getTagList("vectors", Constants.NBT.TAG_COMPOUND);
// spin through the vectors
for (int x = 0; x < vectors.tagCount(); ++x) {
// get the current vector tag
NBTTagCompound vectorItem = vectors.getCompoundTagAt(x);
// read the vector from the NBT compound
AMVector3 vec = AMVector3.readFromNBT(vectorItem);
// add the vector location if it read correctly
if (vec != null && vec != AMVector3.zero()) {
locationsInPriority.add(vec);
}
}
// insert the list into the output list at the specified priority
this.outList.put(priority, locationsInPriority);
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityFlickerHabitat method writeToNBT.
@Override
public void writeToNBT(NBTTagCompound nbttagcompound) {
super.writeToNBT(nbttagcompound);
// write in list
NBTTagList inItems = new NBTTagList();
for (AMVector3 inItem : inList) {
NBTTagCompound vectorItem = new NBTTagCompound();
vectorItem.setFloat("x", inItem.x);
vectorItem.setFloat("y", inItem.y);
vectorItem.setFloat("z", inItem.z);
inItems.appendTag(vectorItem);
}
nbttagcompound.setTag("InList", inItems);
// write out list
writeOutList(nbttagcompound);
if (flickerJar != null) {
NBTTagCompound jar = new NBTTagCompound();
flickerJar.writeToNBT(jar);
nbttagcompound.setTag("flickerJar", jar);
}
// write upgrade status
nbttagcompound.setBoolean("upgrade", isUpgrade);
if (this.isUpgrade) {
nbttagcompound.setInteger("mainHabitatDirection", mainHabitatDirection.flag);
}
}
Aggregations