From f2c0a4fc6b65749871b60580a6f65374f589b994 Mon Sep 17 00:00:00 2001 From: Mary <33456283+FourIsTheNumber@users.noreply.github.com> Date: Sat, 7 Sep 2024 09:16:14 -0400 Subject: Finishing touches on black hole compressor (#3060) Co-authored-by: Martin Robertz Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: BucketBrigade <138534411+CookieBrigade@users.noreply.github.com> --- src/main/java/gregtech/api/GregTechAPI.java | 1 + src/main/java/gregtech/api/enums/Textures.java | 18 +- .../implementations/MTEBasicMachine.java | 3 +- src/main/java/gregtech/common/GTClient.java | 2 + .../common/blocks/BlockBlackholeRenderer.java | 74 ++ .../gregtech/common/items/MetaGeneratedItem01.java | 4 +- .../gregtech/common/render/BlackholeRenderer.java | 222 ++++ .../multi/compressor/MTEBlackHoleCompressor.java | 382 ++++-- .../multi/compressor/MTEHIPCompressor.java | 15 +- .../machines/multi/compressor/MTEHeatSensor.java | 4 +- .../multi/compressor/MTEIndustrialCompressor.java | 17 +- .../multi/compressor/MTENeutroniumCompressor.java | 16 +- .../tileentities/render/TileEntityBlackhole.java | 99 ++ .../loaders/oreprocessing/ProcessingPlate.java | 2 +- .../loaders/preload/LoaderGTBlockFluid.java | 6 + .../multi/processing/steam/MTESteamCompressor.java | 3 + .../assets/gregtech/shaders/blackhole.frag.glsl | 42 + .../assets/gregtech/shaders/blackhole.vert.glsl | 81 ++ .../assets/gregtech/shaders/laser.frag.glsl | 25 + .../assets/gregtech/shaders/laser.vert.glsl | 47 + .../blocks/iconsets/OVERLAY_HATCH_BLACKHOLE.png | Bin 1711 -> 0 bytes .../iconsets/OVERLAY_HATCH_BLACKHOLE_GLOW.png | Bin 1702 -> 0 bytes .../blocks/iconsets/OVERLAY_HATCH_HEAT_SENSOR.png | Bin 0 -> 1711 bytes .../iconsets/OVERLAY_HATCH_HEAT_SENSOR_GLOW.png | Bin 0 -> 1702 bytes .../blocks/iconsets/OVERLAY_MULTI_BLACKHOLE.png | Bin 0 -> 217 bytes .../iconsets/OVERLAY_MULTI_BLACKHOLE_ACTIVE.png | Bin 0 -> 394 bytes .../OVERLAY_MULTI_BLACKHOLE_ACTIVE.png.mcmeta | 1 + .../OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW.png | Bin 0 -> 316 bytes .../OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW.png.mcmeta | 1 + .../iconsets/OVERLAY_MULTI_BLACKHOLE_GLOW.png | Bin 0 -> 131 bytes .../iconsets/OVERLAY_MULTI_BLACKHOLE_UNSTABLE.png | Bin 0 -> 391 bytes .../OVERLAY_MULTI_BLACKHOLE_UNSTABLE.png.mcmeta | 1 + .../OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW.png | Bin 0 -> 315 bytes ...VERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW.png.mcmeta | 1 + .../blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM.png | Bin 0 -> 228 bytes .../iconsets/OVERLAY_MULTI_NEUTRONIUM_ACTIVE.png | Bin 0 -> 444 bytes .../OVERLAY_MULTI_NEUTRONIUM_ACTIVE.png.mcmeta | 1 + .../OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW.png | Bin 0 -> 375 bytes ...OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW.png.mcmeta | 1 + .../iconsets/OVERLAY_MULTI_NEUTRONIUM_GLOW.png | Bin 0 -> 176 bytes .../gregtech/textures/items/gt.metaitem.01/418.png | Bin 164 -> 553 bytes .../textures/items/gt.metaitem.01/418.png.mcmeta | 1 + .../gregtech/textures/items/gt.metaitem.01/419.png | Bin 164 -> 550 bytes .../textures/items/gt.metaitem.01/419.png.mcmeta | 1 + .../assets/gregtech/textures/model/blackhole.obj | 1364 ++++++++++++++++++++ .../assets/gregtech/textures/model/blackhole.png | Bin 0 -> 81661 bytes .../assets/gregtech/textures/model/laser.png | Bin 0 -> 155 bytes 47 files changed, 2296 insertions(+), 139 deletions(-) create mode 100644 src/main/java/gregtech/common/blocks/BlockBlackholeRenderer.java create mode 100644 src/main/java/gregtech/common/render/BlackholeRenderer.java create mode 100644 src/main/java/gregtech/common/tileentities/render/TileEntityBlackhole.java create mode 100644 src/main/resources/assets/gregtech/shaders/blackhole.frag.glsl create mode 100644 src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl create mode 100644 src/main/resources/assets/gregtech/shaders/laser.frag.glsl create mode 100644 src/main/resources/assets/gregtech/shaders/laser.vert.glsl delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_HATCH_BLACKHOLE.png delete mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_HATCH_BLACKHOLE_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_HATCH_HEAT_SENSOR.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_HATCH_HEAT_SENSOR_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_ACTIVE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_ACTIVE.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_UNSTABLE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_UNSTABLE.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM_ACTIVE.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM_ACTIVE.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/blocks/iconsets/OVERLAY_MULTI_NEUTRONIUM_GLOW.png create mode 100644 src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/418.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/items/gt.metaitem.01/419.png.mcmeta create mode 100644 src/main/resources/assets/gregtech/textures/model/blackhole.obj create mode 100644 src/main/resources/assets/gregtech/textures/model/blackhole.png create mode 100644 src/main/resources/assets/gregtech/textures/model/laser.png (limited to 'src/main') diff --git a/src/main/java/gregtech/api/GregTechAPI.java b/src/main/java/gregtech/api/GregTechAPI.java index e10c773579..e9cfe16237 100644 --- a/src/main/java/gregtech/api/GregTechAPI.java +++ b/src/main/java/gregtech/api/GregTechAPI.java @@ -246,6 +246,7 @@ public class GregTechAPI { public static Block sBlockTintedGlass; public static Block sLaserRender; public static Block sWormholeRender; + public static Block sBlackholeRender; /** * Getting assigned by the Config */ diff --git a/src/main/java/gregtech/api/enums/Textures.java b/src/main/java/gregtech/api/enums/Textures.java index bd90cfe8ab..4eace204e6 100644 --- a/src/main/java/gregtech/api/enums/Textures.java +++ b/src/main/java/gregtech/api/enums/Textures.java @@ -346,6 +346,21 @@ public class Textures { OVERLAY_FRONT_MULTI_COMPRESSOR_COOLING, OVERLAY_FRONT_MULTI_COMPRESSOR_COOLING_GLOW, + OVERLAY_HATCH_HEAT_SENSOR, + OVERLAY_HATCH_HEAT_SENSOR_GLOW, + + OVERLAY_MULTI_NEUTRONIUM, + OVERLAY_MULTI_NEUTRONIUM_GLOW, + OVERLAY_MULTI_NEUTRONIUM_ACTIVE, + OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW, + + OVERLAY_MULTI_BLACKHOLE, + OVERLAY_MULTI_BLACKHOLE_GLOW, + OVERLAY_MULTI_BLACKHOLE_ACTIVE, + OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW, + OVERLAY_MULTI_BLACKHOLE_UNSTABLE, + OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW, + OVERLAY_FRONT_INDUSTRIAL_EXTRACTOR, OVERLAY_FRONT_INDUSTRIAL_EXTRACTOR_ACTIVE, OVERLAY_FRONT_INDUSTRIAL_EXTRACTOR_ACTIVE_GLOW, @@ -1343,9 +1358,6 @@ public class Textures { OVERLAY_HATCH_PH_SENSOR, OVERLAY_HATCH_PH_SENSOR_GLOW, - OVERLAY_HATCH_BLACKHOLE, - OVERLAY_HATCH_BLACKHOLE_GLOW, - STRUCTURE_MARK, MV_TOP_CYCLOTRON_SOLENOID, diff --git a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java index ee83857953..0bfff97895 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/MTEBasicMachine.java @@ -14,6 +14,7 @@ import static gregtech.api.metatileentity.BaseTileEntity.STALLED_STUTTERING_TOOL import static gregtech.api.metatileentity.BaseTileEntity.STALLED_VENT_TOOLTIP; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.metatileentity.BaseTileEntity.UNUSED_SLOT_TOOLTIP; +import static gregtech.api.util.GTRecipeConstants.COMPRESSION_TIER; import static gregtech.api.util.GTRecipeConstants.EXPLODE; import static gregtech.api.util.GTRecipeConstants.ON_FIRE; import static gregtech.api.util.GTUtility.moveMultipleItemStacks; @@ -1078,7 +1079,7 @@ public abstract class MTEBasicMachine extends MTEBasicTank implements RecipeMapW getBaseMetaTileEntity().setOnFire(); return DID_NOT_FIND_RECIPE; } - + if (tRecipe.getMetadataOrDefault(COMPRESSION_TIER, 0) > 0) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; if (GTMod.gregtechproxy.mLowGravProcessing && (tRecipe.mSpecialValue == -100 || tRecipe.mSpecialValue == -300) && !isValidForLowGravity(tRecipe, getBaseMetaTileEntity().getWorld().provider.dimensionId)) return FOUND_RECIPE_BUT_DID_NOT_MEET_REQUIREMENTS; diff --git a/src/main/java/gregtech/common/GTClient.java b/src/main/java/gregtech/common/GTClient.java index 127c801b40..276bc7a78a 100644 --- a/src/main/java/gregtech/common/GTClient.java +++ b/src/main/java/gregtech/common/GTClient.java @@ -91,6 +91,7 @@ import gregtech.api.util.WorldSpawnedEventBuilder; import gregtech.client.SeekingOggCodec; import gregtech.common.blocks.BlockFrameBox; import gregtech.common.blocks.ItemMachines; +import gregtech.common.render.BlackholeRenderer; import gregtech.common.render.DroneRender; import gregtech.common.render.FlaskRenderer; import gregtech.common.render.FluidDisplayStackRenderer; @@ -631,6 +632,7 @@ public class GTClient extends GTProxy implements Runnable { new DroneRender(); new LaserRenderer(); new WormholeRenderer(); + new BlackholeRenderer(); metaGeneratedItemRenderer = new MetaGeneratedItemRenderer(); for (MetaGeneratedItem item : MetaGeneratedItem.sInstances.values()) { diff --git a/src/main/java/gregtech/common/blocks/BlockBlackholeRenderer.java b/src/main/java/gregtech/common/blocks/BlockBlackholeRenderer.java new file mode 100644 index 0000000000..84d61172c3 --- /dev/null +++ b/src/main/java/gregtech/common/blocks/BlockBlackholeRenderer.java @@ -0,0 +1,74 @@ +package gregtech.common.blocks; + +import java.util.ArrayList; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.tileentities.render.TileEntityBlackhole; + +public class BlockBlackholeRenderer extends Block { + + public BlockBlackholeRenderer() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setBlockName("BlackHoleRenderer"); + this.setLightLevel(100.0f); + GameRegistry.registerBlock(this, getUnlocalizedName()); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @Override + public String getUnlocalizedName() { + return "gt.blackholerenderer"; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean canRenderInPass(int a) { + return true; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityBlackhole(); + } + + @Override + public ArrayList getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + + @Override + public boolean isCollidable() { + return true; + } + +} diff --git a/src/main/java/gregtech/common/items/MetaGeneratedItem01.java b/src/main/java/gregtech/common/items/MetaGeneratedItem01.java index ab9917435c..5fcb02b657 100644 --- a/src/main/java/gregtech/common/items/MetaGeneratedItem01.java +++ b/src/main/java/gregtech/common/items/MetaGeneratedItem01.java @@ -3203,14 +3203,14 @@ public class MetaGeneratedItem01 extends MetaGeneratedItemX32 { ItemList.Black_Hole_Opener.set( addItem( Black_Hole_Opener.ID, - "Black Hole Activation Catalyst", + "Black Hole Seed", "Opens a semi-stable black hole", new TCAspects.TC_AspectStack(TCAspects.ALIENIS, 32), new TCAspects.TC_AspectStack(TCAspects.ORDO, 64))); ItemList.Black_Hole_Closer.set( addItem( Black_Hole_Closer.ID, - "Black Hole Deactivation Catalyst", + "Black Hole Collapser", "Safely closes a semi-stable black hole", new TCAspects.TC_AspectStack(TCAspects.ALIENIS, 32), new TCAspects.TC_AspectStack(TCAspects.PERDITIO, 64))); diff --git a/src/main/java/gregtech/common/render/BlackholeRenderer.java b/src/main/java/gregtech/common/render/BlackholeRenderer.java new file mode 100644 index 0000000000..733bd3aa9e --- /dev/null +++ b/src/main/java/gregtech/common/render/BlackholeRenderer.java @@ -0,0 +1,222 @@ +package gregtech.common.render; + +import static gregtech.api.enums.Mods.GregTech; + +import java.nio.FloatBuffer; + +import net.minecraft.client.renderer.ActiveRenderInfo; +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; + +import org.joml.Matrix4fStack; +import org.joml.Vector4f; +import org.lwjgl.BufferUtils; +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL20; + +import com.gtnewhorizon.gtnhlib.client.renderer.CapturingTessellator; +import com.gtnewhorizon.gtnhlib.client.renderer.TessellatorManager; +import com.gtnewhorizon.gtnhlib.client.renderer.shader.ShaderProgram; +import com.gtnewhorizon.gtnhlib.client.renderer.vbo.IModelCustomExt; +import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; +import com.gtnewhorizon.gtnhlib.client.renderer.vertex.DefaultVertexFormat; + +import cpw.mods.fml.client.registry.ClientRegistry; +import gregtech.common.tileentities.render.TileEntityBlackhole; + +public class BlackholeRenderer extends TileEntitySpecialRenderer { + + private boolean initialized = false; + + private ShaderProgram blackholeProgram; + private static int u_CameraPosition = -1, u_Scale = -1, u_Time = -1, u_Stability = -1; + private static final Matrix4fStack modelMatrixStack = new Matrix4fStack(4); + + private static IModelCustomExt blackholeModel; + private static ResourceLocation blackholeTexture; + private static float modelScale = .5f; + + private ShaderProgram laserProgram; + private static int u_LaserCameraPosition = -1, u_LaserColor = -1, u_LaserModelMatrix = -1; + private static VertexBuffer laserVBO; + private static ResourceLocation laserTexture; + + private static final Matrix4fStack modelMatrix = new Matrix4fStack(2); + + private static final float WIDTH = .1f; + private static final float EXCLUSION = 1f; + + public BlackholeRenderer() { + ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlackhole.class, this); + } + + private void init() { + try { + blackholeProgram = new ShaderProgram( + GregTech.resourceDomain, + "shaders/blackhole.vert.glsl", + "shaders/blackhole.frag.glsl"); + + u_CameraPosition = blackholeProgram.getUniformLocation("u_CameraPosition"); + + u_Scale = blackholeProgram.getUniformLocation("u_Scale"); + u_Time = blackholeProgram.getUniformLocation("u_Time"); + u_Stability = blackholeProgram.getUniformLocation("u_Stability"); + + } catch (Exception e) { + System.out.println(e.getMessage()); + return; + } + + blackholeModel = (IModelCustomExt) AdvancedModelLoader + .loadModel(new ResourceLocation(GregTech.resourceDomain, "textures/model/blackhole.obj")); + blackholeTexture = new ResourceLocation(GregTech.resourceDomain, "textures/model/blackhole.png"); + + blackholeProgram.use(); + GL20.glUniform1f(u_Scale, modelScale); + GL20.glUniform1f(u_Stability, .1f); + ShaderProgram.clear(); + + try { + laserProgram = new ShaderProgram( + GregTech.resourceDomain, + "shaders/laser.vert.glsl", + "shaders/laser.frag.glsl"); + u_LaserCameraPosition = laserProgram.getUniformLocation("u_CameraPosition"); + u_LaserColor = laserProgram.getUniformLocation("u_Color"); + u_LaserModelMatrix = laserProgram.getUniformLocation("u_ModelMatrix"); + + } catch (Exception e) { + System.out.println(e.getMessage()); + return; + } + + laserTexture = new ResourceLocation(GregTech.resourceDomain, "textures/model/laser.png"); + + TessellatorManager.startCapturing(); + CapturingTessellator tess = (CapturingTessellator) TessellatorManager.get(); + + tess.startDrawingQuads(); + + tess.addVertexWithUV(.5 + 8, 0, -WIDTH, 0, 0); + tess.addVertexWithUV(.5 + 8, 0, WIDTH, 0, 1); + tess.addVertexWithUV(EXCLUSION, 0, WIDTH / 5, 1, 1); + tess.addVertexWithUV(EXCLUSION, 0, -WIDTH / 5, 1, 0); + + tess.addVertexWithUV(-.5 - 8, 0, -WIDTH, 0, 0); + tess.addVertexWithUV(-.5 - 8, 0, WIDTH, 0, 1); + tess.addVertexWithUV(-EXCLUSION, 0, WIDTH / 5, 1, 1); + tess.addVertexWithUV(-EXCLUSION, 0, -WIDTH / 5, 1, 0); + + tess.draw(); + + laserVBO = TessellatorManager.stopCapturingToVBO(DefaultVertexFormat.POSITION_TEXTURE_NORMAL); + + initialized = true; + } + + private void renderBlackHole(TileEntityBlackhole tile, double x, double y, double z, float timer) { + + blackholeProgram.use(); + bindTexture(blackholeTexture); + GL20.glUniform1f(u_Stability, tile.getStability()); + modelMatrixStack.clear(); + + float xLocal = ((float) x + .5f); + float yLocal = ((float) y + .5f); + float zLocal = ((float) z + .5f); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glPushMatrix(); + GL20.glUniform3f( + u_CameraPosition, + ActiveRenderInfo.objectX - xLocal, + ActiveRenderInfo.objectY - yLocal, + ActiveRenderInfo.objectZ - zLocal); + + GL20.glUniform1f(u_Time, timer); + GL11.glTranslated(x + .5f, y + .5f, z + .5f); + blackholeModel.renderAllVBO(); + + GL11.glPopMatrix(); + GL11.glPopAttrib(); + ShaderProgram.clear(); + } + + private void renderLasers(TileEntityBlackhole tile, double x, double y, double z, float timer) { + laserProgram.use(); + bindTexture(laserTexture); + + float cx = ((float) x + .5f); + float cy = ((float) y + .5f); + float cz = ((float) z + .5f); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glPushMatrix(); + GL20.glUniform3f(u_LaserColor, tile.getLaserR(), tile.getLaserG(), tile.getLaserB()); + + modelMatrix.clear(); + modelMatrix.translate(cx, cy, cz); + + // First set + FloatBuffer matrixBuffer = BufferUtils.createFloatBuffer(16); + GL20.glUniformMatrix4(u_LaserModelMatrix, false, modelMatrix.get(matrixBuffer)); + modelMatrix.pushMatrix(); + modelMatrix.invert(); + Vector4f cameraPosition = new Vector4f( + ActiveRenderInfo.objectX, + ActiveRenderInfo.objectY, + ActiveRenderInfo.objectZ, + 1); + cameraPosition = modelMatrix.transform(cameraPosition); + GL20.glUniform3f(u_LaserCameraPosition, cameraPosition.x, cameraPosition.y, cameraPosition.z); + laserVBO.render(); + + // Second set + + modelMatrix.popMatrix(); + matrixBuffer.clear(); + modelMatrix.rotate((float) Math.PI / 2, 0, 1, 0); + + GL20.glUniformMatrix4(u_LaserModelMatrix, false, modelMatrix.get(matrixBuffer)); + + modelMatrix.invert(); + cameraPosition.set(ActiveRenderInfo.objectX, ActiveRenderInfo.objectY, ActiveRenderInfo.objectZ, 1); + cameraPosition = modelMatrix.transform(cameraPosition); + GL20.glUniform3f(u_LaserCameraPosition, cameraPosition.x, cameraPosition.y, cameraPosition.z); + laserVBO.render(); + + GL11.glPopMatrix(); + GL11.glPopAttrib(); + ShaderProgram.clear(); + } + + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (!(tile instanceof TileEntityBlackhole blackhole)) return; + + if (!initialized) { + init(); + if (!initialized) return; + } + if (((TileEntityBlackhole) tile).getLaserRender()) { + renderLasers( + blackhole, + x, + y, + z, + tile.getWorldObj() + .getWorldTime() + timeSinceLastTick); + } + + renderBlackHole( + blackhole, + x, + y, + z, + tile.getWorldObj() + .getWorldTime() + timeSinceLastTick); + + } + +} 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 ba893e045d..367b529bc3 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 @@ -1,16 +1,20 @@ package gregtech.common.tileentities.machines.multi.compressor; +import static bartworks.util.BWTooltipReference.TT; import static com.gtnewhorizon.structurelib.structure.StructureUtility.*; import static gregtech.api.enums.GTValues.AuthorFourIsTheNumber; import static gregtech.api.enums.GTValues.Ollie; import static gregtech.api.enums.HatchElement.*; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_UNSTABLE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW; import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import static gregtech.api.util.GTStructureUtility.ofFrame; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -20,6 +24,7 @@ import javax.annotation.Nonnull; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -42,11 +47,13 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsUEVplus; import gregtech.api.enums.Textures; import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IIconContainer; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; @@ -57,8 +64,10 @@ import gregtech.api.render.TextureFactory; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; import gregtech.common.blocks.BlockCasings10; import gregtech.common.items.MetaGeneratedItem01; +import gregtech.common.tileentities.render.TileEntityBlackhole; import gtPlusPlus.core.util.minecraft.PlayerUtils; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; @@ -111,7 +120,8 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase spacetimeHatches = new ArrayList<>(); + + /** + * 1: Off + * 2: On, stable + * 3: On, unstable + */ + private byte blackHoleStatus = 1; private final FluidStack blackholeCatalyzingCost = (MaterialsUEVplus.SpaceTime).getMolten(1); private int catalyzingCostModifier = 1; @@ -143,6 +159,22 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase getStructureDefinition() { return STRUCTURE_DEFINITION; @@ -171,15 +203,39 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase { + MAIN_OVERLAY = OVERLAY_MULTI_BLACKHOLE; + GLOW_OVERLAY = OVERLAY_MULTI_BLACKHOLE_GLOW; + } + case 2 -> { + MAIN_OVERLAY = OVERLAY_MULTI_BLACKHOLE_ACTIVE; + GLOW_OVERLAY = OVERLAY_MULTI_BLACKHOLE_ACTIVE_GLOW; + } + case 3 -> { + MAIN_OVERLAY = OVERLAY_MULTI_BLACKHOLE_UNSTABLE; + GLOW_OVERLAY = OVERLAY_MULTI_BLACKHOLE_UNSTABLE_GLOW; + } } + + rTexture = new ITexture[] { + Textures.BlockIcons + .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 11)), + TextureFactory.builder() + .addIcon(MAIN_OVERLAY) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(GLOW_OVERLAY) + .extFacing() + .glow() + .build() }; + } else { rTexture = new ITexture[] { Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 11)) }; @@ -227,78 +286,78 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase 1) return false; + energyHatchTier = mExoticEnergyHatches.get(0).mTier; + } else if (!mEnergyHatches.isEmpty()) { + byte tier = mEnergyHatches.get(0).mTier; + for (MTEHatchEnergy hatch : mEnergyHatches) if (hatch.mTier < tier) tier = hatch.mTier; + energyHatchTier = tier; + } return true; } @@ -334,19 +404,21 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase 0) { currentTip.add(EnumChatFormatting.DARK_PURPLE + "Black Hole Active"); currentTip.add( @@ -382,6 +454,8 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase 0) { - if (!blackholeOn) return CheckRecipeResultRegistry.NO_BLACK_HOLE; - } else { - if (blackHoleStability <= 0) setSpeedBonus(5F); - else if (blackholeOn) setSpeedBonus(0.2F); + setSpeedBonus(0.2F); + if (blackHoleStatus == 1) return CheckRecipeResultRegistry.NO_BLACK_HOLE; + + // If the recipe doesn't require black hole, but it is unstable, incur a 0.5x speed penalty + if (recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 0) == 0 && (blackHoleStatus == 3)) { + setSpeedBonus(5F); } return super.validateRecipe(recipe); } @@ -432,7 +522,7 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase 0) { + if ((blackHoleStatus == 3) && recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 0) > 0) { return CheckRecipeResultRegistry.UNSTABLE_BLACK_HOLE; } return CheckRecipeResultRegistry.SUCCESSFUL; @@ -446,29 +536,40 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase= 0) { - float stabilityDecrease = 1F; - // If the machine is running, reduce stability loss by 25% - if (this.maxProgresstime() != 0) { - stabilityDecrease = 0.75F; - } - // Search all hatches for catalyst fluid - // If found enough, drain it and reduce stability loss to 0 - // Every 30 drains, double the cost - FluidStack totalCost = new FluidStack(blackholeCatalyzingCost, catalyzingCostModifier); - for (MTEHatchInput hatch : mInputHatches) { - if (drain(hatch, totalCost, false)) { - drain(hatch, totalCost, true); - catalyzingCounter += 1; - stabilityDecrease = 0; - if (catalyzingCounter >= 30) { - catalyzingCostModifier *= 2; - catalyzingCounter = 0; + if (blackHoleStatus == 2) { + if (blackHoleStability >= 0) { + if (rendererTileEntity == null) createRenderBlock(); + rendererTileEntity.setStability(blackHoleStability / 100F); + float stabilityDecrease = 1F; + // If the machine is running, reduce stability loss by 25% + if (this.maxProgresstime() != 0) { + stabilityDecrease = 0.75F; + } + + // Search all hatches for catalyst fluid + // If found enough, drain it and reduce stability loss to 0 + // Every 30 drains, double the cost + FluidStack totalCost = new FluidStack(blackholeCatalyzingCost, catalyzingCostModifier); + + boolean didDrain = false; + for (MTEHatchInput hatch : spacetimeHatches) { + if (drain(hatch, totalCost, false)) { + drain(hatch, totalCost, true); + catalyzingCounter += 1; + stabilityDecrease = 0; + if (catalyzingCounter >= 30) { + catalyzingCostModifier *= 2; + catalyzingCounter = 0; + } + didDrain = true; + break; } } - } - if (blackHoleStability >= 0) blackHoleStability -= stabilityDecrease; - else blackHoleStability = 0; + if (rendererTileEntity == null) createRenderBlock(); + rendererTileEntity.toggleLaser(didDrain); + if (blackHoleStability >= 0) blackHoleStability -= stabilityDecrease; + else blackHoleStability = 0; + } else blackHoleStatus = 3; } } } @@ -531,4 +632,53 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase 0) doingHIP = true; + int recipeReq = recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 0); + if (recipeReq == 1) { + doingHIP = true; + } else if (recipeReq == 2) { + return CheckRecipeResultRegistry.NO_RECIPE; + } return super.validateRecipe(recipe); } }.setMaxParallelSupplier(this::getMaxParallelRecipes); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHeatSensor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHeatSensor.java index 8ea57bc1cf..82f9d43506 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHeatSensor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHeatSensor.java @@ -31,8 +31,8 @@ public class MTEHeatSensor extends MTEHatch { protected boolean inverted = false; private boolean isOn = false; - private static final IIconContainer textureFont = Textures.BlockIcons.OVERLAY_HATCH_BLACKHOLE; - private static final IIconContainer textureFont_Glow = Textures.BlockIcons.OVERLAY_HATCH_BLACKHOLE_GLOW; + private static final IIconContainer textureFont = Textures.BlockIcons.OVERLAY_HATCH_HEAT_SENSOR; + private static final IIconContainer textureFont_Glow = Textures.BlockIcons.OVERLAY_HATCH_HEAT_SENSOR_GLOW; public MTEHeatSensor(int aID, String aName, String aNameRegional, int aTier) { super(aID, aName, aNameRegional, aTier, 0, "Reads heat from HIP Unit."); diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEIndustrialCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEIndustrialCompressor.java index e21da1856f..c887d1cf03 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEIndustrialCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEIndustrialCompressor.java @@ -14,6 +14,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.common.util.ForgeDirection; +import org.jetbrains.annotations.NotNull; + import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; @@ -29,7 +31,11 @@ import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBas import gregtech.api.multitileentity.multiblock.casing.Glasses; import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.metadata.CompressionTierKey; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTRecipe; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.common.blocks.BlockCasings10; @@ -188,7 +194,16 @@ public class MTEIndustrialCompressor extends MTEExtendedPowerMultiBlockBase 0) + return CheckRecipeResultRegistry.NO_RECIPE; + return super.validateRecipe(recipe); + } + }.setSpeedBonus(1F / 2F) .setMaxParallelSupplier(this::getMaxParallelRecipes) .setEuModifier(0.9F); } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTENeutroniumCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTENeutroniumCompressor.java index 323e09f61b..f5326e284e 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTENeutroniumCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTENeutroniumCompressor.java @@ -9,10 +9,10 @@ import static gregtech.api.enums.HatchElement.Energy; import static gregtech.api.enums.HatchElement.InputBus; import static gregtech.api.enums.HatchElement.Maintenance; import static gregtech.api.enums.HatchElement.OutputBus; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE_GLOW; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_FRONT_MULTI_COMPRESSOR_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_NEUTRONIUM; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_NEUTRONIUM_ACTIVE; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_MULTI_NEUTRONIUM_GLOW; import static gregtech.api.util.GTStructureUtility.buildHatchAdder; import static gregtech.api.util.GTStructureUtility.ofFrame; @@ -115,11 +115,11 @@ public class MTENeutroniumCompressor extends MTEExtendedPowerMultiBlockBase