use of micdoodle8.mods.galacticraft.core.entities.ITumblable in project Galacticraft by micdoodle8.
the class SpinManager method updateSpin.
public void updateSpin() {
if (!this.clientSide) {
if (this.dataNotLoaded) {
this.savefile = OrbitSpinSaveData.initWorldData(this.worldProvider.worldObj);
this.readFromNBT(this.savefile.datacompound);
if (ConfigManagerCore.enableDebug) {
GCLog.info("Loading data from save: " + this.savefile.datacompound.getFloat("omegaSky"));
}
this.dataNotLoaded = false;
}
if (this.doSpinning) {
boolean updateNeeded = true;
if (this.angularVelocityTarget < this.angularVelocityRadians) {
float newAngle = this.angularVelocityRadians - this.angularVelocityAccel;
if (newAngle < this.angularVelocityTarget) {
newAngle = this.angularVelocityTarget;
}
this.setSpinRate(newAngle);
this.thrustersFiring = true;
} else if (this.angularVelocityTarget > this.angularVelocityRadians) {
float newAngle = this.angularVelocityRadians + this.angularVelocityAccel;
if (newAngle > this.angularVelocityTarget) {
newAngle = this.angularVelocityTarget;
}
this.setSpinRate(newAngle);
this.thrustersFiring = true;
} else if (this.thrustersFiring) {
this.thrustersFiring = false;
} else {
updateNeeded = false;
}
if (updateNeeded) {
this.writeToNBT(this.savefile.datacompound);
this.savefile.markDirty();
List<Object> objList = new ArrayList<Object>();
objList.add(Float.valueOf(this.angularVelocityRadians));
objList.add(Boolean.valueOf(this.thrustersFiring));
GalacticraftCore.packetPipeline.sendToDimension(new PacketSimple(PacketSimple.EnumSimplePacket.C_UPDATE_STATION_SPIN, GCCoreUtil.getDimensionID(this.worldProvider), objList), GCCoreUtil.getDimensionID(this.worldProvider));
}
}
// Update entity positions if in freefall
this.loadedEntities.clear();
this.loadedEntities.addAll(this.worldProvider.worldObj.loadedEntityList);
for (Entity e : this.loadedEntities) {
// TODO: What about vehicles from GC (buggies) and other mods?
if ((e instanceof EntityItem || e instanceof EntityLivingBase && !(e instanceof EntityPlayer) || e instanceof EntityTNTPrimed || e instanceof EntityFallingBlock) && !e.onGround) {
AxisAlignedBB entityBoundingBox = e.getEntityBoundingBox();
boolean outsideStation = entityBoundingBox.maxX < this.ssBoundsMinX || entityBoundingBox.minX > this.ssBoundsMaxX || entityBoundingBox.maxY < this.ssBoundsMinY || entityBoundingBox.minY > this.ssBoundsMaxY || entityBoundingBox.maxZ < this.ssBoundsMinZ || entityBoundingBox.minZ > this.ssBoundsMaxZ;
if (outsideStation || FreefallHandler.testEntityFreefall(this.worldProvider.worldObj, entityBoundingBox)) {
if (this.doSpinning) {
this.moveRotatedEntity(e, this.spinCentreX, this.spinCentreZ, this.angularVelocityRadians);
}
FreefallHandler.tickFreefallEntity(e);
if (e instanceof ITumblable) {
((ITumblable) e).setTumbling(3F);
}
} else {
if (e instanceof ITumblable) {
((ITumblable) e).setTumbling(0F);
}
}
}
}
}
}
Aggregations