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 | |
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')
16 files changed, 729 insertions, 139 deletions
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<ItemStack> 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<MTEBl .addElement('A', ofBlock(GregTechAPI.sBlockGlass1, 4)) .addElement( 'B', - buildHatchAdder(MTEBlackHoleCompressor.class).atLeast(Maintenance, Energy) + buildHatchAdder(MTEBlackHoleCompressor.class) + .atLeast(Energy.or(ExoticEnergy), InputBus, OutputBus, InputHatch) .casingIndex(((BlockCasings10) GregTechAPI.sBlockCasings10).getTextureIndex(12)) .dot(2) .buildAndChain( @@ -120,17 +130,23 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl .addElement('D', ofFrame(Materials.NaquadahAlloy)) .addElement( 'E', - buildHatchAdder(MTEBlackHoleCompressor.class).atLeast(InputBus, OutputBus, InputHatch) + buildHatchAdder(MTEBlackHoleCompressor.class).atLeast(InputHatch) + .adder(MTEBlackHoleCompressor::addSpacetimeInput) .casingIndex(((BlockCasings10) GregTechAPI.sBlockCasings10).getTextureIndex(11)) .dot(1) - .buildAndChain( - onElementPass(MTEBlackHoleCompressor::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings10, 11)))) - + .buildAndChain(ofBlock(GregTechAPI.sBlockCasings10, 11))) .build(); - private boolean blackholeOn = false; private int catalyzingCounter = 0; private float blackHoleStability = 100; + private final ArrayList<MTEHatchInput> 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<MTEBl super(aName); } + private boolean addSpacetimeInput(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity != null) { + if (aTileEntity.getMetaTileEntity() instanceof MTEHatchInput hatch) { + hatch.updateTexture(aBaseCasingIndex); + spacetimeHatches.add(hatch); + return true; + } + } + return false; + } + + @Override + protected boolean filtersFluid() { + return false; + } + @Override public IStructureDefinition<MTEBlackHoleCompressor> getStructureDefinition() { return STRUCTURE_DEFINITION; @@ -171,15 +203,39 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl @Override public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - setMachineMode(nextMachineMode()); - PlayerUtils.messagePlayer( - aPlayer, - String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + if (aPlayer.isSneaking()) { + shouldRender = !shouldRender; + if (!shouldRender) { + PlayerUtils.messagePlayer(aPlayer, "Rendering off"); + rendererTileEntity = null; + destroyRenderBlock(); + } else { + if (blackHoleStatus != 1) createRenderBlock(); + PlayerUtils.messagePlayer(aPlayer, "Rendering on"); + } + } else { + setMachineMode(nextMachineMode()); + PlayerUtils.messagePlayer( + aPlayer, + String.format(StatCollector.translateToLocal("GT5U.MULTI_MACHINE_CHANGE"), getMachineModeName())); + } } @Override public String getMachineModeName() { - return StatCollector.translateToLocal("GT5U.COMPRESSION_TIER.mode." + machineMode); + return StatCollector.translateToLocal("GT5U.BLACKHOLE.mode." + machineMode); + } + + @Override + public void onValueUpdate(byte aValue) { + byte oBlackHoleStatus = blackHoleStatus; + blackHoleStatus = aValue; + if (oBlackHoleStatus != blackHoleStatus) getBaseMetaTileEntity().issueTextureUpdate(); + } + + @Override + public byte getUpdateData() { + return blackHoleStatus; } @Override @@ -187,33 +243,36 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl int colorIndex, boolean aActive, boolean redstoneLevel) { ITexture[] rTexture; if (side == aFacing) { - if (aActive) { - rTexture = new ITexture[] { - Textures.BlockIcons - .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 11)), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE) - .extFacing() - .build(), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE_GLOW) - .extFacing() - .glow() - .build() }; - } else { - rTexture = new ITexture[] { - Textures.BlockIcons - .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 11)), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR) - .extFacing() - .build(), - TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_GLOW) - .extFacing() - .glow() - .build() }; + IIconContainer MAIN_OVERLAY; + IIconContainer GLOW_OVERLAY; + switch (blackHoleStatus) { + default -> { + 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<MTEBl tt.addMachineType("Compressor/Advanced Neutronium Compressor") .addInfo("Controller Block for the Semi-Stable Black Hole Containment Field") .addInfo(EnumChatFormatting.LIGHT_PURPLE + "Uses the immense power of the event horizon to compress things") - .addInfo("No longer requires heat management to perform perfect compression") + .addInfo("No longer requires heat management to perform superdense compression") .addInfo("Can create advanced singularities!") .addSeparator() .addInfo( "Insert a " + EnumChatFormatting.WHITE - + "Black Hole Activation Catalyst" + + "Black Hole Seed" + EnumChatFormatting.GRAY + " to open a black hole") .addInfo( "The black hole will begin its life at " + EnumChatFormatting.RED - + "100%" + + "100" + EnumChatFormatting.GRAY + " stability and slowly decay") + .addInfo( + "Stability decays by " + EnumChatFormatting.RED + + "1/s" + + EnumChatFormatting.GRAY + + " until it reaches 0") + .addInfo("At 0 stability, the black hole is " + EnumChatFormatting.DARK_RED + "UNSTABLE") + .addInfo("Once the black hole becomes unstable, it will void all inputs for recipes which require it") .addSeparator() - .addInfo("Natural decay takes " + EnumChatFormatting.RED + "100" + EnumChatFormatting.GRAY + " seconds") - .addInfo("Running recipes in the machine will slow the decay by " + EnumChatFormatting.RED + "25%") + .addInfo("Running recipes in the machine will slow the decay rate by " + EnumChatFormatting.RED + "25%") .addInfo( "The decay can be " + EnumChatFormatting.BOLD + "halted" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY - + " by inserting spacetime") + + " by inserting 1 L/s of spacetime") .addInfo( "Every " + EnumChatFormatting.RED + "30" + EnumChatFormatting.GRAY - + " seconds saved by spacetime insertion will " + + " total seconds saved by spacetime insertion will " + EnumChatFormatting.RED + "double" + EnumChatFormatting.GRAY + " the cost per second!") - .addInfo("Once the black hole becomes unstable, it will void all inputs for recipes which require it") .addInfo( "Insert a " + EnumChatFormatting.WHITE - + "Black Hole Deactivation Catalyst" + + "Black Hole Collapser" + EnumChatFormatting.GRAY + " to close the black hole") + .addInfo("To restore stability and reset spacetime costs, close the black hole and open a new one") .addSeparator() .addInfo( "Recipes not utilizing the black hole have their lengths " + EnumChatFormatting.RED + "doubled" + EnumChatFormatting.GRAY + " if it becomes unstable") - .addInfo("400% faster than singleblock machines of the same voltage when black hole is open") - .addInfo("Only uses 70% of the EU/t normally required") + .addInfo("400% faster than singleblock machines of the same voltage") + .addInfo("Only uses 70% of the EU/t normally required - does not overclock above energy hatch tier") .addInfo("Gains 8 parallels per voltage tier") .addInfo( - "Parallels are " + EnumChatFormatting.RED - + "doubled" + EnumChatFormatting.RED + "2x/4x" + EnumChatFormatting.GRAY - + " when stability is BELOW " + + " parallels when stability is BELOW " + EnumChatFormatting.RED - + "50%") - .addInfo( - "Parallels are " + EnumChatFormatting.RED - + "quadrupled" - + EnumChatFormatting.GRAY - + " when stability is BELOW " - + EnumChatFormatting.RED - + "20%") + + "50/20") + .addInfo("Accepts one " + TT + " energy hatch") .addInfo(AuthorFourIsTheNumber + EnumChatFormatting.RESET + " & " + Ollie) + .addInfo("Rendering by: " + EnumChatFormatting.WHITE + "BucketBrigade") .addSeparator() .beginStructureBlock(35, 33, 35, false) - .addCasingInfoMin("Background Radiation Absorbent Casing", 985, false) + .addCasingInfoMin("Background Radiation Absorbent Casing", 950, false) .addCasingInfoExactly("Extreme Density Space-Bending Casing", 3667, false) .addCasingInfoExactly("Hawking Radiation Realignment Focus", 64, false) .addCasingInfoExactly("Naquadah Alloy Frame Box", 144, false) - .addInputBus("Behind Laser", 1) - .addOutputBus("Behind Laser", 1) - .addInputHatch("Behind Laser", 1) - .addEnergyHatch("Any Radiation Absorbent Casing", 2) - .addMaintenanceHatch("Any Radiation Absorbent Casing", 2) + .addInputHatch("Spacetime Insertion, Behind Laser", 2) + .addInputBus("Any Radiation Absorbent Casing", 1) + .addOutputBus("Any Radiation Absorbent Casing", 1) + .addInputHatch("Any Radiation Absorbent Casing", 1) + .addEnergyHatch("Any Radiation Absorbent Casing", 1) .toolTipFinisher("GregTech"); return tt; } @@ -324,9 +383,20 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasingAmount = 0; mEnergyHatches.clear(); + mExoticEnergyHatches.clear(); + spacetimeHatches.clear(); if (!checkPiece(STRUCTURE_PIECE_MAIN, 17, 27, 10)) return false; - if (mCasingAmount < 0) return false; + if (mCasingAmount < 950) return false; + + if (!mExoticEnergyHatches.isEmpty()) { + if (mExoticEnergyHatches.size() > 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<MTEBl @Override public void loadNBTData(NBTTagCompound aNBT) { super.loadNBTData(aNBT); - aNBT.setInteger("catalyzingCostModifier", catalyzingCostModifier); - aNBT.setInteger("catalyzingCounter", catalyzingCounter); - aNBT.setBoolean("blackholeOn", blackholeOn); - aNBT.setFloat("blackholeStability", blackHoleStability); + if (aNBT.hasKey("catalyzingCounter")) catalyzingCounter = aNBT.getInteger("catalyzingCounter"); + if (aNBT.hasKey("catalyzingCostModifier")) catalyzingCostModifier = aNBT.getInteger("catalyzingCostModifier"); + if (aNBT.hasKey("blackHoleStatus")) blackHoleStatus = aNBT.getByte("blackHoleStatus"); + if (aNBT.hasKey("blackHoleStability")) blackHoleStability = aNBT.getFloat("blackHoleStability"); + if (aNBT.hasKey("shouldRender")) shouldRender = aNBT.getBoolean("shouldRender"); } @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); - if (aNBT.hasKey("catalyzingCounter")) catalyzingCostModifier = aNBT.getInteger("catalyzingCounter"); - if (aNBT.hasKey("catalyzingCostModifier")) catalyzingCostModifier = aNBT.getInteger("catalyzingCostModifier"); - if (aNBT.hasKey("blackholeOn")) blackholeOn = aNBT.getBoolean("blackholeOn"); - if (aNBT.hasKey("blackholeStability")) blackHoleStability = aNBT.getFloat("blackholeStability"); + aNBT.setInteger("catalyzingCounter", catalyzingCounter); + aNBT.setInteger("catalyzingCostModifier", catalyzingCostModifier); + aNBT.setByte("blackHoleStatus", blackHoleStatus); + aNBT.setFloat("blackHoleStability", blackHoleStability); + aNBT.setBoolean("shouldRender", shouldRender); } @Override @@ -359,7 +431,7 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); - tag.setBoolean("blackholeOn", blackholeOn); + tag.setByte("blackHoleStatus", blackHoleStatus); tag.setFloat("blackHoleStability", blackHoleStability); } @@ -368,7 +440,7 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl IWailaConfigHandler config) { super.getWailaBody(itemStack, currentTip, accessor, config); final NBTTagCompound tag = accessor.getNBTData(); - if (tag.getBoolean("blackholeOn")) { + if (tag.getByte("blackHoleStatus") != 1) { if (tag.getFloat("blackHoleStability") > 0) { currentTip.add(EnumChatFormatting.DARK_PURPLE + "Black Hole Active"); currentTip.add( @@ -382,6 +454,8 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl } else currentTip.add(EnumChatFormatting.DARK_PURPLE + "Black Hole Offline"); } + byte energyHatchTier = 0; + @Override protected ProcessingLogic createProcessingLogic() { return new ProcessingLogic() { @@ -394,15 +468,18 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl // Deactivation resets stability to 100 and catalyzing cost to 1 for (ItemStack inputItem : inputItems) { if (inputItem.getItem() instanceof MetaGeneratedItem01) { - if (inputItem.getItemDamage() == 32418 && !blackholeOn) { + if (inputItem.getItemDamage() == 32418 && (blackHoleStatus == 1)) { inputItem.stackSize -= 1; - blackholeOn = true; + blackHoleStatus = 2; + createRenderBlock(); break; - } else if (inputItem.getItemDamage() == 32419 && blackholeOn) { + } else if (inputItem.getItemDamage() == 32419 && !(blackHoleStatus == 1)) { inputItem.stackSize -= 1; - blackholeOn = false; + blackHoleStatus = 1; blackHoleStability = 100; catalyzingCostModifier = 1; + rendererTileEntity = null; + destroyRenderBlock(); break; } } @@ -412,19 +489,32 @@ public class MTEBlackHoleCompressor extends MTEExtendedPowerMultiBlockBase<MTEBl @NotNull @Override + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { + int ocs = energyHatchTier - GTUtility.getTier(recipe.mEUt); + if (ocs < 0) ocs = 0; + return new OverclockCalculator().setRecipeEUt(recipe.mEUt) + .setAmperage(availableAmperage) + .setEUt(availableVoltage) + .setDuration(recipe.mDuration) + .setSpeedBoost(speedBoost) + .setEUtDiscount(euModifier) + .setAmperageOC(amperageOC) + .setDurationDecreasePerOC(overClockTimeReduction) + .setEUtIncreasePerOC(overClockPowerIncrease) + .limitOverclockCount(ocs); + } + + @NotNull + @Override protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { // Default speed bonus - setSpeedBonus(1F); - - // If recipe needs a black hole and one is not open, just wait - // If the recipe doesn't require black hole, incur a 0.5x speed penalty - // If recipe doesn't require black hole but one is open, give 5x speed bonus - if (recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 1) > 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<MTEBl @Nonnull protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { // If recipe needs a black hole and one is active but unstable, continuously void items - if (blackHoleStability <= 0 && recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 1) > 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<MTEBl super.onPostTick(aBaseMetaTileEntity, aTick); if (aTick % 20 == 0) { - if (blackholeOn && blackHoleStability >= 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<MTEBl public boolean supportsSingleRecipeLocking() { return true; } + + @Override + public void onBlockDestroyed() { + destroyRenderBlock(); + super.onBlockDestroyed(); + } + + @Override + public boolean isRotationChangeAllowed() { + return false; + } + + private boolean shouldRender = true; + private TileEntityBlackhole rendererTileEntity = null; + + private void createRenderBlock() { + if (!shouldRender) return; + IGregTechTileEntity base = this.getBaseMetaTileEntity(); + ForgeDirection opposite = getDirection().getOpposite(); + int x = 7 * opposite.offsetX; + int z = 7 * opposite.offsetZ; + int y = 11; + + base.getWorld() + .setBlock(base.getXCoord() + x, base.getYCoord() + y, base.getZCoord() + z, Blocks.air); + base.getWorld() + .setBlock(base.getXCoord() + x, base.getYCoord() + y, base.getZCoord() + z, GregTechAPI.sBlackholeRender); + rendererTileEntity = (TileEntityBlackhole) base.getWorld() + .getTileEntity(base.getXCoord() + x, base.getYCoord() + y, base.getZCoord() + z); + + rendererTileEntity.setStability(blackHoleStability / 100F); + } + + private void destroyRenderBlock() { + IGregTechTileEntity base = this.getBaseMetaTileEntity(); + ForgeDirection opposite = getDirection().getOpposite(); + int x = 7 * opposite.offsetX; + int z = 7 * opposite.offsetZ; + int y = 11; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock(base.getXCoord() + x, base.getYCoord() + y, base.getZCoord() + z, Blocks.air); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } } diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHIPCompressor.java b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHIPCompressor.java index 2491dcff38..aeda7d0cd6 100644 --- a/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHIPCompressor.java +++ b/src/main/java/gregtech/common/tileentities/machines/multi/compressor/MTEHIPCompressor.java @@ -47,6 +47,7 @@ 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; @@ -74,10 +75,10 @@ public class MTEHIPCompressor extends MTEExtendedPowerMultiBlockBase<MTEHIPCompr {" BBB "," BBBBB "," BBBBBBB "," C BBBBBBB D "," BBBBBBB "," BBBBB "," BBB "}, {" HHH "," B B "," BF FB "," C BF FB D "," BF FB "," B B "," HHH "}, {" HAH "," B B "," GF FG "," C GF FG D "," GF FG "," B B "," HAH "}, - {" HAH "," B B "," E GF FG E ","EEE GF FG EEE"," E GF FG E "," B B "," HAH "}, + {" HAH "," B B "," B GF FG B ","BBB GF FG BBB"," B GF FG B "," B B "," HAH "}, {" HAH "," B B "," A GF FG A ","A A GF FG A A"," A GF FG A "," B B "," HAH "}, {" HHH "," B B "," A BF FB A ","A A BF FB A A"," A BF FB A "," B B "," HHH "}, - {" B~B "," BBBBB "," E BBBBBBB E ","EEE BBBBBBB EEE"," E BBBBBBB E "," BBBBB "," BBB "} + {" B~B "," BBBBB "," B BBBBBBB B ","BBB BBBBBBB BBB"," B BBBBBBB B "," BBBBB "," BBB "} })) //spotless:on .addElement('A', Glasses.chainAllGlasses()) @@ -89,13 +90,12 @@ public class MTEHIPCompressor extends MTEExtendedPowerMultiBlockBase<MTEHIPCompr .buildAndChain(onElementPass(MTEHIPCompressor::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings10, 4)))) .addElement('C', ofBlock(GregTechAPI.sBlockCasings10, 9)) .addElement('D', ofBlock(GregTechAPI.sBlockCasings10, 10)) - .addElement('E', ofBlock(GregTechAPI.sBlockCasings4, 1)) .addElement('F', ofCoil(MTEHIPCompressor::setCoilLevel, MTEHIPCompressor::getCoilLevel)) .addElement( 'G', buildHatchAdder(MTEHIPCompressor.class).atLeast(InputBus, OutputBus) .casingIndex(((BlockCasings10) GregTechAPI.sBlockCasings10).getTextureIndex(5)) - .dot(1) + .dot(2) .buildAndChain(onElementPass(MTEHIPCompressor::onCasingAdded, ofBlock(GregTechAPI.sBlockCasings10, 5)))) .addElement('H', ofBlock(GregTechAPI.sBlockCasings10, 5)) .build(); @@ -376,7 +376,12 @@ public class MTEHIPCompressor extends MTEExtendedPowerMultiBlockBase<MTEHIPCompr setEuModifier(1.1F); } - if (recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 1) > 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<MTEI @Override protected ProcessingLogic createProcessingLogic() { - return new ProcessingLogic().setSpeedBonus(1F / 2F) + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { + if (recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 0) > 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<MTEN Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 6)), TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE) + .addIcon(OVERLAY_MULTI_NEUTRONIUM_ACTIVE) .extFacing() .build(), TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_ACTIVE_GLOW) + .addIcon(OVERLAY_MULTI_NEUTRONIUM_ACTIVE_GLOW) .extFacing() .glow() .build() }; @@ -128,11 +128,11 @@ public class MTENeutroniumCompressor extends MTEExtendedPowerMultiBlockBase<MTEN Textures.BlockIcons .getCasingTextureForId(GTUtility.getCasingTextureIndex(GregTechAPI.sBlockCasings10, 6)), TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR) + .addIcon(OVERLAY_MULTI_NEUTRONIUM) .extFacing() .build(), TextureFactory.builder() - .addIcon(OVERLAY_FRONT_MULTI_COMPRESSOR_GLOW) + .addIcon(OVERLAY_MULTI_NEUTRONIUM_GLOW) .extFacing() .glow() .build() }; 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); + } + +} diff --git a/src/main/java/gregtech/loaders/oreprocessing/ProcessingPlate.java b/src/main/java/gregtech/loaders/oreprocessing/ProcessingPlate.java index 9c1c4904db..619ff7a7ed 100644 --- a/src/main/java/gregtech/loaders/oreprocessing/ProcessingPlate.java +++ b/src/main/java/gregtech/loaders/oreprocessing/ProcessingPlate.java @@ -441,7 +441,7 @@ public class ProcessingPlate implements gregtech.api.interfaces.IOreRecipeRegist GTModHandler.removeRecipeByOutputDelayed(aStack); if (!aNoSmashing || aMaterial.contains(SubTag.STRETCHY)) { - int compression_tier = (aMaterial.processingMaterialTierEU >= TierEU.RECIPE_UIV + int compression_tier = (aMaterial.processingMaterialTierEU >= TierEU.RECIPE_UEV || aMaterial.contains(SubTag.BLACK_HOLE)) ? 2 : 1; GTValues.RA.stdBuilder() .itemInputs(GTOreDictUnificator.get(OrePrefixes.plate, aMaterial, 64)) diff --git a/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java b/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java index 0072a8148c..c3bf4d5031 100644 --- a/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java +++ b/src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java @@ -53,6 +53,7 @@ import gregtech.api.util.GTLog; import gregtech.api.util.GTModHandler; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTUtility; +import gregtech.common.blocks.BlockBlackholeRenderer; import gregtech.common.blocks.BlockCasings1; import gregtech.common.blocks.BlockCasings10; import gregtech.common.blocks.BlockCasings11; @@ -91,6 +92,7 @@ import gregtech.common.items.MetaGeneratedItem03; import gregtech.common.items.MetaGeneratedItem98; import gregtech.common.items.MetaGeneratedItem99; import gregtech.common.items.MetaGeneratedTool01; +import gregtech.common.tileentities.render.TileEntityBlackhole; import gregtech.common.tileentities.render.TileEntityDrone; import gregtech.common.tileentities.render.TileEntityLaser; import gregtech.common.tileentities.render.TileEntityWormhole; @@ -558,6 +560,7 @@ public class LoaderGTBlockFluid implements Runnable { GregTechAPI.sBlockTintedGlass = new BlockTintedIndustrialGlass(); GregTechAPI.sLaserRender = new BlockLaser(); GregTechAPI.sWormholeRender = new BlockWormholeRender(); + GregTechAPI.sBlackholeRender = new BlockBlackholeRenderer(); // meta ID order, DO NOT CHANGE ORDER @@ -691,6 +694,9 @@ public class LoaderGTBlockFluid implements Runnable { GTLog.out.println("GTMod: Registering the WormholeRender."); GameRegistry.registerTileEntity(TileEntityWormhole.class, "WormholeRender"); + GTLog.out.println("GTMod: Registering the BlackholeRender."); + GameRegistry.registerTileEntity(TileEntityBlackhole.class, "BlackholeRender"); + GTLog.out.println("GTMod: Registering the BaseMetaPipeEntity."); GameRegistry.registerTileEntity(BaseMetaPipeEntity.class, "BaseMetaPipeEntity"); FMLInterModComms.sendMessage(AppliedEnergistics2.ID, "whitelist-spatial", BaseMetaPipeEntity.class.getName()); diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java index 6db6175896..a4ecc3f3e8 100644 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamCompressor.java @@ -48,6 +48,7 @@ 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.util.GTRecipe; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; @@ -246,6 +247,8 @@ public class MTESteamCompressor extends MTESteamMultiBase<MTESteamCompressor> im if (availableVoltage < recipe.mEUt) { return CheckRecipeResultRegistry.insufficientPower(recipe.mEUt); } + if (recipe.getMetadataOrDefault(CompressionTierKey.INSTANCE, 0) > 0) + return CheckRecipeResultRegistry.NO_RECIPE; return CheckRecipeResultRegistry.SUCCESSFUL; } |