diff options
author | Mary <33456283+FourIsTheNumber@users.noreply.github.com> | 2024-09-07 09:16:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-07 13:16:14 +0000 |
commit | f2c0a4fc6b65749871b60580a6f65374f589b994 (patch) | |
tree | 47d7ffeb0f74eb49fb707b6dfd001c6052c4ebeb /src/main/java/gregtech/common/tileentities/render | |
parent | 67607edb5343c892e46767db782da3b7da0f4c5a (diff) | |
download | GT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.tar.gz GT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.tar.bz2 GT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.zip |
Finishing touches on black hole compressor (#3060)
Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: BucketBrigade <138534411+CookieBrigade@users.noreply.github.com>
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/render')
-rw-r--r-- | src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java b/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java new file mode 100644 index 0000000000..5cd59d2cf4 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java @@ -0,0 +1,99 @@ +package gregtech.common.tileentities.render; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.NetworkManager; +import net.minecraft.network.Packet; +import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import net.minecraft.tileentity.TileEntity; + +public class TileEntityBlackhole extends TileEntity { + + // Should run from 0 to 1, >.5 starts showing changes + private float stability = 1; + 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 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"; + private static final String RENDER_NBT_TAG = NBT_TAG + "LASER_RENDER"; + + public void setLaserColor(float r, float g, float b) { + laserR = r; + laserG = g; + laserB = b; + updateToClient(); + } + + public void toggleLaser(boolean toggle) { + laserRender = toggle; + updateToClient(); + } + + public float getLaserR() { + return laserR; + } + + public float getLaserG() { + return laserG; + } + + public float getLaserB() { + return laserB; + } + + public boolean getLaserRender() { + return laserRender; + } + + public void setStability(float stability) { + // Can probably be simplified, maps stability > .5 as 1, and stability <.5 from 0 to 1 + this.stability = ((float) Math.min(stability + .5, 1f) - .5f) * 2f; + updateToClient(); + } + + public float getStability() { + return stability; + } + + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setFloat(STABILITY_NBT_TAG, stability); + compound.setFloat(COLOR_RED_NBT_TAG, laserR); + compound.setFloat(COLOR_GREEN_NBT_TAG, laserG); + compound.setFloat(COLOR_BLUE_NBT_TAG, laserB); + compound.setBoolean(RENDER_NBT_TAG, laserRender); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + stability = compound.getFloat(STABILITY_NBT_TAG); + laserR = compound.getFloat(COLOR_RED_NBT_TAG); + laserG = compound.getFloat(COLOR_GREEN_NBT_TAG); + laserB = compound.getFloat(COLOR_BLUE_NBT_TAG); + laserRender = compound.getBoolean(RENDER_NBT_TAG); + super.readFromNBT(compound); + + } + + @Override + public Packet getDescriptionPacket() { + NBTTagCompound nbttagcompound = new NBTTagCompound(); + writeToNBT(nbttagcompound); + + return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, nbttagcompound); + } + + @Override + public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { + readFromNBT(pkt.func_148857_g()); + } + + public void updateToClient() { + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + +} |