aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/util
diff options
context:
space:
mode:
authorMary <33456283+FourIsTheNumber@users.noreply.github.com>2024-07-31 13:13:20 -0400
committerGitHub <noreply@github.com>2024-08-01 00:13:20 +0700
commit99b0281dcf4ba451a363f811fdc6b671a239dc71 (patch)
tree7391763433587d53031b3e86dba37aa473eb332c /src/main/java/gregtech/api/util
parentb4ee66356b06d0fcc75654506ed67aa57755393b (diff)
downloadGT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.tar.gz
GT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.tar.bz2
GT5-Unofficial-99b0281dcf4ba451a363f811fdc6b671a239dc71.zip
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 <apple12a1@hotmail.com> Co-authored-by: Martin Robertz <dream-master@gmx.net>
Diffstat (limited to 'src/main/java/gregtech/api/util')
-rw-r--r--src/main/java/gregtech/api/util/LaserRenderingUtil.java102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/main/java/gregtech/api/util/LaserRenderingUtil.java b/src/main/java/gregtech/api/util/LaserRenderingUtil.java
new file mode 100644
index 0000000000..e42d23bc85
--- /dev/null
+++ b/src/main/java/gregtech/api/util/LaserRenderingUtil.java
@@ -0,0 +1,102 @@
+package gregtech.api.util;
+
+import java.util.function.Consumer;
+
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.IChatComponent;
+import net.minecraft.world.World;
+
+import com.gtnewhorizon.structurelib.StructureLibAPI;
+import com.gtnewhorizon.structurelib.structure.ICustomBlockSetting;
+import com.gtnewhorizon.structurelib.structure.IItemSource;
+import com.gtnewhorizon.structurelib.structure.IStructureElement;
+import com.gtnewhorizon.structurelib.structure.StructureUtility;
+
+public class LaserRenderingUtil {
+ // This code is shamelessly ripped from GTNH-Intergalactic
+
+ public interface IBlockAdder<T> {
+
+ /**
+ * Callback on block added, needs to check if block is valid (and add it)
+ *
+ * @param block block attempted to add
+ * @param meta meta of block attempted to add
+ * @param world World of the block
+ * @param x X coordinate of the block
+ * @param y Y coordinate of the block
+ * @param z Z coordinate of the block
+ * @return is structure still valid
+ */
+ boolean apply(T t, Block block, int meta, World world, int x, int y, int z);
+ }
+
+ public static <T> IStructureElement<T> ofBlockAdder(IBlockAdder<T> iBlockAdder, Block defaultBlock,
+ int defaultMeta) {
+ if (iBlockAdder == null || defaultBlock == null) {
+ throw new IllegalArgumentException();
+ }
+ if (defaultBlock instanceof ICustomBlockSetting) {
+ return new IStructureElement<T>() {
+
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ Block worldBlock = world.getBlock(x, y, z);
+ return iBlockAdder.apply(t, worldBlock, worldBlock.getDamageValue(world, x, y, z), world, x, y, z);
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ ((ICustomBlockSetting) defaultBlock).setBlock(world, x, y, z, defaultMeta);
+ return true;
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, defaultBlock, defaultMeta);
+ return true;
+ }
+
+ @Override
+ public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
+ IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
+ if (check(t, world, x, y, z)) return PlaceResult.SKIP;
+ return StructureUtility
+ .survivalPlaceBlock(defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
+ }
+ };
+ } else {
+ return new IStructureElement<T>() {
+
+ @Override
+ public boolean check(T t, World world, int x, int y, int z) {
+ Block worldBlock = world.getBlock(x, y, z);
+ return iBlockAdder
+ .apply(t, worldBlock, ((Block) worldBlock).getDamageValue(world, x, y, z), world, x, y, z);
+ }
+
+ @Override
+ public boolean placeBlock(T t, World world, int x, int y, int z, ItemStack trigger) {
+ world.setBlock(x, y, z, defaultBlock, defaultMeta, 2);
+ return true;
+ }
+
+ @Override
+ public boolean spawnHint(T t, World world, int x, int y, int z, ItemStack trigger) {
+ StructureLibAPI.hintParticle(world, x, y, z, defaultBlock, defaultMeta);
+ return true;
+ }
+
+ @Override
+ public PlaceResult survivalPlaceBlock(T t, World world, int x, int y, int z, ItemStack trigger,
+ IItemSource s, EntityPlayerMP actor, Consumer<IChatComponent> chatter) {
+ if (check(t, world, x, y, z)) return IStructureElement.PlaceResult.SKIP;
+ return StructureUtility
+ .survivalPlaceBlock(defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter);
+ }
+ };
+ }
+ }
+}