From 99b0281dcf4ba451a363f811fdc6b671a239dc71 Mon Sep 17 00:00:00 2001 From: Mary <33456283+FourIsTheNumber@users.noreply.github.com> Date: Wed, 31 Jul 2024 13:13:20 -0400 Subject: Laser Engraver Multi (#2771) * Laser engraver boilerplate and structure * Made a rough, untextured laser renderer * Laser renderer is kind of functional * Laser renderer follows curve * Laser turns on/off when recipe is running * Sampsa laser * Color changing boilerplate * Registered all gt lenses * Fixed default renderer to white * NBT reading functional * Stole SE code to try and get TE working. It does not * Laser renderer finally functioning with more than 1 laser! * Moved tick count to TileLaser so lasers don't tick each other * Implemented laser source hatch * Structure update + spotless * Switched to the GT_Values tier list * Update tooltip and message player about rendering toggle * Allow fluid input/output * Attempting to give proper name to laser plate * Fixed laser plate name * New laser plate texture * New casing just dropped * Allow UMV glass to use any laser source * Switched laser to a simple line renderer instead of a model * Fixed hatch texture I missed earlier * Spotless * Controller textures * render: New laser renderer - Use GL quad rendering instead of line rendering to fix scaling - Set lightmap coords (Emit bloom glow with shaders) - Set opacity to 1.0 - Slight cleanup * Got rid of the old laser model * Tweaked some numbers on the renderer * Spotless * cleanup * I give up on rotation, I've spent too much time trying to get this to work * Got block item working I think * Fixed tooltip for laser and multicanner * Support bartworks lenses * Finishing touches * Removed unneeded assignment * Allow UXV lasers to do all recipes * Forgot to call super for nbt data... * Replace magic numbers * oops, spotless * Another magic voltage number * Rotations and mirror flips Now with spotless * fixed west/east * ok but actually fixed now, mixed up west/east with north/south * Updated laser source snapping to account for rotation being allowed * Cleanup rotation axis and remove unecessary nbt * Re-added nbt but actually load it properly now * Fix NEI displaying lots of hatches --------- Co-authored-by: LekKit <50500857+LekKit@users.noreply.github.com> Co-authored-by: BucketBrigade Co-authored-by: Martin Robertz --- .../common/tileentities/render/TileLaser.java | 124 +++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 src/main/java/gregtech/common/tileentities/render/TileLaser.java (limited to 'src/main/java/gregtech/common/tileentities/render') diff --git a/src/main/java/gregtech/common/tileentities/render/TileLaser.java b/src/main/java/gregtech/common/tileentities/render/TileLaser.java new file mode 100644 index 0000000000..5cc9020cd4 --- /dev/null +++ b/src/main/java/gregtech/common/tileentities/render/TileLaser.java @@ -0,0 +1,124 @@ +package gregtech.common.tileentities.render; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.alignment.enumerable.Flip; +import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; + +import cpw.mods.fml.relauncher.Side; +import micdoodle8.mods.galacticraft.core.tile.TileEntityAdvanced; +import micdoodle8.mods.galacticraft.core.util.Annotations; + +public class TileLaser extends TileEntityAdvanced { + + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public boolean shouldRender = false; + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public float red = 0, green = 0, blue = 0; + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public float counter = 0F; + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public boolean realism = false; + @Annotations.NetworkedField(targetSide = Side.CLIENT) + public double rotAxisX = 0, rotAxisY = 0, rotAxisZ = 0, rotationAngle = 0; + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + compound.setFloat("rgb_red", red); + compound.setFloat("rgb_green", green); + compound.setFloat("rgb_blue", blue); + compound.setBoolean("shouldRender", shouldRender); + compound.setDouble("rotAxisX", rotAxisX); + compound.setDouble("rotAxisY", rotAxisY); + compound.setDouble("rotAxisZ", rotAxisZ); + compound.setDouble("rotationAngle", rotationAngle); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + red = compound.getFloat("rgb_red"); + blue = compound.getFloat("rgb_blue"); + green = compound.getFloat("rgb_green"); + shouldRender = compound.getBoolean("shouldRender"); + rotAxisX = compound.getDouble("rotAxisX"); + rotAxisY = compound.getDouble("rotAxisY"); + rotAxisZ = compound.getDouble("rotAxisZ"); + rotationAngle = compound.getDouble("rotationAngle"); + } + + public void setColors(float red, float green, float blue) { + this.red = red; + this.green = green; + this.blue = blue; + } + + public void setRotationFields(ForgeDirection direction, Rotation rotation, Flip flip) { + setRotationAngle(rotation, flip); + setRotationAxis(direction); + } + + private void setRotationAngle(Rotation rotation, Flip flip) { + int invert = (flip == Flip.HORIZONTAL || flip == Flip.VERTICAL) ? 1 : -1; + switch (rotation) { + case NORMAL -> rotationAngle = 0; + case CLOCKWISE -> rotationAngle = 90 * invert; + case COUNTER_CLOCKWISE -> rotationAngle = -90 * invert; + case UPSIDE_DOWN -> rotationAngle = 180; + } + } + + public void setRotationAxis(ForgeDirection direction) { + rotAxisX = direction.offsetX; + rotAxisY = direction.offsetY; + rotAxisZ = direction.offsetZ; + } + + public void setShouldRender(boolean shouldRender) { + this.shouldRender = shouldRender; + } + + public Boolean getShouldRender() { + return shouldRender; + } + + public float getRed() { + return red; + } + + public float getGreen() { + return green; + } + + public float getBlue() { + return blue; + } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public double getMaxRenderDistanceSquared() { + return 65536; + } + + @Override + public double getPacketRange() { + return 128; + } + + @Override + public int getPacketCooldown() { + return 20; + } + + @Override + public boolean isNetworkedTile() { + return true; + } +} -- cgit