Moved particle vel var to particle class and fixed a few issues not caught by the IDE

This commit is contained in:
Robert S 2014-10-21 18:14:05 -04:00
parent 1f54eee5b2
commit 621b557129
3 changed files with 16 additions and 14 deletions

View file

@ -24,6 +24,11 @@ import scala.collection.JavaConversions._
*/ */
object EntityParticle object EntityParticle
{ {
/**
* User client side to determine the velocity of the particle.
*/
val clientParticleVelocity: Float = 0.9f
def canSpawnParticle(world: World, pos: Vector3): Boolean = def canSpawnParticle(world: World, pos: Vector3): Boolean =
{ {
val block: Block = pos.getBlock(world) val block: Block = pos.getBlock(world)
@ -100,7 +105,7 @@ class EntityParticle(par1World: World) extends Entity(par1World) with IEntityAdd
{ {
if (this.ticksExisted % 10 == 0) if (this.ticksExisted % 10 == 0)
{ {
this.worldObj.playSoundAtEntity(this, Reference.prefix + "accelerator", 1f, (0.6f + (0.4 * (this.getParticleVelocity / TileAccelerator.clientParticleVelocity))).asInstanceOf[Float]) this.worldObj.playSoundAtEntity(this, Reference.prefix + "accelerator", 1f, (0.6f + (0.4 * (this.getParticleVelocity / EntityParticle.clientParticleVelocity))).asInstanceOf[Float])
} }
val t: TileEntity = this.worldObj.getTileEntity(this.movementVector.xi, this.movementVector.yi, this.movementVector.zi) val t: TileEntity = this.worldObj.getTileEntity(this.movementVector.xi, this.movementVector.yi, this.movementVector.zi)
if (!(t.isInstanceOf[TileAccelerator])) if (!(t.isInstanceOf[TileAccelerator]))
@ -157,9 +162,9 @@ class EntityParticle(par1World: World) extends Entity(par1World) with IEntityAdd
val dongLi: Vector3 = new Vector3 val dongLi: Vector3 = new Vector3
dongLi.add(this.movementDirection) dongLi.add(this.movementDirection)
dongLi.multiply(acceleration) dongLi.multiply(acceleration)
this.motionX = Math.min(dongLi.x + this.motionX, TileAccelerator.clientParticleVelocity) this.motionX = Math.min(dongLi.x + this.motionX, EntityParticle.clientParticleVelocity)
this.motionY = Math.min(dongLi.y + this.motionY, TileAccelerator.clientParticleVelocity) this.motionY = Math.min(dongLi.y + this.motionY, EntityParticle.clientParticleVelocity)
this.motionZ = Math.min(dongLi.z + this.motionZ, TileAccelerator.clientParticleVelocity) this.motionZ = Math.min(dongLi.z + this.motionZ, EntityParticle.clientParticleVelocity)
this.isAirBorne = true this.isAirBorne = true
this.lastTickPosX = this.posX this.lastTickPosX = this.posX
this.lastTickPosY = this.posY this.lastTickPosY = this.posY
@ -218,7 +223,7 @@ class EntityParticle(par1World: World) extends Entity(par1World) with IEntityAdd
this.worldObj.playSoundAtEntity(this, Reference.prefix + "antimatter", 1.5f, 1f - this.worldObj.rand.nextFloat * 0.3f) this.worldObj.playSoundAtEntity(this, Reference.prefix + "antimatter", 1.5f, 1f - this.worldObj.rand.nextFloat * 0.3f)
if (!this.worldObj.isRemote) if (!this.worldObj.isRemote)
{ {
if (this.getParticleVelocity > TileAccelerator.clientParticleVelocity / 2) if (this.getParticleVelocity > EntityParticle.clientParticleVelocity / 2)
{ {
val radius: Float = 1f val radius: Float = 1f
val bounds: AxisAlignedBB = AxisAlignedBB.getBoundingBox(this.posX - radius, this.posY - radius, this.posZ - radius, this.posX + radius, this.posY + radius, this.posZ + radius) val bounds: AxisAlignedBB = AxisAlignedBB.getBoundingBox(this.posX - radius, this.posY - radius, this.posZ - radius, this.posX + radius, this.posY + radius, this.posZ + radius)

View file

@ -2,6 +2,7 @@ package resonantinduction.atomic.machine.accelerator
import net.minecraft.entity.player.EntityPlayer import net.minecraft.entity.player.EntityPlayer
import resonant.lib.gui.GuiContainerBase import resonant.lib.gui.GuiContainerBase
import resonantinduction.core.Settings
import universalelectricity.api.UnitDisplay import universalelectricity.api.UnitDisplay
import universalelectricity.core.transform.vector.Vector3 import universalelectricity.core.transform.vector.Vector3
@ -29,10 +30,10 @@ class GuiAccelerator(player: EntityPlayer, tileEntity: TileAccelerator) extends
{ {
status = "\u00a72Idle" status = "\u00a72Idle"
} }
this.fontRendererObj.drawString("Velocity: " + Math.round((this.tileEntity.velocity / TileAccelerator.clientParticleVelocity) * 100) + "%", 8, 27, 4210752) this.fontRendererObj.drawString("Velocity: " + Math.round((this.tileEntity.velocity / EntityParticle.clientParticleVelocity) * 100) + "%", 8, 27, 4210752)
this.fontRendererObj.drawString("Energy Used:", 8, 38, 4210752) this.fontRendererObj.drawString("Energy Used:", 8, 38, 4210752)
this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.totalEnergyConsumed).toString, 8, 49, 4210752) this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.totalEnergyConsumed).toString, 8, 49, 4210752)
this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.WATT, TileAccelerator.energyPerTick * 20).toString, 8, 60, 4210752) this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.WATT, Settings.ACCELERATOR_ENERGY_COST_PER_TICK * 20).toString, 8, 60, 4210752)
this.fontRendererObj.drawString("N?A", 8, 70, 4210752) this.fontRendererObj.drawString("N?A", 8, 70, 4210752)
this.fontRendererObj.drawString("Antimatter: " + this.tileEntity.antimatter + " mg", 8, 80, 4210752) this.fontRendererObj.drawString("Antimatter: " + this.tileEntity.antimatter + " mg", 8, 80, 4210752)
this.fontRendererObj.drawString("Status:", 8, 90, 4210752) this.fontRendererObj.drawString("Status:", 8, 90, 4210752)

View file

@ -19,10 +19,6 @@ import resonantinduction.core.{Reference, Settings}
import universalelectricity.core.transform.vector.Vector3 import universalelectricity.core.transform.vector.Vector3
class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable class TileAccelerator extends TileElectricInventory(Material.iron) with IElectromagnet with IRotatable
{ {
/**
* User client side to determine the velocity of the particle.
*/
val clientParticleVelocity: Float = 0.9f
/** /**
* Multiplier that is used to give extra anti-matter based on density (hardness) of a given ore. * Multiplier that is used to give extra anti-matter based on density (hardness) of a given ore.
*/ */
@ -118,7 +114,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
} }
entityParticle = null entityParticle = null
} }
else if (velocity > clientParticleVelocity) else if (velocity > EntityParticle.clientParticleVelocity)
{ {
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix + "antimatter", 2f, 1f - worldObj.rand.nextFloat * 0.3f) worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix + "antimatter", 2f, 1f - worldObj.rand.nextFloat * 0.3f)
val generatedAntimatter: Int = 5 + worldObj.rand.nextInt(antiMatterDensityMultiplyer) val generatedAntimatter: Int = 5 + worldObj.rand.nextInt(antiMatterDensityMultiplyer)
@ -129,7 +125,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
} }
if (entityParticle != null) if (entityParticle != null)
{ {
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix + "accelerator", 1.5f, (0.6f + (0.4 * (entityParticle.getParticleVelocity) / clientParticleVelocity)).asInstanceOf[Float]) worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix + "accelerator", 1.5f, (0.6f + (0.4 * (entityParticle.getParticleVelocity) / EntityParticle.clientParticleVelocity)).asInstanceOf[Float])
} }
} }
energy.extractEnergy energy.extractEnergy
@ -158,7 +154,7 @@ class TileAccelerator extends TileElectricInventory(Material.iron) with IElectro
} }
} }
override def use(player: EntityPlayer, side: Int, hit: Vector3): Boolean = override def activate(player: EntityPlayer, side: Int, hit: Vector3): Boolean =
{ {
if (!world.isRemote) if (!world.isRemote)
{ {