use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityOtherworldAura method refreshNearbyInventories.
private void refreshNearbyInventories() {
nearbyInventories = new ArrayList<AMVector3>();
int radius = 6;
for (int i = -radius; i <= radius; ++i) {
for (int j = -radius; j <= radius; ++j) {
for (int k = -radius; k <= radius; ++k) {
if (i == 0 && j == 0 && k == 0)
continue;
TileEntity te = worldObj.getTileEntity(xCoord + i, yCoord + j, zCoord + k);
if (te == null)
continue;
if (!(te instanceof IInventory))
continue;
nearbyInventories.add(new AMVector3(te));
}
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityOtherworldAura method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
// sanity check
if (nearbyInventories == null)
return;
if (watchTarget == null || !watchTarget.isCrafting()) {
setActive(false, null);
return;
}
if (helper != null && helper.isDead) {
return;
}
if (!worldObj.isRemote) {
if (PowerNodeRegistry.For(worldObj).checkPower(this, 1.25f)) {
if (delayCounter-- <= 0) {
if (helper == null) {
spawnHelper();
}
ItemStack next = watchTarget.getNextPlannedItem();
if (next == null) {
setActive(false, null);
return;
}
if (next.getItem() == ItemsCommonProxy.essence && next.getItemDamage() > ItemsCommonProxy.essence.META_MAX) {
if (!this.helper.hasSearchLocation())
this.helper.setSearchLocationAndItem(new AMVector3(1, 1, 1), next);
delayCounter = 100;
} else {
AMVector3 location = findInNearbyInventories(next);
if (location == null) {
// can't find it nearby - don't search again for 5 seconds (gives player time to add)
delayCounter = 20;
cantFindItem = true;
return;
} else {
cantFindItem = false;
if (!this.helper.hasSearchLocation())
this.helper.setSearchLocationAndItem(location, next);
// delay for 5s (give the helper time to get the item and toss it in)
delayCounter = 20;
}
}
}
PowerNodeRegistry.For(worldObj).consumePower(this, PowerNodeRegistry.For(worldObj).getHighestPowerType(this), 1.25f);
} else {
if (this.helper != null)
this.helper.unSummon();
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityParticleEmitter method setShow.
public void setShow(boolean show) {
this.show = show;
if (worldObj.isRemote && show) {
forceShow = false;
showTicks = 0;
EntityPlayer localPlayer = AMCore.proxy.getLocalPlayer();
if (localPlayer != null && localPlayer.inventory.getCurrentItem() != null && localPlayer.inventory.getCurrentItem().getItem() == ItemsCommonProxy.crystalWrench) {
AMVector3 myLoc = new AMVector3(xCoord, yCoord, zCoord);
AMVector3 playerLoc = new AMVector3(localPlayer);
if (myLoc.distanceSqTo(playerLoc) < 64D) {
forceShow = true;
}
}
}
int oldMeta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, show ? oldMeta & ~0x8 : oldMeta | 0x8, 2);
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityParticleEmitter method updateEntity.
@Override
public void updateEntity() {
if (worldObj.isRemote && spawnTicks++ >= spawnRate) {
for (int i = 0; i < particleQuantity; ++i) doSpawn();
spawnTicks = 0;
}
if (!show && worldObj.isRemote && ((forceShow && showTicks++ > 100) || !forceShow)) {
showTicks = 0;
forceShow = false;
EntityPlayer localPlayer = AMCore.proxy.getLocalPlayer();
if (localPlayer != null && localPlayer.inventory.getCurrentItem() != null && localPlayer.inventory.getCurrentItem().getItem() == ItemsCommonProxy.crystalWrench) {
AMVector3 myLoc = new AMVector3(xCoord, yCoord, zCoord);
AMVector3 playerLoc = new AMVector3(localPlayer);
if (myLoc.distanceSqTo(playerLoc) < 64D) {
forceShow = true;
}
}
int oldMeta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
if (forceShow) {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, oldMeta & ~0x8, 2);
} else {
this.worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, oldMeta | 0x8, 2);
}
}
}
use of am2.api.math.AMVector3 in project ArsMagica2 by Mithion.
the class TileEntityParticleEmitter method doSpawn.
private void doSpawn() {
if (!hasReceivedFullUpdate)
return;
double x = randomizeCoord(xCoord + 0.5);
double y = randomizeCoord(yCoord + 0.5);
double z = randomizeCoord(zCoord + 0.5);
AMParticle particle = (AMParticle) AMCore.proxy.particleManager.spawn(worldObj, AMParticle.particleTypes[particleType], x, y, z);
if (particle != null) {
particle.AddParticleController(AMCore.proxy.particleManager.createDefaultParticleController(particleBehaviour, particle, new AMVector3(x, y, z), speed, worldObj.getBlockMetadata(xCoord, yCoord, zCoord)));
particle.setParticleAge(Math.min(Math.max(spawnRate, 10), 40));
particle.setIgnoreMaxAge(false);
particle.setParticleScale(particleScale);
particle.SetParticleAlpha(particleAlpha);
if (!defaultColor) {
if (!randomColor)
particle.setRGBColorF(((particleColor >> 16) & 0xFF) / 255f, ((particleColor >> 8) & 0xFF) / 255f, (particleColor & 0xFF) / 255f);
else
particle.setRGBColorF(worldObj.rand.nextFloat(), worldObj.rand.nextFloat(), worldObj.rand.nextFloat());
}
}
}
Aggregations