aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/tileentities
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/tileentities')
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java16
-rw-r--r--src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java25
2 files changed, 39 insertions, 2 deletions
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java
index 7b444c6573..2d84f032af 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEBlackHoleCompressor.java
@@ -496,8 +496,8 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl
blackHoleStatus = 1;
blackHoleStability = 100;
catalyzingCostModifier = 1;
- rendererTileEntity = null;
- destroyRenderBlock();
+ if (rendererTileEntity != null) rendererTileEntity.startScaleChange(false);
+ collapseTimer = 40;
return;
}
}
@@ -574,6 +574,10 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl
return super.onRunningTick(aStack);
}
+ // Asynchronous timer to destroy render block after collapse animation is done playing.
+ // This might not sync perfectly to the renderer but this is very low stakes
+ private int collapseTimer = -1;
+
@Override
public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
super.onPostTick(aBaseMetaTileEntity, aTick);
@@ -581,6 +585,13 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl
playBlackHoleSounds();
}
+ if (collapseTimer != -1) {
+ if (collapseTimer == 0) {
+ destroyRenderBlock();
+ }
+ collapseTimer--;
+ }
+
// Run stability checks once per second if a black hole is open
if (blackHoleStatus == 1 || aTick % 20 != 0) return;
@@ -719,6 +730,7 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl
rendererTileEntity = (TileEntityBlackhole) base.getWorld()
.getTileEntity(base.getXCoord() + x, base.getYCoord() + y, base.getZCoord() + z);
+ rendererTileEntity.startScaleChange(true);
rendererTileEntity.setStability(blackHoleStability / 100F);
}
diff --git a/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java b/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java
index f15aa45eee..2f7114e405 100644
--- a/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java
+++ b/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java
@@ -10,12 +10,17 @@ public class TileEntityBlackhole extends TileEntity {
// Should run from 0 to 1, >.5 starts showing changes
private float stability = 1;
+ // true = growing, false = shrinking
+ private boolean scaling = true;
+ private long startTime = 0;
private float laserR = 0.318f, laserG = 0.157f, laserB = 0.533f;
private boolean laserRender = false;
private static final String NBT_TAG = "BLACKHOLE";
private static final String STABILITY_NBT_TAG = NBT_TAG + "STABILITY";
+ private static final String START_TIME_NBT_TAG = NBT_TAG + "START_TIME";
+ private static final String SCALING_NBT_TAG = NBT_TAG + "SCALING";
private static final String COLOR_RED_NBT_TAG = NBT_TAG + "COLOR_RED";
private static final String COLOR_GREEN_NBT_TAG = NBT_TAG + "COLOR_GREEN";
private static final String COLOR_BLUE_NBT_TAG = NBT_TAG + "COLOR_BLUE";
@@ -53,6 +58,22 @@ public class TileEntityBlackhole extends TileEntity {
return laserRender;
}
+ public void startScaleChange(boolean scaling) {
+ if (!worldObj.isRemote) {
+ this.startTime = worldObj.getTotalWorldTime();
+ this.scaling = scaling;
+ updateToClient();
+ }
+ }
+
+ public long getStartTime() {
+ return startTime;
+ }
+
+ public boolean getScaling() {
+ return scaling;
+ }
+
public void setStability(float stability) {
// Can probably be simplified, maps stability > .5 as 1, and stability <.5 from 0 to 1
if (!worldObj.isRemote) {
@@ -68,6 +89,8 @@ public class TileEntityBlackhole extends TileEntity {
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
compound.setFloat(STABILITY_NBT_TAG, stability);
+ compound.setBoolean(SCALING_NBT_TAG, scaling);
+ compound.setLong(START_TIME_NBT_TAG, startTime);
compound.setFloat(COLOR_RED_NBT_TAG, laserR);
compound.setFloat(COLOR_GREEN_NBT_TAG, laserG);
compound.setFloat(COLOR_BLUE_NBT_TAG, laserB);
@@ -77,6 +100,8 @@ public class TileEntityBlackhole extends TileEntity {
@Override
public void readFromNBT(NBTTagCompound compound) {
stability = compound.getFloat(STABILITY_NBT_TAG);
+ scaling = compound.getBoolean(SCALING_NBT_TAG);
+ startTime = compound.getLong(START_TIME_NBT_TAG);
laserR = compound.getFloat(COLOR_RED_NBT_TAG);
laserG = compound.getFloat(COLOR_GREEN_NBT_TAG);
laserB = compound.getFloat(COLOR_BLUE_NBT_TAG);