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 --- src/main/java/gregtech/api/GregTech_API.java | 1 + src/main/java/gregtech/api/enums/GT_Values.java | 13 ++- src/main/java/gregtech/api/enums/ItemList.java | 3 + .../java/gregtech/api/enums/MetaTileEntityIDs.java | 1 + src/main/java/gregtech/api/enums/Textures.java | 6 ++ .../java/gregtech/api/util/LaserRenderingUtil.java | 102 +++++++++++++++++++++ 6 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 src/main/java/gregtech/api/util/LaserRenderingUtil.java (limited to 'src/main/java/gregtech/api') diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java index 9190d03bab..f252a12965 100644 --- a/src/main/java/gregtech/api/GregTech_API.java +++ b/src/main/java/gregtech/api/GregTech_API.java @@ -297,6 +297,7 @@ public class GregTech_API { sBlockCasings8, sBlockCasings9, sBlockCasings10, sBlockCasings11, sSolenoidCoilCasings; public static Block sBlockLongDistancePipes; public static Block sDroneRender; + public static Block sLaserRender; /** * Getting assigned by the Config */ diff --git a/src/main/java/gregtech/api/enums/GT_Values.java b/src/main/java/gregtech/api/enums/GT_Values.java index bda681dc75..74c392ce67 100644 --- a/src/main/java/gregtech/api/enums/GT_Values.java +++ b/src/main/java/gregtech/api/enums/GT_Values.java @@ -650,7 +650,18 @@ public class GT_Values { public static final String AuthorQuerns = "Author: " + EnumChatFormatting.RED + "Querns"; public static final String AuthorSilverMoon = "Author: " + EnumChatFormatting.AQUA + "SilverMoon"; public static final String AuthorTheEpicGamer274 = "Author: " + "TheEpicGamer274"; - public static final String AuthorFourIsTheNumber = "Author: " + EnumChatFormatting.LIGHT_PURPLE + "FourIsTheNumber"; + public static final String AuthorFourIsTheNumber = "Author: " + EnumChatFormatting.LIGHT_PURPLE + + EnumChatFormatting.ITALIC + + "Four" + + EnumChatFormatting.WHITE + + EnumChatFormatting.ITALIC + + "Is" + + EnumChatFormatting.LIGHT_PURPLE + + EnumChatFormatting.ITALIC + + "The" + + EnumChatFormatting.WHITE + + EnumChatFormatting.ITALIC + + "Number"; public static final String authorBaps = "Author: " + EnumChatFormatting.GOLD + "Ba" + EnumChatFormatting.LIGHT_PURPLE diff --git a/src/main/java/gregtech/api/enums/ItemList.java b/src/main/java/gregtech/api/enums/ItemList.java index f024361c19..d1c30a0935 100644 --- a/src/main/java/gregtech/api/enums/ItemList.java +++ b/src/main/java/gregtech/api/enums/ItemList.java @@ -1462,6 +1462,9 @@ public enum ItemList implements IItemContainer { Electromagnet_Tengam, Machine_Multi_Canner, + Machine_Multi_IndustrialLaserEngraver, + Laser_Plate, + Casing_Laser, Machine_Multi_Lathe, diff --git a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java index 8abf07e1b1..b34c5d79f0 100644 --- a/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java +++ b/src/main/java/gregtech/api/enums/MetaTileEntityIDs.java @@ -610,6 +610,7 @@ public enum MetaTileEntityIDs { CRAFTING_INPUT_SLAVE(2716), INPUT_HATCH_ME(2717), INPUT_BUS_ME(2718), + INDUSTRIAL_LASER_ENGRAVER_CONTROLLER(3004), CHEST_BUFFER_ULV(9230), CHEST_BUFFER_LV(9231), CHEST_BUFFER_MV(9232), diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index ba13de2552..b190d60d00 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -336,6 +336,12 @@ public class Textures { OVERLAY_FRONT_MULTI_CANNER_ACTIVE_GLOW, OVERLAY_FRONT_MULTI_CANNER_GLOW, + LASER_PLATE, + MACHINE_CASING_LASER, + OVERLAY_FRONT_ENGRAVER, + OVERLAY_FRONT_ENGRAVER_ACTIVE, + OVERLAY_FRONT_ENGRAVER_ACTIVE_GLOW, + OVERLAY_FRONT_ENGRAVER_GLOW, OVERLAY_FRONT_MULTI_LATHE, OVERLAY_FRONT_MULTI_LATHE_ACTIVE, OVERLAY_FRONT_MULTI_LATHE_ACTIVE_GLOW, 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 { + + /** + * 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 IStructureElement ofBlockAdder(IBlockAdder iBlockAdder, Block defaultBlock, + int defaultMeta) { + if (iBlockAdder == null || defaultBlock == null) { + throw new IllegalArgumentException(); + } + if (defaultBlock instanceof ICustomBlockSetting) { + return new IStructureElement() { + + @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 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() { + + @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 chatter) { + if (check(t, world, x, y, z)) return IStructureElement.PlaceResult.SKIP; + return StructureUtility + .survivalPlaceBlock(defaultBlock, defaultMeta, world, x, y, z, s, actor, chatter); + } + }; + } + } +} -- cgit