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/gregtech/common/tileentities | |
| 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/gregtech/common/tileentities')
6 files changed, 401 insertions, 132 deletions
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); + } + +} |
