diff options
Diffstat (limited to 'src/main/java/tectech/thing')
109 files changed, 37326 insertions, 0 deletions
diff --git a/src/main/java/tectech/thing/CustomItemList.java b/src/main/java/tectech/thing/CustomItemList.java new file mode 100644 index 0000000000..2c4b4c895b --- /dev/null +++ b/src/main/java/tectech/thing/CustomItemList.java @@ -0,0 +1,629 @@ +package tectech.thing; + +import static gregtech.api.enums.GTValues.W; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + +import gregtech.api.interfaces.IItemContainer; +import gregtech.api.util.GTModHandler; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.GTUtility; + +public enum CustomItemList implements IItemContainer { + + Casing_UEV, + Casing_UIV, + Casing_UMV, + Casing_UXV, + Casing_MAXV, + Hull_UEV, + Hull_UIV, + Hull_UMV, + Hull_UXV, + Hull_MAXV, + Transformer_UEV_UHV, + Transformer_UIV_UEV, + Transformer_UMV_UIV, + Transformer_UXV_UMV, + Transformer_MAXV_UXV, + WetTransformer_LV_ULV, + WetTransformer_MV_LV, + WetTransformer_HV_MV, + WetTransformer_EV_HV, + WetTransformer_IV_EV, + WetTransformer_LuV_IV, + WetTransformer_ZPM_LuV, + WetTransformer_UV_ZPM, + WetTransformer_UHV_UV, + WetTransformer_UEV_UHV, + WetTransformer_UIV_UEV, + WetTransformer_UMV_UIV, + WetTransformer_UXV_UMV, + WetTransformer_MAXV_UXV, + + Transformer_HA_UEV_UHV, + Transformer_HA_UIV_UEV, + Transformer_HA_UMV_UIV, + Transformer_HA_UXV_UMV, + Transformer_HA_MAXV_UXV, + + hatch_CreativeMaintenance, + hatch_CreativeData, + hatch_CreativeUncertainty, + Machine_OwnerDetector, + Machine_BuckConverter_IV, + Machine_BuckConverter_LuV, + Machine_BuckConverter_ZPM, + Machine_BuckConverter_UV, + Machine_BuckConverter_UHV, + Machine_BuckConverter_UEV, + Machine_BuckConverter_UIV, + Machine_BuckConverter_UMV, + Machine_BuckConverter_UXV, + Machine_DebugWriter, + Machine_DebugGenny, + UnusedStuff, + Machine_DebugPollutor, + DATApipe, + LASERpipe, + rack_Hatch, + holder_Hatch, + capacitor_Hatch, + + eM_dynamoMulti4_EV, + eM_dynamoMulti16_EV, + eM_dynamoMulti64_EV, + eM_dynamoMulti4_IV, + eM_dynamoMulti16_IV, + eM_dynamoMulti64_IV, + eM_dynamoMulti4_LuV, + eM_dynamoMulti16_LuV, + eM_dynamoMulti64_LuV, + eM_dynamoMulti4_ZPM, + eM_dynamoMulti16_ZPM, + eM_dynamoMulti64_ZPM, + eM_dynamoMulti4_UV, + eM_dynamoMulti16_UV, + eM_dynamoMulti64_UV, + eM_dynamoMulti4_UHV, + eM_dynamoMulti16_UHV, + eM_dynamoMulti64_UHV, + eM_dynamoMulti4_UEV, + eM_dynamoMulti16_UEV, + eM_dynamoMulti64_UEV, + eM_dynamoMulti4_UIV, + eM_dynamoMulti16_UIV, + eM_dynamoMulti64_UIV, + eM_dynamoMulti4_UMV, + eM_dynamoMulti16_UMV, + eM_dynamoMulti64_UMV, + eM_dynamoMulti4_UXV, + eM_dynamoMulti16_UXV, + eM_dynamoMulti64_UXV, + eM_dynamoTunnel1_IV, + eM_dynamoTunnel2_IV, + eM_dynamoTunnel3_IV, + eM_dynamoTunnel4_IV, + eM_dynamoTunnel5_IV, + eM_dynamoTunnel6_IV, + eM_dynamoTunnel7_IV, + eM_dynamoTunnel1_LuV, + eM_dynamoTunnel2_LuV, + eM_dynamoTunnel3_LuV, + eM_dynamoTunnel4_LuV, + eM_dynamoTunnel5_LuV, + eM_dynamoTunnel6_LuV, + eM_dynamoTunnel7_LuV, + eM_dynamoTunnel1_ZPM, + eM_dynamoTunnel2_ZPM, + eM_dynamoTunnel3_ZPM, + eM_dynamoTunnel4_ZPM, + eM_dynamoTunnel5_ZPM, + eM_dynamoTunnel6_ZPM, + eM_dynamoTunnel7_ZPM, + eM_dynamoTunnel1_UV, + eM_dynamoTunnel2_UV, + eM_dynamoTunnel3_UV, + eM_dynamoTunnel4_UV, + eM_dynamoTunnel5_UV, + eM_dynamoTunnel6_UV, + eM_dynamoTunnel7_UV, + eM_dynamoTunnel1_UHV, + eM_dynamoTunnel2_UHV, + eM_dynamoTunnel3_UHV, + eM_dynamoTunnel4_UHV, + eM_dynamoTunnel5_UHV, + eM_dynamoTunnel6_UHV, + eM_dynamoTunnel7_UHV, + eM_dynamoTunnel1_UEV, + eM_dynamoTunnel2_UEV, + eM_dynamoTunnel3_UEV, + eM_dynamoTunnel4_UEV, + eM_dynamoTunnel5_UEV, + eM_dynamoTunnel6_UEV, + eM_dynamoTunnel7_UEV, + eM_dynamoTunnel1_UIV, + eM_dynamoTunnel2_UIV, + eM_dynamoTunnel3_UIV, + eM_dynamoTunnel4_UIV, + eM_dynamoTunnel5_UIV, + eM_dynamoTunnel6_UIV, + eM_dynamoTunnel7_UIV, + eM_dynamoTunnel1_UMV, + eM_dynamoTunnel2_UMV, + eM_dynamoTunnel3_UMV, + eM_dynamoTunnel4_UMV, + eM_dynamoTunnel5_UMV, + eM_dynamoTunnel6_UMV, + eM_dynamoTunnel7_UMV, + eM_dynamoTunnel8_UMV, + eM_dynamoTunnel1_UXV, + eM_dynamoTunnel2_UXV, + eM_dynamoTunnel3_UXV, + eM_dynamoTunnel4_UXV, + eM_dynamoTunnel5_UXV, + eM_dynamoTunnel6_UXV, + eM_dynamoTunnel7_UXV, + eM_dynamoTunnel8_UXV, + eM_dynamoTunnel9_UXV, + eM_dynamoTunnel9001, + + eM_energyMulti4_EV, + eM_energyMulti16_EV, + eM_energyMulti64_EV, + eM_energyMulti4_IV, + eM_energyMulti16_IV, + eM_energyMulti64_IV, + eM_energyMulti4_LuV, + eM_energyMulti16_LuV, + eM_energyMulti64_LuV, + eM_energyMulti4_ZPM, + eM_energyMulti16_ZPM, + eM_energyMulti64_ZPM, + eM_energyMulti4_UV, + eM_energyMulti16_UV, + eM_energyMulti64_UV, + eM_energyMulti4_UHV, + eM_energyMulti16_UHV, + eM_energyMulti64_UHV, + eM_energyMulti4_UEV, + eM_energyMulti16_UEV, + eM_energyMulti64_UEV, + eM_energyMulti4_UIV, + eM_energyMulti16_UIV, + eM_energyMulti64_UIV, + eM_energyMulti4_UMV, + eM_energyMulti16_UMV, + eM_energyMulti64_UMV, + eM_energyMulti4_UXV, + eM_energyMulti16_UXV, + eM_energyMulti64_UXV, + eM_energyWirelessMulti4_EV, + eM_energyWirelessMulti16_EV, + eM_energyWirelessMulti64_EV, + eM_energyWirelessMulti4_IV, + eM_energyWirelessMulti16_IV, + eM_energyWirelessMulti64_IV, + eM_energyWirelessMulti4_LuV, + eM_energyWirelessMulti16_LuV, + eM_energyWirelessMulti64_LuV, + eM_energyWirelessMulti4_ZPM, + eM_energyWirelessMulti16_ZPM, + eM_energyWirelessMulti64_ZPM, + eM_energyWirelessMulti4_UV, + eM_energyWirelessMulti16_UV, + eM_energyWirelessMulti64_UV, + eM_energyWirelessMulti4_UHV, + eM_energyWirelessMulti16_UHV, + eM_energyWirelessMulti64_UHV, + eM_energyWirelessMulti4_UEV, + eM_energyWirelessMulti16_UEV, + eM_energyWirelessMulti64_UEV, + eM_energyWirelessMulti4_UIV, + eM_energyWirelessMulti16_UIV, + eM_energyWirelessMulti64_UIV, + eM_energyWirelessMulti4_UMV, + eM_energyWirelessMulti16_UMV, + eM_energyWirelessMulti64_UMV, + eM_energyWirelessMulti4_UXV, + eM_energyWirelessMulti16_UXV, + eM_energyWirelessMulti64_UXV, + eM_energyWirelessMulti4_MAX, + eM_energyWirelessMulti16_MAX, + eM_energyWirelessMulti64_MAX, + eM_energyTunnel1_IV, + eM_energyTunnel2_IV, + eM_energyTunnel3_IV, + eM_energyTunnel4_IV, + eM_energyTunnel5_IV, + eM_energyTunnel6_IV, + eM_energyTunnel7_IV, + eM_energyTunnel1_LuV, + eM_energyTunnel2_LuV, + eM_energyTunnel3_LuV, + eM_energyTunnel4_LuV, + eM_energyTunnel5_LuV, + eM_energyTunnel6_LuV, + eM_energyTunnel7_LuV, + eM_energyTunnel1_ZPM, + eM_energyTunnel2_ZPM, + eM_energyTunnel3_ZPM, + eM_energyTunnel4_ZPM, + eM_energyTunnel5_ZPM, + eM_energyTunnel6_ZPM, + eM_energyTunnel7_ZPM, + eM_energyTunnel1_UV, + eM_energyTunnel2_UV, + eM_energyTunnel3_UV, + eM_energyTunnel4_UV, + eM_energyTunnel5_UV, + eM_energyTunnel6_UV, + eM_energyTunnel7_UV, + eM_energyTunnel1_UHV, + eM_energyTunnel2_UHV, + eM_energyTunnel3_UHV, + eM_energyTunnel4_UHV, + eM_energyTunnel5_UHV, + eM_energyTunnel6_UHV, + eM_energyTunnel7_UHV, + eM_energyTunnel1_UEV, + eM_energyTunnel2_UEV, + eM_energyTunnel3_UEV, + eM_energyTunnel4_UEV, + eM_energyTunnel5_UEV, + eM_energyTunnel6_UEV, + eM_energyTunnel7_UEV, + eM_energyTunnel1_UIV, + eM_energyTunnel2_UIV, + eM_energyTunnel3_UIV, + eM_energyTunnel4_UIV, + eM_energyTunnel5_UIV, + eM_energyTunnel6_UIV, + eM_energyTunnel7_UIV, + eM_energyTunnel1_UMV, + eM_energyTunnel2_UMV, + eM_energyTunnel3_UMV, + eM_energyTunnel4_UMV, + eM_energyTunnel5_UMV, + eM_energyTunnel6_UMV, + eM_energyTunnel7_UMV, + eM_energyTunnel8_UMV, + eM_energyTunnel1_UXV, + eM_energyTunnel2_UXV, + eM_energyTunnel3_UXV, + eM_energyTunnel4_UXV, + eM_energyTunnel5_UXV, + eM_energyTunnel6_UXV, + eM_energyTunnel7_UXV, + eM_energyTunnel8_UXV, + eM_energyTunnel9_UXV, + eM_energyTunnel9001, + eM_energyWirelessTunnel1_UXV, + eM_energyWirelessTunnel2_UXV, + eM_energyWirelessTunnel3_UXV, + eM_energyWirelessTunnel4_UXV, + eM_energyWirelessTunnel5_UXV, + eM_energyWirelessTunnel6_UXV, + eM_energyWirelessTunnel7_UXV, + eM_energyWirelessTunnel8_UXV, + eM_energyWirelessTunnel9_UXV, + + Parametrizer_Hatch, + ParametrizerX_Hatch, + ParametrizerTXT_Hatch, + Uncertainty_Hatch, + UncertaintyX_Hatch, + dataIn_Hatch, + dataOut_Hatch, + dataOut_Wireless_Hatch, + dataIn_Wireless_Hatch, + dataInAss_Wireless_Hatch, + dataOutAss_Wireless_Hatch, + dataInAss_Hatch, + dataOutAss_Hatch, + eM_Containment, + eM_Containment_Field, + eM_Containment_Advanced, + eM_Coil, + eM_Teleportation, + eM_Dimensional, + eM_Ultimate_Containment, + eM_Ultimate_Containment_Advanced, + eM_Ultimate_Containment_Field, + eM_Spacetime, + eM_Computer_Casing, + eM_Computer_Bus, + eM_Computer_Vent, + eM_Hollow, + eM_Power, + debugBlock, + + tM_TeslaBase, + tM_TeslaToroid, + EOH_Reinforced_Temporal_Casing, + EOH_Reinforced_Spatial_Casing, + EOH_Infinite_Energy_Casing, + tM_TeslaSecondary, + tM_TeslaPrimary_0, + tM_TeslaPrimary_1, + tM_TeslaPrimary_2, + tM_TeslaPrimary_3, + tM_TeslaPrimary_4, + tM_TeslaPrimary_5, + tM_TeslaPrimary_6, + + Machine_Multi_Microwave, + Machine_Multi_TeslaCoil, + Machine_Multi_Transformer, + Machine_Multi_Computer, + Machine_Multi_Switch, + Machine_Multi_Research, + Machine_Multi_DataBank, + Machine_Multi_Infuser, + Machine_Multi_Decay, + Machine_Multi_Annihilation, + Machine_Multi_EyeOfHarmony, + Machine_Multi_ForgeOfGods, + Machine_Multi_SmeltingModule, + Machine_Multi_MoltenModule, + Machine_Multi_PlasmaModule, + Machine_Multi_QuarkGluonPlasmaModule, + + hint_0, + hint_1, + hint_2, + hint_3, + hint_4, + hint_5, + hint_6, + hint_7, + hint_8, + hint_9, + hint_10, + hint_11, + hint_general, + hint_air, + hint_noAir, + hint_error, + + scanContainer, + parametrizerMemory, + teslaCapacitor, + teslaCover, + teslaComponent, + teslaStaff, + enderLinkFluidCover, + powerPassUpgradeCover, + + Machine_TeslaCoil_1by1_LV, + Machine_TeslaCoil_1by1_MV, + Machine_TeslaCoil_1by1_HV, + Machine_TeslaCoil_1by1_EV, + Machine_TeslaCoil_1by1_IV, + Machine_TeslaCoil_2by2_LV, + Machine_TeslaCoil_2by2_MV, + Machine_TeslaCoil_2by2_HV, + Machine_TeslaCoil_2by2_EV, + Machine_TeslaCoil_2by2_IV, + Machine_TeslaCoil_3by3_LV, + Machine_TeslaCoil_3by3_MV, + Machine_TeslaCoil_3by3_HV, + Machine_TeslaCoil_3by3_EV, + Machine_TeslaCoil_3by3_IV, + Machine_TeslaCoil_4by4_LV, + Machine_TeslaCoil_4by4_MV, + Machine_TeslaCoil_4by4_HV, + Machine_TeslaCoil_4by4_EV, + Machine_TeslaCoil_4by4_IV, + DATApipeBlock, + LASERpipeBlock, + LASERpipeSmart, + + SpacetimeCompressionFieldGeneratorTier0, + SpacetimeCompressionFieldGeneratorTier1, + SpacetimeCompressionFieldGeneratorTier2, + SpacetimeCompressionFieldGeneratorTier3, + SpacetimeCompressionFieldGeneratorTier4, + SpacetimeCompressionFieldGeneratorTier5, + SpacetimeCompressionFieldGeneratorTier6, + SpacetimeCompressionFieldGeneratorTier7, + SpacetimeCompressionFieldGeneratorTier8, + + TimeAccelerationFieldGeneratorTier0, + TimeAccelerationFieldGeneratorTier1, + TimeAccelerationFieldGeneratorTier2, + TimeAccelerationFieldGeneratorTier3, + TimeAccelerationFieldGeneratorTier4, + TimeAccelerationFieldGeneratorTier5, + TimeAccelerationFieldGeneratorTier6, + TimeAccelerationFieldGeneratorTier7, + TimeAccelerationFieldGeneratorTier8, + + StabilisationFieldGeneratorTier0, + StabilisationFieldGeneratorTier1, + StabilisationFieldGeneratorTier2, + StabilisationFieldGeneratorTier3, + StabilisationFieldGeneratorTier4, + StabilisationFieldGeneratorTier5, + StabilisationFieldGeneratorTier6, + StabilisationFieldGeneratorTier7, + StabilisationFieldGeneratorTier8, + + Godforge_GravitationalLens, + Godforge_SingularityShieldingCasing, + Godforge_GuidanceCasing, + Godforge_BoundlessStructureCasing, + Godforge_MagneticConfinementCasing, + Godforge_StellarEnergySiphonCasing, + Godforge_GravitonFlowModulatorTier1, + Godforge_GravitonFlowModulatorTier2, + Godforge_GravitonFlowModulatorTier3, + Godforge_HarmonicPhononTransmissionConduit, + + astralArrayFabricator; + + private ItemStack mStack; + private boolean mHasNotBeenSet = true; + + // public static Fluid sOilExtraHeavy, sOilHeavy, sOilMedium, sOilLight, sNaturalGas; + + @Override + public IItemContainer set(Item aItem) { + mHasNotBeenSet = false; + if (aItem == null) { + return this; + } + ItemStack aStack = new ItemStack(aItem, 1, 0); + mStack = GTUtility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer set(ItemStack aStack) { + mHasNotBeenSet = false; + mStack = GTUtility.copyAmount(1, aStack); + return this; + } + + @Override + public IItemContainer hidden() { + codechicken.nei.api.API.hideItem(get(1L)); + return this; + } + + @Override + public Item getItem() { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return null; + } + return mStack.getItem(); + } + + @Override + public Block getBlock() { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + return GTUtility.getBlockFromStack(new ItemStack(getItem())); + } + + @Override + public final boolean hasBeenSet() { + return !mHasNotBeenSet; + } + + @Override + public boolean isStackEqual(Object aStack) { + return isStackEqual(aStack, false, false); + } + + @Override + public boolean isStackEqual(Object aStack, boolean aWildcard, boolean aIgnoreNBT) { + if (GTUtility.isStackInvalid(aStack)) { + return false; + } + return GTUtility.areUnificationsEqual((ItemStack) aStack, aWildcard ? getWildcard(1) : get(1), aIgnoreNBT); + } + + @Override + public ItemStack get(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return GTUtility.copyAmount(aAmount, aReplacements); + } + return GTUtility.copyAmount(aAmount, GTOreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWildcard(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return GTUtility.copyAmount(aAmount, aReplacements); + } + return GTUtility.copyAmountAndMetaData(aAmount, W, GTOreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getUndamaged(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return GTUtility.copyAmount(aAmount, aReplacements); + } + return GTUtility.copyAmountAndMetaData(aAmount, 0, GTOreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getAlmostBroken(long aAmount, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return GTUtility.copyAmount(aAmount, aReplacements); + } + return GTUtility.copyAmountAndMetaData(aAmount, mStack.getMaxDamage() - 1, GTOreDictUnificator.get(mStack)); + } + + @Override + public ItemStack getWithName(long aAmount, String aDisplayName, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GTUtility.isStackInvalid(rStack)) { + return null; + } + rStack.setStackDisplayName(aDisplayName); + return GTUtility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithCharge(long aAmount, int aEnergy, Object... aReplacements) { + ItemStack rStack = get(1, aReplacements); + if (GTUtility.isStackInvalid(rStack)) { + return null; + } + GTModHandler.chargeElectricItem(rStack, aEnergy, Integer.MAX_VALUE, true, false); + return GTUtility.copyAmount(aAmount, rStack); + } + + @Override + public ItemStack getWithDamage(long aAmount, long aMetaValue, Object... aReplacements) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + if (GTUtility.isStackInvalid(mStack)) { + return GTUtility.copyAmount(aAmount, aReplacements); + } + return GTUtility.copyAmountAndMetaData(aAmount, aMetaValue, GTOreDictUnificator.get(mStack)); + } + + @Override + public IItemContainer registerOre(Object... aOreNames) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + for (Object tOreName : aOreNames) { + GTOreDictUnificator.registerOre(tOreName, get(1)); + } + return this; + } + + @Override + public IItemContainer registerWildcardAsOre(Object... aOreNames) { + if (mHasNotBeenSet) { + throw new IllegalAccessError("The Enum '" + name() + "' has not been set to an Item at this time!"); + } + for (Object tOreName : aOreNames) { + GTOreDictUnificator.registerOre(tOreName, getWildcard(1)); + } + return this; + } +} diff --git a/src/main/java/tectech/thing/block/BlockEOHRender.java b/src/main/java/tectech/thing/block/BlockEOHRender.java new file mode 100644 index 0000000000..db70a4a956 --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockEOHRender.java @@ -0,0 +1,78 @@ +package tectech.thing.block; + +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 tectech.TecTech; + +public class BlockEOHRender extends Block { + + public BlockEOHRender() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("Eye of Harmony Renderer"); + this.setLightLevel(100.0f); + registerOther(this); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @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 TileEntityEyeOfHarmony(); + } + + public static void registerOther(Block block) { + String name = block.getUnlocalizedName() + .substring( + block.getUnlocalizedName() + .indexOf(".") + 1); + GameRegistry.registerBlock(block, name.substring(name.indexOf(":") + 1)); + } + + @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 false; + } + +} diff --git a/src/main/java/tectech/thing/block/BlockForgeOfGods.java b/src/main/java/tectech/thing/block/BlockForgeOfGods.java new file mode 100644 index 0000000000..a53299f229 --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockForgeOfGods.java @@ -0,0 +1,71 @@ +package tectech.thing.block; + +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 tectech.TecTech; + +public class BlockForgeOfGods extends Block { + + public BlockForgeOfGods() { + super(Material.iron); + this.setResistance(20f); + this.setHardness(-1.0f); + this.setCreativeTab(TecTech.creativeTabTecTech); + this.setBlockName("Forge of the Gods Renderer"); + this.setLightLevel(100.0f); + if (TecTech.configTecTech.ENABLE_GOD_FORGE) { + registerOther(this); + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister iconRegister) { + blockIcon = iconRegister.registerIcon("gregtech:iconsets/TRANSPARENT"); + } + + @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 TileEntityForgeOfGods(); + } + + public static void registerOther(Block block) { + GameRegistry.registerBlock(block, "ForgeOfGodsRenderBlock"); + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<>(); + } + +} diff --git a/src/main/java/tectech/thing/block/BlockGodforgeGlass.java b/src/main/java/tectech/thing/block/BlockGodforgeGlass.java new file mode 100644 index 0000000000..e29e815212 --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockGodforgeGlass.java @@ -0,0 +1,106 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +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 eu.usrv.yamcore.blocks.BlockBase; +import gregtech.api.GregTechAPI; +import tectech.Reference; +import tectech.TecTech; + +public class BlockGodforgeGlass extends BlockBase { + + public static IIcon Icon; + public static int renderID; + public static BlockGodforgeGlass INSTANCE; + + public BlockGodforgeGlass() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("spatiallyTranscendentGravitationalLens"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeGlass); + setBlockTextureName(Reference.MODID + ":blockSpatiallyTranscendentGravitationalLens"); + setCreativeTab(TecTech.creativeTabTecTech); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + return block != this; + } + + @Override + public int getRenderType() { + return renderID; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + Icon = blockIcon; + } + + public static void run() { + INSTANCE = new BlockGodforgeGlass(); + GameRegistry.registerBlock(INSTANCE, ItemGodForgeGlass.class, INSTANCE.getUnlocalizedName()); + GregTechAPI.registerMachineBlock(INSTANCE, -1); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (GregTechAPI.isMachineBlock(this, aMeta)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/tectech/thing/block/BlockQuantumGlass.java b/src/main/java/tectech/thing/block/BlockQuantumGlass.java new file mode 100644 index 0000000000..fa0b6c4681 --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockQuantumGlass.java @@ -0,0 +1,110 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +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 eu.usrv.yamcore.blocks.BlockBase; +import gregtech.api.GregTechAPI; +import tectech.Reference; +import tectech.TecTech; + +/** + * Created by danie_000 on 17.12.2016. + */ +public final class BlockQuantumGlass extends BlockBase { + + public static IIcon stuff; + public static int renderID; + public static BlockQuantumGlass INSTANCE; + + public BlockQuantumGlass() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("quantumGlass"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeMetal); + setBlockTextureName(Reference.MODID + ":blockQuantumGlass"); + setCreativeTab(TecTech.creativeTabTecTech); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return true; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + Block block = worldIn.getBlock(x, y, z); + return block != this; // && super.shouldSideBeRendered(worldIn, x, y, z, + // side); + } + + @Override + public int getRenderType() { + return renderID; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + public static void run() { + INSTANCE = new BlockQuantumGlass(); + GameRegistry.registerBlock(INSTANCE, ItemQuantumGlass.class, INSTANCE.getUnlocalizedName()); + GregTechAPI.registerMachineBlock(INSTANCE, -1); + } + + @Override + public void breakBlock(World aWorld, int aX, int aY, int aZ, Block aBlock, int aMeta) { + if (GregTechAPI.isMachineBlock(this, aMeta)) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } + + @Override + public void onBlockAdded(World aWorld, int aX, int aY, int aZ) { + if (GregTechAPI.isMachineBlock(this, aWorld.getBlockMetadata(aX, aY, aZ))) { + GregTechAPI.causeMachineUpdate(aWorld, aX, aY, aZ); + } + } +} diff --git a/src/main/java/tectech/thing/block/BlockQuantumStuff.java b/src/main/java/tectech/thing/block/BlockQuantumStuff.java new file mode 100644 index 0000000000..bdbdb35510 --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockQuantumStuff.java @@ -0,0 +1,103 @@ +package tectech.thing.block; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +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 eu.usrv.yamcore.blocks.BlockBase; +import tectech.Reference; + +/** + * Created by danie_000 on 17.12.2016. + */ +public final class BlockQuantumStuff extends BlockBase { + + public static IIcon stuff; + public static int renderID; + public static BlockQuantumStuff INSTANCE; + + public BlockQuantumStuff() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("quantumStuff"); + setHarvestLevel("wrench", 0); + setHardness(500); + setResistance(1); + setLightOpacity(0); + setBlockTextureName(Reference.MODID + ":blockQuantumStuff"); + } + + @Override + public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean getCanBlockGrass() { + return false; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRenderBlockPass() { + return 1; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldSideBeRendered(IBlockAccess worldIn, int x, int y, int z, int side) { + return false; + } + + @Override + public int getRenderType() { + return renderID; + } + + public static void run() { + INSTANCE = new BlockQuantumStuff(); + GameRegistry.registerBlock(INSTANCE, INSTANCE.getUnlocalizedName()); + } + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) { + return new ArrayList<>(); + } + + @Override + public Item getItemDropped(int meta, Random random, int fortune) { + return null; + } +} diff --git a/src/main/java/tectech/thing/block/BlockReactorSim.java b/src/main/java/tectech/thing/block/BlockReactorSim.java new file mode 100644 index 0000000000..745db9084f --- /dev/null +++ b/src/main/java/tectech/thing/block/BlockReactorSim.java @@ -0,0 +1,94 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.block.ITileEntityProvider; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; +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 ic2.core.IC2; +import ic2.core.IHasGui; +import ic2.core.block.TileEntityBlock; +import tectech.Reference; +import tectech.thing.tileEntity.TileEntityReactorSim; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class BlockReactorSim extends Block implements ITileEntityProvider { + + public static BlockReactorSim INSTANCE; + public static IIcon stuff; + + public BlockReactorSim() { + super(Material.iron); + setBlockBounds(0, 0, 0, 1, 1, 1); + setBlockName("reactorSim"); + setHarvestLevel("wrench", 3); + setHardness(50); + setResistance(30); + setLightOpacity(0); + setStepSound(Block.soundTypeMetal); + setBlockTextureName(Reference.MODID + ":blockReactorSimulator"); + } + + @Override + public boolean isOpaqueCube() { + return true; + } + + @Override + public boolean getCanBlockGrass() { + return true; + } + + @Override + public boolean canBeReplacedByLeaves(IBlockAccess world, int x, int y, int z) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister reg) { + super.registerBlockIcons(reg); + stuff = blockIcon; + } + + public static void run() { + INSTANCE = new BlockReactorSim(); + GameRegistry.registerBlock(INSTANCE, ItemReactorSim.class, INSTANCE.getUnlocalizedName()); + GameRegistry.registerTileEntity(TileEntityReactorSim.class, Reference.MODID + "_reactorSim"); + } + + @Override + public TileEntity createNewTileEntity(World worldIn, int meta) { + return new TileEntityReactorSim(); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float a, + float b, float c) { + if (entityPlayer.isSneaking()) { + return false; + } else { + TileEntity te = world.getTileEntity(x, y, z); + return te instanceof IHasGui + && (!IC2.platform.isSimulating() || IC2.platform.launchGui(entityPlayer, (IHasGui) te)); + } + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block srcBlock) { + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof TileEntityBlock) { + ((TileEntityBlock) te).onNeighborUpdate(srcBlock); + } + } +} diff --git a/src/main/java/tectech/thing/block/ItemGodForgeGlass.java b/src/main/java/tectech/thing/block/ItemGodForgeGlass.java new file mode 100644 index 0000000000..c4c355cc19 --- /dev/null +++ b/src/main/java/tectech/thing/block/ItemGodForgeGlass.java @@ -0,0 +1,31 @@ +package tectech.thing.block; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import tectech.util.CommonValues; + +public class ItemGodForgeGlass extends ItemBlock { + + public static ItemGodForgeGlass INSTANCE; + + public ItemGodForgeGlass(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(CommonValues.GODFORGE_MARK); + aList.add(translateToLocal("tile.godforgeGlass.desc.0")); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("tile.godforgeGlass.desc.1")); + } +} diff --git a/src/main/java/tectech/thing/block/ItemQuantumGlass.java b/src/main/java/tectech/thing/block/ItemQuantumGlass.java new file mode 100644 index 0000000000..441c7363e4 --- /dev/null +++ b/src/main/java/tectech/thing/block/ItemQuantumGlass.java @@ -0,0 +1,34 @@ +package tectech.thing.block; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import tectech.util.CommonValues; + +/** + * Created by Tec on 11.04.2017. + */ +public class ItemQuantumGlass extends ItemBlock { + + public static ItemQuantumGlass INSTANCE; + + public ItemQuantumGlass(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(CommonValues.TEC_MARK_EM); + aList.add(translateToLocal("tile.quantumGlass.desc.0")); // Dense yet transparent + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("tile.quantumGlass.desc.1")); // Glassy & Classy + } +} diff --git a/src/main/java/tectech/thing/block/ItemReactorSim.java b/src/main/java/tectech/thing/block/ItemReactorSim.java new file mode 100644 index 0000000000..bd4bcffde2 --- /dev/null +++ b/src/main/java/tectech/thing/block/ItemReactorSim.java @@ -0,0 +1,37 @@ +package tectech.thing.block; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemBlock; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class ItemReactorSim extends ItemBlock { + + public static ItemQuantumGlass INSTANCE; + + public ItemReactorSim(Block block) { + super(block); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + aList.add(CommonValues.TEC_MARK_GENERAL); + aList.add(translateToLocal("tile.reactorSim.desc.0")); // Fission Reaction Uncertainty Resolver 9001 + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("tile.reactorSim.desc.1")); // Explodes, + // but + // not + // as + // much... + } +} diff --git a/src/main/java/tectech/thing/block/RenderForgeOfGods.java b/src/main/java/tectech/thing/block/RenderForgeOfGods.java new file mode 100644 index 0000000000..976dd6da8e --- /dev/null +++ b/src/main/java/tectech/thing/block/RenderForgeOfGods.java @@ -0,0 +1,65 @@ +package tectech.thing.block; + +import static tectech.Reference.MODID; +import static tectech.rendering.EOH.EOHRenderingUtils.renderStarLayer; +import static tectech.rendering.EOH.EOHTileEntitySR.STAR_LAYER_0; +import static tectech.rendering.EOH.EOHTileEntitySR.STAR_LAYER_1; +import static tectech.rendering.EOH.EOHTileEntitySR.STAR_LAYER_2; + +import java.awt.Color; + +import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.model.AdvancedModelLoader; +import net.minecraftforge.client.model.IModelCustom; + +import org.lwjgl.opengl.GL11; + +public class RenderForgeOfGods extends TileEntitySpecialRenderer { + + public static IModelCustom starModel; + + public RenderForgeOfGods() { + starModel = AdvancedModelLoader.loadModel(new ResourceLocation(MODID, "models/Star.obj")); + } + + @Override + public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float timeSinceLastTick) { + if (!(tile instanceof TileEntityForgeOfGods)) return; + + { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + + // Innermost layer should be opaque + enableOpaqueColorInversion(); + renderStarLayer(0, STAR_LAYER_0, new Color(1.0f, 0.4f, 0.05f, 1.0f), 1.0f, 25); + disableOpaqueColorInversion(); + + enablePseudoTransparentColorInversion(); + renderStarLayer(1, STAR_LAYER_1, new Color(1.0f, 0.4f, 0.05f, 1.0f), 0.4f, 25); + renderStarLayer(2, STAR_LAYER_2, new Color(1.0f, 0.4f, 0.05f, 1.0f), 0.2f, 25); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } + + public static void enablePseudoTransparentColorInversion() { + GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); + GL11.glLogicOp(GL11.GL_OR_INVERTED); + } + + public static void enableOpaqueColorInversion() { + GL11.glEnable(GL11.GL_COLOR_LOGIC_OP); + GL11.glLogicOp(GL11.GL_COPY_INVERTED); + } + + public static void disableOpaqueColorInversion() { + GL11.glDisable(GL11.GL_COLOR_LOGIC_OP); + } +} diff --git a/src/main/java/tectech/thing/block/RenderGodforgeGlass.java b/src/main/java/tectech/thing/block/RenderGodforgeGlass.java new file mode 100644 index 0000000000..12c0327f65 --- /dev/null +++ b/src/main/java/tectech/thing/block/RenderGodforgeGlass.java @@ -0,0 +1,122 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +public class RenderGodforgeGlass implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = BlockGodforgeGlass.Icon; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + + renderer.renderStandardBlock(block, x, y, z); + Tessellator tes = Tessellator.instance; + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + tes.setColorOpaque_F(0F, 1F, 1F); + IIcon side = BlockGodforgeGlass.Icon; + + // South + if (world.getBlock(x, y, z + 1) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x, y, z + 0.999, side.getMinU(), side.getMaxV()); // 0.999 instead of 1 for fighting + // (textures overlapping) + tes.addVertexWithUV(x, y + 1, z + 0.999, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.999, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y, z + 0.999, side.getMaxU(), side.getMaxV()); + } + // East + if (world.getBlock(x + 1, y, z) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x + 0.999, y, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.999, y + 1, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y + 1, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y, z, side.getMaxU(), side.getMaxV()); + } + // North + if (world.getBlock(x, y, z - 1) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x + 1, y, z + 0.001, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.001, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x, y + 1, z + 0.001, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x, y, z + 0.001, side.getMaxU(), side.getMaxV()); + } + // West + if (world.getBlock(x - 1, y, z) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x + 0.001, y, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.001, y + 1, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y + 1, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y, z + 1, side.getMaxU(), side.getMaxV()); + } + // Top + if (world.getBlock(x, y + 1, z) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x, y + 0.999, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.999, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z + 1, side.getMaxU(), side.getMaxV()); + } + // Bottom + if (world.getBlock(x, y - 1, z) + .getClass() != BlockGodforgeGlass.class) { + tes.addVertexWithUV(x, y + 0.001, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.001, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z, side.getMaxU(), side.getMaxV()); + } + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return BlockGodforgeGlass.renderID; + } +} diff --git a/src/main/java/tectech/thing/block/RenderQuantumGlass.java b/src/main/java/tectech/thing/block/RenderQuantumGlass.java new file mode 100644 index 0000000000..43b212d44a --- /dev/null +++ b/src/main/java/tectech/thing/block/RenderQuantumGlass.java @@ -0,0 +1,129 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; + +/** + * Created by danie_000 on 19.12.2016. + */ +public final class RenderQuantumGlass implements ISimpleBlockRenderingHandler { + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + Tessellator tessellator = Tessellator.instance; + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = BlockQuantumGlass.stuff; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tessellator.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + + renderer.renderStandardBlock(block, x, y, z); + Tessellator tes = Tessellator.instance; + GL11.glPushMatrix(); + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + tes.setColorOpaque_F(0F, 1F, 1F); + IIcon side = BlockQuantumGlass.stuff; + GL11.glDisable(GL11.GL_CULL_FACE); + + // South + if (world.getBlock(x, y, z + 1) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x, y, z + 0.999, side.getMinU(), side.getMaxV()); // 0.999 instead of 1 for fighting + // (textures overlapping) + tes.addVertexWithUV(x, y + 1, z + 0.999, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.999, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y, z + 0.999, side.getMaxU(), side.getMaxV()); + } + // East + if (world.getBlock(x + 1, y, z) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x + 0.999, y, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.999, y + 1, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y + 1, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.999, y, z, side.getMaxU(), side.getMaxV()); + } + // North + if (world.getBlock(x, y, z - 1) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x + 1, y, z + 0.001, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 1, y + 1, z + 0.001, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x, y + 1, z + 0.001, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x, y, z + 0.001, side.getMaxU(), side.getMaxV()); + } + // West + if (world.getBlock(x - 1, y, z) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x + 0.001, y, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x + 0.001, y + 1, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y + 1, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 0.001, y, z + 1, side.getMaxU(), side.getMaxV()); + } + // Top + if (world.getBlock(x, y + 1, z) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x, y + 0.999, z + 1, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.999, z, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.999, z + 1, side.getMaxU(), side.getMaxV()); + } + // Bottom + if (world.getBlock(x, y - 1, z) + .getClass() != BlockQuantumGlass.class) { + tes.addVertexWithUV(x, y + 0.001, z, side.getMinU(), side.getMaxV()); + tes.addVertexWithUV(x, y + 0.001, z + 1, side.getMinU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z + 1, side.getMaxU(), side.getMinV()); + tes.addVertexWithUV(x + 1, y + 0.001, z, side.getMaxU(), side.getMaxV()); + } + GL11.glPopMatrix(); + GL11.glEnable(GL11.GL_CULL_FACE); + return true; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return BlockQuantumGlass.renderID; + } +} diff --git a/src/main/java/tectech/thing/block/RenderQuantumStuff.java b/src/main/java/tectech/thing/block/RenderQuantumStuff.java new file mode 100644 index 0000000000..98a0562b3e --- /dev/null +++ b/src/main/java/tectech/thing/block/RenderQuantumStuff.java @@ -0,0 +1,103 @@ +package tectech.thing.block; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraft.util.Vec3; +import net.minecraft.world.IBlockAccess; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import tectech.TecTech; + +/** + * Created by danie_000 on 19.12.2016. + */ +public final class RenderQuantumStuff implements ISimpleBlockRenderingHandler { + + private static final Tessellator tes = Tessellator.instance; + + @Override + public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glPushMatrix(); + // Get icons from custom register (useful for renderers and fluids) + IIcon side = BlockQuantumStuff.stuff; + tes.startDrawingQuads(); + tes.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + tes.startDrawingQuads(); + tes.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, side); + tes.draw(); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + GL11.glPopMatrix(); + } + + @Override + public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, + RenderBlocks renderer) { + // renderer.renderStandardBlock(block, x, y, z); + GL11.glPushMatrix(); + tes.setNormal(0F, 1F, 0F); + tes.setBrightness(15728880); + IIcon side = BlockQuantumStuff.stuff; + for (int i = 0; i < 6; i++) { + float f = 1 - TecTech.RANDOM.nextFloat() / 4f, g = f - TecTech.RANDOM.nextFloat() / 4f, + r = g - TecTech.RANDOM.nextFloat() / 4f - 0.25f; + tes.setColorOpaque_F(r, g, f); + float rotX = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI, + rotY = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI, + rotZ = TecTech.RANDOM.nextFloat() * 2 * (float) Math.PI; + tesAbuse(x, y, z, -1.425f, -1.425f, .1f, rotX, rotY, rotZ, side.getMinU(), side.getMaxV()); + tesAbuse(x, y, z, -1.425f, 1.425f, .1f, rotX, rotY, rotZ, side.getMinU(), side.getMinV()); + tesAbuse(x, y, z, 1.425f, 1.425f, .1f, rotX, rotY, rotZ, side.getMaxU(), side.getMinV()); + tesAbuse(x, y, z, 1.425f, -1.425f, .1f, rotX, rotY, rotZ, side.getMaxU(), side.getMaxV()); + + tesAbuse(x, y, z, 1.425f, -1.425f, -.1f, rotX, rotY, rotZ, side.getMaxU(), side.getMaxV()); + tesAbuse(x, y, z, 1.425f, 1.425f, -.1f, rotX, rotY, rotZ, side.getMaxU(), side.getMinV()); + tesAbuse(x, y, z, -1.425f, 1.425f, -.1f, rotX, rotY, rotZ, side.getMinU(), side.getMinV()); + tesAbuse(x, y, z, -1.425f, -1.425f, -.1f, rotX, rotY, rotZ, side.getMinU(), side.getMaxV()); + } + GL11.glPopMatrix(); + return true; + } + + private void tesAbuse(int x, int y, int z, float sx, float sy, float sz, float rotX, float rotY, float rotZ, + float sideU, float sideV) { + Vec3 pos = Vec3.createVectorHelper(sx, sy, sz); + pos.rotateAroundX(rotX); + pos.rotateAroundY(rotY); + pos.rotateAroundZ(rotZ); + tes.addVertexWithUV(pos.xCoord + x + .5f, pos.yCoord + y + .5f, pos.zCoord + z + .5f, sideU, sideV); + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } + + @Override + public int getRenderId() { + return BlockQuantumStuff.renderID; + } +} diff --git a/src/main/java/tectech/thing/block/TileEntityEyeOfHarmony.java b/src/main/java/tectech/thing/block/TileEntityEyeOfHarmony.java new file mode 100644 index 0000000000..4a46660d0d --- /dev/null +++ b/src/main/java/tectech/thing/block/TileEntityEyeOfHarmony.java @@ -0,0 +1,200 @@ +package tectech.thing.block; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Random; +import java.util.Set; +import java.util.stream.IntStream; + +import net.minecraft.block.Block; +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; +import net.minecraft.util.AxisAlignedBB; + +import gtneioreplugin.plugin.block.ModBlocks; + +public class TileEntityEyeOfHarmony extends TileEntity { + + private static final double EOH_STAR_FIELD_RADIUS = 13; + + // Prevent culling when block is out of frame so model can remain active. + @Override + public AxisAlignedBB getRenderBoundingBox() { + + // Assuming your block is at (x, y, z) + double x = this.xCoord; + double y = this.yCoord; + double z = this.zCoord; + + // Create a bounding box that extends 'size' blocks in all directions from the block. + return AxisAlignedBB.getBoundingBox( + x - EOH_STAR_FIELD_RADIUS, + y - EOH_STAR_FIELD_RADIUS, + z - EOH_STAR_FIELD_RADIUS, + x + EOH_STAR_FIELD_RADIUS + 1, + y + EOH_STAR_FIELD_RADIUS + 1, + z + EOH_STAR_FIELD_RADIUS + 1); + } + + public void setSize(float size) { + this.size = size; + } + + public void setRotationSpeed(float rotationSpeed) { + this.rotationSpeed = rotationSpeed; + } + + private float size = 10; + private float rotationSpeed = 10; + + // Fun fact, these methods were entirely written by ChatGPT3... Take that as you will. + public static <T> ArrayList<T> selectNRandomElements(Collection<T> inputList, long n) { + ArrayList<T> randomElements = new ArrayList<>((int) n); + ArrayList<T> inputArray = new ArrayList<>(inputList); + Random rand = new Random(); + IntStream.range(0, (int) n) + .forEach(i -> { + int randomIndex = rand.nextInt(inputArray.size()); + randomElements.add(inputArray.get(randomIndex)); + inputArray.remove(randomIndex); + }); + return randomElements; + } + + public static float generateRandomFloat(float a, float b) { + Random rand = new Random(); + return rand.nextFloat() * (b - a) + a; + } + + public long getTier() { + return tier; + } + + public void setTier(long tier) { + this.tier = tier; + } + + private long tier = 9; + + public float getSize() { + return size; + } + + public float getRotationSpeed() { + return rotationSpeed; + } + + @Override + public void updateEntity() { + angle += 10.0f; + } + + public static class OrbitingObject { + + public OrbitingObject(Block block, float distance, float rotationSpeed, float orbitSpeed, float xAngle, + float zAngle, float scale) { + this.block = block; + this.distance = distance; + this.rotationSpeed = rotationSpeed; + this.orbitSpeed = orbitSpeed; + this.xAngle = xAngle; + this.zAngle = zAngle; + this.scale = scale; + } + + public final Block block; + public final float distance; + public final float rotationSpeed; + public final float orbitSpeed; + public final float xAngle; + public final float zAngle; + public final float scale; + } + + public ArrayList<OrbitingObject> getOrbitingObjects() { + return orbitingObjects; + } + + private final ArrayList<OrbitingObject> orbitingObjects = new ArrayList<>(); + private static final Set<String> BLACKLISTED_BLOCKS = Collections + .unmodifiableSet(new HashSet<>(Arrays.asList("Tf", "Ow", "ED", "EA", "VA"))); + // Map of strings to blocks + private static final Map<String, Block> BLOCKS = new HashMap<>(); + + static { + // Initialize the map of blocks + ModBlocks.blocks.forEach((dimString, dimBlock) -> { + if (!BLACKLISTED_BLOCKS.contains(dimString)) { + BLOCKS.put(dimString, dimBlock); + } + }); + } + + private static final float MAX_ANGLE = 30; + + // This must be set last. + public void generateImportantInfo() { + + int index = 0; + for (Block block : selectNRandomElements(BLOCKS.values(), tier + 1)) { + + float xAngle = generateRandomFloat(-MAX_ANGLE, MAX_ANGLE); + float zAngle = generateRandomFloat(-MAX_ANGLE, MAX_ANGLE); + index += 1.0; + float distance = index + generateRandomFloat(-0.2f, 0.2f); + float scale = generateRandomFloat(0.2f, 0.9f); + float rotationSpeed = generateRandomFloat(0.5f, 1.5f); + float orbitSpeed = generateRandomFloat(0.5f, 1.5f); + orbitingObjects.add(new OrbitingObject(block, distance, rotationSpeed, orbitSpeed, xAngle, zAngle, scale)); + } + } + + // Used to track the rotation of the star/planets. + public float angle; + + private static final String EOH_NBT_TAG = "EOH:"; + private static final String ROTATION_SPEED_NBT_TAG = EOH_NBT_TAG + "rotationSpeed"; + private static final String SIZE_NBT_TAG = EOH_NBT_TAG + "size"; + private static final String TIER_NBT_TAG = EOH_NBT_TAG + "tier"; + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + // Save other stats. + compound.setFloat(ROTATION_SPEED_NBT_TAG, rotationSpeed); + compound.setFloat(SIZE_NBT_TAG, size); + compound.setLong(TIER_NBT_TAG, tier); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + // Load other stats. + rotationSpeed = compound.getFloat(ROTATION_SPEED_NBT_TAG); + size = compound.getFloat(SIZE_NBT_TAG); + tier = compound.getLong(TIER_NBT_TAG); + } + + @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()); + } + +} diff --git a/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java new file mode 100644 index 0000000000..7c671b8a31 --- /dev/null +++ b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java @@ -0,0 +1,82 @@ +package tectech.thing.block; + +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; +import net.minecraft.util.AxisAlignedBB; + +public class TileEntityForgeOfGods extends TileEntity { + + private float size = 10; + private float rotationSpeed = 10; + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public double getMaxRenderDistanceSquared() { + return 25600; + } + + public void setRenderSize(float size) { + this.size = size; + } + + public void setRenderRotationSpeed(float rotationSpeed) { + this.rotationSpeed = rotationSpeed; + } + + public float getRenderSize() { + return size; + } + + public float getRenderRotationSpeed() { + return rotationSpeed; + } + + @Override + public void updateEntity() { + angle += 10.0f; + } + + // Used to track the rotation of the star + public float angle; + + private static final String FOG_NBT_TAG = "FOG:"; + private static final String ROTATION_SPEED_NBT_TAG = FOG_NBT_TAG + "renderRotationSpeed"; + private static final String SIZE_NBT_TAG = FOG_NBT_TAG + "renderSize"; + + @Override + public void writeToNBT(NBTTagCompound compound) { + super.writeToNBT(compound); + + // Save stats + compound.setFloat(ROTATION_SPEED_NBT_TAG, rotationSpeed); + compound.setFloat(SIZE_NBT_TAG, size); + } + + @Override + public void readFromNBT(NBTTagCompound compound) { + super.readFromNBT(compound); + + // Load stats + rotationSpeed = compound.getFloat(ROTATION_SPEED_NBT_TAG); + size = compound.getFloat(SIZE_NBT_TAG); + } + + @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()); + } +} diff --git a/src/main/java/tectech/thing/casing/BlockGTCasingsBA0.java b/src/main/java/tectech/thing/casing/BlockGTCasingsBA0.java new file mode 100644 index 0000000000..19469a0c70 --- /dev/null +++ b/src/main/java/tectech/thing/casing/BlockGTCasingsBA0.java @@ -0,0 +1,224 @@ +package tectech.thing.casing; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.thing.CustomItemList; + +/** + * Created by danie_000 on 03.10.2016. + */ +// Mostly tesla coils, also 2 eye of harmony casings. +public class BlockGTCasingsBA0 extends BlockCasingsAbstract { + + private static final IIcon[] tM0 = new IIcon[2]; + private static final IIcon[] tM1 = new IIcon[2]; + private static final IIcon[] tM2 = new IIcon[2]; + private static final IIcon[] tM3 = new IIcon[2]; + private static final IIcon[] tM4 = new IIcon[2]; + private static final IIcon[] tM5 = new IIcon[2]; + private static final IIcon[] tM6 = new IIcon[2]; + private static IIcon tM7; + private static final IIcon[] tM8 = new IIcon[2]; + private static final IIcon[] tM9 = new IIcon[2]; + + private static IIcon EOH_INNER; + private static IIcon EOH_OUTER; + private static IIcon EOH_INFINITE; + + private static final byte START_INDEX = 16; + + public BlockGTCasingsBA0() { + super(ItemCasingsBA0.class, "gt.blockcasingsBA0", MaterialCasings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][b + + START_INDEX] = new GTCopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring **/ + } + + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".0.name", "Redstone Alloy Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".1.name", "MV Superconductor Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".2.name", "HV Superconductor Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".3.name", "EV Superconductor Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".4.name", "IV Superconductor Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".5.name", "LuV Superconductor Primary Tesla Windings"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".9.name", "ZPM Superconductor Primary Tesla Windings"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Tesla Base Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Tesla Toroid Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Tesla Secondary Windings"); + + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".10.name", "Reinforced Temporal Structure Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".11.name", "Reinforced Spatial Structure Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".12.name", "Infinite Spacetime Energy Boundary Casing"); + + CustomItemList.tM_TeslaPrimary_0.set(new ItemStack(this, 1, 0)); + CustomItemList.tM_TeslaPrimary_1.set(new ItemStack(this, 1, 1)); + CustomItemList.tM_TeslaPrimary_2.set(new ItemStack(this, 1, 2)); + CustomItemList.tM_TeslaPrimary_3.set(new ItemStack(this, 1, 3)); + CustomItemList.tM_TeslaPrimary_4.set(new ItemStack(this, 1, 4)); + CustomItemList.tM_TeslaPrimary_5.set(new ItemStack(this, 1, 5)); + CustomItemList.tM_TeslaPrimary_6.set(new ItemStack(this, 1, 9)); + + CustomItemList.tM_TeslaBase.set(new ItemStack(this, 1, 6)); + CustomItemList.tM_TeslaToroid.set(new ItemStack(this, 1, 7)); + CustomItemList.tM_TeslaSecondary.set(new ItemStack(this, 1, 8)); + + CustomItemList.EOH_Reinforced_Temporal_Casing.set(new ItemStack(this, 1, 10)); + CustomItemList.EOH_Reinforced_Spatial_Casing.set(new ItemStack(this, 1, 11)); + CustomItemList.EOH_Infinite_Energy_Casing.set(new ItemStack(this, 1, 12)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + tM0[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_0"); + tM0[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_0"); + tM1[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_1"); + tM1[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_1"); + tM2[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_2"); + tM2[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_2"); + tM3[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_3"); + tM3[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_3"); + tM4[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_4"); + tM4[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_4"); + tM5[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_5"); + tM5[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_5"); + tM9[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_TOP_BOTTOM_6"); + tM9[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_PRIMARY_SIDES_6"); + + tM6[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_TOP_BOTTOM"); + tM6[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_BASE_SIDES"); + tM7 = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_TOROID"); + tM8[0] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_SECONDARY_TOP_BOTTOM"); + tM8[1] = aIconRegister.registerIcon("gregtech:iconsets/TM_TESLA_WINDING_SECONDARY_SIDES"); + + EOH_INNER = aIconRegister.registerIcon("gregtech:iconsets/EM_INNER_SPACETIME_REINFORCED_EOH_CASING"); + EOH_OUTER = aIconRegister.registerIcon("gregtech:iconsets/EM_OUTER_SPACETIME_REINFORCED_EOH_CASING"); + EOH_INFINITE = aIconRegister.registerIcon("gregtech:iconsets/EM_POWER_INFINITE"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + switch (ordinalSide) { + case 0: + case 1: + return tM0[0]; + default: + return tM0[1]; + } + case 1: + switch (ordinalSide) { + case 0: + case 1: + return tM1[0]; + default: + return tM1[1]; + } + case 2: + switch (ordinalSide) { + case 0: + case 1: + return tM2[0]; + default: + return tM2[1]; + } + case 3: + switch (ordinalSide) { + case 0: + case 1: + return tM3[0]; + default: + return tM3[1]; + } + case 4: + switch (ordinalSide) { + case 0: + case 1: + return tM4[0]; + default: + return tM4[1]; + } + case 5: + switch (ordinalSide) { + case 0: + case 1: + return tM5[0]; + default: + return tM5[1]; + } + case 6: + switch (ordinalSide) { + case 0: + case 1: + return tM6[0]; + default: + return tM6[1]; + } + case 7: + return tM7; + case 8: + switch (ordinalSide) { + case 0: + case 1: + return tM8[0]; + default: + return tM8[1]; + } + case 9: + switch (ordinalSide) { + case 0: + case 1: + return tM9[0]; + default: + return tM9[1]; + } + case 10: + return EOH_INNER; + case 11: + return EOH_OUTER; + case 12: + return EOH_INFINITE; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i <= 12; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/casing/BlockGTCasingsNH.java b/src/main/java/tectech/thing/casing/BlockGTCasingsNH.java new file mode 100644 index 0000000000..26c7097391 --- /dev/null +++ b/src/main/java/tectech/thing/casing/BlockGTCasingsNH.java @@ -0,0 +1,59 @@ +package tectech.thing.casing; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; + +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.TecTech; +import tectech.thing.CustomItemList; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class BlockGTCasingsNH extends BlockCasingsAbstract { + + public static boolean mConnectedMachineTextures = true; + + public BlockGTCasingsNH() { + super(ItemCasingsNH.class, "gt.blockcasingsNH", MaterialCasings.INSTANCE); + setCreativeTab(TecTech.creativeTabTecTech); + + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[8][b + 64] = new GTCopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring */ + } + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "UEV Machine Casing"); // adding + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "UIV Machine Casing"); // adding + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "UMV Machine Casing"); // adding + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".13.name", "UXV Machine Casing"); // adding + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".14.name", "MAX Machine Casing"); // adding + + CustomItemList.Casing_UEV.set(new ItemStack(this, 1, 10)); + CustomItemList.Casing_UIV.set(new ItemStack(this, 1, 11)); + CustomItemList.Casing_UMV.set(new ItemStack(this, 1, 12)); + CustomItemList.Casing_UXV.set(new ItemStack(this, 1, 13)); + CustomItemList.Casing_MAXV.set(new ItemStack(this, 1, 14)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + // super.registerBlockIcons(aIconRegister); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + if (ordinalSide == 0) { + return tectech.thing.metaTileEntity.Textures.MACHINECASINGS_BOTTOM_TT[aMeta].getIcon(); + } + if (ordinalSide == 1) { + return tectech.thing.metaTileEntity.Textures.MACHINECASINGS_TOP_TT[aMeta].getIcon(); + } + return tectech.thing.metaTileEntity.Textures.MACHINECASINGS_SIDE_TT[aMeta].getIcon(); + } +} diff --git a/src/main/java/tectech/thing/casing/BlockGTCasingsTT.java b/src/main/java/tectech/thing/casing/BlockGTCasingsTT.java new file mode 100644 index 0000000000..33ec58d7da --- /dev/null +++ b/src/main/java/tectech/thing/casing/BlockGTCasingsTT.java @@ -0,0 +1,193 @@ +package tectech.thing.casing; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.TecTech; +import tectech.thing.CustomItemList; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class BlockGTCasingsTT extends BlockCasingsAbstract { + + public static final byte texturePage = TecTech.tectechTexturePage1; + public static final short textureOffset = texturePage << 7; // Start of PAGE 8 (which is the 9th page) (8*128) + private static IIcon eM0, eM1, eM1s, eM2, eM2s, eM3, eM3s, eM4, eM5, eM6, eM7, eM7s, eM8, eM9, eM10, eM11, eM12, + eM13, eM14; + private static final IIcon[] debug = new IIcon[6]; + + public BlockGTCasingsTT() { + super(ItemCasingsTT.class, "gt.blockcasingsTT", MaterialCasings.INSTANCE); + setCreativeTab(TecTech.creativeTabTecTech); + + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[texturePage][b] = new GTCopiedBlockTexture(this, 6, b); + /* IMPORTANT for block recoloring **/ + } + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".0.name", "High Power Casing"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Computer Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".2.name", "Computer Heat Vent"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".3.name", "Advanced Computer Casing"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Molecular Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Advanced Molecular Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Containment Field Generator"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Molecular Coil"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".8.name", "Hollow Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".9.name", "Spacetime Altering Casing"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".10.name", "Teleportation Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".11.name", "Dimensional Bridge Generator"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".12.name", "Ultimate Molecular Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".13.name", "Ultimate Advanced Molecular Casing"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".14.name", "Ultimate Containment Field Generator"); + + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".15.name", "Debug Sides"); // NOT REGISTER AS + // TEXTURE FOR + // HATCHES! + + CustomItemList.eM_Power.set(new ItemStack(this, 1, 0)); + + CustomItemList.eM_Computer_Casing.set(new ItemStack(this, 1, 1)); + CustomItemList.eM_Computer_Vent.set(new ItemStack(this, 1, 2)); + CustomItemList.eM_Computer_Bus.set(new ItemStack(this, 1, 3)); + + CustomItemList.eM_Containment.set(new ItemStack(this, 1, 4)); + CustomItemList.eM_Containment_Advanced.set(new ItemStack(this, 1, 5)); + CustomItemList.eM_Containment_Field.set(new ItemStack(this, 1, 6)); + + CustomItemList.eM_Coil.set(new ItemStack(this, 1, 7)); + CustomItemList.eM_Hollow.set(new ItemStack(this, 1, 8)); + CustomItemList.eM_Spacetime.set(new ItemStack(this, 1, 9)); + + CustomItemList.eM_Teleportation.set(new ItemStack(this, 1, 10)); + CustomItemList.eM_Dimensional.set(new ItemStack(this, 1, 11)); + + CustomItemList.eM_Ultimate_Containment.set(new ItemStack(this, 1, 12)); + CustomItemList.eM_Ultimate_Containment_Advanced.set(new ItemStack(this, 1, 13)); + CustomItemList.eM_Ultimate_Containment_Field.set(new ItemStack(this, 1, 14)); + + CustomItemList.debugBlock.set(new ItemStack(this, 1, 15)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + // super.registerBlockIcons(aIconRegister); + eM0 = aIconRegister.registerIcon("gregtech:iconsets/EM_POWER"); + + eM1 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_NONSIDE"); + eM1s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC"); + eM2 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_VENT_NONSIDE"); + eM2s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_VENT"); + eM3 = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_ADV_NONSIDE"); + eM3s = aIconRegister.registerIcon("gregtech:iconsets/EM_PC_ADV"); + + eM4 = aIconRegister.registerIcon("gregtech:iconsets/EM_CASING"); + eM5 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_CASING"); + eM6 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD"); + + eM7 = aIconRegister.registerIcon("gregtech:iconsets/EM_COIL_NONSIDE"); + eM7s = aIconRegister.registerIcon("gregtech:iconsets/EM_COIL"); + eM8 = aIconRegister.registerIcon("gregtech:iconsets/EM_HOLLOW"); + eM9 = aIconRegister.registerIcon("gregtech:iconsets/EM_TIMESPACE"); + + eM10 = aIconRegister.registerIcon("gregtech:iconsets/EM_TELE"); + eM11 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM"); + + eM12 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_CASING"); + eM13 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_FIELD_CASING"); + eM14 = aIconRegister.registerIcon("gregtech:iconsets/EM_ULTIMATE_FIELD"); + + debug[0] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_0"); + debug[1] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_1"); + debug[2] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_2"); + debug[3] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_3"); + debug[4] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_4"); + debug[5] = aIconRegister.registerIcon("gregtech:iconsets/DEBUG_5"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return eM0; + case 1: + if (ordinalSide < 2) { + return eM1; + } + return eM1s; + case 2: + if (ordinalSide < 2) { + return eM2; + } + return eM2s; + case 3: + if (ordinalSide < 2) { + return eM3; + } + return eM3s; + case 4: + return eM4; + case 5: + return eM5; + case 6: + return eM6; + case 7: + if (ordinalSide < 2) { + return eM7; + } + return eM7s; + case 8: + return eM8; + case 9: + return eM9; + case 10: + return eM10; + case 11: + return eM11; + case 12: + return eM12; + case 13: + return eM13; + case 14: + return eM14; + case 15: + return debug[ordinalSide]; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i <= 15; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/casing/BlockGodforgeCasings.java b/src/main/java/tectech/thing/casing/BlockGodforgeCasings.java new file mode 100644 index 0000000000..e744cdf9b7 --- /dev/null +++ b/src/main/java/tectech/thing/casing/BlockGodforgeCasings.java @@ -0,0 +1,130 @@ +package tectech.thing.casing; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.thing.CustomItemList; + +public class BlockGodforgeCasings extends BlockCasingsAbstract { + + private static IIcon GodforgeTrim; + private static IIcon GodforgeInner; + private static IIcon GodforgeSupport; + private static IIcon GodforgeOuter; + private static IIcon GodforgeEnergy; + private static IIcon GravitonModulatorT1; + private static IIcon GravitonModulatorT2; + private static IIcon GravitonModulatorT3; + private static IIcon PhononConduit; + + private static final byte START_INDEX = 64; + + public BlockGodforgeCasings() { + super(ItemCasingsGodforge.class, "gt.godforgecasing", MaterialCasings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GTCopiedBlockTexture(this, 6, b); + } + + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".0.name", "Singularity Reinforced Stellar Shielding Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".1.name", "Celestial Matter Guidance Casing"); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".2.name", + "Boundless Gravitationally Severed Structure Casing"); + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + ".3.name", + "Transcendentally Amplified Magnetic Confinement Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".4.name", "Stellar Energy Siphon Casing"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".5.name", "Remote Graviton Flow Modulator"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".6.name", "Medial Graviton Flow Modulator"); + GTLanguageManager.addStringLocalization(getUnlocalizedName() + ".7.name", "Central Graviton Flow Modulator"); + GTLanguageManager + .addStringLocalization(getUnlocalizedName() + ".8.name", "Harmonic Phonon Transmission Conduit"); + + CustomItemList.Godforge_SingularityShieldingCasing.set(new ItemStack(this, 1, 0)); + CustomItemList.Godforge_GuidanceCasing.set(new ItemStack(this, 1, 1)); + CustomItemList.Godforge_BoundlessStructureCasing.set(new ItemStack(this, 1, 2)); + CustomItemList.Godforge_MagneticConfinementCasing.set(new ItemStack(this, 1, 3)); + CustomItemList.Godforge_StellarEnergySiphonCasing.set(new ItemStack(this, 1, 4)); + CustomItemList.Godforge_GravitonFlowModulatorTier1.set(new ItemStack(this, 1, 5)); + CustomItemList.Godforge_GravitonFlowModulatorTier2.set(new ItemStack(this, 1, 6)); + CustomItemList.Godforge_GravitonFlowModulatorTier3.set(new ItemStack(this, 1, 7)); + CustomItemList.Godforge_HarmonicPhononTransmissionConduit.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + GodforgeTrim = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_TRIM"); + GodforgeInner = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_INNER"); + GodforgeSupport = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_SUPPORT"); + GodforgeOuter = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_TOP_BOTTOM"); + GodforgeEnergy = aIconRegister.registerIcon("gregtech:iconsets/GODFORGE_ENERGY"); + GravitonModulatorT1 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_2"); + GravitonModulatorT2 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_1"); + GravitonModulatorT3 = aIconRegister.registerIcon("gregtech:iconsets/GRAVITON_CASING_0"); + PhononConduit = aIconRegister.registerIcon("gregtech:iconsets/PHONON_CONDUIT"); + } + + @Override + public IIcon getIcon(int aSide, int aMeta) { + switch (aMeta) { + case 0: + return GodforgeTrim; + case 1: + return GodforgeInner; + case 2: + return GodforgeSupport; + case 3: + return GodforgeOuter; + case 4: + return GodforgeEnergy; + case 5: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT1; + case 6: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT2; + case 7: + if (aSide < 2) { + return GodforgeOuter; + } + return GravitonModulatorT3; + case 8: + return PhononConduit; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int aSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(aSide, tMeta); + } + + @SuppressWarnings("unchecked") + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List aList) { + for (int i = 0; i <= 8; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsBA0.java b/src/main/java/tectech/thing/casing/ItemCasingsBA0.java new file mode 100644 index 0000000000..8d3896d600 --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsBA0.java @@ -0,0 +1,110 @@ +package tectech.thing.casing; + +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.util.GTUtility.formatNumbers; +import static net.minecraft.util.EnumChatFormatting.AQUA; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.enums.TierEU; +import gregtech.common.blocks.ItemCasingsAbstract; +import tectech.util.CommonValues; + +public class ItemCasingsBA0 extends ItemCasingsAbstract { + + public ItemCasingsBA0(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + if (aStack.getItemDamage() < 15) { + aList.add(CommonValues.THETA_MOVEMENT); + } else { + aList.add(CommonValues.COSMIC_MARK); + } + switch (aStack.getItemDamage()) { + case 0: // "Redstone Alloy Primary Tesla Windings" + case 1: // "MV Superconductor Primary Tesla Windings" + case 2: // "HV Superconductor Primary Tesla Windings" + case 3: // "EV Superconductor Primary Tesla Windings" + case 4: // "IV Superconductor Primary Tesla Windings" + case 5: // "LuV Superconductor Primary Tesla Windings" + aList.add( + translateToLocal("gt.blockcasingsBA0.0.desc.0") + " " + + formatNumbers(V[aStack.getItemDamage() + 1]) + + " EU/t"); // Handles up to + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.0.desc.1")); // What + // one + // man + // calls + // God, + // another + // calls + // the + // laws of physics. + break; + case 6: // "Tesla Base Casing" + aList.add(translateToLocal("gt.blockcasingsBA0.6.desc.0")); // The base of a wondrous contraption + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.6.desc.1")); // it's + // alive, + // IT'S + // ALIVE! + break; + case 7: // "Tesla Toroid Casing" + aList.add(translateToLocal("gt.blockcasingsBA0.7.desc.0")); // Made out of the finest tin foil! + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.7.desc.1")); // Faraday + // suits + // might + // come + // later + break; + case 8: // "Tesla Secondary Windings" + aList.add(translateToLocal("gt.blockcasingsBA0.8.desc.0")); // Picks up power from a primary coil + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.8.desc.1")); // Who + // wouldn't + // want + // a + // 32k + // epoxy + // multi? + break; + case 9: // "ZPM Superconductor Primary Tesla Windings" + aList.add(translateToLocal("gt.blockcasingsBA0.0.desc.0") + " " + formatNumbers(TierEU.ZPM) + " EU/t"); // Handles + // up + // to + aList.add(AQUA.toString() + EnumChatFormatting.BOLD + translateToLocal("gt.blockcasingsBA0.0.desc.1")); // What + // one + // man + // calls + // God, + // another + case 10: // Reinforced Temporal Structure Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.10.desc.0")); + aList.add(GRAY + translateToLocal("gt.blockcasingsBA0.10.desc.1")); + // Designed to resist spatial shearing from internal volume expansion. + // Can survive at least one big bang, maybe two... + break; + case 11: // Reinforced Temporal Structure Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.11.desc.0")); + aList.add(GRAY + translateToLocal("gt.blockcasingsBA0.11.desc.1")); + // Resistant to temporal shearing from time dilation differences. + // This block can last an eternity without any decay. + break; + case 12: // Infinite Spacetime Energy Boundary Casing + aList.add(AQUA + translateToLocal("gt.blockcasingsBA0.12.desc.0")); + // Provides a stable bridge between spacetime regions. + break; + default: + aList.add("Damn son where did you get that!?"); + aList.add(EnumChatFormatting.BLUE + "From outer space... I guess..."); + } + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsGodforge.java b/src/main/java/tectech/thing/casing/ItemCasingsGodforge.java new file mode 100644 index 0000000000..52b741ca76 --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsGodforge.java @@ -0,0 +1,124 @@ +package tectech.thing.casing; + +import static net.minecraft.util.EnumChatFormatting.AQUA; +import static net.minecraft.util.EnumChatFormatting.BOLD; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.ItemCasingsAbstract; +import tectech.util.CommonValues; + +public class ItemCasingsGodforge extends ItemCasingsAbstract { + + public ItemCasingsGodforge(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List aList, boolean aF3_H) { + aList.add(CommonValues.GODFORGE_MARK); + switch (aStack.getItemDamage()) { + case 0: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.0.Tooltip.0", + "Shielded by the event horizon of a singularity")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager + .addStringLocalization("godforge.casings.0.Tooltip.1", "Don't get too close...")); + break; + case 1: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.1.Tooltip.0", + "Designed to route stellar matter using spacetime distortion")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager + .addStringLocalization("godforge.casings.1.Tooltip.1", "Reality Distortion")); + break; + case 2: + aList.add( + GTLanguageManager + .addStringLocalization("godforge.casings.2.Tooltip.0", "Unaffected by gravitational forces")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization( + "godforge.casings.2.Tooltip.1", + "Not even a black hole could tear it apart.")); + break; + case 3: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.3.Tooltip.0", + "Creates enormous magnetic fields capable of constraining entire stars")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager + .addStringLocalization("godforge.casings.3.Tooltip.1", "It's super effective!")); + break; + case 4: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.4.Tooltip.0", + "Taps into streams of stellar matter to harness their heat energy")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization("godforge.casings.4.Tooltip.1", "Turn up the heat!")); + break; + case 5: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.5.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization( + "godforge.casings.5.Tooltip.1", + "Exponential scaling past 800 Galaxies")); + break; + case 6: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.6.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization("godforge.casings.6.Tooltip.1", "Getting closer...")); + break; + case 7: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.7.Tooltip.0", + "Controls the flow of gravitons to manipulate gravity")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization("godforge.casings.7.Tooltip.1", "Gravity Central")); + break; + case 8: + aList.add( + GTLanguageManager.addStringLocalization( + "godforge.casings.8.Tooltip.0", + "Transfers and stores extreme amounts of heat without any loss")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization("godforge.casings.8.Tooltip.1", "<<<Thermal<<<")); + aList.add( + AQUA.toString() + BOLD + + GTLanguageManager.addStringLocalization("godforge.casings.8.Tooltip.2", ">>>Wave>>>")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + BOLD + + GTLanguageManager + .addStringLocalization("godforge.casings.Error.Tooltip", "Error, report to GTNH team")); + } + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsNH.java b/src/main/java/tectech/thing/casing/ItemCasingsNH.java new file mode 100644 index 0000000000..c1f57e018f --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsNH.java @@ -0,0 +1,15 @@ +package tectech.thing.casing; + +import net.minecraft.block.Block; + +import gregtech.common.blocks.ItemCasingsAbstract; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class ItemCasingsNH extends ItemCasingsAbstract { + + public ItemCasingsNH(Block par1) { + super(par1); + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsSpacetime.java b/src/main/java/tectech/thing/casing/ItemCasingsSpacetime.java new file mode 100644 index 0000000000..f6cf548d84 --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsSpacetime.java @@ -0,0 +1,56 @@ +package tectech.thing.casing; + +import static com.google.common.math.LongMath.pow; +import static gregtech.api.enums.GTValues.AuthorColen; +import static gregtech.api.util.GTUtility.formatNumbers; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.ItemCasingsAbstract; + +public class ItemCasingsSpacetime extends ItemCasingsAbstract { + + public ItemCasingsSpacetime(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + GTLanguageManager.addStringLocalization( + "EOH.Spacetime.Standard.Tooltip.0", + "Supports an internal spacetime volume of up to ") + + formatNumbers(pow(10, 5 + aStack.getItemDamage())) + + "km³."); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GTLanguageManager.addStringLocalization( + "EOH.Spacetime.Standard.Tooltip.1", + "Capable of running recipes up to tier ") + + (aStack.getItemDamage() + 1)); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GTLanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsStabilisation.java b/src/main/java/tectech/thing/casing/ItemCasingsStabilisation.java new file mode 100644 index 0000000000..9d802c4a93 --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsStabilisation.java @@ -0,0 +1,47 @@ +package tectech.thing.casing; + +import static gregtech.api.enums.GTValues.AuthorColen; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.ItemCasingsAbstract; + +public class ItemCasingsStabilisation extends ItemCasingsAbstract { + + public ItemCasingsStabilisation(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GTLanguageManager.addStringLocalization( + "EOH.Stability.Tooltip.0", + "Increases stability of spacetime field.")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GTLanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsTT.java b/src/main/java/tectech/thing/casing/ItemCasingsTT.java new file mode 100644 index 0000000000..d335729a10 --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsTT.java @@ -0,0 +1,132 @@ +package tectech.thing.casing; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.common.blocks.ItemCasingsAbstract; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 03.10.2016. + */ +public class ItemCasingsTT extends ItemCasingsAbstract { + + public ItemCasingsTT(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + if (aStack.getItemDamage() < 15) { + aList.add(CommonValues.TEC_MARK_EM); + } else { + aList.add(CommonValues.COSMIC_MARK); + } + switch (aStack.getItemDamage()) { + case 0: // "High Power Casing" + aList.add(translateToLocal("gt.blockcasingsTT.0.desc.0")); // Well suited for high power applications. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.0.desc.1")); // The power levels are rising! + break; + case 1: // "Computer Casing" + aList.add(translateToLocal("gt.blockcasingsTT.1.desc.0")); // Nice and clean casing. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.1.desc.1")); // Dust can break it!? + break; + case 2: // "Computer Heat Vent" + aList.add(translateToLocal("gt.blockcasingsTT.2.desc.0")); // Air vent with a filter. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.2.desc.1")); // Perfectly muffled sound! + break; + case 3: // "Advanced Computer Casing" + aList.add(translateToLocal("gt.blockcasingsTT.3.desc.0")); // Contains high bandwidth bus + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.3.desc.1")); // couple thousand qubits wide. + break; + case 4: // "Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.4.desc.0")); // Stops elemental things. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.4.desc.1")); // Radiation and emotions too... + break; + case 5: // "Advanced Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.5.desc.0")); // Cooling and stabilization. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.5.desc.1")); // A comfortable machine bed. + break; + case 6: // "Containment Field Generator" + aList.add(translateToLocal("gt.blockcasingsTT.6.desc.0")); // Creates a field that... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.6.desc.1")); // can stop even force carriers. + break; + case 7: // "Molecular Coil" + aList.add(translateToLocal("gt.blockcasingsTT.7.desc.0")); // Well it does things too... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.7.desc.1")); // [Use this coil!] + break; + case 8: // "Collider Hollow Casing" + aList.add(translateToLocal("gt.blockcasingsTT.8.desc.0")); // Reinforced accelerator tunnel. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.8.desc.1")); // Most advanced pipe ever. + break; + case 9: // "Spacetime Altering Casing" + aList.add(translateToLocal("gt.blockcasingsTT.9.desc.0")); // c is no longer the limit. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.9.desc.1")); // Wibbly wobbly timey wimey stuff. + break; + case 10: // "Teleportation Casing" + aList.add(translateToLocal("gt.blockcasingsTT.10.desc.0")); // Remote connection. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.10.desc.1")); // Better touch with a stick. + break; + case 11: // "Dimensional Bridge Generator" + aList.add(translateToLocal("gt.blockcasingsTT.11.desc.0")); // Interdimensional Operations. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.11.desc.1")); // Around the universe and other + // places too. + break; + case 12: // "Ultimate Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.12.desc.0")); // Ultimate in every way. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.12.desc.1")); // I don't know what it can't do. + break; + case 13: // "Ultimate Advanced Molecular Casing" + aList.add(translateToLocal("gt.blockcasingsTT.13.desc.0")); // More Ultimate in every way. + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.13.desc.1")); // I don't know what I am doing! + break; + case 14: // "Ultimate Containment Field Generator" + aList.add(translateToLocal("gt.blockcasingsTT.14.desc.0")); // Black Hole... + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockcasingsTT.14.desc.1")); // Meh... + break; + case 15: // "Debug Sides" + aList.add(translateToLocal("gt.blockcasingsTT.15.desc.0")); // Lazy man way of determining sides. + aList.add(EnumChatFormatting.BLUE + translateToLocal("gt.blockcasingsTT.15.desc.1")); + break; + default: // WTF? + aList.add("Damn son where did you get that!?"); + aList.add(EnumChatFormatting.BLUE + "From outer space... I guess..."); + } + } +} diff --git a/src/main/java/tectech/thing/casing/ItemCasingsTimeAcceleration.java b/src/main/java/tectech/thing/casing/ItemCasingsTimeAcceleration.java new file mode 100644 index 0000000000..a4aac6e5cc --- /dev/null +++ b/src/main/java/tectech/thing/casing/ItemCasingsTimeAcceleration.java @@ -0,0 +1,46 @@ +package tectech.thing.casing; + +import static gregtech.api.enums.GTValues.AuthorColen; + +import java.util.List; + +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.ItemCasingsAbstract; + +public class ItemCasingsTimeAcceleration extends ItemCasingsAbstract { + + public ItemCasingsTimeAcceleration(Block par1) { + super(par1); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer aPlayer, List<String> aList, boolean aF3_H) { + switch (aStack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + GTLanguageManager + .addStringLocalization("EOH.TimeDilation.Standard.Tooltip", "Time dilation in a box.")); + break; + default: + aList.add( + EnumChatFormatting.RED.toString() + EnumChatFormatting.BOLD + + GTLanguageManager + .addStringLocalization("EOH.TimeDilation.Error.Tooltip", "Error, report to GTNH team")); + } + aList.add(AuthorColen); + } +} diff --git a/src/main/java/tectech/thing/casing/SpacetimeCompressionFieldCasing.java b/src/main/java/tectech/thing/casing/SpacetimeCompressionFieldCasing.java new file mode 100644 index 0000000000..cc89d83b7d --- /dev/null +++ b/src/main/java/tectech/thing/casing/SpacetimeCompressionFieldCasing.java @@ -0,0 +1,116 @@ +package tectech.thing.casing; + +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +@SuppressWarnings("SpellCheckingInspection") +public class SpacetimeCompressionFieldCasing extends BlockCasingsAbstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 16; + + public SpacetimeCompressionFieldCasing() { + super(ItemCasingsSpacetime.class, "gt.spacetime_compression_field_generator", MaterialCasings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GTCopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + CommonValues.EOH_TIER_FANCY_NAMES[i] + RESET + " Spacetime Compression Field Generator"); + } + + CustomItemList.SpacetimeCompressionFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.SpacetimeCompressionFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/EM_DIM_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/casing/StabilisationFieldCasing.java b/src/main/java/tectech/thing/casing/StabilisationFieldCasing.java new file mode 100644 index 0000000000..21fb7acb76 --- /dev/null +++ b/src/main/java/tectech/thing/casing/StabilisationFieldCasing.java @@ -0,0 +1,116 @@ +package tectech.thing.casing; + +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +@SuppressWarnings("SpellCheckingInspection") +public class StabilisationFieldCasing extends BlockCasingsAbstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 32; + + public StabilisationFieldCasing() { + super(ItemCasingsStabilisation.class, "gt.stabilisation_field_generator", MaterialCasings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GTCopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + CommonValues.EOH_TIER_FANCY_NAMES[i] + RESET + " Stabilisation Field Generator"); + } + + CustomItemList.StabilisationFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.StabilisationFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.StabilisationFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.StabilisationFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.StabilisationFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.StabilisationFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.StabilisationFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.StabilisationFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.StabilisationFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/STABILITY_CASING_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/casing/TTCasingsContainer.java b/src/main/java/tectech/thing/casing/TTCasingsContainer.java new file mode 100644 index 0000000000..170439e2bc --- /dev/null +++ b/src/main/java/tectech/thing/casing/TTCasingsContainer.java @@ -0,0 +1,28 @@ +package tectech.thing.casing; + +import net.minecraft.block.Block; + +import tectech.thing.block.BlockEOHRender; +import tectech.thing.block.BlockForgeOfGods; + +/** + * Created by danie_000 on 03.10.2016. + */ +public final class TTCasingsContainer { + + public static Block sBlockCasingsTT; + + public static Block sBlockCasingsBA0; + + public static Block sBlockCasingsNH; + public static Block TimeAccelerationFieldGenerator; + public static Block SpacetimeCompressionFieldGenerators; + public static Block StabilisationFieldGenerators; + + public static Block eyeOfHarmonyRenderBlock = new BlockEOHRender(); + public static Block forgeOfGodsRenderBlock = new BlockForgeOfGods(); + + public static Block GodforgeCasings; + + private TTCasingsContainer() {} +} diff --git a/src/main/java/tectech/thing/casing/TimeAccelerationFieldCasing.java b/src/main/java/tectech/thing/casing/TimeAccelerationFieldCasing.java new file mode 100644 index 0000000000..47615e7b79 --- /dev/null +++ b/src/main/java/tectech/thing/casing/TimeAccelerationFieldCasing.java @@ -0,0 +1,116 @@ +package tectech.thing.casing; + +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.world.IBlockAccess; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.objects.GTCopiedBlockTexture; +import gregtech.api.util.GTLanguageManager; +import gregtech.common.blocks.BlockCasingsAbstract; +import gregtech.common.blocks.MaterialCasings; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +@SuppressWarnings("SpellCheckingInspection") +public class TimeAccelerationFieldCasing extends BlockCasingsAbstract { + + private static IIcon textureTier0; + private static IIcon textureTier1; + private static IIcon textureTier2; + private static IIcon textureTier3; + private static IIcon textureTier4; + private static IIcon textureTier5; + private static IIcon textureTier6; + private static IIcon textureTier7; + private static IIcon textureTier8; + private static final int MAX_BLOCK_TIER = 9; + + private static final byte START_INDEX = 48; + + public TimeAccelerationFieldCasing() { + super(ItemCasingsTimeAcceleration.class, "gt.time_acceleration_field_generator", MaterialCasings.INSTANCE); + for (byte b = 0; b < 16; b = (byte) (b + 1)) { + Textures.BlockIcons.casingTexturePages[7][b + START_INDEX] = new GTCopiedBlockTexture(this, 6, b); + } + + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + GTLanguageManager.addStringLocalization( + getUnlocalizedName() + "." + i + ".name", + WHITE + CommonValues.EOH_TIER_FANCY_NAMES[i] + RESET + " Time Dilation Field Generator"); + } + + CustomItemList.TimeAccelerationFieldGeneratorTier0.set(new ItemStack(this, 1, 0)); + CustomItemList.TimeAccelerationFieldGeneratorTier1.set(new ItemStack(this, 1, 1)); + CustomItemList.TimeAccelerationFieldGeneratorTier2.set(new ItemStack(this, 1, 2)); + CustomItemList.TimeAccelerationFieldGeneratorTier3.set(new ItemStack(this, 1, 3)); + CustomItemList.TimeAccelerationFieldGeneratorTier4.set(new ItemStack(this, 1, 4)); + CustomItemList.TimeAccelerationFieldGeneratorTier5.set(new ItemStack(this, 1, 5)); + CustomItemList.TimeAccelerationFieldGeneratorTier6.set(new ItemStack(this, 1, 6)); + CustomItemList.TimeAccelerationFieldGeneratorTier7.set(new ItemStack(this, 1, 7)); + CustomItemList.TimeAccelerationFieldGeneratorTier8.set(new ItemStack(this, 1, 8)); + } + + @Override + public void registerBlockIcons(IIconRegister aIconRegister) { + textureTier0 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_0"); + textureTier1 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_1"); + textureTier2 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_2"); + textureTier3 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_3"); + textureTier4 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_4"); + textureTier5 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_5"); + textureTier6 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_6"); + textureTier7 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_7"); + textureTier8 = aIconRegister.registerIcon("gregtech:iconsets/EM_FIELD_8"); + } + + @Override + public IIcon getIcon(int ordinalSide, int aMeta) { + switch (aMeta) { + case 0: + return textureTier0; + case 1: + return textureTier1; + case 2: + return textureTier2; + case 3: + return textureTier3; + case 4: + return textureTier4; + case 5: + return textureTier5; + case 6: + return textureTier6; + case 7: + return textureTier7; + case 8: + return textureTier8; + default: + return Textures.BlockIcons.MACHINE_CASING_SOLID_STEEL.getIcon(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess aWorld, int xCoord, int yCoord, int zCoord, int ordinalSide) { + int tMeta = aWorld.getBlockMetadata(xCoord, yCoord, zCoord); + return getIcon(ordinalSide, tMeta); + } + + @Override + public void getSubBlocks(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i < MAX_BLOCK_TIER; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/cover/CoverEnderFluidLink.java b/src/main/java/tectech/thing/cover/CoverEnderFluidLink.java new file mode 100644 index 0000000000..bae4e26b6c --- /dev/null +++ b/src/main/java/tectech/thing/cover/CoverEnderFluidLink.java @@ -0,0 +1,245 @@ +package tectech.thing.cover; + +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.IFluidHandler; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import eu.usrv.yamcore.auxiliary.PlayerChatHelper; +import gregtech.api.gui.modularui.CoverUIBuildContext; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.GTUtility; +import gregtech.api.util.ISerializableObject; +import gregtech.common.gui.modularui.widget.CoverDataControllerWidget; +import gregtech.common.gui.modularui.widget.CoverDataFollowerToggleButtonWidget; +import tectech.mechanics.enderStorage.EnderLinkTag; +import tectech.mechanics.enderStorage.EnderWorldSavedData; + +public class CoverEnderFluidLink extends CoverBehavior { + + private static final int L_PER_TICK = 8000; + private static final int IMPORT_EXPORT_MASK = 0b0001; + private static final int PUBLIC_PRIVATE_MASK = 0b0010; + + public CoverEnderFluidLink() {} + + private void transferFluid(IFluidHandler source, ForgeDirection side, IFluidHandler target, ForgeDirection tSide, + int amount) { + FluidStack fluidStack = source.drain(side, amount, false); + + if (fluidStack != null) { + int fluidTransferred = target.fill(tSide, fluidStack, true); + source.drain(side, fluidTransferred, true); + } + } + + private boolean testBit(int aCoverVariable, int bitMask) { + return (aCoverVariable & bitMask) != 0; + } + + private int toggleBit(int aCoverVariable, int bitMask) { + return (aCoverVariable ^ bitMask); + } + + @Override + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + if ((aTileEntity instanceof IFluidHandler fluidHandlerSelf)) { + IFluidHandler fluidHandlerEnder = EnderWorldSavedData + .getEnderFluidContainer(EnderWorldSavedData.getEnderLinkTag((IFluidHandler) aTileEntity)); + + if (testBit(aCoverVariable, IMPORT_EXPORT_MASK)) { + transferFluid(fluidHandlerEnder, ForgeDirection.UNKNOWN, fluidHandlerSelf, side, L_PER_TICK); + } else { + transferFluid(fluidHandlerSelf, side, fluidHandlerEnder, ForgeDirection.UNKNOWN, L_PER_TICK); + } + } + return aCoverVariable; + } + + @Override + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return ""; + } + + @Override + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + int newCoverVariable = toggleBit(aCoverVariable, IMPORT_EXPORT_MASK); + + if (testBit(aCoverVariable, IMPORT_EXPORT_MASK)) { + PlayerChatHelper.SendInfo(aPlayer, "Ender Suction Engaged!"); // TODO Translation support + } else { + PlayerChatHelper.SendInfo(aPlayer, "Ender Filling Engaged!"); + } + return newCoverVariable; + } + + @Override + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + // Runs each tick + return 1; + } + + // region GUI + + @Override + public boolean hasCoverGUI() { + return true; + } + + @Override + public ModularWindow createWindow(CoverUIBuildContext buildContext) { + // Only open gui if we're placed on a fluid tank + if (buildContext.getTile() instanceof IFluidHandler) { + return new EnderFluidLinkUIFactory(buildContext).createWindow(); + } + return null; + } + + private class EnderFluidLinkUIFactory extends UIFactory { + + private static final int START_X = 10; + private static final int START_Y = 25; + private static final int SPACE_X = 18; + private static final int SPACE_Y = 18; + private static final int PUBLIC_BUTTON_ID = 0; + private static final int PRIVATE_BUTTON_ID = 1; + private static final int IMPORT_BUTTON_ID = 2; + private static final int EXPORT_BUTTON_ID = 3; + + public EnderFluidLinkUIFactory(CoverUIBuildContext buildContext) { + super(buildContext); + } + + @SuppressWarnings("PointlessArithmeticExpression") + @Override + protected void addUIWidgets(ModularWindow.Builder builder) { + TextFieldWidget frequencyField = new TextFieldWidget(); + builder.widget(frequencyField.setGetter(() -> { + ICoverable te = getUIBuildContext().getTile(); + if (!frequencyField.isClient() && te instanceof IFluidHandler) { + return EnderWorldSavedData.getEnderLinkTag((IFluidHandler) te) + .getFrequency(); + } + return ""; + }) + .setSetter(val -> { + ICoverable te = getUIBuildContext().getTile(); + if (!frequencyField.isClient() && te instanceof IFluidHandler) { + UUID uuid; + if (testBit(convert(getCoverData()), PUBLIC_PRIVATE_MASK)) { + uuid = getUUID(); + if (!(te instanceof IGregTechTileEntity)) return; + if (!uuid.equals(((IGregTechTileEntity) te).getOwnerUuid())) return; + } else { + uuid = null; + } + EnderWorldSavedData.bindEnderLinkTag((IFluidHandler) te, new EnderLinkTag(val, uuid)); + } + }) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setFocusOnGuiOpen(true) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 0) + .setSize(SPACE_X * 5 - 8, 12)) + .widget( + new CoverDataControllerWidget.CoverDataIndexedControllerWidget_ToggleButtons<>( + this::getCoverData, + this::setCoverData, + CoverEnderFluidLink.this, + (id, coverData) -> !getClickable(id, convert(coverData)), + (id, coverData) -> new ISerializableObject.LegacyCoverData( + getNewCoverVariable(id, convert(coverData)))) + .addToggleButton( + PUBLIC_BUTTON_ID, + CoverDataFollowerToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GTUITextures.OVERLAY_BUTTON_WHITELIST) + .addTooltip(GTUtility.trans("326", "Public")) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 2)) + .addToggleButton( + PRIVATE_BUTTON_ID, + CoverDataFollowerToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GTUITextures.OVERLAY_BUTTON_BLACKLIST) + .addTooltip(GTUtility.trans("327", "Private")) + .setPos(START_X + SPACE_X * 1, START_Y + SPACE_Y * 2)) + .addToggleButton( + IMPORT_BUTTON_ID, + CoverDataFollowerToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GTUITextures.OVERLAY_BUTTON_IMPORT) + .addTooltip(GTUtility.trans("007", "Import")) + .setPos(START_X + SPACE_X * 0, START_Y + SPACE_Y * 3)) + .addToggleButton( + EXPORT_BUTTON_ID, + CoverDataFollowerToggleButtonWidget.ofDisableable(), + widget -> widget.setStaticTexture(GTUITextures.OVERLAY_BUTTON_EXPORT) + .addTooltip(GTUtility.trans("006", "Export")) + .setPos(START_X + SPACE_X * 1, START_Y + SPACE_Y * 3))) + .widget( + new TextWidget(GTUtility.trans("328", "Channel")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 5, 4 + START_Y + SPACE_Y * 0)) + .widget( + new TextWidget(GTUtility.trans("329", "Public/Private")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 2, 4 + START_Y + SPACE_Y * 2)) + .widget( + new TextWidget(GTUtility.trans("229", "Import/Export")).setDefaultColor(COLOR_TEXT_GRAY.get()) + .setPos(START_X + SPACE_X * 2, 4 + START_Y + SPACE_Y * 3)); + } + + private int getNewCoverVariable(int id, int coverVariable) { + switch (id) { + case PUBLIC_BUTTON_ID: + case PRIVATE_BUTTON_ID: + return toggleBit(coverVariable, PUBLIC_PRIVATE_MASK); + case IMPORT_BUTTON_ID: + case EXPORT_BUTTON_ID: + return toggleBit(coverVariable, IMPORT_EXPORT_MASK); + } + return coverVariable; + } + + private boolean getClickable(int id, int coverVariable) { + switch (id) { + case PUBLIC_BUTTON_ID: + return testBit(coverVariable, PUBLIC_PRIVATE_MASK); + case PRIVATE_BUTTON_ID: + return !testBit(coverVariable, PUBLIC_PRIVATE_MASK); + case IMPORT_BUTTON_ID: + return testBit(coverVariable, IMPORT_EXPORT_MASK); + case EXPORT_BUTTON_ID: + return !testBit(coverVariable, IMPORT_EXPORT_MASK); + } + return false; + } + + private UUID getUUID() { + return getUIBuildContext().getPlayer() + .getUniqueID(); + } + } +} diff --git a/src/main/java/tectech/thing/cover/CoverPowerPassUpgrade.java b/src/main/java/tectech/thing/cover/CoverPowerPassUpgrade.java new file mode 100644 index 0000000000..7666ba132e --- /dev/null +++ b/src/main/java/tectech/thing/cover/CoverPowerPassUpgrade.java @@ -0,0 +1,52 @@ +package tectech.thing.cover; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.CoverBehavior; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; + +public class CoverPowerPassUpgrade extends CoverBehavior { + + public CoverPowerPassUpgrade() {} + + @Override + public boolean isCoverPlaceable(ForgeDirection side, ItemStack aStack, ICoverable aTileEntity) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof TTMultiblockBase multi) { + return !multi.ePowerPassCover; + } + return false; + } + + @Override + public void placeCover(ForgeDirection side, ItemStack aCover, ICoverable aTileEntity) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof TTMultiblockBase multi) { + multi.ePowerPassCover = true; + multi.ePowerPass = true; + } + super.placeCover(side, aCover, aTileEntity); + } + + @Override + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + IMetaTileEntity iGregTechTileEntityOffset = aTileEntity.getIGregTechTileEntityOffset(0, 0, 0) + .getMetaTileEntity(); + if (iGregTechTileEntityOffset instanceof TTMultiblockBase multi) { + multi.ePowerPassCover = false; + multi.ePowerPass = false; + } + return true; + } + + @Deprecated + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return 0; + } +} diff --git a/src/main/java/tectech/thing/cover/CoverTeslaCoil.java b/src/main/java/tectech/thing/cover/CoverTeslaCoil.java new file mode 100644 index 0000000000..a1dba25e03 --- /dev/null +++ b/src/main/java/tectech/thing/cover/CoverTeslaCoil.java @@ -0,0 +1,85 @@ +package tectech.thing.cover; + +import static ic2.api.info.Info.DMG_ELECTRIC; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.tileentity.ICoverable; +import gregtech.api.util.CoverBehavior; +import gregtech.api.util.GTUtility; +import tectech.mechanics.tesla.ITeslaConnectable; +import tectech.mechanics.tesla.TeslaCoverConnection; + +public class CoverTeslaCoil extends CoverBehavior { + + public CoverTeslaCoil() {} + + @Override + public int doCoverThings(ForgeDirection side, byte aInputRedstone, int aCoverID, int aCoverVariable, + ICoverable aTileEntity, long aTimer) { + // Only do stuff if we're on top and have power + if (side == ForgeDirection.UP || aTileEntity.getEUCapacity() > 0) { + // Makes sure we're on the list + ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetAdd( + new TeslaCoverConnection( + aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), + getTeslaReceptionCapability())); + } + return super.doCoverThings(side, aInputRedstone, aCoverID, aCoverVariable, aTileEntity, aTimer); + } + + @Override + public void onCoverUnload(ICoverable aTileEntity) { + if (!aTileEntity.isClientSide()) { + ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove( + new TeslaCoverConnection( + aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), + getTeslaReceptionCapability())); + } + } + + @Override + public boolean onCoverRemoval(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + boolean aForced) { + ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove( + new TeslaCoverConnection(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), getTeslaReceptionCapability())); + return super.onCoverRemoval(side, aCoverID, aCoverVariable, aTileEntity, aForced); + } + + @Override + public void onBaseTEDestroyed(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + ITeslaConnectable.TeslaUtil.teslaSimpleNodeSetRemove( + new TeslaCoverConnection(aTileEntity.getIGregTechTileEntityOffset(0, 0, 0), getTeslaReceptionCapability())); + } + + @Override + public String getDescription(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return "Do not attempt to use screwdriver!"; // TODO Translation support + } + + @Override + public boolean letsEnergyIn(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + @Override + public int onCoverScrewdriverclick(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity, + EntityPlayer aPlayer, float aX, float aY, float aZ) { + // Shock a non-hazmat player if they dare stuff a screwdriver into one of these + if (aTileEntity.getStoredEU() > 0 && !GTUtility.isWearingFullElectroHazmat(aPlayer)) { + aPlayer.attackEntityFrom(DMG_ELECTRIC, 20); + } + return aCoverVariable; + } + + @Override + public int getTickRate(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + // It updates once every 10 ticks, so once every 0.5 second + return 10; + } + + public byte getTeslaReceptionCapability() { + return 2; + } +} diff --git a/src/main/java/tectech/thing/cover/CoverTeslaCoilUltimate.java b/src/main/java/tectech/thing/cover/CoverTeslaCoilUltimate.java new file mode 100644 index 0000000000..8f7ab28869 --- /dev/null +++ b/src/main/java/tectech/thing/cover/CoverTeslaCoilUltimate.java @@ -0,0 +1,44 @@ +package tectech.thing.cover; + +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; + +import gregtech.api.interfaces.tileentity.ICoverable; + +public class CoverTeslaCoilUltimate extends CoverTeslaCoil { + + public CoverTeslaCoilUltimate() {} + + @Override + public boolean letsEnergyOut(ForgeDirection side, int aCoverID, int aCoverVariable, ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsItemsIn(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsItemsOut(ForgeDirection side, int aCoverID, int aCoverVariable, int aSlot, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidIn(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + @Override + public boolean letsFluidOut(ForgeDirection side, int aCoverID, int aCoverVariable, Fluid aFluid, + ICoverable aTileEntity) { + return true; + } + + public byte getTeslaReceptionCapability() { + return 1; + } +} diff --git a/src/main/java/tectech/thing/gui/TecTechUITextures.java b/src/main/java/tectech/thing/gui/TecTechUITextures.java new file mode 100644 index 0000000000..d4bc73f8e1 --- /dev/null +++ b/src/main/java/tectech/thing/gui/TecTechUITextures.java @@ -0,0 +1,192 @@ +package tectech.thing.gui; + +import static tectech.Reference.MODID; + +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import com.gtnewhorizons.modularui.api.drawable.AdaptableUITexture; +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +@SuppressWarnings("SimplifyStreamApiCallChains") +public class TecTechUITextures { + + public static final AdaptableUITexture BACKGROUND_SCREEN_BLUE = AdaptableUITexture + .of(MODID, "gui/background/screen_blue", 90, 72, 2); + public static final UITexture BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT = UITexture + .fullImage(MODID, "gui/background/screen_blue_parametrizer_txt"); + public static final UITexture BACKGROUND_SCREEN_BLUE_NO_INVENTORY = UITexture + .fullImage(MODID, "gui/background/screen_blue_no_inventory"); + public static final UITexture BACKGROUND_STAR = UITexture.fullImage(MODID, "gui/background/star"); + public static final UITexture BACKGROUND_GLOW_ORANGE = UITexture.fullImage(MODID, "gui/background/orange_glow"); + public static final UITexture BACKGROUND_GLOW_PURPLE = UITexture.fullImage(MODID, "gui/background/purple_glow"); + public static final UITexture BACKGROUND_GLOW_BLUE = UITexture.fullImage(MODID, "gui/background/blue_glow"); + public static final UITexture BACKGROUND_GLOW_GREEN = UITexture.fullImage(MODID, "gui/background/green_glow"); + public static final UITexture BACKGROUND_GLOW_WHITE = UITexture.fullImage(MODID, "gui/background/white_glow"); + public static final UITexture BACKGROUND_SPACE = UITexture.fullImage(MODID, "gui/background/space"); + + public static final UITexture BUTTON_STANDARD_16x16 = UITexture.fullImage(MODID, "gui/button/standard_16x16"); + public static final UITexture BUTTON_STANDARD_LIGHT_16x16 = UITexture + .fullImage(MODID, "gui/button/standard_light_16x16"); + public static final UITexture BUTTON_CELESTIAL_32x32 = UITexture.fullImage(MODID, "gui/button/celestial"); + public static final UITexture BUTTON_SPACE_32x16 = UITexture.fullImage(MODID, "gui/button/purple"); + public static final UITexture BUTTON_SPACE_PRESSED_32x16 = UITexture.fullImage(MODID, "gui/button/purple_pressed"); + public static final UITexture BUTTON_BOXED_CHECKMARK_18x18 = UITexture + .fullImage(MODID, "gui/button/boxed_checkmark"); + public static final UITexture BUTTON_BOXED_EXCLAMATION_POINT_18x18 = UITexture + .fullImage(MODID, "gui/button/boxed_exclamation_point"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_disabled"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_off"); + public static final UITexture OVERLAY_BUTTON_POWER_SWITCH_ON = UITexture + .fullImage(MODID, "gui/overlay_button/power_switch_on"); + public static final UITexture OVERLAY_BUTTON_HEAT_OFF = UITexture.fullImage(MODID, "gui/overlay_button/heat_off"); + public static final UITexture OVERLAY_BUTTON_HEAT_ON = UITexture.fullImage(MODID, "gui/overlay_button/heat_on"); + public static final UITexture[] OVERLAY_BUTTON_UNCERTAINTY = IntStream.range(0, 16) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/overlay_button/uncertainty/" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_disabled"); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_off"); + public static final UITexture OVERLAY_BUTTON_SAFE_VOID_ON = UITexture + .fullImage(MODID, "gui/overlay_button/safe_void_on"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_DISABLED = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_disabled"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_off"); + public static final UITexture OVERLAY_BUTTON_POWER_PASS_ON = UITexture + .fullImage(MODID, "gui/overlay_button/power_pass_on"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_ID = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_id"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_0 = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_0"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_1 = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_1"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_X = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_x"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_S = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_s"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_T = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_t"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_C = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_c"); + public static final UITexture OVERLAY_BUTTON_PARAMETRIZER_IF = UITexture + .fullImage(MODID, "gui/overlay_button/parametrizer_if"); + public static final UITexture OVERLAY_BUTTON_ARROW_BLUE_UP = UITexture + .fullImage(MODID, "gui/overlay_button/arrow_blue_up"); + public static final UITexture OVERLAY_BUTTON_BATTERY_ON = UITexture + .fullImage(MODID, "gui/overlay_button/battery_on"); + public static final UITexture OVERLAY_BUTTON_BATTERY_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/battery_off"); + public static final UITexture OVERLAY_BUTTON_FLAG = UITexture.fullImage(MODID, "gui/overlay_button/flag"); + public static final UITexture OVERLAY_CYCLIC_BLUE = UITexture.fullImage(MODID, "gui/overlay_button/cyclic_blue"); + public static final UITexture OVERLAY_EJECTION_LOCKED = UITexture + .fullImage(MODID, "gui/overlay_button/eject_disabled"); + public static final UITexture OVERLAY_EJECTION_ON = UITexture.fullImage(MODID, "gui/overlay_button/eject"); + + public static final UITexture OVERLAY_SLOT_RACK = UITexture.fullImage(MODID, "gui/overlay_slot/rack"); + public static final UITexture OVERLAY_SLOT_MESH = UITexture.fullImage(MODID, "gui/overlay_slot/mesh"); + + public static final UITexture PROGRESSBAR_RESEARCH_STATION_1 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_1"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_2 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_2"); + public static final UITexture PROGRESSBAR_RESEARCH_STATION_3 = UITexture + .fullImage(MODID, "gui/progressbar/research_station_3"); + public static final UITexture PROGRESSBAR_GODFORGE_PLASMA = UITexture + .fullImage(MODID, "gui/progressbar/godforge_plasma"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_background"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BLUE = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_blue"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_red"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_PURPLE = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_purple"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_rainbow"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_BLUE_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_blue_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RED_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_red_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_PURPLE_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_purple_inverted"); + public static final UITexture PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW_INVERTED = UITexture + .fullImage(MODID, "gui/progressbar/godforge_progressbar_rainbow_inverted"); + + public static final UITexture PICTURE_TECTECH_LOGO = UITexture.fullImage(MODID, "gui/picture/tectech_logo"); + public static final UITexture PICTURE_TECTECH_LOGO_DARK = UITexture + .fullImage(MODID, "gui/picture/tectech_logo_dark"); + public static final UITexture PICTURE_GODFORGE_LOGO = UITexture.fullImage(MODID, "gui/picture/gorge_logo"); + public static final UITexture PICTURE_RACK_LARGE = UITexture.fullImage(MODID, "gui/picture/rack_large"); + public static final UITexture PICTURE_HEAT_SINK = UITexture.fullImage(MODID, "gui/picture/heat_sink"); + public static final UITexture PICTURE_UNCERTAINTY_MONITOR = UITexture + .fullImage(MODID, "gui/picture/uncertainty/monitor"); + public static final UITexture PICTURE_UNCERTAINTY_INDICATOR = UITexture + .fullImage(MODID, "gui/picture/uncertainty/indicator"); + public static final UITexture PICTURE_UNCERTAINTY_SELECTED = UITexture + .fullImage(MODID, "gui/picture/uncertainty/selected"); + public static final UITexture[] PICTURE_UNCERTAINTY_VALID = IntStream.range(0, 9) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/picture/uncertainty/valid_" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_UNCERTAINTY_INVALID = IntStream.range(0, 9) + .mapToObj(i -> UITexture.fullImage(MODID, "gui/picture/uncertainty/invalid_" + i)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_HEAT_SINK_SMALL = UITexture.fullImage(MODID, "gui/picture/heat_sink_small"); + public static final UITexture PICTURE_PARAMETER_BLANK = UITexture.fullImage(MODID, "gui/picture/parameter_blank"); + public static final UITexture[] PICTURE_PARAMETER_BLUE = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_blue", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_CYAN = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_cyan", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_GREEN = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_green", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_ORANGE = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_orange", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture[] PICTURE_PARAMETER_RED = IntStream.range(0, 20) + .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_red", 158, 4, i * 8, 0, i * 8 + 6, 4)) + .collect(Collectors.toList()) + .toArray(new UITexture[0]); + public static final UITexture PICTURE_PARAMETER_GRAY = UITexture.fullImage(MODID, "gui/picture/parameter_gray"); + public static final UITexture PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE = UITexture + .fullImage(MODID, "gui/picture/uncertainty/monitor_multimachine"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_FULL = UITexture.fullImage(MODID, "gui/picture/connector"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_EMPTY = UITexture + .fullImage(MODID, "gui/picture/connector_empty"); + public static final UITexture PICTURE_UPGRADE_CONNECTOR_SWITCH = UITexture + .fullImage(MODID, "gui/picture/connector_switch"); + public static final UITexture SLOT_OUTLINE_GREEN = UITexture.fullImage(MODID, "gui/picture/green_selector"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CHARGE = UITexture + .fullImage(MODID, "gui/picture/milestone_charge"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CONVERSION = UITexture + .fullImage(MODID, "gui/picture/milestone_conversion"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CATALYST = UITexture + .fullImage(MODID, "gui/picture/milestone_catalyst"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_COMPOSITION = UITexture + .fullImage(MODID, "gui/picture/milestone_composition"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CHARGE_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_charge_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CONVERSION_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_conversion_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_CATALYST_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_catalyst_glow"); + public static final UITexture PICTURE_GODFORGE_MILESTONE_COMPOSITION_GLOW = UITexture + .fullImage(MODID, "gui/picture/milestone_composition_glow"); + public static final UITexture PICTURE_OVERLAY_BLUE = UITexture.fullImage(MODID, "gui/picture/overlay_blue"); + public static final UITexture PICTURE_OVERLAY_ORANGE = UITexture.fullImage(MODID, "gui/picture/overlay_orange"); + public static final UITexture PICTURE_OVERLAY_GREEN = UITexture.fullImage(MODID, "gui/picture/overlay_green"); + public static final UITexture PICTURE_OVERLAY_PURPLE = UITexture.fullImage(MODID, "gui/picture/overlay_purple"); + +} diff --git a/src/main/java/tectech/thing/item/ItemAstralArrayFabricator.java b/src/main/java/tectech/thing/item/ItemAstralArrayFabricator.java new file mode 100644 index 0000000000..2d09a4b6bd --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemAstralArrayFabricator.java @@ -0,0 +1,53 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.TecTech; +import tectech.thing.CustomItemList; + +public class ItemAstralArrayFabricator extends Item { + + public static ItemAstralArrayFabricator INSTANCE; + + private ItemAstralArrayFabricator() { + setHasSubtypes(false); + setUnlocalizedName("tm.itemAstralArrayFabricator"); + setTextureName(Reference.MODID + ":itemAstralArray"); + setCreativeTab(TecTech.creativeTabTecTech); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc1")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc2")); + aList.add(EnumChatFormatting.GRAY + translateToLocal("item.tm.itemAstralArrayFabricator.desc3")); + aList.add( + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("item.tm.itemAstralArrayFabricator.desc0")); + } + + public static void run() { + INSTANCE = new ItemAstralArrayFabricator(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.astralArrayFabricator.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } + +} diff --git a/src/main/java/tectech/thing/item/ItemEnderFluidLinkCover.java b/src/main/java/tectech/thing/item/ItemEnderFluidLinkCover.java new file mode 100644 index 0000000000..b1b5c32540 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemEnderFluidLinkCover.java @@ -0,0 +1,55 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemEnderFluidLinkCover extends Item { + + public static ItemEnderFluidLinkCover INSTANCE; + + private ItemEnderFluidLinkCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.enderfluidlinkcover"); + setTextureName(Reference.MODID + ":itemEnderFluidLinkCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.enderfluidlinkcover.desc.0")); // Ender-Fluid-Enables Machines! + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.enderfluidlinkcover.desc.1")); // Use on any side + // of a fluid tank + // to link it to + // the Ender + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.enderfluidlinkcover.desc.2")); // Ender Tanks so + // are laggy -Bot + // from the Chads + // of NH + } + + public static void run() { + INSTANCE = new ItemEnderFluidLinkCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.enderLinkFluidCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } +} diff --git a/src/main/java/tectech/thing/item/ItemEuMeterGT.java b/src/main/java/tectech/thing/item/ItemEuMeterGT.java new file mode 100644 index 0000000000..72928360f3 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemEuMeterGT.java @@ -0,0 +1,167 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.BaseMetaTileEntity; +import gregtech.api.metatileentity.implementations.MTECable; +import gregtech.api.util.GTUtility; +import tectech.Reference; +import tectech.TecTech; +import tectech.util.CommonValues; + +public class ItemEuMeterGT extends Item { + + public static ItemEuMeterGT INSTANCE; + + private ItemEuMeterGT() { + setMaxStackSize(1); + setUnlocalizedName("em.EuMeterGT"); + setTextureName(Reference.MODID + ":itemEuMeterGT"); + setCreativeTab(TecTech.creativeTabTecTech); + } + + @Override + public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ) { + final ForgeDirection side = ForgeDirection.getOrientation(ordinalSide); + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tTileEntity == null || aPlayer instanceof FakePlayer) { + return aPlayer instanceof EntityPlayerMP; + } + if (aPlayer instanceof EntityPlayerMP && !aPlayer.isSneaking() && tTileEntity instanceof IGregTechTileEntity) { + String clientLocale; + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + + if (tTileEntity instanceof BaseMetaTileEntity) { + GTUtility.sendChatToPlayer( + aPlayer, + EnumChatFormatting.AQUA + "----- X:" + + aX + + " Y:" + + aY + + " Z:" + + aZ + + " D:" + + aWorld.provider.dimensionId + + " S:" + + ordinalSide + + " -----"); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Stored_energy", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyStored()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GREEN + + (((BaseMetaTileEntity) tTileEntity).getUniversalEnergyCapacity())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Stored_EU", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getStoredEU()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GREEN + + (((BaseMetaTileEntity) tTileEntity).getEUCapacity())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getAverageElectricInput()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.YELLOW + + (((BaseMetaTileEntity) tTileEntity).getAverageElectricOutput())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO_(max)", clientLocale) + ": " + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getInputVoltage()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getOutputVoltage())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Average_IO_max", clientLocale) + ": " + + EnumChatFormatting.RED + + (((BaseMetaTileEntity) tTileEntity).getMaxSafeInput()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.RED + + (((BaseMetaTileEntity) tTileEntity).getMaxEnergyOutput())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Amperage_IO_(max)", clientLocale) + ": " + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getInputAmperage()) + + EnumChatFormatting.RESET + + '/' + + EnumChatFormatting.GOLD + + (((BaseMetaTileEntity) tTileEntity).getOutputAmperage())); + GTUtility.sendChatToPlayer( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Side_capabilities", clientLocale) + ": " + + (((BaseMetaTileEntity) tTileEntity).inputEnergyFrom(side) + ? translateToLocalFormatted("tt.keyword.input", clientLocale) + " " + : "") + + (((BaseMetaTileEntity) tTileEntity).outputsEnergyTo(side) + ? translateToLocalFormatted("tt.keyword.output", clientLocale) + : "")); + return true; + } else if (tTileEntity instanceof BaseMetaPipeEntity) { + if (((BaseMetaPipeEntity) tTileEntity).getMetaTileEntity() instanceof MTECable) { + ArrayList<String> tList = new ArrayList<>(); + GTUtility.getCoordinateScan(tList, aPlayer, aWorld, 1, aX, aY, aZ, side, hitX, hitY, hitZ); + for (String str : tList) { + GTUtility.sendChatToPlayer(aPlayer, str); + } + } + return true; + } + } + if (!(aPlayer instanceof EntityPlayerMP)) { + GTUtility.doSoundAtClient(new ResourceLocation(Reference.MODID, "fx_scan"), 1, 1.0F, aX, aY, aZ); + } + return false; + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.TEC_MARK_GENERAL); + aList.add(translateToLocal("item.em.EuMeterGT.desc.0")); // Measures basic EU related stuff + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.EuMeterGT.desc.1")); // Just right click on + // blocks. + } + + public static void run() { + INSTANCE = new ItemEuMeterGT(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + } +} diff --git a/src/main/java/tectech/thing/item/ItemParametrizerMemoryCard.java b/src/main/java/tectech/thing/item/ItemParametrizerMemoryCard.java new file mode 100644 index 0000000000..5039871764 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemParametrizerMemoryCard.java @@ -0,0 +1,233 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.Constants; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import tectech.Reference; +import tectech.TecTech; +import tectech.thing.CustomItemList; +import tectech.thing.metaTileEntity.hatch.MTEHatchParam; +import tectech.thing.metaTileEntity.hatch.MTEHatchParamText; +import tectech.thing.metaTileEntity.multi.base.Parameters; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 15.03.2017. + */ +public final class ItemParametrizerMemoryCard extends Item { + + public static ItemParametrizerMemoryCard INSTANCE; + private static IIcon locked, unlocked; + + private ItemParametrizerMemoryCard() { + setMaxStackSize(1); + setHasSubtypes(true); + setUnlocalizedName("em.parametrizerMemoryCard"); + setTextureName(Reference.MODID + ":itemParametrizerMemoryCardUnlocked"); + setCreativeTab(TecTech.creativeTabTecTech); + } + + @Override + public boolean onItemUseFirst(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, + int ordinalSide, float hitX, float hitY, float hitZ) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (!(aPlayer instanceof EntityPlayerMP)) return false; + if (!(tTileEntity instanceof IGregTechTileEntity)) return false; + aStack.stackSize = 1; + IMetaTileEntity metaTE = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + + if (metaTE instanceof MTEHatchParamText parametrizer) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to parametrizer + parametrizer.param = tNBT.getInteger("param"); + parametrizer.value0D = tNBT.getDouble("value0D"); + parametrizer.value1D = tNBT.getDouble("value1D"); + parametrizer.value0s = tNBT.getString("value0s"); + parametrizer.value1s = tNBT.getString("value1s"); + } else { + // read from parametrizer + NBTTagCompound newTag = new NBTTagCompound(); + newTag.setInteger("param", parametrizer.param); + newTag.setDouble("value0D", parametrizer.value0D); + newTag.setDouble("value1D", parametrizer.value1D); + newTag.setString("value0s", parametrizer.value0s); + newTag.setString("value1s", parametrizer.value1s); + aStack.setTagCompound(newTag); + } + return true; + } else if (metaTE instanceof MTEHatchParam parametrizer) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to parametrizer + parametrizer.param = tNBT.getInteger("param"); + parametrizer.value0D = tNBT.getDouble("value0D"); + parametrizer.value1D = tNBT.getDouble("value1D"); + } else { + // read from parametrizer + NBTTagCompound newTag = new NBTTagCompound(); + tNBT.setInteger("param", parametrizer.param); + tNBT.setDouble("value0D", parametrizer.value0D); + tNBT.setDouble("value1D", parametrizer.value1D); + aStack.setTagCompound(newTag); + } + return true; + } else if (metaTE instanceof TTMultiblockBase controller) { + if (aStack.getTagCompound() == null) { + aStack.setTagCompound(new NBTTagCompound()); + } + NBTTagCompound tNBT = aStack.getTagCompound(); + if (aStack.getItemDamage() == 1) { + // write to controller + if (tNBT.hasKey("paramList", Constants.NBT.TAG_LIST)) { + // from controller + NBTTagList tagList = tNBT.getTagList("paramList", Constants.NBT.TAG_COMPOUND); + for (int hatch = 0; hatch < 10; hatch++) { + NBTTagCompound tag = tagList.getCompoundTagAt(hatch); + controller.parametrization + .trySetParameters(hatch, tag.getDouble("value0D"), tag.getDouble("value1D")); + } + } else { + // from parametrizer + controller.parametrization.trySetParameters( + tNBT.getInteger("param"), + tNBT.getDouble("value0D"), + tNBT.getDouble("value1D")); + } + } else { + // read from controller + NBTTagCompound newTag = new NBTTagCompound(); + NBTTagList tagList = new NBTTagList(); + for (int hatch = 0; hatch < 10; hatch++) { + NBTTagCompound tagChild = new NBTTagCompound(); + Parameters.Group.ParameterIn[] parameters = controller.parametrization.getGroup(hatch).parameterIn; + if (parameters[0] != null) { + tagChild.setDouble("value0D", parameters[0].get()); + } + if (parameters[1] != null) { + tagChild.setDouble("value1D", parameters[1].get()); + } + tagList.appendTag(tagChild); + } + newTag.setTag("paramList", tagList); + aStack.setTagCompound(newTag); + } + return true; + } + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + if (aPlayer instanceof EntityPlayerMP && aPlayer.isSneaking()) { + aStack.stackSize = 1; + if (aStack.getItemDamage() == 1) { + aStack.setItemDamage(0); + } else { + aStack.setItemDamage(1); + } + return aStack; + } + return aStack; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + if (stack.getItemDamage() == 1) { + return StatCollector.translateToLocal("item.em.parametrizerMemoryCard.name.paste"); + } else { + return StatCollector.translateToLocal("item.em.parametrizerMemoryCard.name.copy"); + } + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + NBTTagCompound tNBT = aStack.getTagCompound(); + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.em.parametrizerMemoryCard.desc.0")); // Stores Parameters + + if (aStack.getItemDamage() == 1) { + // Use on Multiblock Controller to configure it + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.1")); + } else { + // Use on Multiblock Controller to store parameters + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.2")); + } + // Sneak right click to lock/unlock + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.em.parametrizerMemoryCard.desc.3")); + + double temp; + if (tNBT != null && tNBT.hasKey("param")) { + aList.add("Hatch ID: " + EnumChatFormatting.AQUA + tNBT.getInteger("param")); + temp = tNBT.getInteger("value0D"); + aList.add("Value 0D: " + EnumChatFormatting.AQUA + temp); + aList.add( + "Value 0B: " + EnumChatFormatting.AQUA + + TTUtility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 0s: " + EnumChatFormatting.AQUA + tNBT.getString("value0s")); + temp = tNBT.getInteger("value1D"); + aList.add("Value 1D: " + EnumChatFormatting.AQUA + temp); + aList.add( + "Value 1B: " + EnumChatFormatting.AQUA + + TTUtility.longBitsToShortString(Double.doubleToLongBits(temp))); + aList.add("Value 1s: " + EnumChatFormatting.AQUA + tNBT.getString("value1s")); + } + } + + public static void run() { + INSTANCE = new ItemParametrizerMemoryCard(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.parametrizerMemory.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + locked = iconRegister.registerIcon(Reference.MODID + ":itemParametrizerMemoryCardLocked"); + unlocked = itemIcon = iconRegister.registerIcon(getIconString()); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return locked; + } + return unlocked; + } + + @Override + public void getSubItems(Item item, CreativeTabs tab, List<ItemStack> list) { + ItemStack that = new ItemStack(this, 1); + that.setTagCompound(new NBTTagCompound()); + list.add(that); + } +} diff --git a/src/main/java/tectech/thing/item/ItemPowerPassUpgradeCover.java b/src/main/java/tectech/thing/item/ItemPowerPassUpgradeCover.java new file mode 100644 index 0000000000..49b5eaf923 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemPowerPassUpgradeCover.java @@ -0,0 +1,54 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemPowerPassUpgradeCover extends Item { + + public static ItemPowerPassUpgradeCover INSTANCE; + + private ItemPowerPassUpgradeCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.powerpassupgradecover"); + setTextureName(Reference.MODID + ":itemPowerPassUpgradeCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.powerpassupgradecover.desc.0")); // Add power pass functionality to TecTech + // Multiblocks + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.powerpassupgradecover.desc.1")); // Active + // transformer in + // a can?? + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.powerpassupgradecover.desc.2")); // Chain them up + // like Christmas + // lights! + } + + public static void run() { + INSTANCE = new ItemPowerPassUpgradeCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.powerPassUpgradeCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } +} diff --git a/src/main/java/tectech/thing/item/ItemRenderForgeOfGods.java b/src/main/java/tectech/thing/item/ItemRenderForgeOfGods.java new file mode 100644 index 0000000000..12248c4844 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemRenderForgeOfGods.java @@ -0,0 +1,59 @@ +package tectech.thing.item; + +import static tectech.rendering.EOH.EOHRenderingUtils.renderStarLayer; +import static tectech.rendering.EOH.EOHTileEntitySR.*; +import static tectech.thing.block.RenderForgeOfGods.disableOpaqueColorInversion; +import static tectech.thing.block.RenderForgeOfGods.enableOpaqueColorInversion; +import static tectech.thing.block.RenderForgeOfGods.enablePseudoTransparentColorInversion; + +import java.awt.Color; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.client.IItemRenderer; + +import org.lwjgl.opengl.GL11; + +public class ItemRenderForgeOfGods implements IItemRenderer { + + @Override + public boolean handleRenderType(ItemStack item, IItemRenderer.ItemRenderType type) { + return true; + } + + @Override + public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType type, ItemStack item, + IItemRenderer.ItemRendererHelper helper) { + return true; + } + + @Override + public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); + + if (type == IItemRenderer.ItemRenderType.INVENTORY) GL11.glRotated(180, 0, 1, 0); + else if (type == IItemRenderer.ItemRenderType.EQUIPPED + || type == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslated(0.5, 0.5, 0.5); + if (type == IItemRenderer.ItemRenderType.EQUIPPED) GL11.glRotated(90, 0, 1, 0); + } + + { + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_BLEND); + + // Innermost layer should be opaque + enableOpaqueColorInversion(); + renderStarLayer(0, STAR_LAYER_0, new Color(1.0f, 0.4f, 0.05f, 1.0f), 1.0f, 1); + disableOpaqueColorInversion(); + + enablePseudoTransparentColorInversion(); + renderStarLayer(1, STAR_LAYER_1, new Color(1.0f, 0.4f, 0.05f, 1.0f), 0.4f, 1); + renderStarLayer(2, STAR_LAYER_2, new Color(1.0f, 0.4f, 0.05f, 1.0f), 0.2f, 1); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } +} diff --git a/src/main/java/tectech/thing/item/ItemTeslaCoilCapacitor.java b/src/main/java/tectech/thing/item/ItemTeslaCoilCapacitor.java new file mode 100644 index 0000000000..99a2c8556a --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemTeslaCoilCapacitor.java @@ -0,0 +1,107 @@ +package tectech.thing.item; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemTeslaCoilCapacitor extends Item { + + public static ItemTeslaCoilCapacitor INSTANCE; + private static IIcon LVicon, MVicon, HVicon, EVicon, IVicon, LuVicon, ZPMicon; + + private ItemTeslaCoilCapacitor() { + setHasSubtypes(true); + setUnlocalizedName("tm.teslaCoilCapacitor"); + setTextureName(Reference.MODID + ":itemCapacitorLV"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + if (aStack.getItemDamage() >= 0 && aStack.getItemDamage() <= 6) { + aList.add( + translateToLocal("item.tm.teslaCoilCapacitor.desc.0") + " " + + V[aStack.getItemDamage() + 1] * 512 + + " " + + translateToLocal("item.tm.teslaCoilCapacitor.desc.1") + + " " + + V[aStack.getItemDamage() + 1] + + " EU/t"); // Stores 16384 EU in a tesla tower at 32 EU/t + } else { + aList.add(translateToLocal("item.tm.teslaCoilCapacitor.desc.2")); // Yeet this broken item into some spicy + // water! + } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCoilCapacitor.desc.3")); // Insert into a + // Capacitor hatch + // of a Tesla Tower + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCoilCapacitor.desc.4")); // Capacitors are + // the same thing as + // batteries, right? + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new ItemTeslaCoilCapacitor(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.teslaCapacitor.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + LVicon = itemIcon = iconRegister.registerIcon(getIconString()); + MVicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorMV"); + HVicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorHV"); + EVicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorEV"); + IVicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorIV"); + LuVicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorLuV"); + ZPMicon = iconRegister.registerIcon(Reference.MODID + ":itemCapacitorZPM"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + switch (damage) { + case 1: + return MVicon; + case 2: + return HVicon; + case 3: + return EVicon; + case 4: + return IVicon; + case 5: + return LuVicon; + case 6: + return ZPMicon; + default: + return LVicon; + } + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + for (int i = 0; i <= 6; i++) { + aList.add(new ItemStack(aItem, 1, i)); + } + } +} diff --git a/src/main/java/tectech/thing/item/ItemTeslaCoilComponent.java b/src/main/java/tectech/thing/item/ItemTeslaCoilComponent.java new file mode 100644 index 0000000000..d18acb9d86 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemTeslaCoilComponent.java @@ -0,0 +1,71 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemTeslaCoilComponent extends Item { + + public static ItemTeslaCoilComponent INSTANCE; + private static IIcon ultItemIcon; + + private ItemTeslaCoilComponent() { + setHasSubtypes(true); + setUnlocalizedName("tm.itemTeslaComponent"); + setTextureName(Reference.MODID + ":itemTeslaComponent"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.itemTeslaComponent.desc")); // Tesla bois need + // these! + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new ItemTeslaCoilComponent(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.teslaComponent.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + ultItemIcon = iconRegister.registerIcon(Reference.MODID + ":itemTeslaComponentUltimate"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return ultItemIcon; + } + return itemIcon; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 1)); + } +} diff --git a/src/main/java/tectech/thing/item/ItemTeslaCoilCover.java b/src/main/java/tectech/thing/item/ItemTeslaCoilCover.java new file mode 100644 index 0000000000..2cb4390522 --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemTeslaCoilCover.java @@ -0,0 +1,86 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.IIcon; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemTeslaCoilCover extends Item { + + public static ItemTeslaCoilCover INSTANCE; + private static IIcon ultItemIcon; + + private ItemTeslaCoilCover() { + setHasSubtypes(true); + setUnlocalizedName("tm.teslaCover"); + setTextureName(Reference.MODID + ":itemTeslaCover"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + switch (aStack.getItemDamage()) { + case 0: + aList.add(translateToLocal("item.tm.teslaCover.desc.0")); // Tesla-Enables Machines! + break; + case 1: + aList.add(translateToLocal("item.tm.teslaCover.desc.1")); // Tesla-Enables Machines! (BUT LOUDER!!) + break; + default: + aList.add(translateToLocal("item.tm.teslaCover.desc.2")); // Yeet this broken item into some spicy + // water! + break; + } + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCover.desc.3")); // Use on top of a machine + // to enable Tesla + // capabilities + aList.add(EnumChatFormatting.BLUE + translateToLocal("item.tm.teslaCover.desc.4")); // Who the hell uses cables + // anyway? + } + + @Override + public String getUnlocalizedName(ItemStack aStack) { + return getUnlocalizedName() + "." + getDamage(aStack); + } + + public static void run() { + INSTANCE = new ItemTeslaCoilCover(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.teslaCover.set(INSTANCE); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + ultItemIcon = iconRegister.registerIcon(Reference.MODID + ":itemTeslaCoverUltimate"); + } + + @Override + public IIcon getIconFromDamage(int damage) { + if (damage == 1) { + return ultItemIcon; + } + return itemIcon; + } + + @Override + public void getSubItems(Item aItem, CreativeTabs par2CreativeTabs, List<ItemStack> aList) { + aList.add(new ItemStack(aItem, 1, 0)); + aList.add(new ItemStack(aItem, 1, 1)); + } +} diff --git a/src/main/java/tectech/thing/item/ItemTeslaStaff.java b/src/main/java/tectech/thing/item/ItemTeslaStaff.java new file mode 100644 index 0000000000..f1c7045b0a --- /dev/null +++ b/src/main/java/tectech/thing/item/ItemTeslaStaff.java @@ -0,0 +1,52 @@ +package tectech.thing.item; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.List; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; + +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GTUtility; +import tectech.Reference; +import tectech.thing.CustomItemList; +import tectech.util.CommonValues; + +public final class ItemTeslaStaff extends Item { + + public static ItemTeslaStaff INSTANCE; + + private ItemTeslaStaff() { + setUnlocalizedName("tm.teslaStaff"); + setTextureName(Reference.MODID + ":itemTeslaStaff"); + } + + @Override + public void addInformation(ItemStack aStack, EntityPlayer ep, List<String> aList, boolean boo) { + aList.add(CommonValues.THETA_MOVEMENT); + aList.add(translateToLocal("item.tm.teslaStaff.desc")); + } + + @Override + public boolean onLeftClickEntity(ItemStack stack, EntityPlayer aPlayer, Entity entity) { + GTUtility.sendChatToPlayer(aPlayer, "Zapperoni!"); + if (!(aPlayer instanceof EntityPlayerMP)) { + double aX = aPlayer.posX; + double aY = aPlayer.posY; + double aZ = aPlayer.posZ; + GTUtility.doSoundAtClient(new ResourceLocation(Reference.MODID, "fx_scan"), 1, 1.0F, aX, aY, aZ); + } + return false; + } + + public static void run() { + INSTANCE = new ItemTeslaStaff(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.teslaStaff.set(INSTANCE); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/Textures.java b/src/main/java/tectech/thing/metaTileEntity/Textures.java new file mode 100644 index 0000000000..d9e6c47a28 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/Textures.java @@ -0,0 +1,318 @@ +package tectech.thing.metaTileEntity; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static gregtech.api.enums.Textures.BlockIcons.CustomIcon; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_8V_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_EV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_HV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_IV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_LuV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MAX_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_MV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_UV_TOP; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_BOTTOM; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_SIDE; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_ZPM_TOP; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_IN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_IN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_IN_MULTI; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_ON_WIRELESS; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_OUT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ENERGY_OUT_MULTI; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.objects.GTSidedTexture; +import gregtech.api.render.TextureFactory; + +public class Textures { + + private static final IIconContainer OVERLAY_ENERGY_IN_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_POWER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_POWER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_POWER"); + private static final IIconContainer OVERLAY_ENERGY_IN_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_IN_LASER"); + private static final IIconContainer OVERLAY_ENERGY_OUT_LASER = new CustomIcon("iconsets/OVERLAY_ENERGY_OUT_LASER"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_4A = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_4A"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_16A = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_16A"); + private static final IIconContainer OVERLAY_ENERGY_ON_WIRELESS_LASER = new CustomIcon( + "iconsets/OVERLAY_ENERGY_ON_WIRELESS_LASER"); + private static final IIconContainer MACHINE_UEV_SIDE = new CustomIcon("iconsets/MACHINE_UEV_SIDE"); + private static final IIconContainer MACHINE_UIV_SIDE = new CustomIcon("iconsets/MACHINE_UIV_SIDE"); + private static final IIconContainer MACHINE_UMV_SIDE = new CustomIcon("iconsets/MACHINE_UMV_SIDE"); + private static final IIconContainer MACHINE_UXV_SIDE = new CustomIcon("iconsets/MACHINE_UXV_SIDE"); + private static final IIconContainer MACHINE_MAXV_SIDE = new CustomIcon("iconsets/MACHINE_MAXV_SIDE"); + private static final IIconContainer MACHINE_UEV_TOP = new CustomIcon("iconsets/MACHINE_UEV_TOP"); + private static final IIconContainer MACHINE_UIV_TOP = new CustomIcon("iconsets/MACHINE_UIV_TOP"); + private static final IIconContainer MACHINE_UMV_TOP = new CustomIcon("iconsets/MACHINE_UMV_TOP"); + private static final IIconContainer MACHINE_UXV_TOP = new CustomIcon("iconsets/MACHINE_UXV_TOP"); + private static final IIconContainer MACHINE_MAXV_TOP = new CustomIcon("iconsets/MACHINE_MAXV_TOP"); + private static final IIconContainer MACHINE_UEV_BOTTOM = new CustomIcon("iconsets/MACHINE_UEV_BOTTOM"); + private static final IIconContainer MACHINE_UIV_BOTTOM = new CustomIcon("iconsets/MACHINE_UIV_BOTTOM"); + private static final IIconContainer MACHINE_UMV_BOTTOM = new CustomIcon("iconsets/MACHINE_UMV_BOTTOM"); + private static final IIconContainer MACHINE_UXV_BOTTOM = new CustomIcon("iconsets/MACHINE_UXV_BOTTOM"); + private static final IIconContainer MACHINE_MAXV_BOTTOM = new CustomIcon("iconsets/MACHINE_MAXV_BOTTOM"); + + private static final IIconContainer TESLA_TRANSCEIVER_TOP = new CustomIcon("iconsets/TESLA_TRANSCEIVER_TOP"); + + public static IIconContainer[] MACHINECASINGS_SIDE_TT = new IIconContainer[] { MACHINE_8V_SIDE, MACHINE_LV_SIDE, + MACHINE_MV_SIDE, MACHINE_HV_SIDE, MACHINE_EV_SIDE, MACHINE_IV_SIDE, MACHINE_LuV_SIDE, MACHINE_ZPM_SIDE, + MACHINE_UV_SIDE, MACHINE_MAX_SIDE, MACHINE_UEV_SIDE, MACHINE_UIV_SIDE, MACHINE_UMV_SIDE, MACHINE_UXV_SIDE, + MACHINE_MAXV_SIDE, }, + MACHINECASINGS_TOP_TT = new IIconContainer[] { MACHINE_8V_TOP, MACHINE_LV_TOP, MACHINE_MV_TOP, MACHINE_HV_TOP, + MACHINE_EV_TOP, MACHINE_IV_TOP, MACHINE_LuV_TOP, MACHINE_ZPM_TOP, MACHINE_UV_TOP, MACHINE_MAX_TOP, + MACHINE_UEV_TOP, MACHINE_UIV_TOP, MACHINE_UMV_TOP, MACHINE_UXV_TOP, MACHINE_MAXV_TOP, }, + MACHINECASINGS_BOTTOM_TT = new IIconContainer[] { MACHINE_8V_BOTTOM, MACHINE_LV_BOTTOM, MACHINE_MV_BOTTOM, + MACHINE_HV_BOTTOM, MACHINE_EV_BOTTOM, MACHINE_IV_BOTTOM, MACHINE_LuV_BOTTOM, MACHINE_ZPM_BOTTOM, + MACHINE_UV_BOTTOM, MACHINE_MAX_BOTTOM, MACHINE_UEV_BOTTOM, MACHINE_UIV_BOTTOM, MACHINE_UMV_BOTTOM, + MACHINE_UXV_BOTTOM, MACHINE_MAXV_BOTTOM, }; + public static ITexture[] OVERLAYS_ENERGY_IN_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_MULTI_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_MULTI, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_MULTI_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_MULTI, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_POWER_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_POWER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_POWER_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_POWER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_IN_LASER_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_IN_LASER, new short[] { 60, 60, 245, 0 }), }, + OVERLAYS_ENERGY_OUT_LASER_TT = new ITexture[] { + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 180, 180, 180, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 220, 220, 220, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 255, 100, 0, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 255, 255, 30, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 128, 128, 128, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 240, 240, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 220, 220, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 200, 200, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 180, 180, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 160, 160, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 140, 140, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 120, 120, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 100, 100, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 80, 80, 245, 0 }), + new GTRenderedTexture(OVERLAY_ENERGY_OUT_LASER, new short[] { 60, 60, 245, 0 }), }; + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_4A, new short[] { 255, 255, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_16A, new short[] { 255, 255, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS, new short[] { 25, 43, 255, 0 }) }; + + public static final ITexture[] OVERLAYS_ENERGY_IN_WIRELESS_LASER = { + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }), + TextureFactory.of(OVERLAY_ENERGY_ON_WIRELESS_LASER, new short[] { 255, 255, 255, 0 }) }; + + public static ITexture[][] MACHINE_CASINGS_TT = new ITexture[15][17]; + + public static ITexture TESLA_TRANSCEIVER_TOP_BA = new GTRenderedTexture(TESLA_TRANSCEIVER_TOP); + + public static void run() { + for (byte i = 0; i < MACHINE_CASINGS_TT.length; i++) { + for (byte j = 0; j < MACHINE_CASINGS_TT[i].length; j++) { + MACHINE_CASINGS_TT[i][j] = new GTSidedTexture( + MACHINECASINGS_BOTTOM_TT[i], + MACHINECASINGS_TOP_TT[i], + MACHINECASINGS_SIDE_TT[i], + Dyes.getModulation(j - 1, MACHINE_METAL.mRGBa)); + } + } + MACHINE_CASINGS = MACHINE_CASINGS_TT; + + // These will throw IndexOutOfBoundsException if one of the arrays are the wrong length + System.arraycopy(OVERLAYS_ENERGY_IN_TT, 0, OVERLAYS_ENERGY_IN, 0, OVERLAYS_ENERGY_IN_TT.length); + System.arraycopy(OVERLAYS_ENERGY_OUT_TT, 0, OVERLAYS_ENERGY_OUT, 0, OVERLAYS_ENERGY_OUT_TT.length); + System + .arraycopy(OVERLAYS_ENERGY_IN_MULTI_TT, 0, OVERLAYS_ENERGY_IN_MULTI, 0, OVERLAYS_ENERGY_IN_MULTI_TT.length); + System.arraycopy( + OVERLAYS_ENERGY_OUT_MULTI_TT, + 0, + OVERLAYS_ENERGY_OUT_MULTI, + 0, + OVERLAYS_ENERGY_OUT_MULTI_TT.length); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCapacitor.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCapacitor.java new file mode 100644 index 0000000000..d3cfb21c29 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCapacitor.java @@ -0,0 +1,241 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.Reference; +import tectech.TecTech; +import tectech.loader.TecTechConfig; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 03.04.2017. + */ +public class MTEHatchCapacitor extends MTEHatch implements IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon TM_H; + private static Textures.BlockIcons.CustomIcon TM_H_ACTIVE; + private static final Map<String, MTEHatchCapacitor.CapacitorComponent> componentBinds = new HashMap<>(); + + public MTEHatchCapacitor(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 16, + new String[] { CommonValues.THETA_MOVEMENT, translateToLocal("gt.blockmachines.hatch.capacitor.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.capacitor.desc.1") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchCapacitor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 16, aDescription, aTextures); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + TM_H_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_CAPS_ACTIVE"); + TM_H = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_CAPS"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(TM_H_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(TM_H) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchCapacitor(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public int getSizeInventory() { + return getBaseMetaTileEntity().isActive() ? 0 : mInventory.length; + } + + public long[] getCapacitors() { + long tier = -1; + long tCurrent = 0; + long tEnergyMax = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + CapacitorComponent cap = componentBinds.get(TTUtility.getUniqueIdentifier(mInventory[i])); + if (cap != null && cap.tier > tier) { + tier = cap.tier; + } + } + if (tier >= 0) { + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + CapacitorComponent cap = componentBinds.get(TTUtility.getUniqueIdentifier(mInventory[i])); + if (cap == null) { + continue; + } + if (cap.tier < tier) { + if (getBaseMetaTileEntity().isActive()) { + mInventory[i] = null; + getBaseMetaTileEntity().setOnFire(); + } + } else { + tCurrent += cap.current; + tEnergyMax += cap.energyMax; + } + } + } + return new long[] { tier, tCurrent, tEnergyMax }; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + SlotGroup.ofItemHandler(inventoryHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .slotCreator(index -> new BaseSlot(inventoryHandler, index) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive(); + } + }) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(52, 7)); + } + + public static void run() { + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.0", 0, 1, V[1] * 512); // LV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.1", 1, 1, V[2] * 512); // MV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.2", 2, 1, V[3] * 512); // HV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.3", 3, 1, V[4] * 512); // EV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.4", 4, 1, V[5] * 512); // IV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.5", 5, 1, V[6] * 512); // LuV + // Capacitor + new MTEHatchCapacitor.CapacitorComponent(Reference.MODID + ":item.tm.teslaCoilCapacitor.6", 6, 1, V[7] * 512); // ZPM + // Capacitor + } + + public static class CapacitorComponent implements Comparable<MTEHatchCapacitor.CapacitorComponent> { + + private final String unlocalizedName; + private final long tier, current, energyMax; + + CapacitorComponent(ItemStack is, long tier, long current, long energyMax) { + this(TTUtility.getUniqueIdentifier(is), tier, current, energyMax); + } + + CapacitorComponent(String is, long tier, long current, long energyMax) { + unlocalizedName = is; + this.tier = tier; + this.current = current; + this.energyMax = energyMax; + componentBinds.put(unlocalizedName, this); + if (TecTechConfig.DEBUG_MODE) { + TecTech.LOGGER.info("Tesla Capacitor registered: " + unlocalizedName); + } + } + + @Override + public int compareTo(CapacitorComponent o) { + return unlocalizedName.compareTo(o.unlocalizedName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof CapacitorComponent) { + return compareTo((CapacitorComponent) obj) == 0; + } + return false; + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeData.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeData.java new file mode 100644 index 0000000000..ed162e59e6 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeData.java @@ -0,0 +1,129 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import tectech.mechanics.dataTransport.QuantumDataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.thing.metaTileEntity.pipe.MTEPipeData; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class MTEHatchCreativeData extends MTEHatchDataConnector<QuantumDataPacket> { + + public MTEHatchCreativeData(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.debug.tt.data.desc.0"), + translateToLocal("gt.blockmachines.debug.tt.data.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.data.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchCreativeData(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchCreativeData(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof MTEHatchDataInput) { + ((MTEHatchDataInput) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof MTEPipeData) { + ((MTEPipeData) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof MTEHatchDataInput && ((MTEHatchDataInput) meta).getColorization() == color + && ((MTEHatchDataInput) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (CommonValues.MOVE_AT == aTick % 20) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + getBaseMetaTileEntity().setActive(true); + if (q == null) q = new QuantumDataPacket(0xFFFFFFFFL); + moveAround(aBaseMetaTileEntity); + } else { + q = null; + getBaseMetaTileEntity().setActive(false); + } + } + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeMaintenance.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeMaintenance.java new file mode 100644 index 0000000000..28d631e606 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeMaintenance.java @@ -0,0 +1,90 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.objects.GTRenderedTexture; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEHatchCreativeMaintenance extends MTEHatchMaintenance { + + private static Textures.BlockIcons.CustomIcon face; + + public MTEHatchCreativeMaintenance(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + TTUtility.setTier(aTier, this); + } + + public MTEHatchCreativeMaintenance(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures, false); + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.THETA_MOVEMENT, + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.0"), // For automatically maintaining + // Multiblocks + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.1"), // Does fix everything but itself. + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.maintenance.desc.2") // Fixing is + // for plebs! + }; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + face = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_FULLAUTOMAINTENANCE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(face) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(face) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchCreativeMaintenance(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + this.mWrench = this.mScrewdriver = this.mSoftHammer = this.mHardHammer = this.mCrowbar = this.mSolderingTool = true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer, ForgeDirection side, + float aX, float aY, float aZ) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeUncertainty.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeUncertainty.java new file mode 100644 index 0000000000..953506e4d9 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchCreativeUncertainty.java @@ -0,0 +1,56 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.EnumChatFormatting; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import tectech.util.CommonValues; + +public class MTEHatchCreativeUncertainty extends MTEHatchUncertainty { + + public MTEHatchCreativeUncertainty(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public MTEHatchCreativeUncertainty(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEHatchCreativeUncertainty(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.debug.tt.certain.desc.0"), // Feeling + // certain, + // for + // sure + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.debug.tt.certain.desc.1") // Schrödinger's cat escaped the + // box + }; + } + + @Override + public void regenerate() { + // no-op + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && (aTick % 100) == 0) { + if (mode == 0) { + aBaseMetaTileEntity.setActive(false); + status = -128; + } else { + aBaseMetaTileEntity.setActive(true); + compute(); + } + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java new file mode 100644 index 0000000000..484fcdaff1 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataConnector.java @@ -0,0 +1,198 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.mechanics.dataTransport.DataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 11.12.2016. + */ +public abstract class MTEHatchDataConnector<T extends DataPacket> extends MTEHatch implements IConnectsToDataPipe { + + public static Textures.BlockIcons.CustomIcon EM_D_SIDES; + public static Textures.BlockIcons.CustomIcon EM_D_ACTIVE; + public static Textures.BlockIcons.CustomIcon EM_D_CONN; + + private String clientLocale = "en_US"; + + public T q; + + public short id = -1; + + protected MTEHatchDataConnector(int aID, String aName, String aNameRegional, int aTier, String[] descr) { + super(aID, aName, aNameRegional, aTier, 0, descr); + TTUtility.setTier(aTier, this); + } + + protected MTEHatchDataConnector(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_D_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_ACTIVE"); + EM_D_SIDES = new Textures.BlockIcons.CustomIcon("iconsets/OVERLAY_EM_D_SIDES"); + EM_D_CONN = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA_CONN"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setShort("eID", id); + if (q != null) { + aNBT.setTag("eDATA", q.toNbt()); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + id = aNBT.getShort("eID"); + if (aNBT.hasKey("eDATA")) { + q = loadPacketFromNBT(aNBT.getCompoundTag("eDATA")); + } + } + + protected abstract T loadPacketFromNBT(NBTTagCompound nbt); + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (CommonValues.MOVE_AT == aTick % 20) { + if (q == null) { + getBaseMetaTileEntity().setActive(false); + } else { + getBaseMetaTileEntity().setActive(true); + moveAround(aBaseMetaTileEntity); + } + } + } + } + + public abstract void moveAround(IGregTechTileEntity aBaseMetaTileEntity); + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + if (id > 0) { + return new String[] { + translateToLocalFormatted("tt.keyword.ID", clientLocale) + ": " + EnumChatFormatting.AQUA + id, + translateToLocalFormatted("tt.keyword.Content", clientLocale) + ": " + + EnumChatFormatting.AQUA + + (q != null ? q.getContentString() : 0), + translateToLocalFormatted("tt.keyword.PacketHistory", clientLocale) + ": " + + EnumChatFormatting.RED + + (q != null ? q.getTraceSize() : 0), }; + } + return new String[] { + translateToLocalFormatted("tt.keyword.Content", clientLocale) + ": " + + EnumChatFormatting.AQUA + + (q != null ? q.getContentString() : 0), + translateToLocalFormatted("tt.keyword.PacketHistory", clientLocale) + ": " + + EnumChatFormatting.RED + + (q != null ? q.getTraceSize() : 0), }; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataInput.java new file mode 100644 index 0000000000..57ecd948b5 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataInput.java @@ -0,0 +1,101 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import tectech.mechanics.dataTransport.QuantumDataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class MTEHatchDataInput extends MTEHatchDataConnector<QuantumDataPacket> { + + private boolean delDelay = true; + + public MTEHatchDataInput(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.datain.desc.0"), + translateToLocal("gt.blockmachines.hatch.datain.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.datain.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchDataInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDataInput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + return null; + } + + public void setContents(QuantumDataPacket qIn) { + if (qIn == null) { + this.q = null; + } else { + if (qIn.getContent() > 0) { + this.q = qIn; + delDelay = true; + } else { + this.q = null; + } + } + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + if (delDelay) { + delDelay = false; + } else { + setContents(null); + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java new file mode 100644 index 0000000000..533c9cb695 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsInput.java @@ -0,0 +1,255 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_ACTIVE; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_CONN; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_SIDES; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; +import gregtech.api.objects.GTRenderedTexture; +import tectech.mechanics.dataTransport.InventoryDataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.recipe.TTRecipeAdder; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEHatchDataItemsInput extends MTEHatchDataAccess implements IConnectsToDataPipe { + + public boolean delDelay = true; + private ItemStack[] stacks; + + private String clientLocale = "en_US"; + + public MTEHatchDataItemsInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + TTUtility.setTier(aTier, this); + } + + public MTEHatchDataItemsInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDataItemsInput(this.mName, this.mTier, mDescriptionArray, this.mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + return null; + } + + public void setContents(InventoryDataPacket iIn) { + if (iIn == null) { + stacks = null; + } else { + if (iIn.getContent().length > 0) { + stacks = iIn.getContent(); + delDelay = true; + } else { + stacks = null; + } + } + } + + @Override + public void onRemoval() { + stacks = null; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + NBTTagCompound stacksTag = new NBTTagCompound(); + if (stacks != null) { + stacksTag.setInteger("count", stacks.length); + for (int i = 0; i < stacks.length; i++) { + stacksTag.setTag(Integer.toString(i), stacks[i].writeToNBT(new NBTTagCompound())); + } + } + aNBT.setTag("data_stacks", stacksTag); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + NBTTagCompound stacksTag = aNBT.getCompoundTag("data_stacks"); + int count = stacksTag.getInteger("count"); + if (count > 0) { + ArrayList<ItemStack> stacks = new ArrayList<>(); + for (int i = 0; i < count; i++) { + ItemStack stack = ItemStack.loadItemStackFromNBT(stacksTag.getCompoundTag(Integer.toString(i))); + if (stack != null) { + stacks.add(stack); + } + } + if (stacks.size() > 0) { + this.stacks = stacks.toArray(TTRecipeAdder.nullItem); + } + } + } + + @Override + public int getSizeInventory() { + return stacks != null ? stacks.length : 0; + } + + @Override + public ItemStack getStackInSlot(int aIndex) { + return stacks != null && aIndex < stacks.length ? stacks[aIndex] : null; + } + + @Override + public List<ItemStack> getInventoryItems(Predicate<ItemStack> filter) { + if (stacks == null) return Collections.emptyList(); + return Arrays.stream(stacks) + .filter(stack -> stack != null && filter.test(stack)) + .collect(Collectors.toList()); + } + + @Override + public boolean shouldDropItemAt(int index) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (CommonValues.MOVE_AT == aTick % 20) { + if (stacks == null) { + getBaseMetaTileEntity().setActive(false); + } else { + getBaseMetaTileEntity().setActive(true); + if (delDelay) { + delDelay = false; + } else { + setContents(null); + } + } + } + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.datainass.desc.0"), + translateToLocal("gt.blockmachines.hatch.datainass.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.datainass.desc.2") }; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { translateToLocalFormatted("tt.keyphrase.Content_Stack_Count", clientLocale) + ": " + + (stacks == null ? 0 : stacks.length) }; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsOutput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsOutput.java new file mode 100644 index 0000000000..8a2c005fec --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataItemsOutput.java @@ -0,0 +1,133 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import tectech.mechanics.dataTransport.InventoryDataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.thing.metaTileEntity.pipe.MTEPipeData; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEHatchDataItemsOutput extends MTEHatchDataConnector<InventoryDataPacket> { + + public MTEHatchDataItemsOutput(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.dataoutass.desc.0"), + translateToLocal("gt.blockmachines.hatch.dataoutass.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.dataoutass.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchDataItemsOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDataItemsOutput(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + protected InventoryDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new InventoryDataPacket(nbt); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof MTEHatchDataItemsInput) { + ((MTEHatchDataItemsInput) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof MTEPipeData) { + ((MTEPipeData) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof MTEHatchDataItemsInput && ((MTEHatchDataItemsInput) meta).getColorization() == color + && ((MTEHatchDataItemsInput) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataOutput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataOutput.java new file mode 100644 index 0000000000..094423cb0a --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDataOutput.java @@ -0,0 +1,113 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import tectech.mechanics.dataTransport.QuantumDataPacket; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.thing.metaTileEntity.pipe.MTEPipeData; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 27.10.2016. + */ +public class MTEHatchDataOutput extends MTEHatchDataConnector<QuantumDataPacket> { + + public MTEHatchDataOutput(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.dataout.desc.0"), + translateToLocal("gt.blockmachines.hatch.dataout.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.dataout.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchDataOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDataOutput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + protected QuantumDataPacket loadPacketFromNBT(NBTTagCompound nbt) { + return new QuantumDataPacket(nbt); + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return isOutputFacing(side); + } + + @Override + public void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + IConnectsToDataPipe current = this, source = this, next; + int range = 0; + while ((next = current.getNext(source)) != null && range++ < 1000) { + if (next instanceof MTEHatchDataInput) { + ((MTEHatchDataInput) next).setContents(q); + break; + } + source = current; + current = next; + } + q = null; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source /* ==this */) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + byte color = base.getColorization(); + if (color < 0) { + return null; + } + IGregTechTileEntity next = base.getIGregTechTileEntityAtSide(base.getFrontFacing()); + if (next == null) { + return null; + } + IMetaTileEntity meta = next.getMetaTileEntity(); + if (meta instanceof MTEPipeData) { + ((MTEPipeData) meta).markUsed(); + return (IConnectsToDataPipe) meta; + } else if (meta instanceof MTEHatchDataInput && ((MTEHatchDataInput) meta).getColorization() == color + && ((MTEHatchDataInput) meta).canConnectData( + base.getFrontFacing() + .getOpposite())) { + return (IConnectsToDataPipe) meta; + } + return null; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoMulti.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoMulti.java new file mode 100644 index 0000000000..e5f457ccc2 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoMulti.java @@ -0,0 +1,127 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class MTEHatchDynamoMulti extends MTEHatch { + + public final int maxAmperes; + public int Amperes; + + public MTEHatchDynamoMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.dynamomulti.desc.0") }); // Multiple Ampere Energy + // Extractor for Multiblocks + Amperes = maxAmperes = aAmp; + TTUtility.setTier(aTier, this); + } + + public MTEHatchDynamoMulti(String aName, int aTier, int aAmp, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + Amperes = maxAmperes = aAmp; + } + + public MTEHatchDynamoMulti(int aID, String aName, String aNameRegional, int aTier, int i, String[] description, + int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = maxAmperes = aAmp; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 128L * Amperes; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier] * 4L * Amperes; + } + + @Override + public long maxAmperesOut() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDynamoMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java new file mode 100644 index 0000000000..2a72fb31f2 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchDynamoTunnel.java @@ -0,0 +1,286 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GTUtility; +import tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import tectech.thing.metaTileEntity.Textures; +import tectech.thing.metaTileEntity.pipe.MTEPipeEnergy; +import tectech.thing.metaTileEntity.pipe.MTEPipeEnergyMirror; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class MTEHatchDynamoTunnel extends MTEHatchDynamoMulti implements IConnectsToEnergyTunnel { + + public MTEHatchDynamoTunnel(int ID, String unlocalisedName, String localisedName, int tier, int amps) { + super( + ID, + unlocalisedName, + localisedName, + tier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.0"), + translateToLocal("gt.blockmachines.hatch.dynamotunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(amps * V[tier]) + + EnumChatFormatting.RESET + + " EU/t" }, + amps); + + TTUtility.setTier(tier, this); + } + + public MTEHatchDynamoTunnel(String aName, int aTier, int aAmp, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier]; + } + + @Override + public long maxEUOutput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return V[mTier] * 24L * Amperes; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.LASER; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchDynamoTunnel(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (aTick % 20); + if (CommonValues.TRANSFER_AT == Tick) { + if (aBaseMetaTileEntity.getStoredEU() > 0) { + setEUVar(aBaseMetaTileEntity.getStoredEU() - Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0) { + setEUVar(0); + } + } + if (aBaseMetaTileEntity.getStoredEU() > getMinimumStoredEU()) { + moveAround(aBaseMetaTileEntity); + } + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (Amperes != maxAmperes) { + aNBT.setInteger("amperes", Amperes); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + int savedAmperes = aNBT.getInteger("amperes"); + if (savedAmperes != 0) { + Amperes = savedAmperes; + } + } + + private void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + byte color = getBaseMetaTileEntity().getColorization(); + if (color < 0) { + return; + } + final ForgeDirection front = aBaseMetaTileEntity.getFrontFacing(); + ForgeDirection opposite = front.getOpposite(); + for (short dist = 1; dist < 1000; dist++) { + + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity + .getIGregTechTileEntityAtSideAndDistance(front, dist); + if (tGTTileEntity != null && tGTTileEntity.getColorization() == color) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + // If we hit a mirror, use the mirror's view instead + if (aMetaTileEntity instanceof MTEPipeEnergyMirror tMirror) { + + tGTTileEntity = tMirror.bendAround(opposite); + if (tGTTileEntity == null) { + break; + } else { + aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + opposite = tMirror.getChainedFrontFacing(); + } + } + + if (aMetaTileEntity instanceof MTEHatchEnergyTunnel && opposite == tGTTileEntity.getFrontFacing()) { + if (maxEUOutput() > ((MTEHatchEnergyTunnel) aMetaTileEntity).maxEUInput()) { + aMetaTileEntity.doExplosion(maxEUOutput()); + setEUVar(aBaseMetaTileEntity.getStoredEU() - maxEUOutput()); + return; + } else if (maxEUOutput() == ((MTEHatchEnergyTunnel) aMetaTileEntity).maxEUInput()) { + long diff = Math.min( + Amperes * 20L * maxEUOutput(), + Math.min( + ((MTEHatchEnergyTunnel) aMetaTileEntity).maxEUStore() + - aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU(), + aBaseMetaTileEntity.getStoredEU())); + + setEUVar(aBaseMetaTileEntity.getStoredEU() - diff); + + ((MTEHatchEnergyTunnel) aMetaTileEntity).setEUVar( + aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU() + diff); + } + return; + } else if (aMetaTileEntity instanceof MTEPipeEnergy) { + if (((MTEPipeEnergy) aMetaTileEntity).connectionCount < 2) { + return; + } else { + ((MTEPipeEnergy) aMetaTileEntity).markUsed(); + } + } else { + return; + } + } else { + if (tGTTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tGTTileEntity).getPowerLogic(opposite); + if (logic == null || !logic.canUseLaser() || opposite != tGTTileEntity.getFrontFacing()) { + return; + } + + long ampsUsed = logic.injectEnergy(maxEUOutput(), Amperes); + setEUVar(aBaseMetaTileEntity.getStoredEU() - ampsUsed * maxEUOutput()); + } + return; + } + } else { + return; + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + final int x = getGUIWidth() / 2 - 37; + final int y = getGUIHeight() / 5 - 7; + builder.widget( + TextWidget.localised("GT5U.machines.laser_hatch.amperage") + .setPos(x, y) + .setSize(74, 14)) + .widget( + new NumericWidget().setSetter(val -> Amperes = (int) val) + .setGetter(() -> Amperes) + .setBounds(1, maxAmperes) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(x, y + 16) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + } + + @Override + public boolean canConnect(ForgeDirection side) { + return isOutputFacing(side); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyMulti.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyMulti.java new file mode 100644 index 0000000000..12112b0290 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyMulti.java @@ -0,0 +1,133 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class MTEHatchEnergyMulti extends MTEHatch { + + public final int maxAmperes; + public int Amperes; + + public MTEHatchEnergyMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.hatch.energymulti.desc.0"), + translateToLocalFormatted("gt.blockmachines.hatch.energymulti.desc.2", aAmp + (aAmp >> 2)), + translateToLocalFormatted("gt.blockmachines.hatch.energymulti.desc.3", aAmp) }); + Amperes = maxAmperes = aAmp; + TTUtility.setTier(aTier, this); + } + + public MTEHatchEnergyMulti(String aName, int aTier, int aAmp, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + Amperes = maxAmperes = aAmp; + } + + public MTEHatchEnergyMulti(int aID, String aName, String aNameRegional, int aTier, int i, String[] description, + int aAmp) { + super(aID, aName, aNameRegional, aTier, 0, description); + Amperes = maxAmperes = aAmp; + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return 128L * Amperes; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier] * 4L * Amperes; + } + + @Override + public long maxAmperesIn() { + return Amperes + (Amperes >> 2); + } + + @Override + public long maxWorkingAmperesIn() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchEnergyMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyTunnel.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyTunnel.java new file mode 100644 index 0000000000..f01415606b --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchEnergyTunnel.java @@ -0,0 +1,203 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.util.GTUtility; +import tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 16.12.2016. + */ +public class MTEHatchEnergyTunnel extends MTEHatchEnergyMulti implements IConnectsToEnergyTunnel { + + public MTEHatchEnergyTunnel(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.hatch.energytunnel.desc.0"), + translateToLocal("gt.blockmachines.hatch.energytunnel.desc.1") + ": " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(aAmp * V[aTier]) + + EnumChatFormatting.RESET + + " EU/t" }, + aAmp); // Energy injecting terminal for Multiblocks + TTUtility.setTier(aTier, this); + } + + public MTEHatchEnergyTunnel(String aName, int aTier, int aAmp, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_LASER_TT[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, Textures.OVERLAYS_ENERGY_IN_LASER_TT[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier]; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return V[mTier] * 24L * Amperes; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.LASER; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchEnergyTunnel(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (Amperes != maxAmperes) { + aNBT.setInteger("amperes", Amperes); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + int savedAmperes = aNBT.getInteger("amperes"); + if (savedAmperes != 0) { + Amperes = savedAmperes; + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + final int x = getGUIWidth() / 2 - 37; + final int y = getGUIHeight() / 5 - 7; + builder.widget( + TextWidget.localised("GT5U.machines.laser_hatch.amperage") + .setPos(x, y) + .setSize(74, 14)) + .widget( + new NumericWidget().setSetter(val -> Amperes = (int) val) + .setGetter(() -> Amperes) + .setBounds(1, maxAmperes) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(x, y + 16) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + } + + @Override + public boolean canConnect(ForgeDirection side) { + return isInputFacing(side); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + byte Tick = (byte) (aTick % 20); + if (CommonValues.TRANSFER_AT == Tick) { + if (aBaseMetaTileEntity.getStoredEU() > 0) { + setEUVar(aBaseMetaTileEntity.getStoredEU() - Amperes); + if (aBaseMetaTileEntity.getStoredEU() < 0) { + setEUVar(0); + } + } + } + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchObjectHolder.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchObjectHolder.java new file mode 100644 index 0000000000..201b54e24c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchObjectHolder.java @@ -0,0 +1,176 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.thing.gui.TecTechUITextures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 03.04.2017. + */ +public class MTEHatchObjectHolder extends MTEHatch implements IAddGregtechLogo { + + private static Textures.BlockIcons.CustomIcon EM_H; + private static Textures.BlockIcons.CustomIcon EM_H_ACTIVE; + + public MTEHatchObjectHolder(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 1, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.holder.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.holder.desc.1") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchObjectHolder(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 1, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_H_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER_ACTIVE"); + EM_H = new Textures.BlockIcons.CustomIcon("iconsets/EM_HOLDER"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(EM_H_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(EM_H) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchObjectHolder(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return facing.offsetY == 0; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + // if(aBaseMetaTileEntity.isActive()) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + // else if(heat>0) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + // else + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO) + .setSize(18, 18) + .setPos(151, 63)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK) + .setPos(46, 17) + .setSize(84, 60)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_RACK_LARGE) + .setPos(68, 27) + .setSize(40, 40)) + .widget(new SlotWidget(new BaseSlot(inventoryHandler, 0) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive(); + } + }).setPos(79, 38)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> getBaseMetaTileEntity().isActive() ? TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON + : TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isActive(), + val -> getBaseMetaTileEntity().setActive(val))); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java new file mode 100644 index 0000000000..259bc4d164 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParam.java @@ -0,0 +1,554 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.atomic.AtomicInteger; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.TecTech; +import tectech.thing.gui.TecTechUITextures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class MTEHatchParam extends MTEHatch implements IAddGregtechLogo, IAddUIWidgets { + + public int pointer = 0; + public int param = -1; + public double value0D = 0; + public double value1D = 0; + public double input0D = 0; + public double input1D = 0; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + + private String clientLocale = "en_US"; + + public MTEHatchParam(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + EnumChatFormatting.DARK_RED + + "Deprecated; Now you can set parameter by clicking LED on multiblock GUI.", + EnumChatFormatting.DARK_RED + + "If it doesn't work, try removing Parametrizer from multiblock structure." }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchParam(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/PARAM"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/PARAM_ACTIVE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(ScreenON) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(ScreenOFF) }; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEHatchParam(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Parametrizer", clientLocale) + " " + + translateToLocalFormatted("tt.keyword.ID", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + param, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0D: " + EnumChatFormatting.AQUA + value0D, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1D: " + EnumChatFormatting.BLUE + value1D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 0D: " + EnumChatFormatting.GOLD + input0D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 1D: " + + EnumChatFormatting.YELLOW + + input1D, }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("ePointer", pointer); + aNBT.setDouble("eValue0D", value0D); + aNBT.setDouble("eValue1D", value1D); + aNBT.setDouble("eInput0D", input0D); + aNBT.setDouble("eInput1D", input1D); + aNBT.setInteger("eParam", param); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + pointer = aNBT.getInteger("ePointer"); + if (aNBT.hasKey("eFloats") || aNBT.hasKey("eValue0i") + || aNBT.hasKey("eValue1i") + || aNBT.hasKey("eInput0i") + || aNBT.hasKey("eInput1i")) { + boolean usesFloat = aNBT.getBoolean("eFloats"); + if (usesFloat) { + value0D = Double.longBitsToDouble(aNBT.getLong("eValue0i")); + value1D = Double.longBitsToDouble(aNBT.getLong("eValue1i")); + input0D = Double.longBitsToDouble(aNBT.getLong("eInput0i")); + input1D = Double.longBitsToDouble(aNBT.getLong("eInput1i")); + } else { + value0D = aNBT.getLong("eValue0i"); + value1D = aNBT.getLong("eValue1i"); + input0D = aNBT.getLong("eInput0i"); + input1D = aNBT.getLong("eInput1i"); + } + } else { + value0D = aNBT.getDouble("eValue0D"); + value1D = aNBT.getDouble("eValue1D"); + input0D = aNBT.getDouble("eInput0D"); + input1D = aNBT.getDouble("eInput1D"); + } + param = aNBT.getInteger("eParam"); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(112, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final boolean isAdvanced = mTier > 5; + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(43, 4) + .setSize(90, 72)); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 16 : 4, + 7, + 4, + GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -16 : -4); + } + } else { + value0D -= shift ? 4096 : 256; + } + }, 7, 22, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -16 : -4); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 4096 : 256; + } + }, 7, 40, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } else { + value0D = Double.longBitsToDouble(0xFFFF_FFFF_FFFF_FFFFL); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp |= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp |= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 4096 : 256; + value1D /= shift ? 4096 : 256; + } + }, + 7, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_S : GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param -= shift ? 2 : 1, + 25, + 4, + GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? -2 : -1); + } + } else { + value0D -= shift ? 16 : 1; + } + }, 25, 22, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? -2 : -1); + } else { + secondRow.set(true); + } + } else { + value1D -= shift ? 16 : 1; + } + }, 25, 40, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(0); + } else { + value0D = Double.longBitsToDouble(0); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp &= ~(1L << (long) columnPointer.get()); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp &= ~(1L << (long) columnPointer.get()); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D /= shift ? 16 : 2; + value1D /= shift ? 16 : 2; + } + }, + 25, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_C : GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_X); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 2 : 1, + 133, + 4, + GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 2 : 1); + } + } else { + value0D += shift ? 16 : 1; + } + }, 133, 22, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 2 : 1); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 16 : 1; + } + }, 133, 40, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (shift) { + if (secondRow.get()) { + value1D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } else { + value0D = Double.longBitsToDouble(~Double.doubleToLongBits(value1D)); + } + } else { + if (secondRow.get()) { + long temp = Double.doubleToLongBits(value1D); + temp ^= 1L << (long) columnPointer.get(); + value1D = Double.longBitsToDouble(temp); + } else { + long temp = Double.doubleToLongBits(value0D); + temp ^= 1L << (long) columnPointer.get(); + value0D = Double.longBitsToDouble(temp); + } + } + } else { + value0D *= shift ? 16 : 2; + value1D *= shift ? 16 : 2; + } + }, + 133, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_T : GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + addChangeParamButton( + builder, + (shift, columnPointer, secondRow) -> param += shift ? 16 : 4, + 151, + 4, + GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, + TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + secondRow.set(false); + } else { + columnPointer.addAndGet(shift ? 16 : 4); + } + } else { + value0D += shift ? 4096 : 256; + } + }, 151, 22, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_0); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + if (secondRow.get()) { + columnPointer.addAndGet(shift ? 16 : 4); + } else { + secondRow.set(true); + } + } else { + value1D += shift ? 4096 : 256; + } + }, 151, 40, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_1); + addChangeParamButton(builder, (shift, columnPointer, secondRow) -> { + if (isAdvanced) { + value0D = input0D; + value1D = input1D; + } else { + value0D *= shift ? 4096 : 256; + value1D *= shift ? 4096 : 256; + } + }, + 151, + 58, + isAdvanced ? TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_IF : GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, + isAdvanced ? null : TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> pointer, val -> pointer = val)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget( + TextWidget.dynamicString(() -> (isAdvanced ? "Parameters X: " : "Parameters: ") + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TTUtility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(46, 16)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TTUtility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(46, 24)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_UP + TTUtility.formatNumberExp(value0D)) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setPos(46, 33)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_UP + TTUtility.formatNumberExp(value1D)) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setPos(46, 41)) + .widget( + TextWidget + .dynamicString( + () -> CIRCLED_0 + ARROW_UP + TTUtility.longBitsToShortString(Double.doubleToLongBits(value0D))) + .setSynced(false) + .setDefaultColor(0x00bbff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 50)) + .widget( + TextWidget + .dynamicString( + () -> CIRCLED_1 + ARROW_UP + TTUtility.longBitsToShortString(Double.doubleToLongBits(value1D))) + .setSynced(false) + .setDefaultColor(0x0077ff) + .setScale(.5f) + .setTextAlignment(Alignment.CenterLeft) + .setPos(46, 58)); + if (isAdvanced) { + builder.widget( + TextWidget.dynamicString( + () -> "Pointer " + Integer.toHexString(pointer | 0x10000) + .substring(1)) + .setSynced(false) + .setDefaultColor(0x0033ff) + .setPos(46, 66)); + } + } + + private void addChangeParamButton(ModularWindow.Builder builder, OnClick onClick, int xPos, int yPos, + IDrawable overlay1, IDrawable overlay2) { + final boolean isAdvanced = mTier > 5; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + AtomicInteger columnPointer = new AtomicInteger(pointer & 0xff); + AtomicBoolean secondRow = new AtomicBoolean((pointer & 0x0100) != 0); + onClick.accept(clickData.shift, columnPointer, secondRow); + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (isAdvanced) { + if (columnPointer.get() >= 64) { + columnPointer.set(63); + } else if (columnPointer.get() < 0) { + columnPointer.set(0); + } + pointer = secondRow.get() ? columnPointer.get() + 0x100 : columnPointer.get(); + } + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground( + overlay2 != null ? new IDrawable[] { GTUITextures.BUTTON_STANDARD, overlay1, overlay2 } + : new IDrawable[] { GTUITextures.BUTTON_STANDARD, overlay1 }) + .setSize(18, 18) + .setPos(xPos, yPos)); + } + + @FunctionalInterface + private interface OnClick { + + void accept(boolean shift, AtomicInteger columnPointer, AtomicBoolean secondRow); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java new file mode 100644 index 0000000000..7efe4e1fd0 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchParamText.java @@ -0,0 +1,291 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import tectech.TecTech; +import tectech.thing.gui.TecTechUITextures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class MTEHatchParamText extends MTEHatchParam { + + public String value0s = ""; + public String value1s = ""; + + private String clientLocale = "en_US"; + + public MTEHatchParamText(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public MTEHatchParamText(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEHatchParamText(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Parametrizer", clientLocale) + " " + + translateToLocalFormatted("tt.keyword.ID", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + param, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0S: " + + EnumChatFormatting.DARK_AQUA + + value0s, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1S: " + + EnumChatFormatting.DARK_BLUE + + value1s, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 0D: " + EnumChatFormatting.AQUA + value0D, + translateToLocalFormatted("tt.keyword.Value", clientLocale) + " 1D: " + EnumChatFormatting.BLUE + value1D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 0D: " + EnumChatFormatting.GOLD + input0D, + translateToLocalFormatted("tt.keyword.Input", clientLocale) + " 1D: " + + EnumChatFormatting.YELLOW + + input1D, }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setString("eIeValue0S", value0s); + aNBT.setString("eIeValue1S", value1s); + aNBT.removeTag("ePointer"); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + value0s = aNBT.getString("eIeValue0S"); + value1s = aNBT.getString("eIeValue1S"); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_GENERAL, + EnumChatFormatting.DARK_RED + "Deprecated; Now you can set parameter by clicking LED on multiblock GUI.", + EnumChatFormatting.DARK_RED + "If it doesn't work, try removing Parametrizer from multiblock structure.", }; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(148, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_PARAMETRIZER_TXT) + .setPos(7, 4) + .setSize(162, 72)); + + addChangeNumberButton(builder, -16, -4, 7, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE); + addChangeNumberButton(builder, -2, -1, 25, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL); + addChangeNumberButton(builder, 2, 1, 133, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL); + addChangeNumberButton(builder, 16, 4, 151, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE); + + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> param, val -> param = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value0D, val -> value0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> value1D, val -> value1D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input0D, val -> input0D = val)) + .widget(new FakeSyncWidget.DoubleSyncer(() -> input1D, val -> input1D = val)); + // .widget(new FakeSyncWidget.StringSyncer(() -> value0s, val -> value0s = val)) + // .widget(new FakeSyncWidget.StringSyncer(() -> value1s, val -> value1s = val)); + + final String CIRCLED_0 = "\u24EA"; + final String CIRCLED_1 = "\u2460"; + final String ARROW_DOWN = "\u2b07"; + final String ARROW_UP = "\u2b06"; + builder.widget( + TextWidget.dynamicString(() -> "Parameters: " + param) + .setSynced(false) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)) + .widget( + new TextWidget(CIRCLED_0 + ARROW_UP).setDefaultColor(0x00bbff) + .setPos(10, 29)) + .widget( + new TextWidget(CIRCLED_1 + ARROW_UP).setDefaultColor(0x0077ff) + .setPos(10, 44)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_0 + ARROW_DOWN + TTUtility.formatNumberExp(input0D)) + .setSynced(false) + .setDefaultColor(0x22ddff) + .setPos(10, 56)) + .widget( + TextWidget.dynamicString(() -> CIRCLED_1 + ARROW_DOWN + TTUtility.formatNumberExp(input1D)) + .setSynced(false) + .setDefaultColor(0x00ffff) + .setPos(10, 65)); + + addTextField(builder, true); + addTextField(builder, false); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, int changeNumberShift, int changeNumber, int xPos, + IDrawable overlay) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + param += clickData.shift ? changeNumberShift : changeNumber; + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (param > 9) { + param = 9; + } else if (param < -1) { + param = -1; + } + }) + .setPlayClickSound(false) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay, TecTechUITextures.OVERLAY_BUTTON_PARAMETRIZER_ID) + .setSize(18, 18) + .setPos(xPos, 4)); + } + + private void addTextField(ModularWindow.Builder builder, boolean isIndex0) { + TextFieldWidget widget = new TextFieldWidget(); + builder.widget( + widget.setGetter(() -> isIndex0 ? value0s : value1s) + .setSetter(str -> { + double val; + try { + val = parse(str); + } catch (Exception e) { + // This shouldn't happen as long as validator works + str = ""; + val = 0; + } + if (isIndex0) { + value0s = str; + value0D = val; + } else { + value1s = str; + value1D = val; + } + }) + .setValidator(str -> { + try { + parse(str); + return str; + } catch (Exception e) { + return widget.getLastText() + .size() > 0 ? widget.getLastText() + .get(0) : ""; + } + }) + .setTextColor(Color.WHITE.dark(1)) + .setTextAlignment(Alignment.CenterLeft) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(26, isIndex0 ? 26 : 41) + .setSize(138, 12)); + } + + private double parse(String str) { + double val; + if (str.contains("b")) { + String[] split = str.split("b"); + val = TTUtility.bitStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else if (str.contains("x")) { + String[] split = str.split("x"); + val = TTUtility.hexStringToInt(split[0].replaceAll("[^-]", "") + split[1].replaceAll("_", "")); + } else { + val = TTUtility.stringToDouble(str); + } + return val; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java new file mode 100644 index 0000000000..03e11cc4f1 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchRack.java @@ -0,0 +1,412 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.Mods.GraviSuite; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; +import static gregtech.api.enums.Mods.OpenComputers; +import static gregtech.api.util.GTModHandler.getModItem; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.TecTech; +import tectech.loader.TecTechConfig; +import tectech.thing.gui.TecTechUITextures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 03.04.2017. + */ +public class MTEHatchRack extends MTEHatch implements IAddGregtechLogo, IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon EM_R; + private static Textures.BlockIcons.CustomIcon EM_R_ACTIVE; + public int heat = 0; + private float overClock = 1, overVolt = 1; + private static final Map<String, RackComponent> componentBinds = new HashMap<>(); + + private String clientLocale = "en_US"; + + public MTEHatchRack(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 4, + new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.rack.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.hatch.rack.desc.1") }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchRack(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 4, aDescription, aTextures); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setInteger("eHeat", heat); + aNBT.setFloat("eOverClock", overClock); + aNBT.setFloat("eOverVolt", overVolt); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + heat = aNBT.getInteger("eHeat"); + overClock = aNBT.getFloat("eOverClock"); + overVolt = aNBT.getFloat("eOverVolt"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + EM_R_ACTIVE = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK_ACTIVE"); + EM_R = new Textures.BlockIcons.CustomIcon("iconsets/EM_RACK"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(EM_R_ACTIVE) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(EM_R) }; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchRack(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (aBaseMetaTileEntity.isActive() || heat > 2000) { + return false; + } + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + if (aBaseMetaTileEntity.isActive() || heat > 2000) { + return false; + } + return side == aBaseMetaTileEntity.getFrontFacing(); + } + + @Override + public int getSizeInventory() { // HACK TO NOT DROP CONTENTS!!! + return heat > 2000 || getBaseMetaTileEntity().isActive() ? 0 : mInventory.length; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + // if(aBaseMetaTileEntity.isActive()) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still active...")); + // else if(heat>0) + // aPlayer.addChatComponentMessage(new ChatComponentText("It is still warm...")); + // else + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + private int getComputationPower(float overclock, float overvolt, boolean tickingComponents) { + float computation = 0, heat = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(TTUtility.getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } + if (tickingComponents) { + if (this.heat > comp.maxHeat) { + mInventory[i] = null; + continue; + } else if (comp.subZero || this.heat >= 0) { + heat += (1f + comp.coolConstant * this.heat / 100000f) + * (comp.heatConstant > 0 ? comp.heatConstant * overclock * overvolt * overvolt : -10f); + + if (overvolt > TecTech.RANDOM.nextFloat()) { + computation += comp.computation * (1 + overclock * overclock) + / (1 + (overclock - overvolt) * (overclock - overvolt)); + } + } + } else { + computation += comp.computation * (1 + overclock * overclock) + / (1 + (overclock - overvolt) * (overclock - overvolt)); // For getInfoData() + } + } + if (tickingComponents) { + this.heat += Math.ceil(heat); + } + return (int) Math.floor(computation); + } + + public int tickComponents(float oc, float ov) { + overClock = oc; + overVolt = ov; + return getComputationPower(overClock, overVolt, true); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (aTick % 20 == CommonValues.MULTI_CHECK_AT) { + if (heat > 0) { + float heatC = 0; + for (int i = 0; i < mInventory.length; i++) { + if (mInventory[i] == null || mInventory[i].stackSize != 1) { + continue; + } + RackComponent comp = componentBinds.get(TTUtility.getUniqueIdentifier(mInventory[i])); + if (comp == null) { + continue; + } + if (heat - 20 > comp.maxHeat) { + mInventory[i] = null; + } else if (comp.heatConstant < 0) { + heatC += comp.heatConstant * (heat / 10000f); + } + } + heat += Math.max(-heat, Math.ceil(heatC)); + heat -= Math.max(heat / 1000, 20); + } + } + } + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyphrase.Base_computation", clientLocale) + ": " + + EnumChatFormatting.AQUA + + getComputationPower(overClock, overVolt, false), + translateToLocalFormatted("tt.keyphrase.Heat_Accumulated", clientLocale) + ": " + + EnumChatFormatting.RED + + heat + + EnumChatFormatting.RESET }; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO) + .setSize(18, 18) + .setPos(151, 63)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK) + .setPos(46, 17) + .setSize(84, 60)); + + Pos2d[] positions = new Pos2d[] { new Pos2d(68, 27), new Pos2d(90, 27), new Pos2d(68, 49), new Pos2d(90, 49), }; + for (int i = 0; i < positions.length; i++) { + builder.widget(new SlotWidget(new BaseSlot(inventoryHandler, i) { + + @Override + public int getSlotStackLimit() { + return 1; + } + + @Override + public boolean isEnabled() { + return !getBaseMetaTileEntity().isActive() && heat <= 0; + } + }).setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_RACK) + .setPos(positions[i])); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> getBaseMetaTileEntity().isActive() ? TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON + : TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED) + .setPos(152, 24) + .setSize(16, 16)) + .widget( + new FakeSyncWidget.BooleanSyncer( + () -> getBaseMetaTileEntity().isActive(), + val -> getBaseMetaTileEntity().setActive(val))); + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BUTTON_STANDARD_LIGHT_16x16) + .setPos(152, 41) + .setSize(16, 16)) + .widget( + new DrawableWidget() + .setDrawable( + () -> heat > 0 ? TecTechUITextures.OVERLAY_BUTTON_HEAT_ON + : TecTechUITextures.OVERLAY_BUTTON_HEAT_OFF) + .setPos(152, 41) + .setSize(16, 16)) + .widget(new FakeSyncWidget.IntegerSyncer(() -> heat, val -> heat = val)); + } + } + + public static void run() { // 20k heat cap max! + new RackComponent(ItemList.Circuit_Crystalprocessor.get(1), 60, 56, -1f, 2000, true); // IV + new RackComponent(ItemList.Circuit_Crystalcomputer.get(1), 80, 54, -1f, 2000, true); // LuV + new RackComponent(ItemList.Circuit_Ultimatecrystalcomputer.get(1), 100, 52, -1f, 2000, true); // ZPM + new RackComponent(ItemList.Circuit_Crystalmainframe.get(1), 120, 50, -1f, 2000, true); // UV + + new RackComponent(ItemList.Circuit_Neuroprocessor.get(1), 160, 46, -1f, 4000, true); // LuV + new RackComponent(ItemList.Circuit_Wetwarecomputer.get(1), 180, 44, -1f, 4000, true); // ZPM + new RackComponent(ItemList.Circuit_Wetwaresupercomputer.get(1), 200, 42, -1f, 4000, true); // UV + new RackComponent(ItemList.Circuit_Wetwaremainframe.get(1), 220, 40, -1f, 4000, true); // UHV + + new RackComponent("IC2:ic2.reactorVent", 0, -1, 40f, 2000, false); // Heat Vent + new RackComponent("IC2:ic2.reactorVentCore", 0, -1, 80f, 4000, false); // Reactor Heat Vent + new RackComponent("IC2:ic2.reactorVentGold", 0, -1, 120f, 6000, false); // Overclocked Heat Vent + new RackComponent("IC2:ic2.reactorVentDiamond", 0, -1, 160f, 8000, false); // Advanced Heat Vent + + if (NewHorizonsCoreMod.isModLoaded()) { + // GTNH-GT5u circuits (these components causes crashes when used with the original GT5u) + new RackComponent(ItemList.Circuit_Bioprocessor.get(1), 200, 36, -1f, 6000, true); // ZPM + new RackComponent(ItemList.Circuit_Biowarecomputer.get(1), 220, 34, -1f, 6000, true); // UV + new RackComponent(ItemList.Circuit_Biowaresupercomputer.get(1), 240, 32, -1f, 6000, true); // UHV + new RackComponent(ItemList.Circuit_Biomainframe.get(1), 260, 30, -1f, 6000, true); // UEV + + new RackComponent(ItemList.Circuit_OpticalProcessor.get(1), 200, 26, -1f, 8000, true); // UV + new RackComponent(ItemList.Circuit_OpticalAssembly.get(1), 220, 24, -1f, 8000, true); // UHV + new RackComponent(ItemList.Circuit_OpticalComputer.get(1), 240, 22, -1f, 8000, true); // UEV + new RackComponent(ItemList.Circuit_OpticalMainframe.get(1), 260, 20, -1f, 8000, true); // UIV + + new RackComponent("dreamcraft:item.PikoCircuit", 260, 12, -1f, 9500, true); // UMV + new RackComponent("dreamcraft:item.QuantumCircuit", 320, 10, -1f, 10000, true); // UXV + } + + if (OpenComputers.isModLoaded()) { + new RackComponent("OpenComputers:item.oc.CPU2", 80, 46, -1f, 2000, true); // CPU T3 + new RackComponent("OpenComputers:item.oc.GraphicsCard2", 100, 44, -1f, 2000, true); // GPU T3 + new RackComponent("OpenComputers:item.oc.APU1", 120, 42, -1f, 2000, true); // APU T3 + new RackComponent("OpenComputers:item.oc.APU2", 240, 40, -1f, 2000, true); // APU Creative + } + + if (GraviSuite.isModLoaded()) { + new RackComponent(getModItem(GraviSuite.ID, "itemSimpleItem", 1, 2), 0, -1, 200f, 10000, false); // CC + } + } + + public static class RackComponent implements Comparable<RackComponent> { + + private final String unlocalizedName; + private final float heatConstant, coolConstant, computation, maxHeat; + private final boolean subZero; + + RackComponent(ItemStack is, float computation, float heatConstant, float coolConstant, float maxHeat, + boolean subZero) { + this(TTUtility.getUniqueIdentifier(is), computation, heatConstant, coolConstant, maxHeat, subZero); + } + + RackComponent(String is, float computation, float heatConstant, float coolConstant, float maxHeat, + boolean subZero) { + unlocalizedName = is; + this.computation = computation; + this.heatConstant = heatConstant; + this.coolConstant = coolConstant; + this.maxHeat = maxHeat; + this.subZero = subZero; + componentBinds.put(unlocalizedName, this); + if (TecTechConfig.DEBUG_MODE) { + TecTech.LOGGER.info("Component registered: " + unlocalizedName); + } + } + + @Override + public int compareTo(RackComponent o) { + return unlocalizedName.compareTo(o.unlocalizedName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof RackComponent) { + return compareTo((RackComponent) obj) == 0; + } + return false; + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java new file mode 100644 index 0000000000..f8c2587269 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchUncertainty.java @@ -0,0 +1,467 @@ +package tectech.thing.metaTileEntity.hatch; + +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; +import static org.lwjgl.opengl.GL11.GL_BLEND; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glColor4f; +import static org.lwjgl.opengl.GL11.glDisable; +import static org.lwjgl.opengl.GL11.glEnable; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizons.modularui.api.GlStateManager; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import tectech.TecTech; +import tectech.thing.gui.TecTechUITextures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 15.12.2016. + */ +public class MTEHatchUncertainty extends MTEHatch implements IAddGregtechLogo, IAddUIWidgets { + + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + public short[] matrix = new short[] { 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, 500, + 500 }; + public byte selection = -1, mode = 0, status = -128; // all 8 bits set + + private String clientLocale = "en_US"; + + public MTEHatchUncertainty(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, 0, ""); + TTUtility.setTier(aTier, this); + regenerate(); + } + + public MTEHatchUncertainty(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + regenerate(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/UC"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/UC_ACTIVE"); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(ScreenON) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, new GTRenderedTexture(ScreenOFF) }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && (aTick & 15) == 0) { + if (mode == 0) { + aBaseMetaTileEntity.setActive(false); + status = -128; + } else { + aBaseMetaTileEntity.setActive(true); + shift(); + compute(); + } + } + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEHatchUncertainty(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { + translateToLocalFormatted("tt.keyword.Status", clientLocale) + ": " + EnumChatFormatting.GOLD + status }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setByte("mSel", selection); + aNBT.setByte("mMode", mode); + aNBT.setByte("mStatus", status); + NBTTagCompound mat = new NBTTagCompound(); + for (int i = 0; i < 16; i++) { + mat.setShort(Integer.toString(i), matrix[i]); + } + aNBT.setTag("mMat", mat); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + selection = aNBT.getByte("mSel"); + mode = aNBT.getByte("mMode"); + status = aNBT.getByte("mStatus"); + NBTTagCompound mat = aNBT.getCompoundTag("mMat"); + for (int i = 0; i < 16; i++) { + matrix[i] = mat.getShort(Integer.toString(i)); + } + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public boolean isLiquidInput(ForgeDirection side) { + return false; + } + + @Override + public boolean isFluidInputAllowed(FluidStack aFluid) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.hatch.certain.desc.0"), // Feeling + // certain, + // or + // not? + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.hatch.certain.desc.1") // Schrödinger equation in a box + }; + } + + private boolean balanceCheck(int sideLenY, short... masses) { + float inequality = 0; + for (int i = 0; i < masses.length >> 1; i++) { + inequality += Math.abs(masses[i] - masses[masses.length - i - 1]); + } + return inequality < masses.length << 7; + } + + public void regenerate() { + for (int i = 0; i < matrix.length; i++) { + matrix[i] = (short) TecTech.RANDOM.nextInt(1000); + } + } + + public byte compute() { + int result = 0; + switch (mode) { + case 1: // ooo oxo ooo + result = balanceCheck(4, matrix) ? 0 : 1; + break; + case 2: // ooo xox ooo + result += balanceCheck( + 4, + matrix[0], + matrix[4], + matrix[1], + matrix[5], + matrix[2], + matrix[6], + matrix[3], + matrix[7]) ? 0 : 1; + result += balanceCheck( + 4, + matrix[8], + matrix[12], + matrix[9], + matrix[13], + matrix[10], + matrix[14], + matrix[11], + matrix[15]) ? 0 : 2; + break; + case 3: // oxo xox oxo + result += balanceCheck( + 2, + matrix[0], + matrix[4], + matrix[8], + matrix[12], + matrix[1], + matrix[5], + matrix[9], + matrix[13]) ? 0 : 1; + result += balanceCheck( + 4, + matrix[0], + matrix[4], + matrix[1], + matrix[5], + matrix[2], + matrix[6], + matrix[3], + matrix[7]) ? 0 : 2; + result += balanceCheck( + 4, + matrix[8], + matrix[12], + matrix[9], + matrix[13], + matrix[10], + matrix[14], + matrix[11], + matrix[15]) ? 0 : 4; + result += balanceCheck( + 2, + matrix[2], + matrix[6], + matrix[10], + matrix[14], + matrix[3], + matrix[7], + matrix[11], + matrix[15]) ? 0 : 8; + break; + case 4: // xox ooo xox + result += balanceCheck(2, matrix[0], matrix[4], matrix[1], matrix[5]) ? 0 : 1; + result += balanceCheck(2, matrix[8], matrix[12], matrix[9], matrix[13]) ? 0 : 2; + result += balanceCheck(2, matrix[2], matrix[6], matrix[3], matrix[7]) ? 0 : 4; + result += balanceCheck(2, matrix[10], matrix[14], matrix[11], matrix[15]) ? 0 : 8; + break; + case 5: // xox oxo xox + result += balanceCheck(2, matrix[0], matrix[4], matrix[1], matrix[5]) ? 0 : 1; + result += balanceCheck(2, matrix[8], matrix[12], matrix[9], matrix[13]) ? 0 : 2; + result += balanceCheck(4, matrix) ? 0 : 4; + result += balanceCheck(2, matrix[2], matrix[6], matrix[3], matrix[7]) ? 0 : 8; + result += balanceCheck(2, matrix[10], matrix[14], matrix[11], matrix[15]) ? 0 : 16; + break; + } + return status = (byte) result; + } + + private void shift() { + int i = TecTech.RANDOM.nextInt(16), j = TecTech.RANDOM.nextInt(128); + matrix[i] += ((matrix[i] & 1) == 0 ? 2 : -2) * j >> 5; + matrix[i] += j == 0 ? 1 : 0; + if (matrix[i] < 0) { + matrix[i] = 0; + } else if (matrix[i] > 1000) { + matrix[i] = 999; + } + } + + public byte update(int newMode) { + if (newMode == mode) { + return status; + } + if (newMode < 0 || newMode > 5) { + newMode = 0; + } + mode = (byte) newMode; + regenerate(); + compute(); + return status; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(112, 55)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + final boolean isAdvanced = mTier > 7; + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(43, 4) + .setSize(90, 72)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR) + .setPos(46, 27) + .setSize(46, 46)); + + int[] xPositions = new int[] { 7, 25, 133, 151 }; + for (int i = 0; i < 4; i++) { + for (int j = 0; j < 4; j++) { + final int index = i * 4 + j; + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (selection == -1) { + selection = (byte) index; + } else { + short temp = matrix[selection]; + matrix[selection] = matrix[index]; + matrix[index] = temp; + selection = -1; + } + compute(); + }) + .setPlayClickSound(false) + .setBackground(GTUITextures.BUTTON_STANDARD, TecTechUITextures.OVERLAY_BUTTON_UNCERTAINTY[index]) + .setPos(xPositions[i], 4 + j * 18) + .setSize(18, 18)) + .widget(new FakeSyncWidget.ShortSyncer(() -> matrix[index], val -> matrix[index] = val)); + } + } + builder.widget(new FakeSyncWidget.ByteSyncer(() -> selection, val -> selection = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> mode, val -> mode = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> status, val -> status = val)); + + builder.widget( + new TextWidget().setStringSupplier(() -> "Status: " + (status == 0 ? "OK" : "NG")) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 7)); + + for (int i = 0; i < 9; i++) { + final int index = i; + builder.widget(new DrawableWidget().setDrawable(() -> { + UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; + UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; + switch (mode) { + case 1: // ooo oxo ooo + if (index == 4) return status == 0 ? valid : invalid; + break; + case 2: // ooo xox ooo + if (index == 3) return (status & 1) == 0 ? valid : invalid; + if (index == 5) return (status & 2) == 0 ? valid : invalid; + break; + case 3: // oxo xox oxo + if (index == 1) return (status & 1) == 0 ? valid : invalid; + if (index == 3) return (status & 2) == 0 ? valid : invalid; + if (index == 5) return (status & 4) == 0 ? valid : invalid; + if (index == 7) return (status & 8) == 0 ? valid : invalid; + break; + case 4: // xox ooo xox + if (index == 0) return (status & 1) == 0 ? valid : invalid; + if (index == 2) return (status & 2) == 0 ? valid : invalid; + if (index == 6) return (status & 4) == 0 ? valid : invalid; + if (index == 8) return (status & 8) == 0 ? valid : invalid; + break; + case 5: // xox oxo xox + if (index == 0) return (status & 1) == 0 ? valid : invalid; + if (index == 2) return (status & 2) == 0 ? valid : invalid; + if (index == 4) return (status & 4) == 0 ? valid : invalid; + if (index == 6) return (status & 8) == 0 ? valid : invalid; + if (index == 8) return (status & 16) == 0 ? valid : invalid; + break; + } + return null; + }) + .setPos(55 + (index % 3) * 12, 36 + (index / 3) * 12) + .setSize(4, 4)); + } + + for (int i = 0; i < 16; i++) { + final int index = i; + builder.widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + if (isAdvanced) { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(1f, 1f, 1f, (float) matrix[index] / 1000f); + + // super.draw but without disabling blend + GlStateManager.pushMatrix(); + getDrawable().draw(Pos2d.ZERO, getSize(), partialTicks); + GlStateManager.popMatrix(); + + glDisable(GL_BLEND); + glColor4f(1f, 1f, 1f, 1f); + } else { + if (TecTech.RANDOM.nextInt(1000) < matrix[index]) { + super.draw(partialTicks); + } + } + } + }.setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_INDICATOR) + .setPos(47 + (i / 4) * 12, 28 + (i % 4) * 12) + .setSize(8, 8)) + .widget( + new DrawableWidget() + .setDrawable(() -> selection == index ? TecTechUITextures.PICTURE_UNCERTAINTY_SELECTED : null) + .setPos(46 + (i / 4) * 12, 27 + (i % 4) * 12) + .setSize(10, 10)); + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java new file mode 100644 index 0000000000..94f8181566 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationInput.java @@ -0,0 +1,132 @@ +package tectech.thing.metaTileEntity.hatch; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.WirelessComputationPacket; +import tectech.thing.gui.TecTechUITextures; + +public class MTEHatchWirelessComputationInput extends MTEHatchDataInput implements IAddGregtechLogo, IAddUIWidgets { + + public long requiredComputation = 10000; + + private String clientLocale = "en_US"; + + public MTEHatchWirelessComputationInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + } + + public MTEHatchWirelessComputationInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchWirelessComputationInput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + if (!aPlayer.isUsingItem()) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && q == null) { + q = WirelessComputationPacket.downloadData(aBaseMetaTileEntity.getOwnerUuid(), requiredComputation, aTick); + } + + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO) + .setSize(18, 18) + .setPos(151, 63)); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + requiredComputation = aNBT.getLong("requiredComputation"); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("requiredComputation", requiredComputation); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + TextWidget.localised("tt.wirelessInputData.config.text") + .setPos(20, 12) + .setSize(140, 14)) + .widget( + new TextFieldWidget().setSetterInt(val -> requiredComputation = val) + .setGetterLong(() -> requiredComputation) + .setNumbers(1, Integer.MAX_VALUE) + .setOnScrollNumbers(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(54, 36) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + } + + private static String[] tooltips; + + @Override + public String[] getDescription() { + if (tooltips == null) { + tooltips = new String[] { "Wireless Computation Data Input for Multiblocks" }; + } + return tooltips; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationOutput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationOutput.java new file mode 100644 index 0000000000..8495f95e6f --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessComputationOutput.java @@ -0,0 +1,60 @@ +package tectech.thing.metaTileEntity.hatch; + +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.common.WirelessComputationPacket; + +public class MTEHatchWirelessComputationOutput extends MTEHatchDataOutput { + + public MTEHatchWirelessComputationOutput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + + } + + public MTEHatchWirelessComputationOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchWirelessComputationOutput(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && q != null) { + WirelessComputationPacket.uploadData(aBaseMetaTileEntity.getOwnerUuid(), q.getContent(), aTick); + q = null; + } + } + + private static String[] tooltips; + + @Override + public String[] getDescription() { + if (tooltips == null) { + tooltips = new String[] { "Wireless Computation Output for Multiblocks" }; + } + return tooltips; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java new file mode 100644 index 0000000000..e7d604328a --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsInput.java @@ -0,0 +1,139 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_ACTIVE; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_CONN; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_SIDES; + +import java.util.List; +import java.util.function.Predicate; +import java.util.stream.Collectors; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.WirelessDataStore; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEHatchWirelessDataItemsInput extends MTEHatchDataAccess { + + private String clientLocale = "en_US"; + + public MTEHatchWirelessDataItemsInput(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier); + TTUtility.setTier(aTier, this); + } + + public MTEHatchWirelessDataItemsInput(String aName, int aTier, String aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + public MTEHatchWirelessDataItemsInput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchWirelessDataItemsInput(this.mName, this.mTier, mDescriptionArray, this.mTextures); + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isClientSide()) { + return true; + } + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + return true; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, + translateToLocal("gt.blockmachines.hatch.datainasswireless.desc.0"), + translateToLocal("gt.blockmachines.hatch.datainasswireless.desc.1"), }; + } + + @Override + public List<ItemStack> getInventoryItems(Predicate<ItemStack> filter) { + WirelessDataStore wirelessData = WirelessDataStore + .getWirelessDataSticks(getBaseMetaTileEntity().getOwnerUuid()); + return wirelessData.downloadData() + .stream() + .filter(stack -> stack != null && filter.test(stack)) + .collect(Collectors.toList()); + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return new String[] { translateToLocalFormatted("tt.keyphrase.Content_Stack_Count", clientLocale) + ": " + + getInventoryItems(_stack -> true).size() }; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsOutput.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsOutput.java new file mode 100644 index 0000000000..2765598475 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessDataItemsOutput.java @@ -0,0 +1,142 @@ +package tectech.thing.metaTileEntity.hatch; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_ACTIVE; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_CONN; +import static tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector.EM_D_SIDES; + +import java.util.Arrays; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.WirelessDataStore; +import tectech.mechanics.dataTransport.InventoryDataPacket; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEHatchWirelessDataItemsOutput extends MTEHatch { + + public InventoryDataPacket dataPacket = null; + + public boolean uploadedSinceReset = false; + + public MTEHatchWirelessDataItemsOutput(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_EM, + translateToLocal("gt.blockmachines.hatch.wirelessdataoutass.desc.0"), + translateToLocal("gt.blockmachines.hatch.wirelessdataoutass.desc.1"), }); + TTUtility.setTier(aTier, this); + } + + public MTEHatchWirelessDataItemsOutput(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchWirelessDataItemsOutput(this.mName, this.mTier, this.mDescriptionArray, this.mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + if (dataPacket != null) { + aNBT.setTag("eDATA", dataPacket.toNbt()); + } + aNBT.setBoolean("uploadedSinceReset", uploadedSinceReset); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("eDATA")) { + dataPacket = new InventoryDataPacket(aNBT.getCompoundTag("eDATA")); + } + if (aNBT.hasKey("uploadedSinceReset")) { + uploadedSinceReset = aNBT.getBoolean("uploadedSinceReset"); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + // Upload data packet and mark it as uploaded, so it will not be uploaded again + // until the data bank resets the wireless network + if (dataPacket != null && !uploadedSinceReset) { + WirelessDataStore wirelessDataStore = WirelessDataStore + .getWirelessDataSticks(getBaseMetaTileEntity().getOwnerUuid()); + wirelessDataStore.uploadData(Arrays.asList(dataPacket.getContent())); + uploadedSinceReset = true; + } + } + } + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_ACTIVE, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture, + new GTRenderedTexture( + EM_D_SIDES, + Dyes.getModulation(getBaseMetaTileEntity().getColorization(), MACHINE_METAL.getRGBA())), + new GTRenderedTexture(EM_D_CONN) }; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java new file mode 100644 index 0000000000..09d76c29a1 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/hatch/MTEHatchWirelessMulti.java @@ -0,0 +1,209 @@ +package tectech.thing.metaTileEntity.hatch; + +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.BLUE; +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.BOLD; +import static com.gtnewhorizon.gtnhlib.util.AnimatedTooltipHandler.GRAY; +import static gregtech.api.enums.GTValues.AuthorColen; +import static gregtech.api.enums.GTValues.V; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.strongCheckOrAddUser; +import static java.lang.Long.min; + +import java.math.BigInteger; +import java.util.UUID; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.util.ForgeDirection; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IWirelessEnergyHatchInformation; +import gregtech.api.metatileentity.MetaTileEntity; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.TTUtility; + +public class MTEHatchWirelessMulti extends MTEHatchEnergyMulti implements IWirelessEnergyHatchInformation { + + private final BigInteger eu_transferred_per_operation = BigInteger + .valueOf(Amperes * V[mTier] * ticks_between_energy_addition); + private final long eu_transferred_per_operation_long = eu_transferred_per_operation.longValue(); + + private UUID owner_uuid; + + public MTEHatchWirelessMulti(int aID, String aName, String aNameRegional, int aTier, int aAmp) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { GRAY + "Stores energy globally in a network, up to 2^(2^31) EU.", + GRAY + "Does not connect to wires. This block withdraws EU from the network.", + AuthorColen + GRAY + BOLD + " & " + BLUE + BOLD + "Cloud" }, + aAmp); + TTUtility.setTier(aTier, this); + } + + public MTEHatchWirelessMulti(String aName, int aTier, int aAmp, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aAmp, aDescription, aTextures); + } + + private ITexture[] TEXTURE_OVERLAY; + + @Override + public ITexture[] getTexturesActive(ITexture aBaseTexture) { + switch (Amperes) { + case 4: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A; + break; + case 16: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A; + break; + case 64: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A; + break; + default: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_LASER; + break; + } + return new ITexture[] { aBaseTexture, TEXTURE_OVERLAY[mTier] }; + } + + @Override + public ITexture[] getTexturesInactive(ITexture aBaseTexture) { + switch (Amperes) { + case 4: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_4A; + break; + case 16: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_16A; + break; + case 64: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_MULTI_64A; + break; + default: + TEXTURE_OVERLAY = Textures.OVERLAYS_ENERGY_IN_WIRELESS_LASER; + break; + } + return new ITexture[] { aBaseTexture, TEXTURE_OVERLAY[mTier] }; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isValidSlot(int aIndex) { + return false; + } + + @Override + public long getMinimumStoredEU() { + return Amperes * V[mTier]; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUStore() { + return totalStorage(V[mTier]) * Amperes / 2; + } + + @Override + public long maxAmperesIn() { + return Amperes; + } + + @Override + public long maxWorkingAmperesIn() { + return Amperes; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEHatchWirelessMulti(mName, mTier, Amperes, mDescriptionArray, mTextures); + } + + @Override + public boolean allowPullStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity aBaseMetaTileEntity, int aIndex, ForgeDirection side, + ItemStack aStack) { + return false; + } + + @Override + public ConnectionType getConnectionType() { + return ConnectionType.WIRELESS; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + // On first tick find the player name and attempt to add them to the map. + + // UUID and username of the owner. + owner_uuid = aBaseMetaTileEntity.getOwnerUuid(); + + strongCheckOrAddUser(owner_uuid); + + tryFetchingEnergy(); + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide()) { + + // This is set up in a way to be as optimised as possible. If a user has a relatively plentiful energy + // network + // it should make no difference to them. Minimising the number of operations on BigInteger is essential. + + // Every ticks_between_energy_addition add eu_transferred_per_operation to internal EU storage from network. + if (aTick % ticks_between_energy_addition == 0L) { + tryFetchingEnergy(); + } + } + } + + private void tryFetchingEnergy() { + long currentEU = getBaseMetaTileEntity().getStoredEU(); + long maxEU = maxEUStore(); + long euToTransfer = min(maxEU - currentEU, eu_transferred_per_operation_long); + if (euToTransfer <= 0) return; // nothing to transfer + if (!addEUToGlobalEnergyMap(owner_uuid, -euToTransfer)) return; + setEUVar(currentEU + euToTransfer); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java new file mode 100644 index 0000000000..56aabb28ec --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java @@ -0,0 +1,5105 @@ +package tectech.thing.metaTileEntity.multi; + +import static tectech.util.TTUtility.replaceLetters; + +public abstract class ForgeOfGodsRingsStructureString { + + public static final String[][] SECOND_RING = { { + + " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBEC CEBB ", + " BEEC CEEB ", + " EEC CEE ", + " EC CE ", + " EC CCCCC CE ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " EC CCCCC CE ", + " EC CE ", + " EEC CEE ", + " BEEC CEEB ", + " BBEC CEBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC D CCBB ", + " BBEC D CEBB ", + " BBBEEC DD CEEBBB ", + " EEEEC D CEEEE ", + " EEEC DD CEEE ", + " EEEC CCCCC CEEE ", + " EEC CHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHHHC CEE ", + " EEC CHHHHHC CEE ", + " EEEC CCCCC CEEE ", + " EEEC DD CEEE ", + " EEEEC D CEEEE ", + " BBBEEC DD CEEBBB ", + " BBEC D CEBB ", + " BBCC D CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBEC CEBB ", + " BBBEEC CEEBBB ", + " BBBBEEEEC CEEEEBBBB ", + " EEEEEEEC CEEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEEC CEEEEEEE ", + " BBBBEEEEC CEEEEBBBB ", + " BBBEEC CEEBBB ", + " BBEC CEBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBEEE EEEBBBB ", + " BBBEEEEEEE EEEEEEEBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEKKK KKKEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBEEEEEEE EEEEEEEBBB ", + " BBBBEEE EEEBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBBEEEE EEEEBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBEEEE EEEEBBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " BBBEEEEE EEEEEBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBEEEEE EEEEEBBB ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBBEEE EEEBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBEEE EEEBBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBEEEE EEEEBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBEEEE EEEEBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBEE EEBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBEE EEBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BEEEE EEEEB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BEEEE EEEEB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBEEE EEEBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBEEE EEEBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBBE EBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBE EBBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEK KEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEK KEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEK KEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEKK KKEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEK KEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEKK KKEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEKKK KKKEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEKK KKEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBB BBBBBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEKKKK KKKKEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBBBBB BBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBB BBBBBBBBBBBB ", + " EEEEEEEEEEEE EEEEEEEEEEEE ", + " EEEEEEEKKKKK KKKKKEEEEEEE ", + " EEEEEEEEEEEE EEEEEEEEEEEE ", + " BBBBBBBBBBBB BBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEKKKKKKKKKKKKKKKEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + + public static final String[][] THIRD_RING = { + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEC CEBBB ", + " EEEC CEEE ", + " EEC CEE ", + " EEC CCCCC CEE ", + " EC CC CC CE ", + " EC C C CE ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C C C C ", + " EC C C CE ", + " EC CC CC CE ", + " EEC CCCCC CEE ", + " EEC CEE ", + " EEEC CEEE ", + " BBBEC CEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCCD CCBB ", + " BBBEC DD CEBBB ", + " BBBEEEC D CEEEBBB ", + " EEEEEC DD CEEEEE ", + " EEEEEC DCCCCC CEEEEE ", + " EEEEC CCHHHHHCC CEEEE ", + " EEEEC CHHHHHHHHHC CEEEE ", + " EEEC CHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHHHC CEEE ", + " EEEC CHHHHHHHHHC CEEE ", + " EEEEC CHHHHHHHHHC CEEEE ", + " EEEEC CCHHHHHCC CEEEE ", + " EEEEEC CCCCCD CEEEEE ", + " EEEEEC DD CEEEEE ", + " BBBEEEC D CEEEBBB ", + " BBBEC DD CEBBB ", + " BBCC DCCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " BBBBBBB ", + " BBCCCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEC CEBBB ", + " BBBBEEEC CEEEBBBB ", + " BEEEEEEC CEEEEEEB ", + " EEEEEEEC CCCCC CEEEEEEE ", + " EEEEEEC CC CC CEEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEC C C CEEEEE ", + " EEEEEEC C C CEEEEEE ", + " EEEEEEC CC CC CEEEEEE ", + " EEEEEEEC CCCCC CEEEEEEE ", + " BEEEEEEC CEEEEEEB ", + " BBBBEEEC CEEEBBBB ", + " BBBEC CEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCCCBB ", + " BBBBBBB " }, + { " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBEEEE EEEEBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEII IIEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBEEEE EEEEBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBBEE EEBBBBB ", + " BEEEEEEE EEEEEEEB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEEEE EEEEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BEEEEEEE EEEEEEEB ", + " BBBBBEE EEBBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBEEEE EEEEBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBEEEE EEEEBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBBBE EBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBE EBBBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBEEE EEEBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEII IIEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBEEE EEEBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BEEE EEEB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BEEE EEEB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BBBE EBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBE EBBB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI EEEE ", + " EEEI IEEE ", + " EEEI EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEI IEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEI IEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEI IEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEII IIEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEI IEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEII IIEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEIII IIIEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBB BBBBBBBBB ", + " EEEEEEEEE EEEEEEEEE ", + " EEEEEEIII IIIEEEEEE ", + " EEEEEEEEE EEEEEEEEE ", + " BBBBBBBBB BBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBB BBBBBBBBBBB ", + " EEEEEEEEEEE EEEEEEEEEEE ", + " EEEEEEIIIII IIIIIEEEEEE ", + " EEEEEEEEEEE EEEEEEEEEEE ", + " BBBBBBBBBBB BBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEIIIIIIIIIIIIIEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBB ", + " EEEEEEEEEEEEE ", + " EEEEEEEEEEEEE ", + " EEEEEEEEEEEEE ", + " BBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + public static final String[][] SECOND_RING_AIR = replaceLetters(SECOND_RING, "L"); + public static final String[][] THIRD_RING_AIR = replaceLetters(THIRD_RING, "L"); + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java new file mode 100644 index 0000000000..776689eee5 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java @@ -0,0 +1,5435 @@ +package tectech.thing.metaTileEntity.multi; + +import static tectech.util.TTUtility.appendStringArrays; +import static tectech.util.TTUtility.replaceLetters; + +public abstract class ForgeOfGodsStructureString { + + public static final String[][] BEAM_SHAFT = { { + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BB BB ", + " B DDD DDD B ", + " DDFD DFDD ", + " DDADD DDADD ", + " DFDD DDFD ", + " DDD DDD ", + " ", + " ", + " ", + " DDD DDD ", + " DFDD DDFD ", + " DDADD DDADD ", + " DDFD DFDD ", + " B DDD DDD B ", + " BB BB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BEEBBBBB BBBBBEEB ", + " BEEEECCCCBCCCCEEEEB ", + " BEEECEE CFC EECEEEB ", + " BECEEE CFC EEECEB ", + " BCEE CFC EECB ", + " BCEE CCCFC EECB ", + " BC CFFCCFC CB ", + " BCCCCFCCFCFCCCCCB ", + " BFFFCCF~FCCFFFB ", + " BCCCCCFCFCCFCCCCB ", + " BC CFCCFFC CB ", + " BCEE CFCCC EECB ", + " BCEE CFC EECB ", + " BECEEE CFC EEECEB ", + " BEEECEE CFC EECEEEB ", + " BEEEECCCCBCCCCEEEEB ", + " BEEBBBBB BBBBBEEB ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BB BB ", + " BBEEBBB BBBEEBB ", + " BEEEEEEB BEEEEEEB ", + " BEEDDDDDBBBBBDDDDDEEB ", + " BEEDEE EEDEEB ", + " BEDE EDEB ", + " BED DEB ", + " BED DEB ", + " BB BB ", + " B B ", + " B B ", + " B B ", + " BB BB ", + " BED DEB ", + " BED DEB ", + " BEDE EDEB ", + " BEEDEE EEDEEB ", + " BEEDDDDDBBBBBDDDDDEEB ", + " BEEEEEEB BEEEEEEB ", + " BBEEBBB BBBEEBB ", + " BB BB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BEEEEB BEEEEB ", + " BEEDDBBB BBBDDEEB ", + " BED DEB ", + " BED DEB ", + " BB BB ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " BB BB ", + " BED DEB ", + " BED DEB ", + " BEEDDBBB BBBDDEEB ", + " BEEEEB BEEEEB ", + " BBBB BBBB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " BB BB ", + " BEEBB BBEEB ", + " BBB BEB ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " BEB BEB ", + " BEBBB BBEEB ", + " BB BB ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BB BB ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " BB BB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " J ", + " BEEEEEB ", + " EEE EEE ", + " E E ", + " EE EE ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " JE EJ ", + " E E ", + " E E ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " EE EE ", + " E E ", + " EEE EEE ", + " BEEEEEB ", + " J " }, + { " ", + " BEEEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEEEB ", + " " }, + { " ", + " BEEEB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " E E ", + " E E ", + " E E ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BEEEB ", + " " }, + { " ", + " BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " B B ", + " B B ", + " B B ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + public static final String[][] FIRST_RING = { { + " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " EEC CEE ", + " EC CE ", + " EC CE ", + " C CCC C ", + " C C C C ", + " C C C C ", + " C C C C ", + " C CCC C ", + " EC CE ", + " EC CE ", + " EEC CEE ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEEC CEEBBB ", + " BBEEEEC DDCEEEEBB ", + " EEEEEEC DDD CEEEEEE ", + " EEEEEC CCCDD CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC CHHHC CEEEEE ", + " EEEEEC DDCCC CEEEEE ", + " EEEEEEC DDD CEEEEEE ", + " BBEEEECDD CEEEEBB ", + " BBBEEC CEEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " BBBBB ", + " BBCCCCCBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBBEEC CEEBBB ", + " BBBBEEEEC CEEEEBBBB ", + " BBEEEEEEEEC CEEEEEEEEBB ", + " EEEEEEEEEC CCC CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC C C CEEEEEEEEE ", + " EEEEEEEEEC CCC CEEEEEEEEE ", + " BBEEEEEEEEC CEEEEEEEEBB ", + " BBBBEEEEC CEEEEBBBB ", + " BBBEEC CEEBBB ", + " BBCC CCBB ", + " BBCC CCBB ", + " BBCCCCCBB ", + " BBBBB ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " BBBBEEEE EEEEBBBB ", + " BBBBBEEEEEEEE EEEEEEEEBBBBB ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " EEEEEEEEEGGGG GGGGEEEEEEEEE ", + " EEEEEEEGGGGGG GGGGGGEEEEEEE ", + " EEEEEEEEEGGGG GGGGEEEEEEEEE ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " BBBBBEEEEEEEE EEEEEEEEBBBBB ", + " BBBBEEEE EEEEBBBB ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BB BB ", + " BBBBBEE EEBBBBB ", + " BBBEEEEEEE EEEEEEEBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEGGGG GGGGEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBEEEEEEE EEEEEEEBBB ", + " BBBBBEE EEBBBBB ", + " BB BB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " BBBBBEEE EEEBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEGGG GGGEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBEEE EEEBBBBB ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEEGG GGEEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEGGG GGGEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + "BBB BBB", + "EEE EEE", + "EEG GEE", + "EEE EEE", + "BBB BBB", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBB BBB ", + " EEE EEE ", + " EEG GEE ", + " EEE EEE ", + " BBB BBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBB BBBB ", + " EEEE EEEE ", + " EEEG GEEE ", + " EEEE EEEE ", + " BBBB BBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEGG GGEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBB BBBBB ", + " EEEEE EEEEE ", + " EEEEG GEEEE ", + " EEEEE EEEEE ", + " BBBBB BBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBB BBBBBB ", + " EEEEEE EEEEEE ", + " EEEEGG GGEEEE ", + " EEEEEE EEEEEE ", + " BBBBBB BBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEGGG GGGEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBB BBBBBBB ", + " EEEEEEE EEEEEEE ", + " EEEEEGG GGEEEEE ", + " EEEEEEE EEEEEEE ", + " BBBBBBB BBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBB BBBBBBBB ", + " EEEEEEEE EEEEEEEE ", + " EEEEEGGG GGGEEEEE ", + " EEEEEEEE EEEEEEEE ", + " BBBBBBBB BBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBB BBBBBBBBBB ", + " EEEEEEEEEE EEEEEEEEEE ", + " EEEEEEGGGG GGGGEEEEEE ", + " EEEEEEEEEE EEEEEEEEEE ", + " BBBBBBBBBB BBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBB BBBBBBBBBBBBB ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " EEEEEEEGGGGGG GGGGGGEEEEEEE ", + " EEEEEEEEEEEEE EEEEEEEEEEEEE ", + " BBBBBBBBBBBBB BBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEGGGGGGGGGGGGGGGEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " }, + { " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " BBBBBBBBBBBBBBB ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " EEEEEEEEEEEEEEE ", + " BBBBBBBBBBBBBBB ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " } }; + public static final String[][] MAIN_STRUCTURE = appendStringArrays(BEAM_SHAFT, FIRST_RING); + public static final String[][] FIRST_RING_AIR = replaceLetters(FIRST_RING, "L"); +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEActiveTransformer.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEActiveTransformer.java new file mode 100644 index 0000000000..d9cc9080cb --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEActiveTransformer.java @@ -0,0 +1,231 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; +import static gregtech.api.GregTechAPI.sBlockCasings1; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.MultiblockTooltipBuilder; +import tectech.Reference; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class MTEActiveTransformer extends TTMultiblockBase implements ISurvivalConstructable { + + // Gives a one-chance grace period for deforming the multi. This is to allow you to hotswap hatches without + // powerfailing due to an unlucky tick timing - this grace period is already a part of base TecTech but the + // tick timer is essentially random, so it was extremely unreliable. Now you are guaranteed the length + // of one structure check to finish your hotswap before it deforms. + private boolean grace = false; + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + casingCount = 0; + if (structureCheck_EM("main", 1, 1, 0) && casingCount >= 5) { + grace = true; + return true; + } else if (grace) { + grace = false; + return true; + } + return false; + } + + @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (!mMachine) { + aBaseMetaTileEntity.disableWorking(); + } + } + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.transformer.hint"), // 1 - Energy IO Hatches or High + // Power Casing + }; + private static final IStructureDefinition<MTEActiveTransformer> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEActiveTransformer>builder() + .addShape( + "main", + new String[][] { { "111", "1~1", "111", }, { "111", "101", "111", }, { "111", "111", "111", }, }) + .addElement('0', ofBlock(sBlockCasings1, 15)) + .addElement( + '1', + buildHatchAdder(MTEActiveTransformer.class) + .atLeast(Energy, HatchElement.EnergyMulti, Dynamo, HatchElement.DynamoMulti) + .casingIndex(BlockGTCasingsTT.textureOffset) + .dot(1) + .buildAndChain(onElementPass(t -> t.casingCount++, ofBlock(TTCasingsContainer.sBlockCasingsTT, 0)))) + .build(); + private int casingCount = 0; + + @Override + public IStructureDefinition<MTEActiveTransformer> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + // endregion + + public MTEActiveTransformer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + eDismantleBoom = false; + } + + public MTEActiveTransformer(String aName) { + super(aName); + eDismantleBoom = false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEActiveTransformer(mName); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (ePowerPass) { + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + } else { + mEfficiencyIncrease = 0; + mMaxProgresstime = 0; + } + eAmpereFlow = 0; + mEUt = 0; + return ePowerPass ? SimpleCheckRecipeResult.ofSuccess("routing") + : SimpleCheckRecipeResult.ofFailure("no_routing"); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.transformer.name")) // Machine Type: + // Transformer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.0")) // Controller block of + // the + // Active Transformer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.1")) // Can transform to + // and from any + // voltage + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.2")) // Only 0.004% power + // loss, HAYO! + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.transformer.desc.3")) // Will explode if + // broken while + // running + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("gt.blockcasingsTT.0.name"), 5, false) // 5x High Power Casing + // (minimum) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.SuperconductingCoilBlock"), + translateToLocal("tt.keyword.Structure.Center")) // SuperconductingCoilBlock: Center + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Energy Hatch: Any + // High Power Casing + .addDynamoHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Dynamo Hatch: Any + // High Power Casing + .toolTipFinisher(CommonValues.TEC_MARK_GENERAL); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][0], + new TTRenderedExtendedFacingTexture(aActive ? TTMultiblockBase.ScreenON : TTMultiblockBase.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][0] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_noise"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + return true; + } + + @Override + public boolean doRandomMaintenanceDamage() { + return true; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if ((aTick & 31) == 31) { + ePowerPass = aBaseMetaTileEntity.isAllowedToWork(); + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 1, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEDataBank.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEDataBank.java new file mode 100644 index 0000000000..30a417ae91 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEDataBank.java @@ -0,0 +1,382 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchDataAccess; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTUtility; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.WirelessComputationPacket; +import gregtech.common.WirelessDataStore; +import tectech.Reference; +import tectech.mechanics.dataTransport.InventoryDataPacket; +import tectech.recipe.TTRecipeAdder; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataItemsInput; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataItemsOutput; +import tectech.thing.metaTileEntity.hatch.MTEHatchWirelessDataItemsOutput; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +public class MTEDataBank extends TTMultiblockBase implements ISurvivalConstructable { + + // region variables + private final ArrayList<MTEHatchDataItemsOutput> eStacksDataOutputs = new ArrayList<>(); + private final ArrayList<MTEHatchWirelessDataItemsOutput> eWirelessStacksDataOutputs = new ArrayList<>(); + private final ArrayList<IInventory> eDataAccessHatches = new ArrayList<>(); + private boolean slave = false; + private boolean wirelessModeEnabled = false; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.databank.hint.0"), // 1 - Classic Hatches or high power + // casing + translateToLocal("gt.blockmachines.multimachine.em.databank.hint.1"), // 2 - Data Access/Data Bank Master + // Hatches or + // computer casing + }; + + private static final IStructureDefinition<MTEDataBank> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEDataBank>builder() + .addShape( + "main", + transpose( + new String[][] { { "BCCCB", "BDDDB", "BDDDB" }, { "BC~CB", "BAAAB", "BDDDB" }, + { "BCCCB", "BDDDB", "BDDDB" } })) + .addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsTT, 1)) + .addElement('B', ofBlock(TTCasingsContainer.sBlockCasingsTT, 2)) + .addElement('C', classicHatches(BlockGTCasingsTT.textureOffset, 1, TTCasingsContainer.sBlockCasingsTT, 0)) + .addElement( + 'D', + buildHatchAdder(MTEDataBank.class) + .atLeast( + DataBankHatches.OutboundConnector, + DataBankHatches.InboundConnector, + DataBankHatches.WirelessOutboundConnector) + .casingIndex(BlockGTCasingsTT.textureOffset + 1) + .dot(2) + .buildAndChain( + DataBankHatches.DataStick + .newAnyOrCasing(BlockGTCasingsTT.textureOffset + 1, 2, TTCasingsContainer.sBlockCasingsTT, 1))) + .build(); + // endregion + + public MTEDataBank(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEDataBank(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDataBank(mName); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.databank.name")) // Machine Type: Data Bank + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.0")) // Controller block of + // the Data Bank + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.1")) // Used to supply + // Assembling Lines + // with more Data Sticks + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.2")) // and give multiple + // Assembling Lines access to + // the same Data + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.databank.desc.3")) // Use screwdriver to toggle + // wireless mode + + // Stick + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(5, 3, 3, false) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataAccessHatch"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Access Hatch: Any Computer Casing + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.dataoutass.tier.07.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Bank Master Connector: Any Computer Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Energy Hatch: Any + // High Power Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) // Maintenance + // Hatch: Any High + // Power Casing + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + eDataAccessHatches.clear(); + eStacksDataOutputs.clear(); + eWirelessStacksDataOutputs.clear(); + slave = false; + return structureCheck_EM("main", 2, 1, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (eDataAccessHatches.size() > 0 && (eStacksDataOutputs.size() > 0 || eWirelessStacksDataOutputs.size() > 0)) { + mEUt = -(int) V[slave ? 6 : 4]; + eAmpereFlow = 1 + + (long) (eStacksDataOutputs.size() + eWirelessStacksDataOutputs.size()) * eDataAccessHatches.size(); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("providing_data"); + } + return SimpleCheckRecipeResult.ofFailure("no_data"); + } + + @Override + public void outputAfterRecipe_EM() { + ArrayList<ItemStack> stacks = new ArrayList<>(); + for (IInventory dataAccess : eDataAccessHatches) { + int count = dataAccess.getSizeInventory(); + for (int i = 0; i < count; i++) { + ItemStack stack = dataAccess.getStackInSlot(i); + if (stack != null) { + stacks.add(stack); + } + } + } + if (stacks.size() > 0) { + ItemStack[] arr = stacks.toArray(TTRecipeAdder.nullItem); + for (MTEHatchDataItemsOutput hatch : eStacksDataOutputs) { + hatch.q = new InventoryDataPacket(arr); + } + if (wirelessModeEnabled) { + for (MTEHatchWirelessDataItemsOutput hatch : eWirelessStacksDataOutputs) { + hatch.dataPacket = new InventoryDataPacket(arr); + } + } + } else { + for (MTEHatchDataItemsOutput hatch : eStacksDataOutputs) { + hatch.q = null; + } + for (MTEHatchWirelessDataItemsOutput hatch : eWirelessStacksDataOutputs) { + hatch.dataPacket = null; + } + } + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][1], + new TTRenderedExtendedFacingTexture(aActive ? TTMultiblockBase.ScreenON : TTMultiblockBase.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][1] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_hi_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + public final boolean addDataBankHatchToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchWirelessDataItemsOutput) { + ((MTEHatchWirelessDataItemsOutput) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eWirelessStacksDataOutputs.add((MTEHatchWirelessDataItemsOutput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataItemsOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eStacksDataOutputs.add((MTEHatchDataItemsOutput) aMetaTileEntity); + } else + if (aMetaTileEntity instanceof MTEHatchDataAccess && !(aMetaTileEntity instanceof MTEHatchDataItemsInput)) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDataAccessHatches.add(aMetaTileEntity); + } else if (aMetaTileEntity instanceof MTEHatchDataItemsInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + slave = true; + return eDataAccessHatches.add(aMetaTileEntity); + } + return false; + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + // Every 200 ticks, clear wireless data store so hatches need to provide their data again in + // their onPostTick() call. This also happens every 200 ticks + if (mMachine && aBaseMetaTileEntity.isActive() && wirelessModeEnabled && aTick % 200 == 0) { + WirelessDataStore wirelessStore = WirelessDataStore + .getWirelessDataSticks(aBaseMetaTileEntity.getOwnerUuid()); + wirelessStore.clearData(); + + // After reset, clear uploadedSinceReset of all connected hatches + for (MTEHatchWirelessDataItemsOutput hatch : eWirelessStacksDataOutputs) { + hatch.uploadedSinceReset = false; + } + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isServerSide()) { + wirelessModeEnabled = !wirelessModeEnabled; + if (wirelessModeEnabled) { + GTUtility.sendChatToPlayer(aPlayer, "Wireless mode enabled"); + WirelessComputationPacket.enableWirelessNetWork(getBaseMetaTileEntity()); + } else { + GTUtility.sendChatToPlayer(aPlayer, "Wireless mode disabled"); + WirelessComputationPacket.disableWirelessNetWork(getBaseMetaTileEntity()); + } + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setBoolean("wirelessModeEnabled", wirelessModeEnabled); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (aNBT.hasKey("wirelessModeEnabled")) { + wirelessModeEnabled = aNBT.getBoolean("wirelessModeEnabled"); + } else { + wirelessModeEnabled = false; + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 2, 1, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 2, 1, 0, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition<MTEDataBank> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + private enum DataBankHatches implements IHatchElement<MTEDataBank> { + + DataStick(MTEHatchDataAccess.class) { + + @Override + public long count(MTEDataBank t) { + return t.eDataAccessHatches.size(); + } + }, + OutboundConnector(MTEHatchDataItemsOutput.class) { + + @Override + public long count(MTEDataBank t) { + return t.eStacksDataOutputs.size(); + } + }, + InboundConnector(MTEHatchDataItemsInput.class) { + + @Override + public long count(MTEDataBank t) { + return t.eDataAccessHatches.size(); + } + }, + WirelessOutboundConnector(MTEHatchWirelessDataItemsOutput.class) { + + @Override + public long count(MTEDataBank t) { + return t.eWirelessStacksDataOutputs.size(); + } + }; + + private final List<? extends Class<? extends IMetaTileEntity>> mteClasses; + + @SafeVarargs + DataBankHatches(Class<? extends IMetaTileEntity>... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + } + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return mteClasses; + } + + @Override + public IGTHatchAdder<? super MTEDataBank> adder() { + return MTEDataBank::addDataBankHatchToMachineList; + } + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEEnergyInfuser.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEEnergyInfuser.java new file mode 100644 index 0000000000..b52069fe96 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEEnergyInfuser.java @@ -0,0 +1,315 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.mEUtoRF; +import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.MTEHatchInputBusME; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import tectech.Reference; +import tectech.TecTech; +import tectech.loader.TecTechConfig; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class MTEEnergyInfuser extends TTMultiblockBase implements IConstructable { + + private static final int maxRepairedDamagePerOperation = 1000; + private static final long usedEuPerDurability = 1000; + private static final int usedUumPerDurability = 1; + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + // 1 - Classic Hatches or High Power Casing + translateToLocal("gt.blockmachines.multimachine.em.infuser.hint"), }; + + private static final IStructureDefinition<MTEEnergyInfuser> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEEnergyInfuser>builder() + .addShape( + "main", + transpose( + new String[][] { { "CCC", "CCC", "CCC" }, { "BBB", "BAB", "BBB" }, { "A~A", "AAA", "AAA" }, + { "BBB", "BAB", "BBB" }, { "CCC", "CCC", "CCC" } })) + .addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsTT, 4)) + .addElement('B', ofBlock(TTCasingsContainer.sBlockCasingsTT, 7)) + .addElement( + 'C', + ofHatchAdderOptional( + MTEEnergyInfuser::addClassicToMachineList, + BlockGTCasingsTT.textureOffset, + 1, + TTCasingsContainer.sBlockCasingsTT, + 0)) + .build(); + // endregion + + public MTEEnergyInfuser(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + minRepairStatus = (byte) getIdealStatus(); + eDismantleBoom = true; + } + + public MTEEnergyInfuser(String aName) { + super(aName); + minRepairStatus = (byte) getIdealStatus(); + eDismantleBoom = true; + } + + private boolean isItemStackFullyCharged(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + if (stack.stackSize == 1) { + if (item instanceof IElectricItem) { + return ElectricItem.manager.getCharge(stack) >= ((IElectricItem) item).getMaxCharge(stack); + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + return ((IEnergyContainerItem) item).getEnergyStored(stack) + >= ((IEnergyContainerItem) item).getMaxEnergyStored(stack); + } + } + return true; + } + + private boolean isItemStackFullyRepaired(ItemStack stack) { + if (stack == null) { + return true; + } + Item item = stack.getItem(); + return !item.isRepairable() || item.getMaxDamage(stack) <= 0 || item.getDamage(stack) <= 0; + } + + private long doChargeItemStack(IElectricItem item, ItemStack stack) { + try { + double euDiff = item.getMaxCharge(stack) - ElectricItem.manager.getCharge(stack); + long remove = (long) Math.ceil( + ElectricItem.manager.charge(stack, Math.min(euDiff, getEUVar()), item.getTier(stack), true, false)); + setEUVar(getEUVar() - remove); + if (getEUVar() < 0) { + setEUVar(0); + } + return remove; + } catch (Exception e) { + if (TecTechConfig.DEBUG_MODE) { + e.printStackTrace(); + } + } + return 0; + } + + private long doChargeItemStackRF(IEnergyContainerItem item, ItemStack stack) { + try { + long RF = Math + .min(item.getMaxEnergyStored(stack) - item.getEnergyStored(stack), getEUVar() * mEUtoRF / 100L); + RF = item.receiveEnergy(stack, RF > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) RF, false); + RF = RF * 100L / mEUtoRF; + setEUVar(getEUVar() - RF); + if (getEUVar() < 0) { + setEUVar(0); + } + return RF; + } catch (Exception e) { + if (TecTechConfig.DEBUG_MODE) { + e.printStackTrace(); + } + } + return 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEEnergyInfuser(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 1, 2, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + for (MTEHatchInputBus inputBus : mInputBusses) { + if (inputBus instanceof MTEHatchInputBusME) continue; + for (int i = 0; i < inputBus.getSizeInventory(); i++) { + ItemStack itemStackInBus = inputBus.getStackInSlot(i); + if (itemStackInBus == null) continue; + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize != 1 || item == null) continue; + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + return SimpleCheckRecipeResult.ofSuccess("charging"); + } + } + } + return SimpleCheckRecipeResult.ofFailure("no_chargeable_item"); + } + + @Override + public void outputAfterRecipe_EM() { + boolean itemProcessed = false; + startRecipeProcessing(); + for (MTEHatchInputBus inputBus : mInputBusses) { + if (inputBus instanceof MTEHatchInputBusME) continue; + for (int i = 0; i < inputBus.getSizeInventory(); i++) { + ItemStack itemStackInBus = inputBus.getStackInSlot(i); + if (itemStackInBus == null) continue; + Item item = itemStackInBus.getItem(); + if (itemStackInBus.stackSize != 1 || item == null) continue; + if (isItemStackFullyCharged(itemStackInBus) && isItemStackFullyRepaired(itemStackInBus)) { + itemProcessed = true; + if (addOutput(itemStackInBus)) { + this.depleteInput(itemStackInBus); + } + } else { + if (item.isRepairable()) { + FluidStack uum = getStoredFluids().stream() + .filter( + fluid -> Materials.UUMatter.getFluid(1) + .isFluidEqual(fluid)) + .findAny() + .orElse(null); + if (uum != null) { + int repairedDamage = Math + .min(item.getDamage(itemStackInBus), maxRepairedDamagePerOperation); + long euCost = repairedDamage * usedEuPerDurability; + if (getEUVar() >= euCost && depleteInput( + new FluidStack(Materials.UUMatter.mFluid, repairedDamage * usedUumPerDurability))) { + item.setDamage( + itemStackInBus, + Math.max(item.getDamage(itemStackInBus) - repairedDamage, 0)); + setEUVar(Math.min(getEUVar() - euCost, 0)); + } + } + } + if (item instanceof IElectricItem) { + doChargeItemStack((IElectricItem) item, itemStackInBus); + return; + } else if (TecTech.hasCOFH && item instanceof IEnergyContainerItem) { + doChargeItemStackRF((IEnergyContainerItem) item, itemStackInBus); + return; + } + } + } + } + endRecipeProcessing(); + if (!itemProcessed) { + afterRecipeCheckFailed(); + } + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + // Machine Type: Energy Infuser + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.infuser.name")) + // Controller block of the Energy Infuser + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.0")) + // Can be used to charge items (lossless) + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.1")) + // Can be fed with UU-Matter to repair items + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.2")) + // Stocking Bus is not supported + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.infuser.desc.3")) + .addSeparator() + .beginStructureBlock(3, 5, 3, false) + // Controller: Front 3rd layer center + .addController(translateToLocal("tt.keyword.Structure.FrontCenter3rd")) + .addOtherStructurePart( + // High Power + translateToLocal("gt.blockcasingsTT.0.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.HighPowerCasing")) + // Casing: Layer + // 1 and 5 + .addOtherStructurePart( + // Molecular Coil + translateToLocal("gt.blockcasingsTT.7.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.MolecularCoil")) + // Layer 2 and 4 + .addOtherStructurePart( + // Molecular + translateToLocal("gt.blockcasingsTT.4.name"), + translateToLocal("gt.blockmachines.multimachine.em.infuser.Structure.MolecularCasing")) + // Casing: Layer + // 3 (hollow) + // Energy Hatch: Any High Power Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) + // Maintenance Hatch: Any High Power Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyHighPowerCasing"), 1) + .toolTipFinisher(CommonValues.TEC_MARK_GENERAL); + return tt; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_whooum"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 2, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition<MTEEnergyInfuser> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEEyeOfHarmony.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEEyeOfHarmony.java new file mode 100644 index 0000000000..0104723c3c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEEyeOfHarmony.java @@ -0,0 +1,1845 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.withChannel; +import static gregtech.api.enums.GTValues.AuthorColen; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.formatNumbers; +import static gregtech.api.util.ParallelHelper.calculateChancedOutputMultiplier; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.strongCheckOrAddUser; +import static java.lang.Math.exp; +import static java.lang.Math.max; +import static java.lang.Math.pow; +import static kekztech.util.Util.toStandardForm; +import static net.minecraft.util.EnumChatFormatting.AQUA; +import static net.minecraft.util.EnumChatFormatting.BLUE; +import static net.minecraft.util.EnumChatFormatting.GOLD; +import static net.minecraft.util.EnumChatFormatting.GRAY; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +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.util.ChatComponentText; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.MathHelper; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.google.common.collect.ImmutableList; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTLanguageManager; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.common.tileentities.machines.MTEHatchInputBusME; +import gregtech.common.tileentities.machines.MTEHatchOutputBusME; +import gregtech.common.tileentities.machines.MTEHatchOutputME; +import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtneioreplugin.plugin.block.BlockDimensionDisplay; +import gtneioreplugin.plugin.block.ModBlocks; +import tectech.TecTech; +import tectech.recipe.EyeOfHarmonyRecipe; +import tectech.recipe.TecTechRecipeMaps; +import tectech.thing.CustomItemList; +import tectech.thing.block.TileEntityEyeOfHarmony; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; +import tectech.util.FluidStackLong; +import tectech.util.ItemStackLong; + +@SuppressWarnings("SpellCheckingInspection") +public class MTEEyeOfHarmony extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { + + public static final boolean EOH_DEBUG_MODE = false; + private static final long MOLTEN_SPACETIME_PER_FAILURE_TIER = 14_400L; + private static final double SPACETIME_FAILURE_BASE = 2; + private static final String TOOLTIP_BAR = GOLD + + "---------------------------------------------------------------------------------------"; + + // Region variables. + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int spacetimeCompressionFieldMetadata = -1; + private int timeAccelerationFieldMetadata = -1; + private int stabilisationFieldMetadata = -1; + + private static final double SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE = 0.03; + private static final double TIME_ACCEL_DECREASE_CHANCE_PER_TIER = 0.0925; + // % Increase in recipe chance and % decrease in yield per tier. + private static final double STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER = 0.05; + private static final double PARALLEL_FOR_FIRST_ASTRAL_ARRAY = 8; + private static final double CONSTANT_FOR_LOG = 1.7; + private static final double LOG_CONSTANT = Math.log(CONSTANT_FOR_LOG); + private static final double PARALLEL_MULTIPLIER_CONSTANT = 1.63; + private static final double POWER_DIVISION_CONSTANT = 20.7; + private static final double POWER_INCREASE_CONSTANT = 2.3; + private static final int TOTAL_CASING_TIERS_WITH_POWER_PENALTY = 8; + private static final long PRECISION_MULTIPLIER = 1_000_000; + // Exact value to get 2^21 parallels. + private static final long ASTRAL_ARRAY_LIMIT = 8637; + + private UUID userUUID; + private BigInteger outputEU_BigInt = BigInteger.ZERO; + private long startEU = 0; + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int realBudget = elementBudget >= 200 ? elementBudget : Math.min(200, elementBudget * 5); // 200 blocks max per + // placement. + return survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 16, 16, 0, realBudget, source, actor, false, true); + } + + protected static final String STRUCTURE_PIECE_MAIN = "main"; + + // Multiblock structure. + private static final IStructureDefinition<MTEEyeOfHarmony> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEEyeOfHarmony>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + transpose( + new String[][] { + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " C C ", " CCCCCCCCC ", + " C C ", " CCCCCCCCC ", + " C C ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " C C ", " DDDDD ", + " DDCDCDD ", " CCCCDCCDCCDCCCC ", + " DDDDDDD ", " CCCCDCCDCCDCCCC ", + " DDCDCDD ", " DDDDD ", + " C C ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " D ", " D ", + " DDDDDDD ", " DD DD ", + " D EEE D ", " CCC D EAAAE D CCC ", + " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", + " D EEE D ", " DD DD ", + " DDDDDDD ", " D ", + " D ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " D ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DD DD ", " CC CC ", + " ", " ", + " ", " ", + " ", " D ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " A ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDAA AADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " A ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDA ADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " " }, + { " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " " }, + { " ", " ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " DA AD ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " ", + " " }, + { " ", " C C ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DA AD ", " CC CC ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " CCCCCCC ", " C C ", + " DDDDDDD ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " D D ", + " D D ", "CCD DCC", + " D D ", "CCD DCC", + " D D ", " D D ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " DDDDDDD ", " C C ", + " C C " }, + { " CCHHHHHCC ", " DDDDD ", + " DD DD ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CD DC", + " D D ", "CD DC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " DD DD ", " DDDDD ", + " C C " }, + { " CHHHHHHHC ", " DDCDCDD ", + " D EEE D ", " ", + " C C ", " E E ", + " C C ", " E E ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CCE ECC", + " DE ED ", "CCE ECC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " E E ", + " C C ", " E E ", + " C C ", " ", + " D EEE D ", " DDCDCDD ", + " C C " }, + { " CHHCCCHHC ", " CCCCDCCDCCDCCCC ", + " CCC D EAAAE D CCC ", " CC CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " C C ", " CC CC ", + " C C ", " C C ", + "CCD DCC", "CD DC", + "CCE ECC", "CCA ACC", + "CDA ADC", "CCA ACC", + "CCE ECC", "CD DC", + "CCD DCC", " C C ", + " C C ", " CC CC ", + " C C ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC CC ", + " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", + " CCCCCCCCC " }, + { " CHHC~CHHC ", " DDDDDDD ", + " DDD EAAAE DDD ", " DD DD ", + " CDAA AADC ", " DA AD ", + " CDA ADC ", " DA AD ", + " DA AD ", " DA AD ", + " D D ", " D D ", + " D D ", " D D ", + " DE ED ", "CDA ADC", + " DA AD ", "CDA ADC", + " DE ED ", " D D ", + " D D ", " D D ", + " D D ", " DA AD ", + " DA AD ", " DA AD ", + " CDA ADC ", " DA AD ", + " CDAA AADC ", " DD DD ", + " DDD EAAAE DDD ", " DDDDDDD ", + " C C " }, + { " CHHCCCHHC ", " CCCCDCCDCCDCCCC ", + " CCC D EAAAE D CCC ", " CC CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " C C ", " CC CC ", + " C C ", " C C ", + "CCD DCC", "CD DC", + "CCE ECC", "CCA ACC", + "CDA ADC", "CCA ACC", + "CCE ECC", "CD DC", + "CCD DCC", " C C ", + " C C ", " CC CC ", + " C C ", " CC E E CC ", + " CC CC ", " CC E E CC ", + " CC CC ", " CC CC ", + " CCC D EAAAE D CCC ", " CCCCDCCDCCDCCCC ", + " CCCCCCCCC " }, + { " CHHHHHHHC ", " DDCDCDD ", + " D EEE D ", " ", + " C C ", " E E ", + " C C ", " E E ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CCE ECC", + " DE ED ", "CCE ECC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " E E ", + " C C ", " E E ", + " C C ", " ", + " D EEE D ", " DDCDCDD ", + " C C " }, + { " CCHHHHHCC ", " DDDDD ", + " DD DD ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " ", " ", + " D D ", " D D ", + " D D ", "CD DC", + " D D ", "CD DC", + " D D ", " D D ", + " D D ", " ", + " ", " ", + " ", " S S ", + " ", " S S ", + " ", " ", + " DD DD ", " DDDDD ", + " C C " }, + { " CCCCCCC ", " C C ", + " DDDDDDD ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " D D ", + " D D ", "CCD DCC", + " D D ", "CCD DCC", + " D D ", " D D ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " DDDDDDD ", " C C ", + " C C " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " D ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " D D ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " D ", " C C ", + " " }, + { " ", " C C ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DA AD ", " CC CC ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " C C ", + " " }, + { " ", " ", + " C C ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " DA AD ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " C C ", " ", + " " }, + { " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " " }, + { " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDA ADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " SEEAEES ", + " ", " ", + " ", " ", + " ", " S S ", + " E E ", " CC E E CC ", + " DA AD ", " CC E E CC ", + " E E ", " S S ", + " ", " ", + " ", " ", + " ", " SEEAEES ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " C C ", + " CCCCC ", " D ", + " A ", " A ", + " ", " ", + " ", " ", + " C C ", " CC CC ", + " CDAA AADC ", " CC CC ", + " C C ", " ", + " ", " ", + " ", " A ", + " A ", " D ", + " CCCCC ", " C C ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " D ", " D ", + " ", " ", + " ", " ", + " ", " CC CC ", + " DD DD ", " CC CC ", + " ", " ", + " ", " ", + " ", " D ", + " D ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " D ", " D ", + " DDDDDDD ", " DD DD ", + " D EEE D ", " CCC D EAAAE D CCC ", + " DDD EAAAE DDD ", " CCC D EAAAE D CCC ", + " D EEE D ", " DD DD ", + " DDDDDDD ", " D ", + " D ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " C C ", + " C C ", " C C ", + " C C ", " DDDDD ", + " DDCDCDD ", " CCCCDCCDCCDCCCC ", + " DDDDDDD ", " CCCCDCCDCCDCCCC ", + " DDCDCDD ", " DDDDD ", + " C C ", " C C ", + " C C ", " C C ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " }, + { " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " C C ", " C C ", + " C C ", " CCCCCCCCC ", + " C C ", " CCCCCCCCC ", + " C C ", " C C ", + " C C ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " ", " ", + " " } })) + .addElement( + 'A', + withChannel( + "spacetime compression", + ofBlocksTiered( + (block, meta) -> block == TTCasingsContainer.SpacetimeCompressionFieldGenerators ? meta : null, + ImmutableList.of( + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 0), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 1), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 2), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 3), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 4), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 5), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 6), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 7), + Pair.of(TTCasingsContainer.SpacetimeCompressionFieldGenerators, 8)), + -1, + (t, meta) -> t.spacetimeCompressionFieldMetadata = meta, + t -> t.spacetimeCompressionFieldMetadata))) + .addElement( + 'S', + withChannel( + "stabilisation", + ofBlocksTiered( + (block, meta) -> block == TTCasingsContainer.StabilisationFieldGenerators ? meta : null, + ImmutableList.of( + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 0), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 1), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 2), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 3), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 4), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 5), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 6), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 7), + Pair.of(TTCasingsContainer.StabilisationFieldGenerators, 8)), + -1, + (t, meta) -> t.stabilisationFieldMetadata = meta, + t -> t.stabilisationFieldMetadata))) + .addElement('C', ofBlock(TTCasingsContainer.sBlockCasingsBA0, 11)) + .addElement('D', ofBlock(TTCasingsContainer.sBlockCasingsBA0, 10)) + .addElement( + 'H', + buildHatchAdder(MTEEyeOfHarmony.class).atLeast(InputHatch, OutputHatch, InputBus, OutputBus) + .casingIndex(BlockGTCasingsTT.texturePage << 7) + .dot(1) + .buildAndChain(TTCasingsContainer.sBlockCasingsBA0, 12)) + .addElement( + 'E', + withChannel( + "time dilation", + ofBlocksTiered( + (block, meta) -> block == TTCasingsContainer.TimeAccelerationFieldGenerator ? meta : null, + ImmutableList.of( + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 0), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 1), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 2), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 3), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 4), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 5), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 6), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 7), + Pair.of(TTCasingsContainer.TimeAccelerationFieldGenerator, 8)), + -1, + (t, meta) -> t.timeAccelerationFieldMetadata = meta, + t -> t.timeAccelerationFieldMetadata))) + .build(); + + private double hydrogenOverflowProbabilityAdjustment; + private double heliumOverflowProbabilityAdjustment; + private double stellarPlasmaOverflowProbabilityAdjustment; + private static final long TICKS_BETWEEN_HATCH_DRAIN = EOH_DEBUG_MODE ? 10 : 20; + + private List<ItemStackLong> outputItems = new ArrayList<>(); + private List<FluidStackLong> outputFluids = new ArrayList<>(); + + private void calculateInputFluidExcessValues(final long hydrogenRecipeRequirement, + final long heliumRecipeRequirement) { + + double hydrogenStored = getHydrogenStored(); + double heliumStored = getHeliumStored(); + double stellarPlasmaStored = getStellarPlasmaStored(); + + double hydrogenExcessPercentage = hydrogenStored / hydrogenRecipeRequirement - 1; + double heliumExcessPercentage = heliumStored / heliumRecipeRequirement - 1; + double stellarPlasmaExcessPercentage = stellarPlasmaStored + / (heliumRecipeRequirement * (12.4 / 1_000_000f) * parallelAmount) - 1; + + hydrogenOverflowProbabilityAdjustment = 1 - exp(-pow(30 * hydrogenExcessPercentage, 2)); + heliumOverflowProbabilityAdjustment = 1 - exp(-pow(30 * heliumExcessPercentage, 2)); + stellarPlasmaOverflowProbabilityAdjustment = 1 - exp(-pow(30 * stellarPlasmaExcessPercentage, 2)); + } + + private double recipeChanceCalculator() { + double chance = currentRecipe.getBaseRecipeSuccessChance() + - timeAccelerationFieldMetadata * TIME_ACCEL_DECREASE_CHANCE_PER_TIER + + stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + + if (parallelAmount > 1) { + chance -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + chance -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } + + return MathHelper.clamp_double(chance, 0.0, 1.0); + } + + private double recipeYieldCalculator() { + double yield = 1.0 - stabilisationFieldMetadata * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + + if (parallelAmount > 1) { + yield -= stellarPlasmaOverflowProbabilityAdjustment; + } else { + yield -= (hydrogenOverflowProbabilityAdjustment + heliumOverflowProbabilityAdjustment); + } + return MathHelper.clamp_double(yield, 0.0, 1.0); + } + + private int recipeProcessTimeCalculator(final long recipeTime, final long recipeSpacetimeCasingRequired) { + + // Tier 1 recipe. + // Tier 2 spacetime blocks. + // = 3% discount. + + // Tier 1 recipe. + // Tier 3 spacetime blocks. + // = 3%*3% = 5.91% discount. + + final long spacetimeCasingDifference = (recipeSpacetimeCasingRequired - spacetimeCompressionFieldMetadata); + final double recipeTimeDiscounted = recipeTime * pow(2.0, -timeAccelerationFieldMetadata) + * pow(1 - SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE, -spacetimeCasingDifference) + / max(1, pow(2, currentCircuitMultiplier)); + return (int) Math.max(recipeTimeDiscounted, 1.0); + } + + @Override + public IStructureDefinition<MTEEyeOfHarmony> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + public MTEEyeOfHarmony(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEEyeOfHarmony(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEEyeOfHarmony(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + + spacetimeCompressionFieldMetadata = -1; + timeAccelerationFieldMetadata = -1; + stabilisationFieldMetadata = -1; + + // Check structure of multi. + if (!structureCheck_EM(STRUCTURE_PIECE_MAIN, 16, 16, 0)) { + return false; + } + + // Make sure there are no Crafting Input Buffers/Buses/Slaves. + if (!mDualInputHatches.isEmpty()) { + return false; + } + + // Check if there is 1 output bus, and it is a ME output bus. + { + if (mOutputBusses.size() != 1) { + return false; + } + + if (!(mOutputBusses.get(0) instanceof MTEHatchOutputBusME)) { + return false; + } + } + + // Check if there is 1 output hatch, and they are ME output hatches. + { + if (mOutputHatches.size() != 1) { + return false; + } + + if (!(mOutputHatches.get(0) instanceof MTEHatchOutputME)) { + return false; + } + } + + // Check there is 1 input bus, and it is not a stocking input bus. + { + if (mInputBusses.size() != 1) { + return false; + } + + if (mInputBusses.get(0) instanceof MTEHatchInputBusME) { + return false; + } + } + + // Make sure there are no energy hatches. + { + if (mEnergyHatches.size() > 0) { + return false; + } + + if (mExoticEnergyHatches.size() > 0) { + return false; + } + } + + // Make sure there are 2 input hatches. + if (mInputHatches.size() != 2) { + return false; + } + + return true; + } + + private boolean animationsEnabled = true; + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + animationsEnabled = !animationsEnabled; + aPlayer.addChatMessage( + new ChatComponentText("Animations are now " + (animationsEnabled ? "enabled" : "disabled") + ".")); + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ, ItemStack aTool) { + if (astralArrayAmount != 0) { + while (astralArrayAmount >= 64) { + if (aPlayer.inventory.getFirstEmptyStack() != -1) { + aPlayer.inventory.addItemStackToInventory(CustomItemList.astralArrayFabricator.get(64)); + astralArrayAmount -= 64; + } else { + break; + } + } + if (aPlayer.inventory.getFirstEmptyStack() != -1) { + aPlayer.inventory.addItemStackToInventory(CustomItemList.astralArrayFabricator.get(astralArrayAmount)); + astralArrayAmount = 0; + } + } + return true; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (getControllerSlot() == null) { + ItemStack heldItem = aPlayer.getHeldItem(); + if (GTUtility.getBlockFromStack(heldItem) instanceof BlockDimensionDisplay) { + mInventory[getControllerSlotIndex()] = heldItem.copy(); + mInventory[getControllerSlotIndex()].stackSize = 1; + aPlayer.setCurrentItemOrArmor(0, ItemUtils.depleteStack(heldItem)); + return true; + } + } + return super.onRightclick(aBaseMetaTileEntity, aPlayer); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Spacetime Manipulator, EOH") + .addInfo(TOOLTIP_BAR) + .addInfo("Creates a pocket of spacetime that is bigger on the inside using transdimensional") + .addInfo("engineering. Certified Time Lord regulation compliant. This multi uses too much EU") + .addInfo("to be handled with conventional means. All EU requirements are handled directly by") + .addInfo("your wireless EU network.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock will constantly consume hydrogen and helium when it is not running a") + .addInfo("recipe once per second. It will store this internally, you can see the totals by") + .addInfo("using a scanner. This multi also has three tiered blocks with " + RED + 9 + GRAY + " tiers") + .addInfo("each. They are as follows and have the associated effects on the multi.") + .addInfo(BLUE + "Spacetime Compression Field Generator:") + .addInfo("- The tier of this block determines what recipes can be run. If the multiblocks") + .addInfo(" spacetime compression field block exceeds the requirements of the recipe it") + .addInfo( + " will decrease the processing time by " + RED + + formatNumbers(SPACETIME_CASING_DIFFERENCE_DISCOUNT_PERCENTAGE * 100) + + "%" + + GRAY + + " per tier over the requirement (multiplicative).") + .addInfo(BLUE + "Time Dilation Field Generator:") + .addInfo( + "- Decreases the time required for a recipe by " + RED + + "50%" + + GRAY + + " per tier of block (multiplicative).") + .addInfo( + " Decreases the probability of a recipe succeeding by " + RED + + formatNumbers(TIME_ACCEL_DECREASE_CHANCE_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive)") + .addInfo(BLUE + "Stabilisation Field Generator:") + .addInfo( + "- Increases the probability of a recipe succeeding by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive).") + .addInfo( + " Decreases the yield of a recipe by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive). ") + .addInfo(" > Low tier stabilisation field generators have a power output penalty.") + .addInfo( + " The power output penalty for using Crude Stabilisation Field Generators is " + RED + + formatNumbers( + STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * TOTAL_CASING_TIERS_WITH_POWER_PENALTY + * 100) + + "%" + + GRAY + + ".") + .addInfo( + " This penalty decreases by " + RED + + formatNumbers(STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER * 100) + + "%" + + GRAY + + " per tier (additive).") + .addInfo(TOOLTIP_BAR) + .addInfo("Going over a recipe requirement on hydrogen or helium has a penalty on yield and recipe chance.") + .addInfo("All stored hydrogen and helium is consumed during a craft. The associated formulas are:") + .addInfo(GREEN + "Overflow ratio = (Stored fluid / Recipe requirement) - 1") + .addInfo(GREEN + "Adjustment value = 1 - exp(-(30 * Overflow ratio)^2)") + .addInfo("The Adjustment value is then subtracted from the total yield and recipe chance.") + .addInfo(TOOLTIP_BAR) + .addInfo("It should be noted that base recipe chance is determined per recipe and yield always starts") + .addInfo("at 1 and subtracts depending on penalties. All fluid/item outputs are multiplied by the") + .addInfo("yield. Failure fluid is exempt.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock can only output to ME output buses/hatches.") + .addInfo(TOOLTIP_BAR) + .addInfo("This multiblock can be overclocked by placing a programmed circuit into the input bus.") + .addInfo( + "E.g. A circuit of 2 will provide 2 OCs, 16x EU input and 0.25x the time. EU output is unaffected.") + .addInfo("All outputs are equal. All item and fluid output chances & amounts per recipe are unaffected.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "If a recipe fails the EOH will output " + GREEN + + "Success chance * " + + formatNumbers(MOLTEN_SPACETIME_PER_FAILURE_TIER) + + " * (" + + SPACETIME_FAILURE_BASE + + ")^(Recipe tier)" + + GRAY + + "L of molten") + .addInfo( + MaterialsUEVplus.SpaceTime.getLocalizedNameForItem("%material") + + " instead of fluid/item outputs and output as much EU as a successful recipe.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "This multiblock can perform parallel processing by placing Astral Array Fabricators into the input bus.") + .addInfo( + "They are stored internally and can be retrieved via right-clicking the controller with a wire cutter.") + .addInfo( + "The maximum amount of stored Astral Arrays is " + formatNumbers(ASTRAL_ARRAY_LIMIT) + + ". The amount of parallel is calculated via these formulas:") + .addInfo( + GREEN + "Parallel exponent = floor(log(" + + formatNumbers(PARALLEL_FOR_FIRST_ASTRAL_ARRAY) + + " * Astral Array amount) / log(" + + formatNumbers(CONSTANT_FOR_LOG) + + "))") + .addInfo(GREEN + "Parallel = 2^(Parallel exponent)") + .addInfo("If the EOH is running parallel recipes, the power calculation changes.") + .addInfo("The power needed for parallel processing is calculated as follows:") + .addInfo( + GREEN + "total EU = ((EU output - EU input * " + + formatNumbers(PARALLEL_MULTIPLIER_CONSTANT) + + ") / " + + formatNumbers(POWER_DIVISION_CONSTANT) + + ") * " + + formatNumbers(POWER_INCREASE_CONSTANT) + + "^(Parallel exponent)") + .addInfo( + "Furthermore, if parallel recipes are run, the recipes consume " + + MaterialsUEVplus.RawStarMatter.getLocalizedNameForItem("%material")) + .addInfo("instead of helium and hydrogen. Overflow penalties still apply.") + .addInfo( + "The required amount of fluid to start a recipe is " + GREEN + + "12.4 / 10^6 * Helium amount * Parallel" + + GRAY + + ".") + .addInfo("The success or failure of each parallel is determined independently.") + .addInfo(TOOLTIP_BAR) + .addInfo("Animations can be disabled by using a screwdriver on the multiblock.") + .addInfo("Planet block can be inserted directly by right-clicking the controller with planet block.") + .addSeparator() + .addStructureInfo("Eye of Harmony structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "896" + EnumChatFormatting.GRAY + " Reinforced Spatial Structure Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "534" + EnumChatFormatting.GRAY + " Reinforced Temporal Structure Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "31" + + EnumChatFormatting.GRAY + + " Infinite SpaceTime Energy Boundary Casing.") + .addStructureInfo( + EnumChatFormatting.GOLD + "168" + EnumChatFormatting.GRAY + " Time Dilation Field Generator.") + .addStructureInfo( + EnumChatFormatting.GOLD + "48" + EnumChatFormatting.GRAY + " Stabilisation Field Generator.") + .addStructureInfo( + EnumChatFormatting.GOLD + "138" + EnumChatFormatting.GRAY + " Spacetime Compression Field Generator.") + .addStructureInfo("--------------------------------------------") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 2 + EnumChatFormatting.GRAY + " input hatches.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " ME output hatch.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " input bus.") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " ME output bus.") + .addStructureInfo("--------------------------------------------") + .beginStructureBlock(33, 33, 33, false) + .toolTipFinisher(AuthorColen.substring(8) + EnumChatFormatting.GRAY + "&" + CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_BHG"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_BHG_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][12], + new TTRenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][12] }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 16, 16, 0, stackSize, hintsOnly); + } + + private final Map<Fluid, Long> validFluidMap = new HashMap<>() { + + private static final long serialVersionUID = -8452610443191188130L; + + { + put(Materials.Hydrogen.mGas, 0L); + put(Materials.Helium.mGas, 0L); + put(MaterialsUEVplus.RawStarMatter.mFluid, 0L); + } + }; + + private void drainFluidFromHatchesAndStoreInternally() { + List<FluidStack> fluidStacks = getStoredFluids(); + for (FluidStack fluidStack : fluidStacks) { + if (validFluidMap.containsKey(fluidStack.getFluid())) { + validFluidMap.merge(fluidStack.getFluid(), (long) fluidStack.amount, Long::sum); + fluidStack.amount = 0; + } + } + updateSlots(); + } + + @Override + public RecipeMap<?> getRecipeMap() { + // Only for visual + return TecTechRecipeMaps.eyeOfHarmonyRecipes; + } + + private EyeOfHarmonyRecipe currentRecipe; + + // Counter for lag prevention. + private long lagPreventer = 0; + + // Check for recipe every recipeCheckInterval ticks. + private static final long RECIPE_CHECK_INTERVAL = 3 * 20; + private long currentCircuitMultiplier = 0; + private long astralArrayAmount = 0; + private long parallelAmount = 1; + private long successfulParallelAmount = 0; + private double yield = 0; + private BigInteger usedEU = BigInteger.ZERO; + private FluidStackLong stellarPlasma; + private FluidStackLong starMatter; + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + ItemStack controllerStack = getControllerSlot(); + if (controllerStack == null) { + return SimpleCheckRecipeResult.ofFailure("no_planet_block"); + } + + lagPreventer++; + if (lagPreventer < RECIPE_CHECK_INTERVAL) { + lagPreventer = 0; + // No item in multi gui slot. + + currentRecipe = TecTech.eyeOfHarmonyRecipeStorage.recipeLookUp(controllerStack); + if (currentRecipe == null) { + return CheckRecipeResultRegistry.NO_RECIPE; + } + CheckRecipeResult result = processRecipe(currentRecipe); + if (!result.wasSuccessful()) currentRecipe = null; + return result; + } + return CheckRecipeResultRegistry.NO_RECIPE; + } + + private long getHydrogenStored() { + return validFluidMap.get(Materials.Hydrogen.mGas); + } + + private long getHeliumStored() { + return validFluidMap.get(Materials.Helium.mGas); + } + + private long getStellarPlasmaStored() { + return validFluidMap.get(MaterialsUEVplus.RawStarMatter.mFluid); + } + + public CheckRecipeResult processRecipe(EyeOfHarmonyRecipe recipeObject) { + + // Get circuit damage, clamp it and then use it later for overclocking. + currentCircuitMultiplier = 0; + for (ItemStack itemStack : mInputBusses.get(0) + .getRealInventory()) { + if (GTUtility.isAnyIntegratedCircuit(itemStack)) { + currentCircuitMultiplier = MathHelper.clamp_int(itemStack.getItemDamage(), 0, 24); + break; + } + } + + for (ItemStack itemStack : mInputBusses.get(0) + .getRealInventory()) { + if (astralArrayAmount >= ASTRAL_ARRAY_LIMIT) break; + if (itemStack != null && itemStack.isItemEqual(CustomItemList.astralArrayFabricator.get(1))) { + long insertAmount = Math.min(itemStack.stackSize, ASTRAL_ARRAY_LIMIT - astralArrayAmount); + astralArrayAmount += insertAmount; + itemStack.stackSize -= insertAmount; + } + } + + long parallelExponent = 1; + + if (astralArrayAmount != 0) { + parallelExponent = (long) Math.floor( + Math.log(PARALLEL_FOR_FIRST_ASTRAL_ARRAY * Math.min(astralArrayAmount, ASTRAL_ARRAY_LIMIT)) + / LOG_CONSTANT); + parallelAmount = (long) pow(2, parallelExponent); + } else { + parallelAmount = 1; + } + + // Debug mode, overwrites the required fluids to initiate the recipe to 100L of each. + if (parallelAmount > 1) { + if ((EOH_DEBUG_MODE && getStellarPlasmaStored() < 100) || (!EOH_DEBUG_MODE && getStellarPlasmaStored() + < currentRecipe.getHeliumRequirement() * (12.4 / 1_000_000f) * parallelAmount)) { + return SimpleCheckRecipeResult.ofFailure("no_stellar_plasma"); + } + } + + if (parallelAmount == 1) { + if ((EOH_DEBUG_MODE && getHydrogenStored() < 100) + || (!EOH_DEBUG_MODE && getHydrogenStored() < currentRecipe.getHydrogenRequirement())) { + return SimpleCheckRecipeResult.ofFailure("no_hydrogen"); + } + + if ((EOH_DEBUG_MODE && getHeliumStored() < 100) + || (!EOH_DEBUG_MODE && getHeliumStored() < currentRecipe.getHeliumRequirement())) { + return SimpleCheckRecipeResult.ofFailure("no_helium"); + } + } + + if (spacetimeCompressionFieldMetadata == -1) { + return CheckRecipeResultRegistry + .insufficientMachineTier((int) recipeObject.getSpacetimeCasingTierRequired()); + } + + // Check tier of spacetime compression blocks is high enough. + if (spacetimeCompressionFieldMetadata < recipeObject.getSpacetimeCasingTierRequired()) { + return CheckRecipeResultRegistry + .insufficientMachineTier((int) recipeObject.getSpacetimeCasingTierRequired()); + } + + // Calculate multipliers used in power calculations + double powerMultiplier = Math.max(1, Math.pow(POWER_INCREASE_CONSTANT, parallelExponent)); + + // Determine EU recipe input + startEU = recipeObject.getEUStartCost(); + + // Calculate normal EU values + double outputEUPenalty = (TOTAL_CASING_TIERS_WITH_POWER_PENALTY - stabilisationFieldMetadata) + * STABILITY_INCREASE_PROBABILITY_DECREASE_YIELD_PER_TIER; + outputEU_BigInt = BigInteger.valueOf((long) (recipeObject.getEUOutput() * (1 - outputEUPenalty))); + usedEU = BigInteger.valueOf(-startEU) + .multiply(BigInteger.valueOf((long) Math.pow(4, currentCircuitMultiplier))); + + // Calculate parallel EU values + if (parallelAmount > 1) { + outputEU_BigInt = outputEU_BigInt + .multiply(BigInteger.valueOf((long) (powerMultiplier * PRECISION_MULTIPLIER))) + .divide(BigInteger.valueOf((long) (PRECISION_MULTIPLIER * POWER_DIVISION_CONSTANT))); + + usedEU = usedEU + .multiply( + BigInteger.valueOf((long) (powerMultiplier * PARALLEL_MULTIPLIER_CONSTANT * PRECISION_MULTIPLIER))) + .divide(BigInteger.valueOf((long) (PRECISION_MULTIPLIER * POWER_DIVISION_CONSTANT))); + } + + // Remove EU from the users network. + if (!addEUToGlobalEnergyMap(userUUID, usedEU)) { + return CheckRecipeResultRegistry.insufficientStartupPower(usedEU.abs()); + } + + mMaxProgresstime = recipeProcessTimeCalculator( + recipeObject.getRecipeTimeInTicks(), + recipeObject.getSpacetimeCasingTierRequired()); + + calculateInputFluidExcessValues(recipeObject.getHydrogenRequirement(), recipeObject.getHeliumRequirement()); + + if (EOH_DEBUG_MODE) { + hydrogenOverflowProbabilityAdjustment = 0; + heliumOverflowProbabilityAdjustment = 0; + stellarPlasmaOverflowProbabilityAdjustment = 0; + } + + successChance = recipeChanceCalculator(); + currentRecipeRocketTier = currentRecipe.getRocketTier(); + + // Reduce internal storage by input fluid quantity required for recipe. + if (parallelAmount > 1) { + validFluidMap.put(MaterialsUEVplus.RawStarMatter.mFluid, 0L); + } else { + validFluidMap.put(Materials.Hydrogen.mGas, 0L); + validFluidMap.put(Materials.Helium.mGas, 0L); + } + + yield = recipeYieldCalculator(); + if (EOH_DEBUG_MODE) { + successChance = 1; // Debug recipes, sets them to 100% output chance. + } + + // Return copies of the output objects. + outputFluids = recipeObject.getOutputFluids(); + outputItems = recipeObject.getOutputItems(); + + // Star matter is always the last element in the array. + starMatter = new FluidStackLong(outputFluids.get(outputFluids.size() - 1)); + + // And stellar plasma is the second last. + stellarPlasma = new FluidStackLong(outputFluids.get(outputFluids.size() - 2)); + + successfulParallelAmount = (long) calculateChancedOutputMultiplier( + (int) (10000 * successChance), + (int) parallelAmount); + // Iterate over item output list and apply yield & successful parallel values. + for (ItemStackLong itemStackLong : outputItems) { + itemStackLong.stackSize *= yield * successfulParallelAmount; + } + + // Iterate over fluid output list and apply yield & successful parallel values. + for (FluidStackLong fluidStackLong : outputFluids) { + fluidStackLong.amount *= yield * successfulParallelAmount; + } + + updateSlots(); + + if (animationsEnabled) { + createRenderBlock(currentRecipe); + } + + recipeRunning = true; + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + private void createRenderBlock(final EyeOfHarmonyRecipe currentRecipe) { + + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock( + (int) (x + xOffset), + (int) (y + yOffset), + (int) (z + zOffset), + TTCasingsContainer.eyeOfHarmonyRenderBlock); + TileEntityEyeOfHarmony rendererTileEntity = (TileEntityEyeOfHarmony) this.getBaseMetaTileEntity() + .getWorld() + .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + + rendererTileEntity.setTier(currentRecipe.getRocketTier()); + + int recipeSpacetimeTier = (int) currentRecipe.getSpacetimeCasingTierRequired(); + + // Star is a larger size depending on the spacetime tier of the recipe. + rendererTileEntity.setSize((1 + recipeSpacetimeTier)); + + // Star rotates faster the higher tier time dilation you use in the multi. + // Lower value = faster rotation speed. + rendererTileEntity.setRotationSpeed((1 + timeAccelerationFieldMetadata) / 2.0f); + } + + private double successChance; + private long currentRecipeRocketTier; + + private void outputFailedChance() { + long failedParallelAmount = parallelAmount - successfulParallelAmount; + if (failedParallelAmount > 0) { + // 2^Tier spacetime released upon recipe failure. + outputFluidToAENetwork( + MaterialsUEVplus.SpaceTime.getMolten(1), + (long) ((successChance * MOLTEN_SPACETIME_PER_FAILURE_TIER + * pow(SPACETIME_FAILURE_BASE, currentRecipeRocketTier + 1)) * failedParallelAmount)); + } + super.outputAfterRecipe_EM(); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + destroyRenderBlock(); + recipeRunning = false; + } + + @Override + public void onBlockDestroyed() { + super.onBlockDestroyed(); + destroyRenderBlock(); + } + + private void destroyRenderBlock() { + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 16 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + } + + public void outputAfterRecipe_EM() { + recipeRunning = false; + eRequiredData = 0L; + + destroyRenderBlock(); + + // Output EU + addEUToGlobalEnergyMap(userUUID, outputEU_BigInt); + + startEU = 0; + outputEU_BigInt = BigInteger.ZERO; + + outputFailedChance(); + + if (successfulParallelAmount > 0) { + for (ItemStackLong itemStack : outputItems) { + outputItemToAENetwork(itemStack.itemStack, itemStack.stackSize); + } + + for (FluidStackLong fluidStack : outputFluids) { + outputFluidToAENetwork(fluidStack.fluidStack, fluidStack.amount); + } + } + + // Clear the array list for new recipes. + outputItems = new ArrayList<>(); + outputFluids = new ArrayList<>(); + + // Do other stuff from TT superclasses. E.g. outputting fluids. + super.outputAfterRecipe_EM(); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aTick == 1) { + userUUID = getBaseMetaTileEntity().getOwnerUuid(); + strongCheckOrAddUser(userUUID); + } + + if (!recipeRunning && mMachine) { + if ((aTick % TICKS_BETWEEN_HATCH_DRAIN) == 0) { + drainFluidFromHatchesAndStoreInternally(); + } + } + } + + private boolean recipeRunning = false; + + private void outputItemToAENetwork(ItemStack item, long amount) { + if (item == null || amount <= 0) return; + + while (amount >= Integer.MAX_VALUE) { + ItemStack tmpItem = item.copy(); + tmpItem.stackSize = Integer.MAX_VALUE; + ((MTEHatchOutputBusME) mOutputBusses.get(0)).store(tmpItem); + amount -= Integer.MAX_VALUE; + } + ItemStack tmpItem = item.copy(); + tmpItem.stackSize = (int) amount; + ((MTEHatchOutputBusME) mOutputBusses.get(0)).store(tmpItem); + } + + private void outputFluidToAENetwork(FluidStack fluid, long amount) { + if (fluid == null || amount <= 0) return; + + while (amount >= Integer.MAX_VALUE) { + FluidStack tmpFluid = fluid.copy(); + tmpFluid.amount = Integer.MAX_VALUE; + ((MTEHatchOutputME) mOutputHatches.get(0)).tryFillAE(tmpFluid); + amount -= Integer.MAX_VALUE; + } + FluidStack tmpFluid = fluid.copy(); + tmpFluid.amount = (int) amount; + ((MTEHatchOutputME) mOutputHatches.get(0)).tryFillAE(tmpFluid); + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(Arrays.asList(super.getInfoData())); + str.add(GOLD + "---------------- Control Block Statistics ----------------"); + if (spacetimeCompressionFieldMetadata < 0) { + str.add("Spacetime Compression Field Grade: None"); + } else { + str.add( + "Spacetime Compression Field Grade: " + + CommonValues.EOH_TIER_FANCY_NAMES[spacetimeCompressionFieldMetadata] + + RESET + + " (" + + YELLOW + + spacetimeCompressionFieldMetadata + + RESET + + ")"); + } + if (timeAccelerationFieldMetadata < 0) { + str.add("Time Dilation Field Grade: None"); + } else { + str.add( + "Time Dilation Field Grade: " + CommonValues.EOH_TIER_FANCY_NAMES[timeAccelerationFieldMetadata] + + RESET + + " (" + + YELLOW + + timeAccelerationFieldMetadata + + RESET + + ")"); + } + if (stabilisationFieldMetadata < 0) { + str.add("Stabilisation Field Grade: None"); + } else { + str.add( + "Stabilisation Field Grade: " + CommonValues.EOH_TIER_FANCY_NAMES[stabilisationFieldMetadata] + + RESET + + " (" + + YELLOW + + stabilisationFieldMetadata + + RESET + + ")"); + } + str.add(GOLD + "----------------- Internal Storage ----------------"); + validFluidMap.forEach( + (key, value) -> str.add(BLUE + key.getLocalizedName() + RESET + " : " + RED + formatNumbers(value))); + str.add(BLUE + "Astral Array Fabricators" + RESET + " : " + RED + formatNumbers(astralArrayAmount)); + if (recipeRunning) { + str.add(GOLD + "---------------------- Other Stats ---------------"); + str.add("Recipe Success Chance: " + RED + formatNumbers(100 * successChance) + RESET + "%"); + str.add("Recipe Yield: " + RED + formatNumbers(100 * yield) + RESET + "%"); + str.add( + "Effective Astral Array Fabricators: " + RED + + formatNumbers(Math.min(astralArrayAmount, ASTRAL_ARRAY_LIMIT))); + str.add("Total Parallel: " + RED + formatNumbers(parallelAmount)); + str.add("EU Output: " + RED + toStandardForm(outputEU_BigInt) + RESET + " EU"); + str.add("EU Input: " + RED + toStandardForm(usedEU.abs()) + RESET + " EU"); + int currentMaxProgresstime = Math.max(maxProgresstime(), 1); + if (starMatter != null && starMatter.fluidStack != null) { + FluidStackLong starMatterOutput = new FluidStackLong( + starMatter.fluidStack, + (long) (starMatter.amount * yield * successChance * parallelAmount)); + str.add( + "Average " + starMatterOutput.fluidStack.getLocalizedName() + + " Output: " + + RED + + formatNumbers(starMatterOutput.amount) + + RESET + + " L, " + + YELLOW + + formatNumbers(starMatterOutput.amount * 20.0 / currentMaxProgresstime) + + RESET + + " L/s"); + + FluidStackLong stellarPlasmaOutput = new FluidStackLong( + MaterialsUEVplus.RawStarMatter.getFluid(0), + (long) (stellarPlasma.amount * yield * successChance * parallelAmount)); + str.add( + "Average " + stellarPlasmaOutput.fluidStack.getLocalizedName() + + " Output: " + + RED + + formatNumbers(stellarPlasmaOutput.amount) + + RESET + + " L, " + + YELLOW + + formatNumbers(stellarPlasmaOutput.amount * 20.0 / currentMaxProgresstime) + + RESET + + " L/s"); + } + BigInteger euPerTick = (outputEU_BigInt.subtract(usedEU.abs())) + .divide(BigInteger.valueOf(currentMaxProgresstime)); + + str.add("Estimated EU/t: " + RED + toStandardForm(euPerTick) + RESET + " EU/t"); + } + str.add(GOLD + "-----------------------------------------------------"); + return str.toArray(new String[0]); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return new String[] { "Eye of Harmony multiblock" }; + } + + // NBT save/load strings. + private static final String EYE_OF_HARMONY = "eyeOfHarmonyOutput"; + private static final String NUMBER_OF_ITEMS_NBT_TAG = EYE_OF_HARMONY + "numberOfItems"; + private static final String NUMBER_OF_FLUIDS_NBT_TAG = EYE_OF_HARMONY + "numberOfFluids"; + private static final String ITEM_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "itemOutput"; + private static final String FLUID_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "fluidOutput"; + private static final String RECIPE_RUNNING_NBT_TAG = EYE_OF_HARMONY + "recipeRunning"; + private static final String CURRENT_RECIPE_STAR_MATTER_TAG = EYE_OF_HARMONY + "recipeStarMatter"; + private static final String CURRENT_RECIPE_STELLAR_PLASMA_TAG = EYE_OF_HARMONY + "recipeStellarPlasma"; + private static final String CURRENT_RECIPE_FIXED_OUTPUTS_TAG = EYE_OF_HARMONY + "recipeFixedOutputs"; + private static final String RECIPE_SUCCESS_CHANCE_NBT_TAG = EYE_OF_HARMONY + "recipeSuccessChance"; + private static final String ROCKET_TIER_NBT_TAG = EYE_OF_HARMONY + "rocketTier"; + private static final String CURRENT_CIRCUIT_MULTIPLIER_TAG = EYE_OF_HARMONY + "currentCircuitMultiplier"; + private static final String ANIMATIONS_ENABLED = EYE_OF_HARMONY + "animationsEnabled"; + private static final String CALCULATED_EU_OUTPUT_NBT_TAG = EYE_OF_HARMONY + "outputEU_BigInt"; + private static final String PARALLEL_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "parallelAmount"; + private static final String YIELD_NBT_TAG = EYE_OF_HARMONY + "yield"; + private static final String SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "successfulParallelAmount"; + private static final String ASTRAL_ARRAY_AMOUNT_NBT_TAG = EYE_OF_HARMONY + "astralArrayAmount"; + private static final String CALCULATED_EU_INPUT_NBT_TAG = EYE_OF_HARMONY + "usedEU"; + + // Sub tags, less specific names required. + private static final String STACK_SIZE = "stackSize"; + private static final String ITEM_STACK_NBT_TAG = "itemStack"; + private static final String FLUID_AMOUNT = "fluidAmount"; + private static final String FLUID_STACK_NBT_TAG = "fluidStack"; + + // Tags for pre-setting + public static final String PLANET_BLOCK = "planetBlock"; + + @Override + public void initDefaultModes(NBTTagCompound aNBT) { + super.initDefaultModes(aNBT); + if (aNBT != null && aNBT.hasKey(PLANET_BLOCK) && getControllerSlot() == null) { + mInventory[getControllerSlotIndex()] = new ItemStack(ModBlocks.getBlock(aNBT.getString(PLANET_BLOCK))); + aNBT.removeTag(PLANET_BLOCK); + } + } + + @Override + public void addAdditionalTooltipInformation(ItemStack stack, List<String> tooltip) { + if (stack.hasTagCompound() && stack.getTagCompound() + .hasKey(PLANET_BLOCK)) { + tooltip.add( + 1, + GTLanguageManager.addStringLocalization("EOH_Controller_PlanetBlock", "Current Planet Block: ") + AQUA + + new ItemStack( + ModBlocks.getBlock( + stack.getTagCompound() + .getString(PLANET_BLOCK))).getDisplayName()); + } + } + + @Override + public void setItemNBT(NBTTagCompound NBT) { + NBT.setLong(ASTRAL_ARRAY_AMOUNT_NBT_TAG, astralArrayAmount); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + // Save the quantity of fluid stored inside the controller. + validFluidMap.forEach((key, value) -> aNBT.setLong("stored." + key.getUnlocalizedName(), value)); + + aNBT.setBoolean(RECIPE_RUNNING_NBT_TAG, recipeRunning); + aNBT.setDouble(RECIPE_SUCCESS_CHANCE_NBT_TAG, successChance); + aNBT.setLong(ROCKET_TIER_NBT_TAG, currentRecipeRocketTier); + aNBT.setLong(CURRENT_CIRCUIT_MULTIPLIER_TAG, currentCircuitMultiplier); + aNBT.setBoolean(ANIMATIONS_ENABLED, animationsEnabled); + aNBT.setLong(PARALLEL_AMOUNT_NBT_TAG, parallelAmount); + aNBT.setLong(SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG, successfulParallelAmount); + aNBT.setDouble(YIELD_NBT_TAG, yield); + aNBT.setLong(ASTRAL_ARRAY_AMOUNT_NBT_TAG, astralArrayAmount); + aNBT.setByteArray(CALCULATED_EU_OUTPUT_NBT_TAG, outputEU_BigInt.toByteArray()); + aNBT.setByteArray(CALCULATED_EU_INPUT_NBT_TAG, usedEU.toByteArray()); + + // Store damage values/stack sizes of GT items being outputted. + NBTTagCompound itemStackListNBTTag = new NBTTagCompound(); + itemStackListNBTTag.setLong(NUMBER_OF_ITEMS_NBT_TAG, outputItems.size()); + + int index = 0; + for (ItemStackLong itemStackLong : outputItems) { + // Save stack size to NBT. + itemStackListNBTTag.setLong(index + STACK_SIZE, itemStackLong.stackSize); + + // Save ItemStack to NBT. + aNBT.setTag(index + ITEM_STACK_NBT_TAG, itemStackLong.itemStack.writeToNBT(new NBTTagCompound())); + + index++; + } + + aNBT.setTag(ITEM_OUTPUT_NBT_TAG, itemStackListNBTTag); + + // Store damage values/stack sizes of GT fluids being outputted. + NBTTagCompound fluidStackListNBTTag = new NBTTagCompound(); + fluidStackListNBTTag.setLong(NUMBER_OF_FLUIDS_NBT_TAG, outputFluids.size()); + + int indexFluids = 0; + for (FluidStackLong fluidStackLong : outputFluids) { + // Save fluid amount to NBT. + fluidStackListNBTTag.setLong(indexFluids + FLUID_AMOUNT, fluidStackLong.amount); + + // Save FluidStack to NBT. + aNBT.setTag(indexFluids + FLUID_STACK_NBT_TAG, fluidStackLong.fluidStack.writeToNBT(new NBTTagCompound())); + + indexFluids++; + } + + aNBT.setTag(FLUID_OUTPUT_NBT_TAG, fluidStackListNBTTag); + + if (starMatter != null && starMatter.fluidStack != null) { + + NBTTagCompound fixedRecipeOutputs = new NBTTagCompound(); + + fixedRecipeOutputs.setLong(0 + FLUID_AMOUNT, starMatter.amount); + aNBT.setTag(CURRENT_RECIPE_STAR_MATTER_TAG, starMatter.fluidStack.writeToNBT(new NBTTagCompound())); + + fixedRecipeOutputs.setLong(1 + FLUID_AMOUNT, stellarPlasma.amount); + aNBT.setTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG, stellarPlasma.fluidStack.writeToNBT(new NBTTagCompound())); + + aNBT.setTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG, fixedRecipeOutputs); + } + + super.saveNBTData(aNBT); + } + + @Override + public void loadNBTData(final NBTTagCompound aNBT) { + + // Load the quantity of fluid stored inside the controller. + validFluidMap + .forEach((key, value) -> validFluidMap.put(key, aNBT.getLong("stored." + key.getUnlocalizedName()))); + + // Load other stuff from NBT. + recipeRunning = aNBT.getBoolean(RECIPE_RUNNING_NBT_TAG); + successChance = aNBT.getDouble(RECIPE_SUCCESS_CHANCE_NBT_TAG); + currentRecipeRocketTier = aNBT.getLong(ROCKET_TIER_NBT_TAG); + currentCircuitMultiplier = aNBT.getLong(CURRENT_CIRCUIT_MULTIPLIER_TAG); + if (aNBT.hasKey(ANIMATIONS_ENABLED)) animationsEnabled = aNBT.getBoolean(ANIMATIONS_ENABLED); + parallelAmount = aNBT.getLong(PARALLEL_AMOUNT_NBT_TAG); + yield = aNBT.getDouble(YIELD_NBT_TAG); + successfulParallelAmount = aNBT.getLong(SUCCESSFUL_PARALLEL_AMOUNT_NBT_TAG); + astralArrayAmount = aNBT.getLong(ASTRAL_ARRAY_AMOUNT_NBT_TAG); + if (aNBT.hasKey(CALCULATED_EU_OUTPUT_NBT_TAG)) + outputEU_BigInt = new BigInteger(aNBT.getByteArray(CALCULATED_EU_OUTPUT_NBT_TAG)); + if (aNBT.hasKey(CALCULATED_EU_INPUT_NBT_TAG)) + usedEU = new BigInteger(aNBT.getByteArray(CALCULATED_EU_INPUT_NBT_TAG)); + + // Load damage values/stack sizes of GT items being outputted and convert back to items. + NBTTagCompound tempItemTag = aNBT.getCompoundTag(ITEM_OUTPUT_NBT_TAG); + + // Iterate over all stored items. + for (int index = 0; index < tempItemTag.getInteger(NUMBER_OF_ITEMS_NBT_TAG); index++) { + + // Load stack size from NBT. + long stackSize = tempItemTag.getLong(index + STACK_SIZE); + + // Load ItemStack from NBT. + ItemStack itemStack = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag(index + ITEM_STACK_NBT_TAG)); + + outputItems.add(new ItemStackLong(itemStack, stackSize)); + } + + // Load damage values/fluid amounts of GT fluids being outputted and convert back to fluids. + NBTTagCompound tempFluidTag = aNBT.getCompoundTag(FLUID_OUTPUT_NBT_TAG); + + // Iterate over all stored fluids. + for (int indexFluids = 0; indexFluids < tempFluidTag.getInteger(NUMBER_OF_FLUIDS_NBT_TAG); indexFluids++) { + + // Load fluid amount from NBT. + long fluidAmount = tempFluidTag.getLong(indexFluids + FLUID_AMOUNT); + + // Load FluidStack from NBT. + FluidStack fluidStack = FluidStack + .loadFluidStackFromNBT(aNBT.getCompoundTag(indexFluids + FLUID_STACK_NBT_TAG)); + + outputFluids.add(new FluidStackLong(fluidStack, fluidAmount)); + } + + tempFluidTag = aNBT.getCompoundTag(CURRENT_RECIPE_FIXED_OUTPUTS_TAG); + starMatter = new FluidStackLong( + FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STAR_MATTER_TAG)), + tempFluidTag.getLong(0 + FLUID_AMOUNT)); + stellarPlasma = new FluidStackLong( + FluidStack.loadFluidStackFromNBT(aNBT.getCompoundTag(CURRENT_RECIPE_STELLAR_PLASMA_TAG)), + tempFluidTag.getLong(1 + FLUID_AMOUNT)); + + super.loadNBTData(aNBT); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEForgeOfGods.java new file mode 100644 index 0000000000..609a09815a --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEForgeOfGods.java @@ -0,0 +1,3059 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.enums.Mods.Avaritia; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTModHandler.getModItem; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTUtility.formatNumbers; +import static java.lang.Math.floor; +import static java.lang.Math.log; +import static java.lang.Math.max; +import static net.minecraft.util.StatCollector.translateToLocal; +import static tectech.loader.recipe.Godforge.godforgeUpgradeMats; +import static tectech.thing.casing.TTCasingsContainer.GodforgeCasings; +import static tectech.thing.casing.TTCasingsContainer.forgeOfGodsRenderBlock; +import static tectech.util.GodforgeMath.allowModuleConnection; +import static tectech.util.GodforgeMath.calculateEnergyDiscountForModules; +import static tectech.util.GodforgeMath.calculateFuelConsumption; +import static tectech.util.GodforgeMath.calculateMaxFuelFactor; +import static tectech.util.GodforgeMath.calculateMaxHeatForModules; +import static tectech.util.GodforgeMath.calculateMaxParallelForModules; +import static tectech.util.GodforgeMath.calculateProcessingVoltageForModules; +import static tectech.util.GodforgeMath.calculateSpeedBonusForModules; +import static tectech.util.GodforgeMath.calculateStartupFuelConsumption; +import static tectech.util.GodforgeMath.queryMilestoneStats; +import static tectech.util.GodforgeMath.setMiscModuleParameters; +import static tectech.util.TTUtility.toExponentForm; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import com.google.common.collect.ImmutableList; +import com.google.common.math.LongMath; +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.ISurvivalBuildEnvironment; +import com.gtnewhorizons.modularui.api.ModularUITextures; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.MainAxisAlignment; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.FluidNameHolderWidget; +import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; +import com.gtnewhorizons.modularui.common.widget.ProgressBar; +import com.gtnewhorizons.modularui.common.widget.Scrollable; +import com.gtnewhorizons.modularui.common.widget.SlotGroup; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTOreDictUnificator; +import gregtech.api.util.HatchElementBuilder; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.common.tileentities.machines.MTEHatchInputBusME; +import gregtech.common.tileentities.machines.MTEHatchInputME; +import gregtech.common.tileentities.machines.MTEHatchOutputBusME; +import tectech.TecTech; +import tectech.thing.block.BlockGodforgeGlass; +import tectech.thing.block.TileEntityForgeOfGods; +import tectech.thing.gui.TecTechUITextures; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.godforge_modules.MTEBaseModule; +import tectech.thing.metaTileEntity.multi.godforge_modules.MTEExoticModule; +import tectech.thing.metaTileEntity.multi.godforge_modules.MTEMoltenModule; +import tectech.thing.metaTileEntity.multi.godforge_modules.MTEPlasmaModule; +import tectech.thing.metaTileEntity.multi.godforge_modules.MTESmeltingModule; +import tectech.util.CommonValues; + +public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { + + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int fuelConsumptionFactor = 1; + private int selectedFuelType = 0; + private int internalBattery = 0; + private int maxBatteryCharge = 100; + private int gravitonShardsAvailable = 0; + private int gravitonShardsSpent = 0; + private int ringAmount = 1; + private int stellarFuelAmount = 0; + private int neededStartupFuel = 0; + private long fuelConsumption = 0; + private long totalRecipesProcessed = 0; + private long totalFuelConsumed = 0; + private float totalExtensionsBuilt = 0; + private float powerMilestonePercentage = 0; + private float recipeMilestonePercentage = 0; + private float fuelMilestonePercentage = 0; + private float structureMilestonePercentage = 0; + private float invertedPowerMilestonePercentage = 0; + private float invertedRecipeMilestonePercentage = 0; + private float invertedFuelMilestonePercentage = 0; + private float invertedStructureMilestonePercentage = 0; + private BigInteger totalPowerConsumed = BigInteger.ZERO; + private boolean batteryCharging = false; + private boolean inversion = false; + private boolean gravitonShardEjection = false; + private boolean noFormatting = false; + private boolean isRenderActive = false; + public ArrayList<MTEBaseModule> moduleHatches = new ArrayList<>(); + protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); + + private static final int FUEL_CONFIG_WINDOW_ID = 9; + private static final int UPGRADE_TREE_WINDOW_ID = 10; + private static final int INDIVIDUAL_UPGRADE_WINDOW_ID = 11; + private static final int BATTERY_CONFIG_WINDOW_ID = 12; + private static final int MILESTONE_WINDOW_ID = 13; + private static final int INDIVIDUAL_MILESTONE_WINDOW_ID = 14; + private static final int MANUAL_INSERTION_WINDOW_ID = 15; + private static final int GENERAL_INFO_WINDOW_ID = 16; + private static final int TEXTURE_INDEX = 960; + private static final int[] FIRST_SPLIT_UPGRADES = new int[] { 12, 13, 14 }; + private static final Integer[] UPGRADE_MATERIAL_ID_CONVERSION = { 0, 5, 7, 11, 26, 29, 30 }; + private static final long POWER_MILESTONE_CONSTANT = LongMath.pow(10, 15); + private static final long RECIPE_MILESTONE_CONSTANT = LongMath.pow(10, 7); + private static final long FUEL_MILESTONE_CONSTANT = 10_000; + private static final long RECIPE_MILESTONE_T7_CONSTANT = RECIPE_MILESTONE_CONSTANT * LongMath.pow(6, 6); + private static final long FUEL_MILESTONE_T7_CONSTANT = FUEL_MILESTONE_CONSTANT * LongMath.pow(3, 6); + private static final BigInteger POWER_MILESTONE_T7_CONSTANT = BigInteger.valueOf(POWER_MILESTONE_CONSTANT) + .multiply(BigInteger.valueOf(LongMath.pow(9, 6))); + private static final double POWER_LOG_CONSTANT = Math.log(9); + private static final double RECIPE_LOG_CONSTANT = Math.log(6); + private static final double FUEL_LOG_CONSTANT = Math.log(3); + protected static final String STRUCTURE_PIECE_MAIN = "main"; + protected static final String STRUCTURE_PIECE_SHAFT = "beam_shaft"; + protected static final String STRUCTURE_PIECE_FIRST_RING = "first_ring"; + protected static final String STRUCTURE_PIECE_FIRST_RING_AIR = "first_ring_air"; + protected static final String STRUCTURE_PIECE_SECOND_RING = "second_ring"; + protected static final String STRUCTURE_PIECE_SECOND_RING_AIR = "second_ring_air"; + protected static final String STRUCTURE_PIECE_THIRD_RING = "third_ring"; + protected static final String STRUCTURE_PIECE_THIRD_RING_AIR = "third_ring_air"; + private static final String SCANNER_INFO_BAR = EnumChatFormatting.BLUE + + "--------------------------------------------"; + private static final String TOOLTIP_BAR = EnumChatFormatting.AQUA + + "--------------------------------------------------------------------------"; + private static final ItemStack STELLAR_FUEL = Avaritia.isModLoaded() ? getModItem(Avaritia.ID, "Resource", 1, 8) + : GTOreDictUnificator.get(OrePrefixes.block, Materials.CosmicNeutronium, 1); + + private final boolean debugMode = true; + + public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { + if (mMachine) return -1; + int realBudget = elementBudget >= 1000 ? elementBudget : Math.min(1000, elementBudget * 5); + // 1000 blocks max per placement. + int built = survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 63, 14, 1, realBudget, env, false, true); + if (stackSize.stackSize > 1) { + built += survivialBuildPiece( + STRUCTURE_PIECE_SECOND_RING, + stackSize, + 55, + 11, + -67, + realBudget, + env, + false, + true); + } + if (stackSize.stackSize > 2) { + built += survivialBuildPiece( + STRUCTURE_PIECE_THIRD_RING, + stackSize, + 47, + 13, + -76, + realBudget, + env, + false, + true); + } + return built; + } + + @Override + public IStructureDefinition<MTEForgeOfGods> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + public static final IStructureDefinition<MTEForgeOfGods> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEForgeOfGods>builder() + .addShape(STRUCTURE_PIECE_MAIN, ForgeOfGodsStructureString.MAIN_STRUCTURE) + .addShape(STRUCTURE_PIECE_SHAFT, ForgeOfGodsStructureString.BEAM_SHAFT) + .addShape(STRUCTURE_PIECE_FIRST_RING, ForgeOfGodsStructureString.FIRST_RING) + .addShape(STRUCTURE_PIECE_FIRST_RING_AIR, ForgeOfGodsStructureString.FIRST_RING_AIR) + .addShape(STRUCTURE_PIECE_SECOND_RING, ForgeOfGodsRingsStructureString.SECOND_RING) + .addShape(STRUCTURE_PIECE_SECOND_RING_AIR, ForgeOfGodsRingsStructureString.SECOND_RING_AIR) + .addShape(STRUCTURE_PIECE_THIRD_RING, ForgeOfGodsRingsStructureString.THIRD_RING) + .addShape(STRUCTURE_PIECE_THIRD_RING_AIR, ForgeOfGodsRingsStructureString.THIRD_RING_AIR) + .addElement('A', classicHatches(TEXTURE_INDEX + 3, 1, GodforgeCasings, 3)) + .addElement('B', ofBlock(GodforgeCasings, 0)) + .addElement('C', ofBlock(GodforgeCasings, 1)) + .addElement('D', ofBlock(GodforgeCasings, 2)) + .addElement('E', ofBlock(GodforgeCasings, 3)) + .addElement('F', ofBlock(GodforgeCasings, 4)) + .addElement('G', ofBlock(GodforgeCasings, 5)) + .addElement('H', ofBlock(BlockGodforgeGlass.INSTANCE, 0)) + .addElement('I', ofBlock(GodforgeCasings, 7)) + .addElement( + 'J', + HatchElementBuilder.<MTEForgeOfGods>builder() + .atLeast(moduleElement.Module) + .casingIndex(TEXTURE_INDEX) + .dot(3) + .buildAndChain(GodforgeCasings, 0)) + .addElement('K', ofBlock(GodforgeCasings, 6)) + .addElement('L', ofBlock(Blocks.air, 0)) + .build(); + + public MTEForgeOfGods(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEForgeOfGods(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEForgeOfGods(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/GODFORGE_CONTROLLER"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX + 1), + TextureFactory.builder() + .addIcon(ScreenON) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(ScreenON) + .extFacing() + .glow() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX + 1) }; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 63, 14, 1, stackSize, hintsOnly); + if (stackSize.stackSize > 1) { + buildPiece(STRUCTURE_PIECE_SECOND_RING, stackSize, hintsOnly, 55, 11, -67); + } + if (stackSize.stackSize > 2) { + buildPiece(STRUCTURE_PIECE_THIRD_RING, stackSize, hintsOnly, 47, 13, -76); + } + } + + private final ArrayList<FluidStack> validFuelList = new ArrayList<>() { + + { + add(MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1)); + add(MaterialsUEVplus.RawStarMatter.getFluid(1)); + add(MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1)); + } + }; + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + + moduleHatches.clear(); + + // Check structure of multi + if (isRenderActive) { + if (!structureCheck_EM(STRUCTURE_PIECE_SHAFT, 63, 14, 1) + || !structureCheck_EM(STRUCTURE_PIECE_FIRST_RING_AIR, 63, 14, -59)) { + destroyRenderer(); + return false; + } + } else if (!structureCheck_EM(STRUCTURE_PIECE_MAIN, 63, 14, 1)) { + return false; + } + + if (internalBattery != 0 && !isRenderActive) { + createRenderer(); + } + + // Check there is 1 input bus + if (mInputBusses.size() != 1) { + return false; + } + + // Check there is 1 me output bus + { + if (mOutputBusses.size() != 1) { + return false; + } + + if (!(mOutputBusses.get(0) instanceof MTEHatchOutputBusME)) { + return false; + } + } + + // Make sure there are no energy hatches + { + if (mEnergyHatches.size() > 0) { + return false; + } + + if (mExoticEnergyHatches.size() > 0) { + return false; + } + } + + // Make sure there is 1 input hatch + if (mInputHatches.size() != 1) { + return false; + } + + if (isUpgradeActive(26)) { + if (checkPiece(STRUCTURE_PIECE_SECOND_RING, 55, 11, -67)) { + ringAmount = 2; + } + if (isRenderActive && ringAmount >= 2 && !checkPiece(STRUCTURE_PIECE_SECOND_RING_AIR, 55, 11, -67)) { + destroyRenderer(); + } + } + + if (isUpgradeActive(29)) { + if (checkPiece(STRUCTURE_PIECE_THIRD_RING, 47, 13, -76)) { + ringAmount = 3; + } + if (isRenderActive && ringAmount == 3 && !checkPiece(STRUCTURE_PIECE_THIRD_RING_AIR, 47, 13, -76)) { + destroyRenderer(); + } + } + + return true; + } + + int ticker = 0; + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide()) { + ticker++; + // Check and drain fuel + if (ticker % (5 * SECONDS) == 0) { + ticker = 0; + startRecipeProcessing(); + FluidStack[] fluidInHatch = null; + boolean fuelDrained = false; + if (mInputHatches != null && mInputHatches.size() != 0) { + fluidInHatch = this.getStoredFluids() + .toArray(new FluidStack[0]); + } + int maxModuleCount = 8; + + if (upgrades[26]) { + maxModuleCount += 4; + } + if (upgrades[29]) { + maxModuleCount += 4; + } + if (mInputBusses.size() != 0) { + if (internalBattery == 0) { + MTEHatchInputBus inputBus = mInputBusses.get(0); + ItemStack[] inputBusInventory = inputBus.getRealInventory(); + if (inputBusInventory != null) { + for (int i = 0; i < inputBusInventory.length; i++) { + ItemStack itemStack = inputBusInventory[i]; + if (itemStack != null && itemStack.isItemEqual(STELLAR_FUEL)) { + int stacksize = itemStack.stackSize; + if (inputBus instanceof MTEHatchInputBusME meBus) { + ItemStack realItem = meBus.getRealInventory()[i + 16]; + if (realItem == null) { + break; + } + stacksize = realItem.stackSize; + } + inputBus.decrStackSize(i, stacksize); + stellarFuelAmount += stacksize; + inputBus.updateSlots(); + } + } + } + neededStartupFuel = calculateStartupFuelConsumption(this); + if (stellarFuelAmount >= neededStartupFuel) { + stellarFuelAmount -= neededStartupFuel; + increaseBattery(neededStartupFuel); + createRenderer(); + } + } else { + fuelConsumption = (long) calculateFuelConsumption(this) * 5 * (batteryCharging ? 2 : 1); + if (fluidInHatch != null && fuelConsumption < Integer.MAX_VALUE) { + for (FluidStack fluid : fluidInHatch) { + if (fluid.isFluidEqual(validFuelList.get(selectedFuelType))) { + FluidStack fluidNeeded = new FluidStack( + validFuelList.get(selectedFuelType), + (int) fuelConsumption); + FluidStack fluidReal; + if (mInputHatches.get(0) instanceof MTEHatchInputME meHatch) { + fluidReal = meHatch.drain(ForgeDirection.UNKNOWN, fluidNeeded, true); + } else { + fluidReal = mInputHatches.get(0) + .drain(fluidNeeded.amount, true); + } + if (fluidReal == null || fluidReal.amount < fluidNeeded.amount) { + reduceBattery(fuelConsumptionFactor); + } else { + totalFuelConsumed += getFuelFactor(); + if (batteryCharging) { + increaseBattery(fuelConsumptionFactor); + } + } + fuelDrained = true; + } + } + if (!fuelDrained) { + reduceBattery(fuelConsumptionFactor); + } + } else { + reduceBattery(fuelConsumptionFactor); + } + } + } + + determineCompositionMilestoneLevel(); + checkInversionStatus(); + determineMilestoneProgress(); + if (!debugMode) { + determineGravitonShardAmount(); + } + if (upgrades[30] && gravitonShardEjection) { + ejectGravitonShards(); + } + + // Do module calculations and checks + if (moduleHatches.size() > 0 && internalBattery > 0 && moduleHatches.size() <= maxModuleCount) { + for (MTEBaseModule module : moduleHatches) { + if (allowModuleConnection(module, this)) { + module.connect(); + calculateMaxHeatForModules(module, this); + calculateSpeedBonusForModules(module, this); + calculateMaxParallelForModules(module, this); + calculateEnergyDiscountForModules(module, this); + setMiscModuleParameters(module, this); + queryMilestoneStats(module, this); + if (!upgrades[28]) { + calculateProcessingVoltageForModules(module, this); + } + } else { + module.disconnect(); + } + } + } else if (moduleHatches.size() > maxModuleCount) { + for (MTEBaseModule module : moduleHatches) { + module.disconnect(); + } + } + if (mEfficiency < 0) mEfficiency = 0; + endRecipeProcessing(); + } + } + } + + public boolean addModuleToMachineList(IGregTechTileEntity tileEntity, int baseCasingIndex) { + if (tileEntity == null) { + return false; + } + IMetaTileEntity metaTileEntity = tileEntity.getMetaTileEntity(); + if (metaTileEntity == null) { + return false; + } + if (metaTileEntity instanceof MTEBaseModule) { + return moduleHatches.add((MTEBaseModule) metaTileEntity); + } + return false; + } + + public enum moduleElement implements IHatchElement<MTEForgeOfGods> { + + Module(MTEForgeOfGods::addModuleToMachineList, MTEBaseModule.class) { + + @Override + public long count(MTEForgeOfGods tileEntity) { + return tileEntity.moduleHatches.size(); + } + }; + + private final List<Class<? extends IMetaTileEntity>> mteClasses; + private final IGTHatchAdder<MTEForgeOfGods> adder; + + @SafeVarargs + moduleElement(IGTHatchAdder<MTEForgeOfGods> adder, Class<? extends IMetaTileEntity>... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return mteClasses; + } + + public IGTHatchAdder<? super MTEForgeOfGods> adder() { + return adder; + } + } + + private void createRenderer() { + + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), forgeOfGodsRenderBlock); + TileEntityForgeOfGods rendererTileEntity = (TileEntityForgeOfGods) this.getBaseMetaTileEntity() + .getWorld() + .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + + rendererTileEntity.setRenderSize(20); + rendererTileEntity.setRenderRotationSpeed(5); + + switch (ringAmount) { + case 2 -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING_AIR, null, false, 63, 14, -59); + buildPiece(STRUCTURE_PIECE_SECOND_RING_AIR, null, false, 55, 11, -67); + } + case 3 -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING_AIR, null, false, 63, 14, -59); + buildPiece(STRUCTURE_PIECE_SECOND_RING_AIR, null, false, 55, 11, -67); + buildPiece(STRUCTURE_PIECE_THIRD_RING_AIR, null, false, 47, 13, -76); + } + default -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING_AIR, null, false, 63, 14, -59); + } + } + + isRenderActive = true; + } + + private void destroyRenderer() { + + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + + double xOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double zOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + double yOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetY; + + this.getBaseMetaTileEntity() + .getWorld() + .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + + switch (ringAmount) { + case 2 -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING, null, false, 63, 14, -59); + buildPiece(STRUCTURE_PIECE_SECOND_RING, null, false, 55, 11, -67); + } + case 3 -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING, null, false, 63, 14, -59); + buildPiece(STRUCTURE_PIECE_SECOND_RING, null, false, 55, 11, -67); + buildPiece(STRUCTURE_PIECE_THIRD_RING, null, false, 47, 13, -76); + } + default -> { + buildPiece(STRUCTURE_PIECE_FIRST_RING, null, false, 63, 14, -59); + } + } + + isRenderActive = false; + } + + @Override + public void onBlockDestroyed() { + super.onBlockDestroyed(); + destroyRenderer(); + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(Arrays.asList(super.getInfoData())); + str.add(SCANNER_INFO_BAR); + str.add("Number of Rings: " + EnumChatFormatting.GOLD + ringAmount); + str.add("Total Upgrades Unlocked: " + EnumChatFormatting.GOLD + getTotalActiveUpgrades()); + str.add("Connected Modules: " + EnumChatFormatting.GOLD + moduleHatches.size()); + str.add(SCANNER_INFO_BAR); + return str.toArray(new String[0]); + } + + @Override + public void onRemoval() { + if (moduleHatches != null && moduleHatches.size() > 0) { + for (MTEBaseModule module : moduleHatches) { + module.disconnect(); + } + } + super.onRemoval(); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 85)); + } else { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY) + .setPos(4, 4) + .setSize(190, 171)); + } + buildContext.addSyncedWindow(UPGRADE_TREE_WINDOW_ID, this::createUpgradeTreeWindow); + buildContext.addSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID, this::createIndividualUpgradeWindow); + buildContext.addSyncedWindow(FUEL_CONFIG_WINDOW_ID, this::createFuelConfigWindow); + buildContext.addSyncedWindow(BATTERY_CONFIG_WINDOW_ID, this::createBatteryWindow); + buildContext.addSyncedWindow(MILESTONE_WINDOW_ID, this::createMilestoneWindow); + buildContext.addSyncedWindow(INDIVIDUAL_MILESTONE_WINDOW_ID, this::createIndividualMilestoneWindow); + buildContext.addSyncedWindow(MANUAL_INSERTION_WINDOW_ID, this::createManualInsertionWindow); + buildContext.addSyncedWindow(GENERAL_INFO_WINDOW_ID, this::createGeneralInfoWindow); + builder.widget( + new ButtonWidget().setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); + }) + .setSize(16, 16) + .setBackground(() -> { + List<UITexture> button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_ARROW_BLUE_UP); + return button.toArray(new IDrawable[0]); + }) + .addTooltip("Path of Celestial Transcendence") + .setPos(174, 167) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + .setPos(174, 183) + .setSize(16, 6)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(FUEL_CONFIG_WINDOW_ID); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List<UITexture> button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_HEAT_ON); + return button.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.fuelconfig.tooltip")) + .setPos(174, 110) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + TextWidget.dynamicText(this::storedFuel) + .setDefaultColor(EnumChatFormatting.WHITE) + .setPos(6, 8) + .setSize(74, 34)) + .widget(createPowerSwitchButton()) + .widget(createBatteryButton(builder)) + .widget(createEjectionSwitch(builder)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) { + getBaseMetaTileEntity().enableWorking(); + } else { + getBaseMetaTileEntity().disableWorking(); + } + })) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + checkMachine_EM(this.getBaseMetaTileEntity(), null); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List<UITexture> button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_CYCLIC_BLUE); + return button.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.structurecheck.tooltip")) + .setPos(8, 91) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(MILESTONE_WINDOW_ID); + } + }) + .setSize(16, 16) + .setBackground(() -> { + List<UITexture> button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_FLAG); + return button.toArray(new IDrawable[0]); + + }) + .addTooltip(translateToLocal("fog.button.milestones.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91)) + .widget( + new ButtonWidget().setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(GENERAL_INFO_WINDOW_ID); + }) + .setSize(18, 18) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.clickhere")) + .setPos(172, 67) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(172, 67)); + } + + @Override + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (getBaseMetaTileEntity().isAllowedToWork()) { + getBaseMetaTileEntity().disableWorking(); + } else { + getBaseMetaTileEntity().enableWorking(); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (getBaseMetaTileEntity().isAllowedToWork()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 148 : 172) + .setSize(16, 16); + button.addTooltip("Power Switch") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + protected ButtonWidget createEjectionSwitch(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (upgrades[30]) { + gravitonShardEjection = !gravitonShardEjection; + } + }) + .setPlayClickSound(upgrades[30]) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (!upgrades[30]) { + return ret.toArray(new IDrawable[0]); + } + if (gravitonShardEjection) { + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + ret.add(TecTechUITextures.OVERLAY_EJECTION_ON); + } else { + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + ret.add(TecTechUITextures.OVERLAY_EJECTION_LOCKED); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> gravitonShardEjection, val -> gravitonShardEjection = val), + builder) + .setPos(26, 91) + .setSize(16, 16) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(() -> upgrades[30], val -> upgrades[30] = val), builder); + if (upgrades[30]) { + button.addTooltip(translateToLocal("fog.button.ejection.tooltip")); + button.setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + protected Widget createBatteryButton(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (clickData.mouseButton == 0) { + batteryCharging = !batteryCharging; + } else if (clickData.mouseButton == 1 && !widget.isClient() && upgrades[8]) { + widget.getContext() + .openSyncedWindow(BATTERY_CONFIG_WINDOW_ID); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (batteryCharging) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATTERY_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATTERY_OFF); + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, 129) + .setSize(16, 16); + button.addTooltip(translateToLocal("fog.button.battery.tooltip.01")) + .addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.battery.tooltip.02")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> batteryCharging, val -> batteryCharging = val), + builder); + return button; + } + + protected ModularWindow createBatteryWindow(final EntityPlayer player) { + final int WIDTH = 78; + final int HEIGHT = 52; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.BottomRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0) + .subtract(0, 10))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.batteryinfo") + .setPos(3, 4) + .setSize(74, 20)) + .widget( + new NumericWidget().setSetter(val -> maxBatteryCharge = (int) val) + .setGetter(() -> maxBatteryCharge) + .setBounds(1, Integer.MAX_VALUE) + .setDefaultValue(100) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(4, 25) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + return builder.build(); + } + + protected ModularWindow createFuelConfigWindow(final EntityPlayer player) { + final int WIDTH = 78; + final int HEIGHT = 130; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelconsumption") + .setPos(3, 2) + .setSize(74, 34)) + .widget( + new NumericWidget().setSetter(val -> fuelConsumptionFactor = (int) val) + .setGetter(() -> fuelConsumptionFactor) + .setBounds(1, calculateMaxFuelFactor(this)) + .setDefaultValue(1) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(70, 18) + .setPos(4, 35) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)) + .widget( + new DrawableWidget().setDrawable(ModularUITextures.ICON_INFO) + .setPos(64, 24) + .setSize(10, 10) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.0")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.1")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.2")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.3")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.4")) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfo.5")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fueltype") + .setPos(3, 57) + .setSize(74, 24)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelusage") + .setPos(3, 100) + .setSize(74, 20)) + .widget( + TextWidget.dynamicText(this::fuelUsage) + .setPos(3, 115) + .setSize(74, 15)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.DimensionallyTranscendentResidue.getFluid(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List<Text> tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 0; + }) + .setBackground(() -> { + if (selectedFuelType == 0) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)) + + .setPos(6, 82) + .setSize(18, 18)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.RawStarMatter.getFluid(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.RawStarMatter.getFluid(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List<Text> tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 1; + }) + .setBackground(() -> { + if (selectedFuelType == 1) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18)) + .setPos(29, 82) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)) + .widget( + new MultiChildWidget().addChild( + new FluidNameHolderWidget( + () -> MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1) + .getUnlocalizedName() + .substring(6), + (String) -> MaterialsUEVplus.MagnetohydrodynamicallyConstrainedStarMatter.getMolten(1) + .getUnlocalizedName()) { + + @Override + public void buildTooltip(List<Text> tooltip) { + FluidStack fluid = createFluidStack(); + addFluidNameInfo(tooltip, fluid); + addAdditionalFluidInfo(tooltip, fluid); + } + }.setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(1, 1) + .setSize(16, 16)) + .addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + selectedFuelType = 2; + }) + .setBackground(() -> { + if (selectedFuelType == 2) { + return new IDrawable[] { TecTechUITextures.SLOT_OUTLINE_GREEN }; + } else { + return new IDrawable[] {}; + } + }) + .setSize(18, 18)) + .setPos(52, 82) + .setSize(18, 18) + .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)); + + return builder.build(); + } + + private final int[] milestoneProgress = new int[] { 0, 0, 0, 0 }; + + protected ModularWindow createMilestoneWindow(final EntityPlayer player) { + final int WIDTH = 400; + final int HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(TecTechUITextures.BACKGROUND_SPACE); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.widget(createMilestoneButton(0, 80, 100, new Pos2d(62, 24))); + builder.widget(createMilestoneButton(1, 70, 98, new Pos2d(263, 25))); + builder.widget(createMilestoneButton(2, 100, 100, new Pos2d(52, 169))); + builder.widget(createMilestoneButton(3, 100, 100, new Pos2d(248, 169))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.powermilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(77, 45) + .setSize(50, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.recipemilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(268, 45) + .setSize(60, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.fuelmilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(77, 190) + .setSize(50, 30)); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.purchasablemilestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(268, 190) + .setSize(60, 30)); + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(37, 70) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(233, 70) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(37, 215) + .setSize(130, 7)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BACKGROUND) + .setPos(233, 215) + .setSize(130, 7)); + builder.widget( + new ProgressBar().setProgress(() -> powerMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 70)) + .widget( + new ProgressBar().setProgress(() -> recipeMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_PURPLE, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 70)) + .widget( + new ProgressBar().setProgress(() -> fuelMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BLUE, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 215)) + .widget( + new ProgressBar().setProgress(() -> structureMilestonePercentage) + .setDirection(ProgressBar.Direction.RIGHT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 215)) + .widget( + new ProgressBar().setProgress(() -> invertedPowerMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RED_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 70)) + .widget( + new ProgressBar().setProgress(() -> invertedRecipeMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_PURPLE_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 70)) + .widget( + new ProgressBar().setProgress(() -> invertedFuelMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_BLUE_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(37, 215)) + .widget( + new ProgressBar().setProgress(() -> invertedStructureMilestonePercentage) + .setDirection(ProgressBar.Direction.LEFT) + .setTexture(TecTechUITextures.PROGRESSBAR_GODFORGE_MILESTONE_RAINBOW_INVERTED, 130) + .setSynced(true, false) + .setSize(130, 7) + .setPos(233, 215)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(382, 6)); + return builder.build(); + } + + protected ModularWindow createIndividualMilestoneWindow(final EntityPlayer player) { + final int WIDTH = 150; + final int HEIGHT = 150; + int symbol_width; + int symbol_height; + String milestoneType; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + UITexture symbol; + switch (currentMilestoneID) { + case 1 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION; + symbol_width = 54; + symbol_height = 75; + milestoneType = "recipe"; + } + case 2 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST; + symbol_width = 75; + symbol_height = 75; + milestoneType = "fuel"; + } + case 3 -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION; + symbol_width = 75; + symbol_height = 75; + milestoneType = "purchasable"; + } + default -> { + symbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE; + symbol_width = 60; + symbol_height = 75; + milestoneType = "power"; + } + } + + builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE); + builder.setDraggable(true); + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(134, 4)) + .widget( + new DrawableWidget().setDrawable(symbol) + .setSize(symbol_width, symbol_height) + .setPos((WIDTH - symbol_width) / 2, (HEIGHT - symbol_height) / 2)) + .widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG." + milestoneType + "milestone") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(0, 8) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(this::inversionStatusText) + .setDefaultColor(EnumChatFormatting.AQUA) + .setTextAlignment(Alignment.Center) + .setScale(0.8f) + .setPos(0, 120) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(() -> totalMilestoneProgress(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.Center) + .setPos(5, 30) + .setSize(140, 30)) + .widget( + TextWidget.dynamicText(() -> currentMilestone(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.Center) + .setPos(5, 50) + .setSize(140, 30)) + .widget( + TextWidget.dynamicText(() -> milestoneProgressText(currentMilestoneID, true)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(140, 30) + .setPos(5, 70)) + .widget( + TextWidget.dynamicText(() -> gravitonShardAmountText(currentMilestoneID)) + .setScale(0.7f) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(140, 30) + .setPos(5, 90)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (clickData.mouseButton == 0) { + noFormatting = !noFormatting; + } + }) + .setSize(10, 10) + .addTooltip(translateToLocal("fog.button.formatting.tooltip")) + .setBackground(TecTechUITextures.OVERLAY_CYCLIC_BLUE) + .setPos(5, 135) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> noFormatting, val -> noFormatting = val), + builder)); + + return builder.build(); + } + + private int currentMilestoneID = 0; + + private Widget createMilestoneButton(int milestoneID, int width, int height, Pos2d pos) { + return new ButtonWidget().setOnClick((clickData, widget) -> { + currentMilestoneID = milestoneID; + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(INDIVIDUAL_MILESTONE_WINDOW_ID); + } + }) + .setSize(width, height) + .setBackground(() -> switch (milestoneID) { + case 1 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION_GLOW }; + case 2 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST_GLOW }; + case 3 -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION_GLOW }; + default -> new IDrawable[] { TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE_GLOW }; + }) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.milestoneinfo")) + .setPos(pos) + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + + private int currentUpgradeID = 0; + private int currentColorCode = 0; + private int currentMilestoneBG = 0; + private int gravitonShardCost = 0; + private int[] prereqUpgrades = new int[] {}; + private int[] followupUpgrades = new int[] {}; + private boolean allPrereqRequired = false; + private boolean isUpradeSplitStart = false; + private boolean doesCurrentUpgradeRequireExtraMats = false; + private boolean[] upgrades = new boolean[31]; + private boolean[] materialPaidUpgrades = new boolean[7]; + + protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { + final Scrollable scrollable = new Scrollable().setVerticalScroll(); + final int PARENT_WIDTH = 300; + final int PARENT_HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(PARENT_WIDTH, PARENT_HEIGHT); + scrollable + .widget( + createUpgradeBox( + 0, + 0, + 3, + new int[] {}, + false, + new int[] { 1 }, + false, + true, + 0, + new Pos2d(126, 56), + scrollable)) + .widget( + createUpgradeBox( + 1, + 0, + 1, + new int[] { 0 }, + false, + new int[] { 2, 3 }, + false, + false, + 1, + new Pos2d(126, 116), + scrollable)) + .widget( + createUpgradeBox( + 2, + 0, + 2, + new int[] { 1 }, + false, + new int[] { 4, 5 }, + false, + false, + 1, + new Pos2d(96, 176), + scrollable)) + .widget( + createUpgradeBox( + 3, + 0, + 2, + new int[] { 1 }, + false, + new int[] { 5, 6 }, + false, + false, + 1, + new Pos2d(156, 176), + scrollable)) + .widget( + createUpgradeBox( + 4, + 0, + 0, + new int[] { 2 }, + false, + new int[] { 8 }, + false, + false, + 1, + new Pos2d(66, 236), + scrollable)) + .widget( + createUpgradeBox( + 5, + 0, + 3, + new int[] { 2, 3 }, + false, + new int[] { 7 }, + false, + true, + 1, + new Pos2d(126, 236), + scrollable)) + .widget( + createUpgradeBox( + 6, + 0, + 1, + new int[] { 3 }, + false, + new int[] { 10 }, + false, + false, + 1, + new Pos2d(186, 236), + scrollable)) + .widget( + createUpgradeBox( + 7, + 0, + 3, + new int[] { 5 }, + false, + new int[] { 8, 9, 10 }, + false, + true, + 2, + new Pos2d(126, 296), + scrollable)) + .widget( + createUpgradeBox( + 8, + 0, + 0, + new int[] { 4, 7 }, + true, + new int[] { 11 }, + false, + false, + 2, + new Pos2d(56, 356), + scrollable)) + .widget( + createUpgradeBox( + 9, + 0, + 2, + new int[] { 7 }, + false, + new int[] {}, + false, + false, + 2, + new Pos2d(126, 356), + scrollable)) + .widget( + createUpgradeBox( + 10, + 0, + 1, + new int[] { 6, 7 }, + true, + new int[] { 11 }, + false, + false, + 2, + new Pos2d(196, 356), + scrollable)) + .widget( + createUpgradeBox( + 11, + 0, + 3, + new int[] { 8, 10 }, + false, + new int[] { 12, 13, 14 }, + false, + true, + 2, + new Pos2d(126, 416), + scrollable)) + .widget( + createUpgradeBox( + 12, + 1, + 2, + new int[] { 11 }, + false, + new int[] { 17 }, + true, + false, + 3, + new Pos2d(66, 476), + scrollable)) + .widget( + createUpgradeBox( + 13, + 2, + 1, + new int[] { 11 }, + false, + new int[] { 18 }, + true, + false, + 3, + new Pos2d(126, 476), + scrollable)) + .widget( + createUpgradeBox( + 14, + 3, + 0, + new int[] { 11 }, + false, + new int[] { 15, 19 }, + true, + false, + 3, + new Pos2d(186, 476), + scrollable)) + .widget( + createUpgradeBox( + 15, + 3, + 1, + new int[] { 14 }, + false, + new int[] {}, + false, + false, + 4, + new Pos2d(246, 496), + scrollable)) + .widget( + createUpgradeBox( + 16, + 1, + 1, + new int[] { 17 }, + false, + new int[] {}, + false, + false, + 4, + new Pos2d(6, 556), + scrollable)) + .widget( + createUpgradeBox( + 17, + 1, + 0, + new int[] { 12 }, + false, + new int[] { 16, 20 }, + false, + false, + 3, + new Pos2d(66, 536), + scrollable)) + .widget( + createUpgradeBox( + 18, + 2, + 1, + new int[] { 13 }, + false, + new int[] { 21 }, + false, + false, + 3, + new Pos2d(126, 536), + scrollable)) + .widget( + createUpgradeBox( + 19, + 3, + 0, + new int[] { 14 }, + false, + new int[] { 22 }, + false, + false, + 3, + new Pos2d(186, 536), + scrollable)) + .widget( + createUpgradeBox( + 20, + 1, + 0, + new int[] { 17 }, + false, + new int[] { 23 }, + false, + false, + 3, + new Pos2d(66, 596), + scrollable)) + .widget( + createUpgradeBox( + 21, + 2, + 1, + new int[] { 18 }, + false, + new int[] { 23 }, + false, + false, + 3, + new Pos2d(126, 596), + scrollable)) + .widget( + createUpgradeBox( + 22, + 3, + 1, + new int[] { 19 }, + false, + new int[] { 23 }, + false, + false, + 3, + new Pos2d(186, 596), + scrollable)) + .widget( + createUpgradeBox( + 23, + 0, + 0, + new int[] { 20, 21, 22 }, + false, + new int[] { 24 }, + false, + false, + 4, + new Pos2d(126, 656), + scrollable)) + .widget( + createUpgradeBox( + 24, + 0, + 1, + new int[] { 23 }, + false, + new int[] { 25 }, + false, + false, + 5, + new Pos2d(126, 718), + scrollable)) + .widget( + createUpgradeBox( + 25, + 0, + 1, + new int[] { 24 }, + false, + new int[] { 26 }, + false, + false, + 6, + new Pos2d(36, 758), + scrollable)) + .widget( + createUpgradeBox( + 26, + 0, + 3, + new int[] { 25 }, + false, + new int[] { 27 }, + false, + true, + 7, + new Pos2d(36, 848), + scrollable)) + .widget( + createUpgradeBox( + 27, + 0, + 2, + new int[] { 26 }, + false, + new int[] { 28 }, + false, + false, + 8, + new Pos2d(126, 888), + scrollable)) + .widget( + createUpgradeBox( + 28, + 0, + 0, + new int[] { 27 }, + false, + new int[] { 29 }, + false, + false, + 9, + new Pos2d(216, 848), + scrollable)) + .widget( + createUpgradeBox( + 29, + 0, + 3, + new int[] { 28 }, + false, + new int[] { 30 }, + false, + true, + 10, + new Pos2d(216, 758), + scrollable)) + .widget( + createUpgradeBox( + 30, + 0, + 3, + new int[] { 29 }, + false, + new int[] {}, + false, + true, + 12, + new Pos2d(126, 798), + scrollable)) + .widget(new TextWidget("").setPos(0, 945)); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_STAR) + .setPos(0, 0) + .setSize(300, 300)) + .widget( + scrollable.setSize(292, 292) + .setPos(4, 4)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(282, 4)); + if (debugMode) { + builder.widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + upgrades = new boolean[31]; + materialPaidUpgrades = new boolean[7]; + }) + .setSize(40, 15) + .setBackground(GTUITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.debug.resetbutton.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.debug.resetbutton.text")).setTextAlignment(Alignment.Center) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 3)) + .addChild( + new NumericWidget().setSetter(val -> gravitonShardsAvailable = (int) val) + .setGetter(() -> gravitonShardsAvailable) + .setBounds(0, 112) + .setDefaultValue(0) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(25, 18) + .setPos(4, 16) + .addTooltip(translateToLocal("fog.debug.gravitonshardsetter.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)) + .addChild( + new ButtonWidget().setOnClick((clickData, widget) -> Arrays.fill(upgrades, true)) + .setSize(40, 15) + .setBackground(GTUITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.debug.unlockall.text")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(0, 35)) + .addChild( + new TextWidget(translateToLocal("fog.debug.unlockall.text")).setTextAlignment(Alignment.Center) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 38)) + .setPos(4, 4)); + + } + return builder.build(); + } + + protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) { + UITexture background; + UITexture overlay; + UITexture milestoneSymbol; + float widthRatio; + switch (currentColorCode) { + case 1 -> { + background = TecTechUITextures.BACKGROUND_GLOW_PURPLE; + overlay = TecTechUITextures.PICTURE_OVERLAY_PURPLE; + } + case 2 -> { + background = TecTechUITextures.BACKGROUND_GLOW_ORANGE; + overlay = TecTechUITextures.PICTURE_OVERLAY_ORANGE; + } + case 3 -> { + background = TecTechUITextures.BACKGROUND_GLOW_GREEN; + overlay = TecTechUITextures.PICTURE_OVERLAY_GREEN; + } + default -> { + background = TecTechUITextures.BACKGROUND_GLOW_BLUE; + overlay = TecTechUITextures.PICTURE_OVERLAY_BLUE; + } + } + switch (currentMilestoneBG) { + case 1 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION; + widthRatio = 0.72f; + } + case 2 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST; + widthRatio = 1f; + } + case 3 -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION; + widthRatio = 1f; + } + default -> { + milestoneSymbol = TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE; + widthRatio = 0.8f; + } + } + int WIDTH = 250; + int HEIGHT = 250; + int LORE_POS = 110; + if (currentUpgradeID == 0 || currentUpgradeID == 30) { + WIDTH = 300; + HEIGHT = 300; + LORE_POS = 85; + } + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT) + .setBackground(background) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(WIDTH - 15, 3)) + .widget( + new DrawableWidget().setDrawable(milestoneSymbol) + .setPos((int) ((1 - widthRatio / 2) * WIDTH / 2), HEIGHT / 4) + .setSize((int) (WIDTH / 2 * widthRatio), HEIGHT / 2)) + .widget( + new DrawableWidget().setDrawable(overlay) + .setPos(WIDTH / 4, HEIGHT / 4) + .setSize(WIDTH / 2, HEIGHT / 2)) + .widget( + new MultiChildWidget() + .addChild( + new TextWidget(translateToLocal("fog.upgrade.tt." + (currentUpgradeID))) + .setTextAlignment(Alignment.Center) + .setDefaultColor(EnumChatFormatting.GOLD) + .setSize(WIDTH - 15, 30) + .setPos(9, 5)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.text." + (currentUpgradeID))) + .setTextAlignment(Alignment.CenterLeft) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(WIDTH - 15, LORE_POS - 30) + .setPos(9, 30)) + .addChild( + new TextWidget( + EnumChatFormatting.ITALIC + translateToLocal("fog.upgrade.lore." + (currentUpgradeID))) + .setTextAlignment(Alignment.Center) + .setDefaultColor(0xbbbdbd) + .setSize(WIDTH - 15, (int) (HEIGHT * 0.9) - LORE_POS) + .setPos(9, LORE_POS)) + .addChild( + new TextWidget( + translateToLocal("gt.blockmachines.multimachine.FOG.shardcost") + " " + + EnumChatFormatting.BLUE + + gravitonShardCost).setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(70) + .setDefaultColor(0x9c9c9c) + .setPos(11, HEIGHT - 25)) + .addChild( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.availableshards")) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(WIDTH - 87, HEIGHT - 25)) + .addChild( + TextWidget.dynamicText(this::gravitonShardAmount) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(WIDTH - 27, HEIGHT - 18))) + .setSize(WIDTH, HEIGHT) + + .widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + int unlockedPrereqUpgrades = 0; + int unlockedFollowupUpgrades = 0; + int unlockedSplitUpgrades = 0; + if (!upgrades[currentUpgradeID]) { + for (int prereqUpgrade : prereqUpgrades) { + if (upgrades[prereqUpgrade]) { + unlockedPrereqUpgrades++; + } + } + if (!doesCurrentUpgradeRequireExtraMats + || materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(currentUpgradeID)]) { + if (allPrereqRequired) { + if (unlockedPrereqUpgrades == prereqUpgrades.length + && gravitonShardsAvailable >= gravitonShardCost) { + gravitonShardsAvailable -= gravitonShardCost; + gravitonShardsSpent += gravitonShardCost; + upgrades[currentUpgradeID] = true; + } + } else if (unlockedPrereqUpgrades > 0 || prereqUpgrades.length == 0) { + if (isUpradeSplitStart) { + for (int splitUpgrade : FIRST_SPLIT_UPGRADES) { + if (upgrades[splitUpgrade]) { + unlockedSplitUpgrades++; + } + } + unlockedSplitUpgrades -= (ringAmount - 1); + } + if (unlockedSplitUpgrades <= 0 && gravitonShardsAvailable >= gravitonShardCost) { + gravitonShardsAvailable -= gravitonShardCost; + gravitonShardsSpent += gravitonShardCost; + upgrades[currentUpgradeID] = true; + } + } + } + } else { + for (int followupUpgrade : followupUpgrades) { + if (upgrades[followupUpgrade]) { + unlockedFollowupUpgrades++; + } + } + if (unlockedFollowupUpgrades == 0) { + gravitonShardsAvailable += gravitonShardCost; + gravitonShardsSpent -= gravitonShardCost; + upgrades[currentUpgradeID] = false; + } + } + }) + .setSize(40, 15) + .setBackground(() -> { + if (upgrades[currentUpgradeID]) { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED }; + } else { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD }; + } + }) + .addTooltip(translateToLocal("fog.upgrade.confirm")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.confirm")).setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(36) + .setPos(3, 5)) + .setPos(WIDTH / 2 - 21, (int) (HEIGHT * 0.9))); + if (Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .contains(currentUpgradeID)) { + builder.widget(createMaterialInputButton(currentUpgradeID, WIDTH / 2 - 40, (int) (HEIGHT * 0.9), builder)); + } + return builder.build(); + } + + private Widget createMaterialInputButton(int upgradeID, int xCoord, int yCoord, IWidgetBuilder<?> builder) { + return new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient() && doesCurrentUpgradeRequireExtraMats) { + widget.getContext() + .openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); + widget.getContext() + .closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + widget.getContext() + .closeWindow(UPGRADE_TREE_WINDOW_ID); + } + }) + .setPlayClickSound(doesCurrentUpgradeRequireExtraMats) + .setBackground(() -> { + if (doesCurrentUpgradeRequireExtraMats) { + if (materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(upgradeID)]) { + return new IDrawable[] { TecTechUITextures.BUTTON_BOXED_CHECKMARK_18x18 }; + } else { + return new IDrawable[] { TecTechUITextures.BUTTON_BOXED_EXCLAMATION_POINT_18x18 }; + } + } else { + return new IDrawable[] { GTUITextures.TRANSPARENT }; + } + }) + .setPos(xCoord, yCoord) + .setSize(15, 15) + .dynamicTooltip(this::upgradeMaterialRequirements) + .addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.materialrequirements.tooltip.clickhere")) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer( + () -> materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(upgradeID)], + val -> materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(upgradeID)] = val), + builder); + } + + /** + * @param upgradeID ID of the upgrade + * @param colorCode Number deciding which colored background to use, 0 for blue, 1 for purple, 2 for + * orange and 3 for green + * @param milestone Number deciding which milestone symbol to display in the background, 0 for charge, + * 1 for conversion, 2 for catalyst and 3 for composition + * @param prerequisiteUpgradeIDs IDs of the prior upgrades directly connected to the current one + * @param requireAllPrerequisites Decides how many connected prerequisite upgrades have to be unlocked to be able to + * unlock this one. True means ALL, False means AT LEAST ONE + * @param followingUpgradeIDs IDs of the following upgrades directly connected to the current one + * @param isStartOfSplit Whether this upgrade is one of the initial split upgrades + * @param requiresExtraMaterials Whether this upgrade requires materials other than graviton shards to unlock + * @param shardCost How many graviton shards are needed to unlock this upgrade + * @param pos Position of the upgrade inside the scrollableWidget + */ + private Widget createUpgradeBox(int upgradeID, int colorCode, int milestone, int[] prerequisiteUpgradeIDs, + boolean requireAllPrerequisites, int[] followingUpgradeIDs, boolean isStartOfSplit, + boolean requiresExtraMaterials, int shardCost, Pos2d pos, IWidgetBuilder<?> builder) { + return new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + currentUpgradeID = upgradeID; + currentColorCode = colorCode; + currentMilestoneBG = milestone; + gravitonShardCost = shardCost; + prereqUpgrades = prerequisiteUpgradeIDs; + allPrereqRequired = requireAllPrerequisites; + followupUpgrades = followingUpgradeIDs; + isUpradeSplitStart = isStartOfSplit; + doesCurrentUpgradeRequireExtraMats = requiresExtraMaterials; + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + }) + .setSize(40, 15) + .setBackground(() -> { + if (upgrades[upgradeID]) { + return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_PRESSED_32x16 }; + } else { + return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_32x16 }; + } + }) + .addTooltip(translateToLocal("fog.upgrade.tt." + upgradeID)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.tt.short." + upgradeID)).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setSize(34, 9) + .setPos(3, 4)) + .setPos(pos) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> upgrades[upgradeID], val -> upgrades[upgradeID] = val), + builder); + } + + protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { + ItemStack[] inputs = godforgeUpgradeMats.get(currentUpgradeID); + final int WIDTH = 189; + final int HEIGHT = 106; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + final MultiChildWidget columns = new MultiChildWidget(); + final DynamicPositionedColumn column1 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column2 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column3 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column4 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column5 = new DynamicPositionedColumn(); + final DynamicPositionedColumn column6 = new DynamicPositionedColumn(); + List<DynamicPositionedColumn> columnList = Arrays.asList(column1, column2, column3, column4, column5, column6); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add(Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT))) + .subtract(5, 0) + .add(0, 4)); + builder.widget( + SlotGroup.ofItemHandler(inputSlotHandler, 4) + .startFromSlot(0) + .endAtSlot(15) + .phantom(false) + .background(getGUITextureSet().getItemSlot()) + .build() + .setPos(112, 6)); + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getWindow() + .closeWindow(); + widget.getContext() + .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); + widget.getContext() + .openSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + } + }) + .setBackground(ModularUITextures.VANILLA_BACKGROUND, new Text("x")) + .setPos(179, 0) + .setSize(10, 10)); + builder.widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + ArrayList<ItemStack> list = new ArrayList<>(inputSlotHandler.getStacks()); + list.removeIf(Objects::isNull); + int foundInputs = 0; + int[] foundInputIndices = new int[inputs.length]; + for (ItemStack inputStack : list) { + for (ItemStack requiredStack : inputs) { + if (ItemStack.areItemStacksEqual(requiredStack, inputStack)) { + foundInputIndices[foundInputs] = inputSlotHandler.getStacks() + .indexOf(inputStack); + foundInputs++; + } + } + } + if (foundInputs == inputs.length) { + for (int index : foundInputIndices) { + inputSlotHandler.extractItem(index, inputSlotHandler.getStackInSlot(index).stackSize, false); + } + materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(currentUpgradeID)] = true; + } + } + }) + .setPlayClickSound(true) + .setBackground(GTUITextures.BUTTON_STANDARD) + .setSize(179, 18)) + .addChild( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.consumeUpgradeMats")) + .setTextAlignment(Alignment.Center) + .setScale(0.75f) + .setPos(0, 1) + .setSize(179, 18)) + .setPos(5, 82) + .setSize(179, 16)); + + int uniqueItems = inputs.length; + for (int i = 0; i < 12; i++) { + int index = i; + int cleanDiv4 = index / 4; + if (i < uniqueItems) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) + .setPos(5 + cleanDiv4 * 36, 6 + index % 4 * 18) + .setSize(18, 18)); + columnList.get(cleanDiv4) + .addChild( + new ItemDrawable().setItem(inputs[index]) + .asWidget() + .dynamicTooltip(() -> { + List<String> tooltip = new ArrayList<>(); + tooltip.add(inputs[index] != null ? inputs[index].getDisplayName() : ""); + return tooltip; + }) + .setSize(16, 16)); + columnList.get(cleanDiv4 + 3) + .addChild( + new TextWidget("x" + inputs[i].stackSize).setTextAlignment(Alignment.CenterLeft) + .setScale(0.8f) + .setSize(18, 8)); + } else { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_DISABLED) + .setPos(5 + cleanDiv4 * 36, 6 + index % 4 * 18) + .setSize(18, 18)); + } + } + + int counter = 0; + for (DynamicPositionedColumn column : columnList) { + int spacing = 2; + int xCord = 1 + counter * 36; + int yCord = 1; + if (counter > 2) { + spacing = 10; + xCord = 19 + (counter - 3) * 36; + yCord = 5; + } + columns.addChild( + column.setSpace(spacing) + .setAlignment(MainAxisAlignment.SPACE_BETWEEN) + .setSize(16, 72) + .setPos(xCord, yCord)); + counter++; + } + + builder.widget( + columns.setSize(108, 72) + .setPos(5, 6)); + + return builder.build(); + } + + protected ModularWindow createGeneralInfoWindow(final EntityPlayer player) { + final Scrollable scrollable = new Scrollable().setVerticalScroll(); + final int WIDTH = 300; + final int HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + + builder.setDraggable(true); + scrollable.widget( + new TextWidget(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.introduction")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 13) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.introductioninfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 30) + .setSize(280, 50)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.tableofcontents")) + .setDefaultColor(EnumChatFormatting.AQUA) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 80) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(150)) + .setBackground( + new Text(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 95) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(434)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 110) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1088)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 125) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1412)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 140) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(this::inversionHeaderText) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 155) + .setSize(150, 15)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (inversion) { + scrollable.setVerticalScrollOffset(1766); + } + }) + .setPlayClickSound(inversion) + .setPos(7, 155) + .setSize(150, 15) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(() -> inversion, (val) -> inversion = val), scrollable)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(127, 160) + .setSize(40, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 177) + .setSize(280, 250)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 440) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.moduleinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 461) + .setSize(280, 620)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1098) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.upgradeinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1115) + .setSize(280, 290)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1422) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.milestoneinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1439) + .setSize(280, 320)) + .widget( + TextWidget.dynamicText(this::inversionHeaderText) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1776) + .setSize(280, 15)) + .widget( + TextWidget.dynamicText(this::inversionInfoText) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1793) + .setSize(280, 160)) + .widget( + new TextWidget("").setPos(7, 1965) + .setSize(10, 10)); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_GLOW_WHITE) + .setPos(0, 0) + .setSize(300, 300)) + .widget( + scrollable.setSize(292, 292) + .setPos(4, 4)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(284, 4)); + + return builder.build(); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Stellar Forge") + .addInfo(EnumChatFormatting.ITALIC + "Also known as Godforge or Gorge for short.") + .addInfo(TOOLTIP_BAR) + .addInfo("Controller block for the Godforge, a massive structure harnessing the thermal,") + .addInfo("gravitational and kinetic energy of a stabilised neutron star for material processing.") + .addInfo( + "This multiblock can house " + EnumChatFormatting.RED + + "up to 16 modules " + + EnumChatFormatting.GRAY + + "which utilize the star to energize materials") + .addInfo("to varying degrees, ranging from regular smelting to matter degeneration.") + .addInfo(TOOLTIP_BAR) + .addInfo( + "This multiblock has an " + EnumChatFormatting.GOLD + + "extensive upgrade tree " + + EnumChatFormatting.GRAY + + "which influences all of its functions,") + .addInfo( + "such as " + EnumChatFormatting.GOLD + + "unlocking new module types, increasing heat levels " + + EnumChatFormatting.GRAY + + "and " + + EnumChatFormatting.GOLD + + "granting") + .addInfo( + EnumChatFormatting.GOLD + "various processing speed bonuses. " + + EnumChatFormatting.GRAY + + "These upgrades can be unlocked by reaching") + .addInfo("certain milestones and/or spending materials.") + .addInfo(TOOLTIP_BAR) + .addInfo( + EnumChatFormatting.GREEN + + "Clicking on the logo in the controller gui opens an extensive information window,") + .addInfo("explaining everything there is to know about this multiblock.") + .addInfo(TOOLTIP_BAR) + .beginStructureBlock(126, 29, 186, false) + .addStructureInfo("The structure is too complex! See schematic for details.") + .addStructureInfo( + "Total blocks needed for the structure with " + EnumChatFormatting.DARK_PURPLE + + "1" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "2" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "3" + + EnumChatFormatting.GRAY + + " rings:") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "3943" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "7279" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "11005" + + EnumChatFormatting.GRAY + + " Transcendentally Amplified Magnetic Confinement Casing") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "2819" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "4831" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "6567" + + EnumChatFormatting.GRAY + + " Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "272" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "512" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "824" + + EnumChatFormatting.GRAY + + " Celestial Matter Guidance Casing") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "130" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "144" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "158" + + EnumChatFormatting.GRAY + + " Boundless Gravitationally Severed Structure Casing") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "9" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "54" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "155" + + EnumChatFormatting.GRAY + + " Spatially Transcendent Gravitational Lens Block") + .addStructureInfo( + EnumChatFormatting.DARK_PURPLE + "345" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "357" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "397" + + EnumChatFormatting.DARK_PURPLE + + " Remote" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + "Medial" + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + "Central" + + EnumChatFormatting.GRAY + + " Graviton Flow Modulator") + .addStructureInfo( + EnumChatFormatting.GOLD + "36" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") + .addStructureInfo("--------------------------------------------") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " Input Hatch") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " Output Bus") + .addStructureInfo("Requires " + EnumChatFormatting.GOLD + 1 + EnumChatFormatting.GRAY + " Input Bus") + .addStructureInfo("--------------------------------------------") + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + + @Override + public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { + return true; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return new String[] { EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.FOG.hint.0"), + translateToLocal("gt.blockmachines.multimachine.FOG.hint.1") }; + } + + public int getFuelType() { + return selectedFuelType; + } + + private void setFuelType(int fuelType) { + selectedFuelType = fuelType; + } + + public int getFuelFactor() { + return fuelConsumptionFactor; + } + + public boolean isUpgradeActive(int upgradeID) { + return upgrades[upgradeID]; + } + + public int getRingAmount() { + return ringAmount; + } + + public int getTotalActiveUpgrades() { + int totalUpgrades = 0; + for (boolean upgrade : upgrades) { + if (upgrade) { + totalUpgrades++; + } + } + return totalUpgrades; + } + + private Text fuelUsage() { + return new Text(fuelConsumption + " L/5s"); + } + + private Text gravitonShardAmount() { + EnumChatFormatting enoughGravitonShards = EnumChatFormatting.RED; + if (gravitonShardsAvailable >= gravitonShardCost) { + enoughGravitonShards = EnumChatFormatting.GREEN; + } + return new Text(enoughGravitonShards + Integer.toString(gravitonShardsAvailable)); + + } + + private Text storedFuel() { + if (internalBattery == 0) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.storedstartupfuel") + " " + + stellarFuelAmount + + "/" + + neededStartupFuel); + } + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.storedfuel") + " " + + internalBattery + + "/" + + maxBatteryCharge); + } + + private void checkInversionStatus() { + int inversionChecker = 0; + for (int progress : milestoneProgress) { + if (progress < 7) { + break; + } + inversionChecker++; + } + inversion = inversionChecker == 4; + } + + private Text inversionStatusText() { + String inversionStatus = ""; + if (inversion) { + inversionStatus = EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.multimachine.FOG.inversionactive"); + } + return new Text(inversionStatus); + } + + private void determineCompositionMilestoneLevel() { + int[] uniqueModuleCount = new int[5]; + int smelting = 0; + int molten = 0; + int plasma = 0; + int exotic = 0; + int exoticMagmatter = 0; + for (MTEBaseModule module : moduleHatches) { + if (module instanceof MTESmeltingModule) { + uniqueModuleCount[0] = 1; + smelting++; + continue; + } + if (module instanceof MTEMoltenModule) { + uniqueModuleCount[1] = 1; + molten++; + continue; + } + if (module instanceof MTEPlasmaModule) { + uniqueModuleCount[2] = 1; + plasma++; + continue; + } + if (module instanceof MTEExoticModule) { + if (!((MTEExoticModule) module).isMagmatterModeOn()) { + uniqueModuleCount[3] = 1; + exotic++; + } else { + uniqueModuleCount[4] = 1; + exoticMagmatter++; + } + } + + } + totalExtensionsBuilt = Arrays.stream(uniqueModuleCount) + .sum() + ringAmount + - 1; + if (inversion) { + totalExtensionsBuilt += (smelting - 1 + + (molten - 1) * 2 + + (plasma - 1) * 3 + + (exotic - 1) * 4 + + (exoticMagmatter - 1) * 5) / 5f; + } + milestoneProgress[3] = (int) Math.floor(totalExtensionsBuilt); + } + + private void determineMilestoneProgress() { + int closestRelevantSeven; + float rawProgress; + float actualProgress; + if (milestoneProgress[0] < 7) { + powerMilestonePercentage = (float) max( + (log((totalPowerConsumed.divide(BigInteger.valueOf(POWER_MILESTONE_CONSTANT))).longValue()) + / POWER_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[0] = (int) floor(powerMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (totalPowerConsumed.divide(POWER_MILESTONE_T7_CONSTANT) + .floatValue() - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[0] = 7 + (int) floor(rawProgress * 7); + if (closestRelevantSeven % 2 == 0) { + invertedPowerMilestonePercentage = actualProgress; + powerMilestonePercentage = 1 - invertedPowerMilestonePercentage; + } else { + powerMilestonePercentage = actualProgress; + invertedPowerMilestonePercentage = 1 - powerMilestonePercentage; + } + } + + if (milestoneProgress[1] < 7) { + recipeMilestonePercentage = (float) max( + (log(totalRecipesProcessed * 1f / RECIPE_MILESTONE_CONSTANT) / RECIPE_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[1] = (int) floor(recipeMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (((float) totalRecipesProcessed / RECIPE_MILESTONE_T7_CONSTANT) - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[1] = 7 + (int) floor(rawProgress * 7); + if (closestRelevantSeven % 2 == 0) { + invertedRecipeMilestonePercentage = actualProgress; + recipeMilestonePercentage = 1 - invertedRecipeMilestonePercentage; + } else { + recipeMilestonePercentage = actualProgress; + invertedRecipeMilestonePercentage = 1 - recipeMilestonePercentage; + } + } + if (milestoneProgress[2] < 7) { + fuelMilestonePercentage = (float) max( + (log(totalFuelConsumed * 1f / FUEL_MILESTONE_CONSTANT) / FUEL_LOG_CONSTANT + 1), + 0) / 7; + milestoneProgress[2] = (int) floor(fuelMilestonePercentage * 7); + } + if (inversion) { + rawProgress = (((float) totalFuelConsumed / FUEL_MILESTONE_T7_CONSTANT) - 1) / 7; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + milestoneProgress[2] = 7 + (int) floor(rawProgress * 7); + if ((closestRelevantSeven % 2) == 0) { + invertedFuelMilestonePercentage = actualProgress; + fuelMilestonePercentage = 1 - invertedFuelMilestonePercentage; + } else { + fuelMilestonePercentage = actualProgress; + invertedFuelMilestonePercentage = 1 - fuelMilestonePercentage; + } + } + + if (milestoneProgress[3] <= 7) { + structureMilestonePercentage = totalExtensionsBuilt / 7f; + } + if (inversion) { + rawProgress = (totalExtensionsBuilt - 7) / 7f; + closestRelevantSeven = (int) floor(rawProgress); + actualProgress = rawProgress - closestRelevantSeven; + if ((closestRelevantSeven % 2) == 0) { + invertedStructureMilestonePercentage = actualProgress; + structureMilestonePercentage = 1 - invertedStructureMilestonePercentage; + } else { + structureMilestonePercentage = actualProgress; + invertedStructureMilestonePercentage = 1 - structureMilestonePercentage; + } + } + } + + private void determineGravitonShardAmount() { + int sum = 0; + for (int progress : milestoneProgress) { + if (!inversion) { + progress = Math.min(progress, 7); + } + sum += progress * (progress + 1) / 2; + } + gravitonShardsAvailable = sum - gravitonShardsSpent; + } + + private void ejectGravitonShards() { + if (mOutputBusses.size() == 1) { + while (gravitonShardsAvailable >= 64) { + addOutput(GTOreDictUnificator.get(OrePrefixes.gem, MaterialsUEVplus.GravitonShard, 64)); + gravitonShardsAvailable -= 64; + } + addOutput( + GTOreDictUnificator.get(OrePrefixes.gem, MaterialsUEVplus.GravitonShard, gravitonShardsAvailable)); + gravitonShardsAvailable = 0; + } + } + + private Text gravitonShardAmountText(int milestoneID) { + int sum; + int progress = milestoneProgress[milestoneID]; + if (!inversion) { + progress = Math.min(progress, 7); + } + sum = progress * (progress + 1) / 2; + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.shardgain") + ": " + EnumChatFormatting.GRAY + sum); + } + + private Text totalMilestoneProgress(int milestoneID) { + long progress; + BigInteger bigProgress; + String suffix; + switch (milestoneID) { + case 1 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.recipes"); + progress = totalRecipesProcessed; + } + case 2 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.fuelconsumed"); + progress = totalFuelConsumed; + } + case 3 -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.extensions"); + progress = milestoneProgress[3]; + } + default -> { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.power"); + bigProgress = totalPowerConsumed; + if (!noFormatting && (totalPowerConsumed.compareTo(BigInteger.valueOf(1_000L)) > 0)) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + toExponentForm(bigProgress) + + " " + + suffix); + } else { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + bigProgress + + " " + + suffix); + } + } + } + if (!noFormatting) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + formatNumbers(progress) + + " " + + suffix); + } else { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.totalprogress") + ": " + + EnumChatFormatting.GRAY + + progress + + " " + + suffix); + } + + } + + private Text currentMilestone(int milestoneID) { + return new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.milestoneprogress") + ": " + + EnumChatFormatting.GRAY + + milestoneProgress[milestoneID]); + } + + private Text milestoneProgressText(int milestoneID, boolean formatting) { + long max; + BigInteger bigMax; + String suffix; + String progressText = translateToLocal("gt.blockmachines.multimachine.FOG.progress"); + Text done = new Text(translateToLocal("gt.blockmachines.multimachine.FOG.milestonecomplete")); + if (noFormatting) { + formatting = false; + done = new Text( + translateToLocal("gt.blockmachines.multimachine.FOG.milestonecomplete") + EnumChatFormatting.DARK_RED + + "?"); + } + switch (milestoneID) { + case 0: + if (milestoneProgress[0] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.power"); + if (inversion) { + bigMax = POWER_MILESTONE_T7_CONSTANT.multiply(BigInteger.valueOf(milestoneProgress[0] - 5)); + } else { + bigMax = BigInteger.valueOf(LongMath.pow(9, milestoneProgress[0])) + .multiply(BigInteger.valueOf(LongMath.pow(10, 15))); + } + if (formatting && (totalPowerConsumed.compareTo(BigInteger.valueOf(1_000L)) > 0)) { + return new Text( + progressText + ": " + EnumChatFormatting.GRAY + toExponentForm(bigMax) + " " + suffix); + } else { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + bigMax + " " + suffix); + } + } else { + return done; + } + case 1: + if (milestoneProgress[1] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.recipes"); + if (inversion) { + max = RECIPE_MILESTONE_T7_CONSTANT * (milestoneProgress[1] - 5); + } else { + max = LongMath.pow(6, milestoneProgress[1]) * LongMath.pow(10, 7); + } + break; + } else { + return done; + } + case 2: + if (milestoneProgress[2] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.fuelconsumed"); + if (inversion) { + max = FUEL_MILESTONE_T7_CONSTANT * (milestoneProgress[2] - 5); + } else { + max = LongMath.pow(3, milestoneProgress[2]) * LongMath.pow(10, 4); + } + break; + } else { + return done; + } + case 3: + if (milestoneProgress[3] < 7 || inversion) { + suffix = translateToLocal("gt.blockmachines.multimachine.FOG.extensions"); + max = milestoneProgress[3] + 1; + break; + } else { + return done; + } + default: + return new Text("Error"); + } + if (formatting) { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + formatNumbers(max) + " " + suffix); + } else { + return new Text(progressText + ": " + EnumChatFormatting.GRAY + max + " " + suffix); + } + } + + private Text inversionHeaderText() { + return inversion + ? new Text( + EnumChatFormatting.BOLD + "§k2" + + EnumChatFormatting.RESET + + EnumChatFormatting.WHITE + + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.multimachine.FOG.inversion") + + EnumChatFormatting.BOLD + + "§k2") + : new Text(""); + } + + private Text inversionInfoText() { + return inversion ? new Text(translateToLocal("gt.blockmachines.multimachine.FOG.inversioninfotext")) + : new Text(""); + } + + private List<String> upgradeMaterialRequirements() { + if (materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) + .indexOf(currentUpgradeID)]) { + return ImmutableList.of(translateToLocal("fog.button.materialrequirementsmet.tooltip")); + } + return ImmutableList.of(translateToLocal("fog.button.materialrequirements.tooltip")); + } + + private void increaseBattery(int amount) { + if ((internalBattery + amount) <= maxBatteryCharge) { + internalBattery += amount; + } else { + internalBattery = maxBatteryCharge; + batteryCharging = false; + } + } + + public void reduceBattery(int amount) { + if (internalBattery - amount <= 0) { + internalBattery = 0; + if (moduleHatches.size() > 0) { + for (MTEBaseModule module : moduleHatches) { + module.disconnect(); + } + } + destroyRenderer(); + } else { + internalBattery -= amount; + totalFuelConsumed += amount; + } + + } + + public int getBatteryCharge() { + return internalBattery; + } + + public int getMaxBatteryCharge() { + return maxBatteryCharge; + } + + public void addTotalPowerConsumed(BigInteger amount) { + totalPowerConsumed = totalPowerConsumed.add(amount); + } + + public void addTotalRecipesProcessed(long amount) { + totalRecipesProcessed += amount; + } + + @Override + protected void setHatchRecipeMap(MTEHatchInput hatch) {} + + @Override + public void setItemNBT(NBTTagCompound NBT) { + NBT.setInteger("selectedFuelType", selectedFuelType); + NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); + NBT.setInteger("internalBattery", internalBattery); + NBT.setBoolean("batteryCharging", batteryCharging); + NBT.setInteger("batterySize", maxBatteryCharge); + NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + NBT.setLong("totalFuelConsumed", totalFuelConsumed); + NBT.setInteger("starFuelStored", stellarFuelAmount); + NBT.setBoolean("gravitonShardEjection", gravitonShardEjection); + + // Store booleanArrays of all upgrades + NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeIndex = 0; + for (Boolean upgrade : upgrades) { + upgradeBooleanArrayNBTTag.setBoolean("upgrade" + upgradeIndex, upgrade); + upgradeIndex++; + } + + NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + + NBTTagCompound upgradeMaterialBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeMaterialIndex = 0; + for (Boolean upgrade : materialPaidUpgrades) { + upgradeBooleanArrayNBTTag.setBoolean("upgradeMaterial" + upgradeMaterialIndex, upgrade); + upgradeMaterialIndex++; + } + + NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setInteger("selectedFuelType", selectedFuelType); + NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); + NBT.setInteger("internalBattery", internalBattery); + NBT.setBoolean("batteryCharging", batteryCharging); + NBT.setInteger("batterySize", maxBatteryCharge); + NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + NBT.setLong("totalFuelConsumed", totalFuelConsumed); + NBT.setInteger("starFuelStored", stellarFuelAmount); + NBT.setBoolean("gravitonShardEjection", gravitonShardEjection); + NBT.setBoolean("isRenderActive", isRenderActive); + NBT.setInteger("ringAmount", ringAmount); + + // Store booleanArray of all upgrades + NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeIndex = 0; + for (boolean upgrade : upgrades) { + upgradeBooleanArrayNBTTag.setBoolean("upgrade" + upgradeIndex, upgrade); + upgradeIndex++; + } + + NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + + NBTTagCompound upgradeMaterialBooleanArrayNBTTag = new NBTTagCompound(); + + int upgradeMaterialIndex = 0; + for (boolean upgrade : materialPaidUpgrades) { + upgradeMaterialBooleanArrayNBTTag.setBoolean("upgradeMaterial" + upgradeMaterialIndex, upgrade); + upgradeMaterialIndex++; + } + + NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(NBTTagCompound NBT) { + selectedFuelType = NBT.getInteger("selectedFuelType"); + fuelConsumptionFactor = NBT.getInteger("fuelConsumptionFactor"); + internalBattery = NBT.getInteger("internalBattery"); + batteryCharging = NBT.getBoolean("batteryCharging"); + maxBatteryCharge = NBT.getInteger("batterySize"); + gravitonShardsAvailable = NBT.getInteger("gravitonShardsAvailable"); + gravitonShardsSpent = NBT.getInteger("gravitonShardsSpent"); + totalPowerConsumed = new BigInteger(NBT.getByteArray("totalPowerConsumed")); + totalRecipesProcessed = NBT.getLong("totalRecipesProcessed"); + totalFuelConsumed = NBT.getLong("totalFuelConsumed"); + stellarFuelAmount = NBT.getInteger("starFuelStored"); + gravitonShardEjection = NBT.getBoolean("gravitonShardEjection"); + isRenderActive = NBT.getBoolean("isRenderActive"); + ringAmount = NBT.getInteger("ringAmount"); + + NBTTagCompound tempBooleanTag = NBT.getCompoundTag("upgrades"); + + for (int upgradeIndex = 0; upgradeIndex < 31; upgradeIndex++) { + boolean upgrade = tempBooleanTag.getBoolean("upgrade" + upgradeIndex); + upgrades[upgradeIndex] = upgrade; + } + + tempBooleanTag = NBT.getCompoundTag("upgradeMaterials"); + + for (int upgradeIndex = 0; upgradeIndex < 7; upgradeIndex++) { + boolean upgrade = tempBooleanTag.getBoolean("upgradeMaterial" + upgradeIndex); + materialPaidUpgrades[upgradeIndex] = upgrade; + } + + super.loadNBTData(NBT); + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java new file mode 100644 index 0000000000..d5e43aaa97 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEMicrowave.java @@ -0,0 +1,342 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.GregTechAPI.sBlockCasings4; +import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.AxisAlignedBB.getBoundingBox; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.HashSet; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import tectech.Reference; +import tectech.loader.MainLoader; +import tectech.recipe.TTRecipeAdder; +import tectech.thing.metaTileEntity.multi.base.INameFunction; +import tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import tectech.thing.metaTileEntity.multi.base.LedStatus; +import tectech.thing.metaTileEntity.multi.base.Parameters; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class MTEMicrowave extends TTMultiblockBase implements IConstructable { + + // region variables + private boolean hasBeenPausedThisCycle = false; + // endregion + + // region structure + // use multi A energy inputs, use less power the longer it runs + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.tm.microwave.hint.0"), // 1 - Classic Hatches or Clean + // Stainless Steel + // Casing + translateToLocal("gt.blockmachines.multimachine.tm.microwave.hint.1"), // Also acts like a hopper so give it + // an Output + // Bus + }; + + private static final IStructureDefinition<MTEMicrowave> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEMicrowave>builder() + .addShape( + "main", + transpose( + new String[][] { { "AAAAA", "A---A", "A---A", "A---A", "AAAAA" }, + { "AAAAA", "A---A", "A---A", "A---A", "AAAAA" }, { "AA~AA", "A---A", "A---A", "A---A", "AAAAA" }, + { "ABBBA", "BAAAB", "BAAAB", "BAAAB", "ABBBA" } })) + .addElement('A', ofBlock(sBlockCasings4, 1)) + .addElement('B', ofHatchAdderOptional(MTEMicrowave::addClassicToMachineList, 49, 1, sBlockCasings4, 1)) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn powerSetting, timerSetting; + protected Parameters.Group.ParameterOut timerValue, remainingTime; + private static final INameFunction<MTEMicrowave> POWER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.0"); // Power setting + private static final INameFunction<MTEMicrowave> TIMER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgi.1"); // Timer setting + + private static final INameFunction<MTEMicrowave> TIMER_VALUE_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.0"); // Timer value + private static final INameFunction<MTEMicrowave> TIMER_REMAINING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.microwave.cfgo.1"); // Timer remaining + private static final IStatusFunction<MTEMicrowave> POWER_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 300, 1000, 1000, Double.POSITIVE_INFINITY); + private static final IStatusFunction<MTEMicrowave> TIMER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value <= 0) return LedStatus.STATUS_TOO_LOW; + if (value > 3000) return LedStatus.STATUS_TOO_HIGH; + return LedStatus.STATUS_OK; + }; + // endregion + + public MTEMicrowave(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMicrowave(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMicrowave(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 2, 2, 0); + } + + @Override + @NotNull + public CheckRecipeResult checkProcessing_EM() { + hasBeenPausedThisCycle = false; + if ((int) powerSetting.get() < 300 || timerSetting.get() <= 0 || timerSetting.get() > 3000) { + return SimpleCheckRecipeResult.ofFailure("invalid_timer"); + } + if (remainingTime.get() <= 0) { + remainingTime.set(timerSetting.get()); + timerValue.set(0); + } + mEUt = -((int) powerSetting.get() >> 1); + eAmpereFlow = 1; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("microwaving"); + } + + @Override + public void outputAfterRecipe_EM() { + if (hasBeenPausedThisCycle) { + return; // skip timer and actions if paused + } + timerValue.set(timerValue.get() + 1); + remainingTime.set(timerSetting.get() - timerValue.get()); + IGregTechTileEntity mte = getBaseMetaTileEntity(); + Vec3Impl xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -1, 2)); + double xPos = mte.getXCoord() + 0.5f + xyzOffsets.get0(); + double yPos = mte.getYCoord() + 0.5f + xyzOffsets.get1(); + double zPos = mte.getZCoord() + 0.5f + xyzOffsets.get2(); + AxisAlignedBB aabb = getBoundingBox(-2, -2, -2, 2, 2, 2).offset(xPos, yPos, zPos); + xyzOffsets = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -4, 0)); + Vec3Impl xyzExpansion = getExtendedFacing().getWorldOffset(new Vec3Impl(1, 0, 1)) + .abs(); + int power = (int) powerSetting.get(); + int damagingFactor = Math.min(power >> 6, 8) + Math.min(power >> 8, 24) + + Math.min(power >> 12, 48) + + (power >> 18); + + ArrayList<ItemStack> itemsToOutput = new ArrayList<>(); + HashSet<Entity> tickedStuff = new HashSet<>(); + + boolean inside = true; + do { + for (Object entity : mte.getWorld() + .getEntitiesWithinAABBExcludingEntity(null, aabb)) { + if (entity instanceof Entity) { + if (tickedStuff.add((Entity) entity)) { + if (inside && entity instanceof EntityItem) { + GTRecipe tRecipe = RecipeMaps.microwaveRecipes.findRecipe( + mte, + null, + true, + 128, + null, + null, + new ItemStack[] { ((EntityItem) entity).getEntityItem() }); + if (tRecipe == null || tRecipe.mInputs.length == 0 || tRecipe.mInputs[0].stackSize != 1) { + itemsToOutput.add(((EntityItem) entity).getEntityItem()); + } else { + ItemStack newStuff = tRecipe.getOutput(0) + .copy(); + newStuff.stackSize = ((EntityItem) entity).getEntityItem().stackSize; + itemsToOutput.add(newStuff); + } + ((EntityItem) entity).delayBeforeCanPickup = 2; + ((EntityItem) entity).setDead(); + } else if (entity instanceof EntityLivingBase) { + if (!GTUtility.isWearingFullElectroHazmat((EntityLivingBase) entity)) { + ((EntityLivingBase) entity).attackEntityFrom(MainLoader.microwaving, damagingFactor); + } + } + } + } + } + aabb.offset(xyzOffsets.get0(), xyzOffsets.get1(), xyzOffsets.get2()); + aabb = aabb.expand(xyzExpansion.get0() * 1.5, xyzExpansion.get1() * 1.5, xyzExpansion.get2() * 1.5); + inside = false; + damagingFactor >>= 1; + } while (damagingFactor > 0); + + mOutputItems = itemsToOutput.toArray(TTRecipeAdder.nullItem); + + if (remainingTime.get() <= 0) { + mte.getWorld() + .playSoundEffect(xPos, yPos, zPos, Reference.MODID + ":microwave_ding", 1, 1); + stopMachine(); + } + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.tm.microwave.name")) // Machine Type: + // Microwave Grinder + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.0")) // Controller block of + // the + // Microwave Grinder + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.1")) // Starts a timer when + // enabled + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.2")) // While the timer is + // running + // anything inside the machine + // will take damage + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.3")) // The machine will also + // collect + // any items inside of it + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.4")) // Can be configured + // with a Parametrizer + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.microwave.desc.5")) // (Do not insert a + // Wither) + .addSeparator() + .beginStructureBlock(5, 4, 5, true) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("tt.keyword.Structure.StainlessSteelCasing"), 60, false) // 60x + // Stainless + // Steel + // Casing (minimum) + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), + 2) // Output Bus: Any outer casing on the bottom layer + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.Optional") + " " + + translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), + 2) // Parametrizer: (optional) Any outer casing on the bottom layer + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), 1) // Energy Hatch: Any + // outer casing on + // the bottom layer + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyOuterCasingOnBottom"), 1) // Maintenance + // Hatch: Any + // outer casing + // on the + // bottom layer + .toolTipFinisher(CommonValues.THETA_MOVEMENT); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49], + new TTRenderedExtendedFacingTexture( + aActive ? Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE_ACTIVE + : Textures.BlockIcons.OVERLAY_FRONT_ELECTRIC_BLAST_FURNACE) }; + } else if (side == facing.getOpposite()) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49], + aActive ? Textures.BlockIcons.casingTexturePages[0][52] + : Textures.BlockIcons.casingTexturePages[0][53] }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[0][49] }; + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0, true); + powerSetting = hatch_0.makeInParameter(0, 1000, POWER_SETTING_NAME, POWER_STATUS); + timerSetting = hatch_0.makeInParameter(1, 360, TIMER_SETTING_NAME, TIMER_STATUS); + + timerValue = hatch_0.makeOutParameter(0, 0, TIMER_VALUE_NAME, TIMER_STATUS); + remainingTime = hatch_0.makeOutParameter(1, 360, TIMER_REMAINING_NAME, TIMER_STATUS); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + remainingTime.set(timerSetting.get()); + timerValue.set(0); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (eSafeVoid) { + hasBeenPausedThisCycle = true; + } + return hasBeenPausedThisCycle || super.onRunningTick(aStack); // consume eu and other resources if not paused + } + + // TODO Why is the basetype 1?? + @Override + public byte getTileEntityBaseType() { + return 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 2, 2, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition<MTEMicrowave> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public boolean isPowerPassButtonEnabled() { + return true; + } + + @Override + public boolean isSafeVoidButtonEnabled() { + return false; + } + + @Override + public boolean isAllowedToWorkButtonEnabled() { + return true; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTENetworkSwitch.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTENetworkSwitch.java new file mode 100644 index 0000000000..4ce04dc6ab --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTENetworkSwitch.java @@ -0,0 +1,283 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.MultiblockTooltipBuilder; +import tectech.Reference; +import tectech.mechanics.dataTransport.QuantumDataPacket; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataInput; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataOutput; +import tectech.thing.metaTileEntity.multi.base.INameFunction; +import tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import tectech.thing.metaTileEntity.multi.base.LedStatus; +import tectech.thing.metaTileEntity.multi.base.Parameters; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class MTENetworkSwitch extends TTMultiblockBase implements IConstructable { + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + "1 - Classic/Data Hatches or Computer casing", // 1 - Classic/Data Hatches or Computer casing + }; + + private static final IStructureDefinition<MTENetworkSwitch> STRUCTURE_DEFINITION = IStructureDefinition + .<MTENetworkSwitch>builder() + .addShape( + "main", + transpose(new String[][] { { "BBB", "BBB", "BBB" }, { "B~B", "BAB", "BBB" }, { "BBB", "BBB", "BBB" } })) + .addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsTT, 3)) + .addElement( + 'B', + ofHatchAdderOptional( + MTENetworkSwitch::addClassicToMachineList, + BlockGTCasingsTT.textureOffset + 1, + 1, + TTCasingsContainer.sBlockCasingsTT, + 1)) + .build(); + // endregion + + // region parameters + private static final INameFunction<MTENetworkSwitch> ROUTE_NAME = (base, + p) -> (p.parameterId() == 0 ? translateToLocal("tt.keyword.Destination") + " " + : translateToLocal("tt.keyword.Weight") + " ") + p.hatchId(); + private static final IStatusFunction<MTENetworkSwitch> WEI_STATUS = (base, p) -> { + double v = p.get(); + if (Double.isNaN(v)) return LedStatus.STATUS_WRONG; + if (v < 0) return LedStatus.STATUS_TOO_LOW; + if (v == 0) return LedStatus.STATUS_LOW; + if (Double.isInfinite(v)) return LedStatus.STATUS_HIGH; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTENetworkSwitch> DST_STATUS = (base, p) -> { + if (base.weight[p.hatchId()].getStatus(false).isOk) { + double v = p.get(); + if (Double.isNaN(v)) return LedStatus.STATUS_WRONG; + v = (int) v; + if (v <= 0) return LedStatus.STATUS_TOO_LOW; + return LedStatus.STATUS_OK; + } + return LedStatus.STATUS_NEUTRAL; + }; + protected Parameters.Group.ParameterIn[] dst; + protected Parameters.Group.ParameterIn[] weight; + // endregion + + public MTENetworkSwitch(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTENetworkSwitch(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTENetworkSwitch(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return structureCheck_EM("main", 1, 1, 0); + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + short thingsActive = 0; + for (MTEHatchDataInput di : eInputData) { + if (di.q != null) { + thingsActive++; + } + } + + if (thingsActive > 0) { + thingsActive += eOutputData.size(); + mEUt = -(int) V[7]; + eAmpereFlow = 1 + (thingsActive >> 2); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + return SimpleCheckRecipeResult.ofSuccess("routing"); + } + return SimpleCheckRecipeResult.ofFailure("no_routing"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eOutputData.isEmpty()) { + double total = 0; + double weight; + for (int i = 0; i < 10; i++) { // each param pair + weight = this.weight[i].get(); + if (weight > 0 && dst[i].get() >= 0) { + total += weight; // Total weighted div + } + } + + Vec3Impl pos = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + QuantumDataPacket pack = new QuantumDataPacket(0L).unifyTraceWith(pos); + if (pack == null) { + return; + } + for (MTEHatchDataInput hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } + } + + long remaining = pack.getContent(); + + double dest; + for (int i = 0; i < 10; i++) { + dest = dst[i].get(); + weight = this.weight[i].get(); + if (weight > 0 && dest >= 0) { + int outIndex = (int) dest - 1; + if (outIndex < 0 || outIndex >= eOutputData.size()) { + continue; + } + MTEHatchDataOutput out = eOutputData.get(outIndex); + if (Double.isInfinite(total)) { + if (Double.isInfinite(weight)) { + out.q = new QuantumDataPacket(remaining).unifyTraceWith(pack); + break; + } + } else { + long part = (long) Math.floor(pack.getContent() * weight / total); + if (part > 0) { + remaining -= part; + if (remaining > 0) { + out.q = new QuantumDataPacket(part).unifyTraceWith(pack); + } else if (part + remaining > 0) { + out.q = new QuantumDataPacket(part + remaining).unifyTraceWith(pack); + break; + } else { + break; + } + } + } + } + } + } + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.switch.name")) // Machine Type: Network + // Switch With QoS + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.0")) // Controller block of the + // Network + // Switch With QoS + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.1")) // Used to route and + // distribute computation + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.2")) // Needs a Parametrizer to + // be configured + .addSeparator() + .beginStructureBlock(3, 3, 3, false) + .addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center + .addCasingInfoMin(translateToLocal("gt.blockcasingsTT.1.name"), 0, false) // 0x Computer Casing + // (minimum) + .addOtherStructurePart( + translateToLocal("gt.blockcasingsTT.3.name"), + translateToLocal("tt.keyword.Structure.Center")) // Advanced Computer Casing: Center + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Data Connector: Any Computer Casing + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasing"), + 2) // Parametrizer: Any Computer Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Energy Hatch: Any + // Computer Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Maintenance + // Hatch: Any + // Computer Casing + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][1], + new TTRenderedExtendedFacingTexture(aActive ? TTMultiblockBase.ScreenON : TTMultiblockBase.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][1] }; + } + + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_hi_freq"); + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + @Override + protected void parametersInstantiation_EM() { + dst = new Parameters.Group.ParameterIn[10]; + weight = new Parameters.Group.ParameterIn[10]; + for (int i = 0; i < 10; i++) { + Parameters.Group hatch = parametrization.getGroup(i); + dst[i] = hatch.makeInParameter(0, i, ROUTE_NAME, DST_STATUS); + weight[i] = hatch.makeInParameter(1, 0, ROUTE_NAME, WEI_STATUS); + } + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 1, 0, stackSize, hintsOnly); + } + + @Override + public IStructureDefinition<MTENetworkSwitch> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEQuantumComputer.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEQuantumComputer.java new file mode 100644 index 0000000000..6a96a79f29 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEQuantumComputer.java @@ -0,0 +1,618 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTUtility; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.common.WirelessComputationPacket; +import tectech.mechanics.dataTransport.QuantumDataPacket; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataInput; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataOutput; +import tectech.thing.metaTileEntity.hatch.MTEHatchRack; +import tectech.thing.metaTileEntity.hatch.MTEHatchWirelessComputationOutput; +import tectech.thing.metaTileEntity.multi.base.INameFunction; +import tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import tectech.thing.metaTileEntity.multi.base.LedStatus; +import tectech.thing.metaTileEntity.multi.base.Parameters; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +public class MTEQuantumComputer extends TTMultiblockBase implements ISurvivalConstructable { + + // region variables + private final ArrayList<MTEHatchRack> eRacks = new ArrayList<>(); + + private final ArrayList<MTEHatchWirelessComputationOutput> eWirelessComputationOutputs = new ArrayList<>(); + + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.computer.hint.0"), // 1 - Classic/Data Hatches or + // Computer casing + translateToLocal("gt.blockmachines.multimachine.em.computer.hint.1"), // 2 - Rack Hatches or Advanced + // computer casing + }; + + private static final IStructureDefinition<MTEQuantumComputer> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEQuantumComputer>builder() + .addShape("front", transpose(new String[][] { { " AA" }, { " AA" }, { " ~A" }, { " AA" } })) + .addShape("cap", transpose(new String[][] { { "-CB" }, { " DD" }, { " DD" }, { "-CB" } })) + .addShape("slice", transpose(new String[][] { { "-CB" }, { " ED" }, { " ED" }, { "-CB" } })) + .addShape("back", transpose(new String[][] { { " AA" }, { " AA" }, { " AA" }, { " AA" } })) + .addElement('B', ofBlock(TTCasingsContainer.sBlockCasingsTT, 1)) + .addElement('C', ofBlock(TTCasingsContainer.sBlockCasingsTT, 2)) + .addElement('D', ofBlock(TTCasingsContainer.sBlockCasingsTT, 3)) + .addElement( + 'A', + buildHatchAdder(MTEQuantumComputer.class) + .atLeast( + Energy.or(HatchElement.EnergyMulti), + Maintenance, + HatchElement.Uncertainty, + HatchElement.OutputData, + WirelessComputationHatchElement.INSTANCE) + .casingIndex(BlockGTCasingsTT.textureOffset + 1) + .dot(1) + .buildAndChain(ofBlock(TTCasingsContainer.sBlockCasingsTT, 1))) + .addElement( + 'E', + RackHatchElement.INSTANCE + .newAnyOrCasing(BlockGTCasingsTT.textureOffset + 3, 2, TTCasingsContainer.sBlockCasingsTT, 3)) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn overclock, overvolt; + protected Parameters.Group.ParameterOut maxCurrentTemp, availableData; + + private boolean wirelessModeEnabled = false; + + private static final INameFunction<MTEQuantumComputer> OC_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.0"); // Overclock ratio + private static final INameFunction<MTEQuantumComputer> OV_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgi.1"); // Overvoltage ratio + private static final INameFunction<MTEQuantumComputer> MAX_TEMP_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.0"); // Current max. heat + private static final INameFunction<MTEQuantumComputer> COMPUTE_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.em.computer.cfgo.1"); // Produced computation + private static final IStatusFunction<MTEQuantumComputer> OC_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 0, 1, 3, 5); + private static final IStatusFunction<MTEQuantumComputer> OV_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 0, 1, 3, 5); + private static final IStatusFunction<MTEQuantumComputer> MAX_TEMP_STATUS = (base, p) -> LedStatus + .fromLimitsInclusiveOuterBoundary(p.get(), 0, 2000, 8000, 10000); + private static final IStatusFunction<MTEQuantumComputer> COMPUTE_STATUS = (base, p) -> { + if (base.eAvailableData < 0) { + return LedStatus.STATUS_TOO_LOW; + } + if (base.eAvailableData == 0) { + return LedStatus.STATUS_NEUTRAL; + } + return LedStatus.STATUS_OK; + }; + // endregion + + public MTEQuantumComputer(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + eCertainMode = 5; + eCertainStatus = -128; // no-brain value + } + + public MTEQuantumComputer(String aName) { + super(aName); + eCertainMode = 5; + eCertainStatus = -128; // no-brain value + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEQuantumComputer(mName); + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0); + overclock = hatch_0.makeInParameter(0, 1, OC_NAME, OC_STATUS); + overvolt = hatch_0.makeInParameter(1, 1, OV_NAME, OV_STATUS); + maxCurrentTemp = hatch_0.makeOutParameter(0, 0, MAX_TEMP_NAME, MAX_TEMP_STATUS); + availableData = hatch_0.makeOutParameter(1, 0, COMPUTE_NAME, COMPUTE_STATUS); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + eRacks.clear(); + if (!structureCheck_EM("front", 1, 2, 0)) { + return false; + } + if (!structureCheck_EM("cap", 1, 2, -1)) { + return false; + } + byte offset = -2, totalLen = 4; + while (offset > -16) { + if (!structureCheck_EM("slice", 1, 2, offset)) { + break; + } + totalLen++; + offset--; + } + if (totalLen > 17) { + return false; + } + if (!structureCheck_EM("cap", 1, 2, ++offset)) { + return false; + } + if (!structureCheck_EM("back", 1, 2, --offset)) { + return false; + } + eCertainMode = (byte) Math.min(totalLen / 3, 5); + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + return eUncertainHatches.size() == 1; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setDouble("computation", availableData.get()); + aNBT.setBoolean("wirelessModeEnabled", wirelessModeEnabled); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + if (availableData != null) { + availableData.set(aNBT.getDouble("computation")); + eAvailableData = (long) availableData.get(); + } + if (aNBT.hasKey("wirelessModeEnabled")) { + wirelessModeEnabled = aNBT.getBoolean("wirelessModeEnabled"); + if (wirelessModeEnabled) { + WirelessComputationPacket.enableWirelessNetWork(getBaseMetaTileEntity()); + } + } else { + wirelessModeEnabled = false; + } + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && wirelessModeEnabled && aTick % 20 == 0) { + WirelessComputationPacket.updatePacket(aBaseMetaTileEntity, aTick); + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isServerSide() && mMachine + && !aBaseMetaTileEntity.isActive() + && aTick % 20 == CommonValues.MULTI_CHECK_AT) { + double maxTemp = 0; + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + if (rack.heat > maxTemp) { + maxTemp = rack.heat; + } + } + maxCurrentTemp.set(maxTemp); + } + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + parametrization.setToDefaults(false, true); + eAvailableData = 0; + double maxTemp = 0; + double overClockRatio = overclock.get(); + double overVoltageRatio = overvolt.get(); + if (Double.isNaN(overClockRatio) || Double.isNaN(overVoltageRatio)) { + return SimpleCheckRecipeResult.ofFailure("no_computing"); + } + if (overclock.getStatus(true).isOk && overvolt.getStatus(true).isOk) { + float eut = V[7] * (float) overClockRatio * (float) overVoltageRatio; + if (eut < Integer.MAX_VALUE - 7) { + mEUt = -(int) eut; + } else { + mEUt = -(int) V[7]; + return CheckRecipeResultRegistry.POWER_OVERFLOW; + } + short thingsActive = 0; + int rackComputation; + + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + if (rack.heat > maxTemp) { + maxTemp = rack.heat; + } + rackComputation = rack.tickComponents((float) overClockRatio, (float) overVoltageRatio); + if (rackComputation > 0) { + eAvailableData += rackComputation; + thingsActive += 4; + } + rack.getBaseMetaTileEntity() + .setActive(true); + } + + for (MTEHatchDataInput di : eInputData) { + if (di.q != null) // ok for power losses + { + thingsActive++; + } + } + + if (thingsActive > 0 && eCertainStatus == 0) { + thingsActive += eOutputData.size(); + eAmpereFlow = 1 + (thingsActive >> 2); + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); + return SimpleCheckRecipeResult.ofSuccess("computing"); + } else { + eAvailableData = 0; + mEUt = -(int) V[7]; + eAmpereFlow = 1; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + maxCurrentTemp.set(maxTemp); + availableData.set(eAvailableData); + return SimpleCheckRecipeResult.ofSuccess("no_computing"); + } + } + return SimpleCheckRecipeResult.ofFailure("no_computing"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eOutputData.isEmpty()) { + Vec3Impl pos = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + QuantumDataPacket pack = new QuantumDataPacket(eAvailableData / (eOutputData.size())).unifyTraceWith(pos); + if (pack == null) { + return; + } + for (MTEHatchDataInput hatch : eInputData) { + if (hatch.q == null || hatch.q.contains(pos)) { + continue; + } + pack = pack.unifyPacketWith(hatch.q); + if (pack == null) { + return; + } + } + + for (MTEHatchDataOutput o : eOutputData) { + o.q = pack; + } + } + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.computer.name")) // Machine Type: Quantum + // Computer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.computer.desc.0")) // Controller block of + // the Quantum Computer + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.computer.desc.1")) // Used to generate + // computation (and heat) + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.computer.desc.2")) // Use screwdriver to toggle + // wireless mode + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginVariableStructureBlock(2, 2, 4, 4, 5, 16, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.certain.tier.07.name"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 1) // Uncertainty Resolver: Any Computer Casing on first or last slice + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 1) // Optical Connector: Any Computer Casing on first or last slice + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.rack.tier.08.name"), + translateToLocal("tt.keyword.Structure.AnyAdvComputerCasingExceptOuter"), + 2) // Computer Rack: Any Advanced Computer Casing, except the outer ones + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.param.tier.05.name"), + translateToLocal("tt.keyword.Structure.Optional") + " " + + translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), + 2) // Parametrizer: (optional) Any Computer Casing on first or last slice + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), 1) // Energy + // Hatch: + // Any + // Computer + // Casing + // on + // first + // or + // last + // slice + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), 1) // Maintenance + // Hatch: + // Any + // Computer + // Casing + // on + // first + // or + // last + // slice + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (getBaseMetaTileEntity().isServerSide()) { + wirelessModeEnabled = !wirelessModeEnabled; + if (wirelessModeEnabled) { + GTUtility.sendChatToPlayer(aPlayer, "Wireless mode enabled"); + WirelessComputationPacket.enableWirelessNetWork(getBaseMetaTileEntity()); + } else { + GTUtility.sendChatToPlayer(aPlayer, "Wireless mode disabled"); + WirelessComputationPacket.disableWirelessNetWork(getBaseMetaTileEntity()); + } + } + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_COMPUTER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_COMPUTER_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][3], + new TTRenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][3] }; + } + + @Override + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return MTENetworkSwitch.activitySound; + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void extraExplosions_EM() { + for (MetaTileEntity tTileEntity : eRacks) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[8]); + } + } + + @Override + protected long getAvailableData_EM() { + return eAvailableData; + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + eAvailableData = 0; + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void afterRecipeCheckFailed() { + super.afterRecipeCheckFailed(); + for (MTEHatchRack rack : filterValidMTEs(eRacks)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + } + + public final boolean addRackToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchRack) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eRacks.add((MTEHatchRack) aMetaTileEntity); + } + return false; + } + + public final boolean addWirelessDataOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchWirelessComputationOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + // Add to wireless computation outputs, so we can detect these and turn on wireless mode, + // but also add to regular outputs, so they are used as output data hatches by the quantum computer + return eWirelessComputationOutputs.add((MTEHatchWirelessComputationOutput) aMetaTileEntity) + && eOutputData.add((MTEHatchWirelessComputationOutput) aMetaTileEntity); + } + return false; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("front", 1, 2, 0, stackSize, hintsOnly); + structureBuild_EM("cap", 1, 2, -1, stackSize, hintsOnly); + + byte offset = -2; + for (int rackSlices = Math.min(stackSize.stackSize, 12); rackSlices > 0; rackSlices--) { + structureBuild_EM("slice", 1, 2, offset--, stackSize, hintsOnly); + } + + structureBuild_EM("cap", 1, 2, offset--, stackSize, hintsOnly); + structureBuild_EM("back", 1, 2, offset, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + int built; + built = survivialBuildPiece("front", stackSize, 1, 2, 0, elementBudget, source, actor, false, true); + if (built >= 0) return built; + built = survivialBuildPiece("cap", stackSize, 1, 2, -1, elementBudget, source, actor, false, true); + if (built >= 0) return built; + + byte offset = -2; + for (int rackSlices = Math.min(stackSize.stackSize, 12); rackSlices > 0; rackSlices--) { + built = survivialBuildPiece("slice", stackSize, 1, 2, offset--, elementBudget, source, actor, false, true); + if (built >= 0) return built; + } + built = survivialBuildPiece("cap", stackSize, 1, 2, offset--, elementBudget, source, actor, false, true); + if (built >= 0) return built; + return survivialBuildPiece("back", stackSize, 1, 2, offset, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition<MTEQuantumComputer> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public String[] getInfoData() { + ArrayList<String> data = new ArrayList<>(Arrays.asList(super.getInfoData())); + if (wirelessModeEnabled) { + WirelessComputationPacket wirelessComputationPacket = WirelessComputationPacket + .getPacketByUserId(getBaseMetaTileEntity().getOwnerUuid()); + data.add("Wireless mode: " + EnumChatFormatting.GREEN + "enabled"); + data.add( + "Total wireless computation available: " + EnumChatFormatting.YELLOW + + wirelessComputationPacket.getTotalComputationStored()); + } else { + data.add("Wireless mode: " + EnumChatFormatting.RED + "disabled"); + } + return data.toArray(new String[] {}); + } + + private enum RackHatchElement implements IHatchElement<MTEQuantumComputer> { + + INSTANCE; + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return Collections.singletonList(MTEHatchRack.class); + } + + @Override + public IGTHatchAdder<? super MTEQuantumComputer> adder() { + return MTEQuantumComputer::addRackToMachineList; + } + + @Override + public long count(MTEQuantumComputer t) { + return t.eRacks.size(); + } + } + + private enum WirelessComputationHatchElement implements IHatchElement<MTEQuantumComputer> { + + INSTANCE; + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return Collections.singletonList(MTEHatchWirelessComputationOutput.class); + } + + @Override + public IGTHatchAdder<? super MTEQuantumComputer> adder() { + return MTEQuantumComputer::addWirelessDataOutputToMachineList; + } + + @Override + public long count(MTEQuantumComputer gtMetaTileEntityEmComputer) { + return gtMetaTileEntityEmComputer.eWirelessComputationOutputs.size(); + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java new file mode 100644 index 0000000000..6f29160d48 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTEResearchStation.java @@ -0,0 +1,687 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.recipe.RecipeMaps.scannerFakeRecipes; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static mcp.mobius.waila.api.SpecialChars.GREEN; +import static mcp.mobius.waila.api.SpecialChars.RED; +import static mcp.mobius.waila.api.SpecialChars.RESET; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Textures; +import gregtech.api.enums.TierEU; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.AssemblyLineUtils; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTUtility; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import mcp.mobius.waila.api.IWailaConfigHandler; +import mcp.mobius.waila.api.IWailaDataAccessor; +import tectech.recipe.TecTechRecipeMaps; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyMulti; +import tectech.thing.metaTileEntity.hatch.MTEHatchObjectHolder; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +/** + * Created by danie_000 on 17.12.2016. + */ +@SuppressWarnings("unchecked") +public class MTEResearchStation extends TTMultiblockBase implements ISurvivalConstructable { + + public static final String machine = "EM Machinery"; + public static final String crafter = "EM Crafting"; + // region variables + private final ArrayList<MTEHatchObjectHolder> eHolders = new ArrayList<>(); + private GTRecipe.RecipeAssemblyLine tRecipe; + private static final String assembly = "Assembly line"; + private static final String scanner = "Scanner"; + private String machineType = assembly; + private ItemStack holdItem; + private long computationRemaining, computationRequired; + + // Used to sync currently researching item to GUI + private String clientOutputName; + + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.em.research.hint.0"), // 1 - Classic/Data Hatches or + // Computer casing + translateToLocal("gt.blockmachines.multimachine.em.research.hint.1"), // 2 - Holder Hatch + }; + + private String clientLocale = "en_US"; + // endregion + + // region structure + private static final IStructureDefinition<MTEResearchStation> STRUCTURE_DEFINITION = IStructureDefinition + .<MTEResearchStation>builder() + .addShape( + "main", + transpose( + new String[][] { { " ", " A ", " A ", "AAA", "AAA", "AAA", "AAA" }, + { "AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB" }, + { " ", " C ", " ", " ", "ACA", "CCC", "DDD" }, + { " ", " E ", " ", " ", "A~A", "CCC", "DDD" }, + { " ", " C ", " ", " ", "ACA", "CCC", "DDD" }, + { "AAA", "ACA", "ACA", "ACA", "BCB", "BCB", "BBB" }, + { " ", " A ", " A ", "AAA", "AAA", "AAA", "AAA" } })) + .addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsTT, 1)) + .addElement('B', ofBlock(TTCasingsContainer.sBlockCasingsTT, 2)) + .addElement('C', ofBlock(TTCasingsContainer.sBlockCasingsTT, 3)) + .addElement( + 'D', + buildHatchAdder(MTEResearchStation.class) + .atLeast(Energy.or(HatchElement.EnergyMulti), Maintenance, HatchElement.InputData) + .casingIndex(BlockGTCasingsTT.textureOffset + 1) + .dot(1) + .buildAndChain(ofBlock(TTCasingsContainer.sBlockCasingsTT, 1))) + .addElement('E', HolderHatchElement.INSTANCE.newAny(BlockGTCasingsTT.textureOffset + 3, 2)) + .build(); + // endregion + + public MTEResearchStation(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEResearchStation(String aName) { + super(aName); + } + + private void makeStick() { + mInventory[1].setTagCompound(new NBTTagCompound()); + mInventory[1].getTagCompound() + .setString( + "author", + EnumChatFormatting.BLUE + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.WHITE + + ' ' + + machineType + + " Recipe Generator"); + AssemblyLineUtils.setAssemblyLineRecipeOnDataStick(mInventory[1], tRecipe); + } + + private boolean iterateRecipes() { + for (GTRecipe ttRecipe : TecTechRecipeMaps.researchStationFakeRecipes.getAllRecipes()) { + if (GTUtility.areStacksEqual(ttRecipe.mInputs[0], holdItem, true)) { + computationRequired = computationRemaining = ttRecipe.mDuration * 20L; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + eRequiredData = (short) (ttRecipe.mSpecialValue >>> 16); + eAmpereFlow = (short) (ttRecipe.mSpecialValue & 0xFFFF); + mEUt = Math.min(ttRecipe.mEUt, -ttRecipe.mEUt); + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(true); + return true; + } + } + return false; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEResearchStation(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (MTEHatchObjectHolder rack : filterValidMTEs(eHolders)) { + rack.getBaseMetaTileEntity() + .setActive(false); + } + eHolders.clear(); + + if (!structureCheck_EM("main", 1, 3, 4)) { + return false; + } + + for (MTEHatchObjectHolder rack : filterValidMTEs(eHolders)) { + rack.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + return eHolders.size() == 1; + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + ItemStack controllerStack = getControllerSlot(); + tRecipe = null; + if (!eHolders.isEmpty() && eHolders.get(0).mInventory[0] != null) { + holdItem = eHolders.get(0).mInventory[0].copy(); + if (ItemList.Tool_DataStick.isStackEqual(controllerStack, false, true)) { + switch (machineType) { + case scanner -> { + for (GTRecipe.RecipeAssemblyLine assRecipe : GTRecipe.RecipeAssemblyLine.sAssemblylineRecipes) { + if (GTUtility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { + boolean failScanner = true; + for (GTRecipe scannerRecipe : scannerFakeRecipes.getAllRecipes()) { + if (GTUtility.areStacksEqual(scannerRecipe.mInputs[0], holdItem, true)) { + failScanner = false; + break; + } + } + if (failScanner) { + return SimpleCheckRecipeResult.ofFailure("wrongRequirements"); + } + this.tRecipe = assRecipe; + // Set property + computationRequired = computationRemaining = assRecipe.mResearchTime; + mMaxProgresstime = 20; + mEfficiencyIncrease = 10000; + eRequiredData = 1; + eAmpereFlow = 1; + mEUt = (int) -TierEU.RECIPE_UV; + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(true); + return SimpleCheckRecipeResult.ofSuccess("scanning"); + } + } + } + case assembly -> { + for (GTRecipe.RecipeAssemblyLine assRecipe : TecTechRecipeMaps.researchableALRecipeList) { + if (GTUtility.areStacksEqual(assRecipe.mResearchItem, holdItem, true)) { + tRecipe = assRecipe; + // if found + if (iterateRecipes()) return SimpleCheckRecipeResult.ofSuccess("researching"); + } + } + } + } + } else { + return CheckRecipeResultRegistry.NO_DATA_STICKS; + } + } + holdItem = null; + computationRequired = computationRemaining = 0; + for (MTEHatchObjectHolder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + return SimpleCheckRecipeResult.ofFailure("no_research_item"); + } + + @Override + public void outputAfterRecipe_EM() { + if (!eHolders.isEmpty()) { + if (tRecipe != null && ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { + eHolders.get(0) + .getBaseMetaTileEntity() + .setActive(false); + eHolders.get(0).mInventory[0] = null; + makeStick(); + } + } + computationRequired = computationRemaining = 0; + tRecipe = null; + holdItem = null; + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.em.research.type")) // Machine Type: Research + // Station, Scanner + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.0")) // Controller block of + // the Research Station + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.1")) // Used to scan Data + // Sticks for + // Assembling Line Recipes + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.2")) // Needs to be fed with + // computation to work + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.3")) // Does not consume the + // item until + // the Data Stick is written + .addInfo(translateToLocal("gt.blockmachines.multimachine.em.research.desc.4")) // Use screwdriver to change + // mode + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(3, 7, 7, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.holder.tier.09.name"), + translateToLocal("tt.keyword.Structure.CenterPillar"), + 2) // Object Holder: Center of the front pillar + .addOtherStructurePart( + translateToLocal("tt.keyword.Structure.DataConnector"), + translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), + 1) // Optical Connector: Any Computer Casing on the backside of the main body + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), 1) // Energy Hatch: + // Any Computer + // Casing on the + // backside of + // the main body + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingBackMain"), 1) // Maintenance + // Hatch: + // Any + // Computer + // Casing on + // the + // backside + // of the + // main body + .toolTipFinisher(CommonValues.TEC_MARK_EM); + return tt; + } + + @Override + public String[] getInfoData() { + long storedEnergy = 0; + long maxEnergy = 0; + for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + return new String[] { translateToLocalFormatted("tt.keyphrase.Energy_Hatches", clientLocale) + ":", + EnumChatFormatting.GREEN + GTUtility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + (mEUt <= 0 ? translateToLocalFormatted("tt.keyphrase.Probably_uses", clientLocale) + ": " + : translateToLocalFormatted("tt.keyphrase.Probably_makes", clientLocale) + ": ") + + EnumChatFormatting.RED + + GTUtility.formatNumbers(Math.abs(mEUt)) + + EnumChatFormatting.RESET + + " EU/t " + + translateToLocalFormatted("tt.keyword.at", clientLocale) + + " " + + EnumChatFormatting.RED + + GTUtility.formatNumbers(eAmpereFlow) + + EnumChatFormatting.RESET + + " A", + translateToLocalFormatted("tt.keyphrase.Tier_Rating", clientLocale) + ": " + + EnumChatFormatting.YELLOW + + VN[getMaxEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.GREEN + + VN[getMinEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyphrase.Amp_Rating", clientLocale) + + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(eMaxAmpereFlow) + + EnumChatFormatting.RESET + + " A", + translateToLocalFormatted("tt.keyword.Problems", clientLocale) + ": " + + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyword.Efficiency", clientLocale) + + ": " + + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + translateToLocalFormatted("tt.keyword.PowerPass", clientLocale) + ": " + + EnumChatFormatting.BLUE + + ePowerPass + + EnumChatFormatting.RESET + + " " + + translateToLocalFormatted("tt.keyword.SafeVoid", clientLocale) + + ": " + + EnumChatFormatting.BLUE + + eSafeVoid, + translateToLocalFormatted("tt.keyphrase.Computation_Available", clientLocale) + ": " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(eAvailableData) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(eRequiredData) + + EnumChatFormatting.RESET, + translateToLocalFormatted("tt.keyphrase.Computation_Remaining", clientLocale) + ":", + EnumChatFormatting.GREEN + GTUtility.formatNumbers(computationRemaining / 20L) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(getComputationRequired()) }; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][3], + new TTRenderedExtendedFacingTexture(aActive ? TTMultiblockBase.ScreenON : TTMultiblockBase.ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][3] }; + } + + @Override + public void onRemoval() { + super.onRemoval(); + for (MTEHatchObjectHolder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + } + + @Override + protected void extraExplosions_EM() { + for (MetaTileEntity tTileEntity : eHolders) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[9]); + } + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eComputationRemaining", computationRemaining); + aNBT.setLong("eComputationRequired", computationRequired); + aNBT.setString("eMachineType", machineType); + if (holdItem != null) { + aNBT.setTag("eHold", holdItem.writeToNBT(new NBTTagCompound())); + } else { + aNBT.removeTag("eHold"); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + computationRemaining = aNBT.getLong("eComputationRemaining"); + computationRequired = aNBT.getLong("eComputationRequired"); + machineType = aNBT.hasKey("eMachineType") ? aNBT.getString("eMachineType") : assembly; + if (aNBT.hasKey("eHold")) { + holdItem = ItemStack.loadItemStackFromNBT(aNBT.getCompoundTag("eHold")); + } else { + holdItem = null; + } + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + for (MTEHatchObjectHolder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + computationRequired = computationRemaining = 0; + tRecipe = null; + holdItem = null; + } + + @Override + protected boolean supportsSlotAutomation(int aSlot) { + return aSlot == getControllerSlotIndex(); + } + + @Override + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + if (computationRemaining > 0) { + tRecipe = null; + if (holdItem != null) { + if (ItemList.Tool_DataStick.isStackEqual(mInventory[1], false, true)) { + for (GTRecipe.RecipeAssemblyLine tRecipe : TecTechRecipeMaps.researchableALRecipeList) { + if (GTUtility.areStacksEqual(tRecipe.mResearchItem, holdItem, true)) { + this.tRecipe = tRecipe; + break; + } + } + } + } + if (tRecipe == null) { + holdItem = null; + computationRequired = computationRemaining = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + for (MTEHatchObjectHolder r : eHolders) { + r.getBaseMetaTileEntity() + .setActive(false); + } + } + } + } + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + if (computationRemaining <= 0) { + computationRemaining = 0; + mProgresstime = mMaxProgresstime; + return true; + } else { + computationRemaining -= eAvailableData; + mProgresstime = 1; + return super.onRunningTick(aStack); + } + } + + public final boolean addHolderToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchObjectHolder) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eHolders.add((MTEHatchObjectHolder) aMetaTileEntity); + } + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + super.onRightclick(aBaseMetaTileEntity, aPlayer); + + if (!aBaseMetaTileEntity.isClientSide() && aPlayer instanceof EntityPlayerMP) { + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + } else { + return true; + } + return true; + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + super.onScrewdriverRightClick(side, aPlayer, aX, aY, aZ); + switch (machineType) { + case scanner -> machineType = assembly; + case assembly -> machineType = scanner; + } + aPlayer.addChatComponentMessage( + new ChatComponentTranslation( + "gt.blockmachines.multimachine.em.research.mode." + machineType.replace(" ", "_"))); + } + + @Override + protected void drawTexts(DynamicPositionedColumn screenElements, SlotWidget inventorySlot) { + super.drawTexts(screenElements, inventorySlot); + screenElements + .widget( + new TextWidget().setStringSupplier( + () -> StatCollector.translateToLocalFormatted("GT5U.gui.text.researching_item", clientOutputName)) + .setTextAlignment(Alignment.CenterLeft) + .setEnabled( + widget -> computationRequired > 0 && clientOutputName != null && !clientOutputName.isEmpty())) + .widget( + new TextWidget() + .setStringSupplier( + () -> StatCollector.translateToLocalFormatted( + "GT5U.gui.text.research_progress", + getComputationConsumed(), + getComputationRequired(), + GTUtility.formatNumbers(getComputationProgress()))) + .setTextAlignment(Alignment.CenterLeft) + .setEnabled( + widget -> computationRequired > 0 && clientOutputName != null && !clientOutputName.isEmpty())) + .widget(new FakeSyncWidget.LongSyncer(() -> computationRequired, aLong -> computationRequired = aLong)) + .widget(new FakeSyncWidget.LongSyncer(() -> computationRemaining, aLong -> computationRemaining = aLong)) + .widget(new FakeSyncWidget.StringSyncer(() -> { + if (tRecipe != null && tRecipe.mOutput != null) { + return tRecipe.mOutput.getDisplayName(); + } + return ""; + }, aString -> clientOutputName = aString)); + } + + @Override + public void getWailaNBTData(EntityPlayerMP player, TileEntity tile, NBTTagCompound tag, World world, int x, int y, + int z) { + tag.setBoolean("hasProblems", (getIdealStatus() - getRepairStatus()) > 0); + tag.setFloat("efficiency", mEfficiency / 100.0F); + tag.setBoolean("incompleteStructure", (getBaseMetaTileEntity().getErrorDisplayID() & 64) != 0); + tag.setString("machineType", machineType); + tag.setLong("computation", getComputationConsumed()); + tag.setLong("computationRequired", getComputationRequired()); + } + + private long getComputationConsumed() { + return (computationRequired - computationRemaining) / 20L; + } + + private long getComputationRequired() { + return computationRequired / 20L; + } + + private double getComputationProgress() { + return 100d + * (getComputationRequired() > 0d ? (double) getComputationConsumed() / getComputationRequired() : 0d); + } + + @Override + public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, + IWailaConfigHandler config) { + final NBTTagCompound tag = accessor.getNBTData(); + + if (tag.getBoolean("incompleteStructure")) { + currentTip.add(RED + "** INCOMPLETE STRUCTURE **" + RESET); + } + String efficiency = RESET + " Efficiency: " + tag.getFloat("efficiency") + "%"; + if (tag.getBoolean("hasProblems")) { + currentTip.add(RED + "** HAS PROBLEMS **" + efficiency); + } else if (!tag.getBoolean("incompleteStructure")) { + currentTip.add(GREEN + "Running Fine" + efficiency); + } + currentTip.add("Mode: " + tag.getString("machineType")); + currentTip.add( + String.format( + "Computation: %,d / %,d", + tag.getInteger("computation"), + tag.getInteger("computationRequired"))); + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 1, 3, 4, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 1, 3, 4, elementBudget, source, actor, false, true); + } + + @Override + public IStructureDefinition<MTEResearchStation> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + private enum HolderHatchElement implements IHatchElement<MTEResearchStation> { + + INSTANCE; + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return Collections.singletonList(MTEHatchObjectHolder.class); + } + + @Override + public IGTHatchAdder<? super MTEResearchStation> adder() { + return MTEResearchStation::addHolderToMachineList; + } + + @Override + public long count(MTEResearchStation t) { + return t.eHolders.size(); + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTETeslaTower.java b/src/main/java/tectech/thing/metaTileEntity/multi/MTETeslaTower.java new file mode 100644 index 0000000000..73a8a8925c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/MTETeslaTower.java @@ -0,0 +1,991 @@ +package tectech.thing.metaTileEntity.multi; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlocksTiered; +import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.HatchElement.Dynamo; +import static gregtech.api.enums.HatchElement.Energy; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.util.GTStructureUtility.buildHatchAdder; +import static gregtech.api.util.GTStructureUtility.ofFrame; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static java.lang.Math.min; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +import javax.annotation.Nonnull; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.apache.commons.lang3.tuple.Pair; +import org.jetbrains.annotations.NotNull; + +import com.google.common.collect.Multimap; +import com.google.common.collect.MultimapBuilder; +import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; +import com.gtnewhorizon.structurelib.structure.IItemSource; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Materials; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import tectech.TecTech; +import tectech.loader.NetworkDispatcher; +import tectech.mechanics.spark.RendererMessage; +import tectech.mechanics.spark.ThaumSpark; +import tectech.mechanics.tesla.ITeslaConnectable; +import tectech.mechanics.tesla.ITeslaConnectableSimple; +import tectech.thing.casing.BlockGTCasingsTT; +import tectech.thing.casing.TTCasingsContainer; +import tectech.thing.metaTileEntity.hatch.MTEHatchCapacitor; +import tectech.thing.metaTileEntity.hatch.MTEHatchDynamoMulti; +import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyMulti; +import tectech.thing.metaTileEntity.hatch.MTEHatchParam; +import tectech.thing.metaTileEntity.multi.base.INameFunction; +import tectech.thing.metaTileEntity.multi.base.IStatusFunction; +import tectech.thing.metaTileEntity.multi.base.LedStatus; +import tectech.thing.metaTileEntity.multi.base.Parameters; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; + +public class MTETeslaTower extends TTMultiblockBase implements ISurvivalConstructable, ITeslaConnectable { + + // Interface fields + private final Multimap<Integer, ITeslaConnectableSimple> teslaNodeMap = MultimapBuilder.treeKeys() + .linkedListValues() + .build(); + private final HashSet<ThaumSpark> sparkList = new HashSet<>(); + private int sparkCount = 10; + + // region variables + private static final int transferRadiusTowerFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TOWER; // Default + // is 32 + private static final int transferRadiusTransceiverFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_TRANSCEIVER; // Default + // is + // 16 + private static final int transferRadiusCoverUltimateFromConfig = TecTech.configTecTech.TESLA_MULTI_RANGE_COVER; // Default + // is + // 16 + private static final int plasmaRangeMultiT1 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1; // Default + // is 2 + private static final int plasmaRangeMultiT2 = TecTech.configTecTech.TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2; // Default + // is 4 + private static final int heliumUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM; // Default is + // 100 + private static final int nitrogenUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN; // Default + // is 50 + private static final int radonUse = TecTech.configTecTech.TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON; // Default is 50 + private static final boolean visualEffect = TecTech.configTecTech.TESLA_VISUAL_EFFECT; // Default is true + // Default is {1, 1, 1} + private static final int[] plasmaTierLoss = new int[] { TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T0, + TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T1, TecTech.configTecTech.TESLA_MULTI_LOSS_PER_BLOCK_T2 }; + private static final float overDriveLoss = TecTech.configTecTech.TESLA_MULTI_LOSS_FACTOR_OVERDRIVE; // Default is + // 0.25F; + private static final boolean doFluidOutput = TecTech.configTecTech.TESLA_MULTI_GAS_OUTPUT; // Default is false + + // Face icons + private static Textures.BlockIcons.CustomIcon ScreenOFF; + private static Textures.BlockIcons.CustomIcon ScreenON; + + private int mTier = 0; // Determines max voltage (LV to ZPM) + private int plasmaTier = 0; // 0 is None, 1 is Helium or Nitrogen, 2 is Radon (Does not match actual plasma tiers) + + private FluidStack[] mOutputFluidsQueue; // Used to buffer the fluid outputs, so the tesla takes a second to 'cool' + // any plasma it + // would output as a gas + + private final ArrayList<MTEHatchCapacitor> eCapacitorHatches = new ArrayList<>(); // Capacitor + // hatches which + // determine the + // max voltage + // tier and count + // of amps + + private long energyCapacity = 0; // Total energy storage limited by capacitors + private long outputVoltageMax = 0; // Tesla voltage output limited by capacitors + private int vTier = -1; // Tesla voltage tier limited by capacitors + private long outputCurrentMax = 0; // Tesla current output limited by capacitors + + // outputVoltage and current after settings + private long outputVoltage; + private long outputCurrent; + + // Prevents unnecessary offset calculation, saving on lag + private byte oldRotation = -1; + private ForgeDirection oldOrientation = ForgeDirection.UNKNOWN; + // Location of the center of the sphere on top of the tower, used as the Thaumcraft lightning and origin + public Vec3Impl posTop = Vec3Impl.NULL_VECTOR; + // endregion + + // region structure + private static final String[] description = new String[] { + EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":", + translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.0"), // 1 - Classic Hatches, Capacitor + // Hatches or Tesla + // Base Casing + translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.hint.1"), // 2 - ""Titanium frames"" + }; + + private static final IStructureDefinition<MTETeslaTower> STRUCTURE_DEFINITION = IStructureDefinition + .<MTETeslaTower>builder() + .addShape( + "main", + transpose( + new String[][] { { " ", " ", " BBB ", " BBB ", " BBB ", " ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " BBB ", " BBBBB ", " BBBBB ", " BBBBB ", " BBB ", " " }, + { " ", " ", " BBB ", " BCB ", " BBB ", " ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " BBB ", " B F B ", " BFCFB ", " B F B ", " BBB ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " ", " ", " C ", " ", " ", " " }, + { " ", " DDD ", " D D ", " D C D ", " D D ", " DDD ", " " }, + { " EE~EE ", "EAAAAAE", "EADDDAE", "EADADAE", "EADDDAE", "EAAAAAE", " EEEEE " } })) + .addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsBA0, 6)) + .addElement('B', ofBlock(TTCasingsContainer.sBlockCasingsBA0, 7)) + .addElement('C', ofBlock(TTCasingsContainer.sBlockCasingsBA0, 8)) + .addElement( + 'D', + ofBlocksTiered( + (block, meta) -> block != TTCasingsContainer.sBlockCasingsBA0 ? null + : meta <= 5 ? Integer.valueOf(meta) : meta == 9 ? 6 : null, + IntStream.range(0, 7) + .map(tier -> tier == 6 ? 9 : tier) + .mapToObj(meta -> Pair.of(TTCasingsContainer.sBlockCasingsBA0, meta)) + .collect(Collectors.toList()), + -1, + (t, v) -> t.mTier = v, + t -> t.mTier)) + .addElement( + 'E', + buildHatchAdder(MTETeslaTower.class) + .atLeast( + CapacitorHatchElement.INSTANCE, + HatchElement.EnergyMulti, + Energy, + HatchElement.DynamoMulti, + Dynamo, + InputHatch, + OutputHatch, + HatchElement.Param, + Maintenance) + .dot(1) + .casingIndex(BlockGTCasingsTT.textureOffset + 16 + 6) + .buildAndChain(TTCasingsContainer.sBlockCasingsBA0, 6)) + .addElement('F', ofFrame(Materials.Titanium)) + .build(); + // endregion + + // region parameters + protected Parameters.Group.ParameterIn popogaSetting, histLowSetting, histHighSetting, transferRadiusTowerSetting, + transferRadiusTransceiverSetting, transferRadiusCoverUltimateSetting, outputVoltageSetting, + outputCurrentSetting, sortTimeMinSetting, overDriveSetting; + protected Parameters.Group.ParameterOut popogaDisplay, transferRadiusTowerDisplay, transferRadiusTransceiverDisplay, + transferRadiusCoverUltimateDisplay, outputVoltageDisplay, outputCurrentDisplay, outputMaxDisplay, + energyCapacityDisplay, energyStoredDisplay, energyFractionDisplay, sortTimeDisplay; + + private static final INameFunction<MTETeslaTower> HYSTERESIS_LOW_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.0"); // Hysteresis low setting + private static final INameFunction<MTETeslaTower> HYSTERESIS_HIGH_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.1"); // Hysteresis high setting + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_TOWER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.2"); // Tesla Towers transfer radius + // setting + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.3"); // Tesla Transceiver transfer + // radius setting + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.4"); // Tesla Ultimate Cover + // transfer radius + // setting + private static final INameFunction<MTETeslaTower> OUTPUT_VOLTAGE_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.5"); // Output voltage setting + private static final INameFunction<MTETeslaTower> OUTPUT_CURRENT_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.6"); // Output current setting + private static final INameFunction<MTETeslaTower> SCAN_TIME_MIN_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.7"); // Scan time Min setting + private static final INameFunction<MTETeslaTower> OVERDRIVE_SETTING_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.8"); // Overdrive setting + private static final INameFunction<MTETeslaTower> POPOGA_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgi.9"); // Unused + + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_TOWER_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.0"); // Tesla Towers transfer radius + // display + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.1"); // Tesla Transceiver transfer + // radius display + private static final INameFunction<MTETeslaTower> TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.2"); // Tesla Ultimate Cover + // transfer radius + // display + private static final INameFunction<MTETeslaTower> OUTPUT_VOLTAGE_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.3"); // Output voltage display + private static final INameFunction<MTETeslaTower> OUTPUT_MAX_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.9"); // Output max display + private static final INameFunction<MTETeslaTower> OUTPUT_CURRENT_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.4"); // Output current display + private static final INameFunction<MTETeslaTower> ENERGY_CAPACITY_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.5"); // Energy Capacity display + private static final INameFunction<MTETeslaTower> ENERGY_STORED_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.6"); // Energy Stored display + private static final INameFunction<MTETeslaTower> ENERGY_FRACTION_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.7"); // Energy Fraction display + private static final INameFunction<MTETeslaTower> SCAN_TIME_DISPLAY_NAME = (base, + p) -> translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.cfgo.8"); // Scan time display + + private static final IStatusFunction<MTETeslaTower> HYSTERESIS_LOW_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) { + return LedStatus.STATUS_WRONG; + } + if (value <= 0.05) return LedStatus.STATUS_TOO_LOW; + if (value > base.histHighSetting.get()) return LedStatus.STATUS_TOO_HIGH; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> HYSTERESIS_HIGH_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + if (value <= base.histLowSetting.get()) return LedStatus.STATUS_TOO_LOW; + if (value > 0.95) return LedStatus.STATUS_TOO_HIGH; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> TRANSFER_RADIUS_TOWER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value < 0) return LedStatus.STATUS_TOO_LOW; + if (value > transferRadiusTowerFromConfig) return LedStatus.STATUS_HIGH; + if (value < transferRadiusTowerFromConfig) return LedStatus.STATUS_LOW; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> TRANSFER_RADIUS_TRANSCEIVER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value < 0) return LedStatus.STATUS_TOO_LOW; + if (value > transferRadiusTransceiverFromConfig) return LedStatus.STATUS_HIGH; + if (value < transferRadiusTransceiverFromConfig) return LedStatus.STATUS_LOW; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> TRANSFER_RADIUS_COVER_ULTIMATE_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value < 0) return LedStatus.STATUS_TOO_LOW; + if (value > transferRadiusCoverUltimateFromConfig) return LedStatus.STATUS_HIGH; + if (value < transferRadiusCoverUltimateFromConfig) return LedStatus.STATUS_LOW; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> OUTPUT_VOLTAGE_OR_CURRENT_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (long) value; + if (value == -1) return LedStatus.STATUS_OK; + if (value <= 0) return LedStatus.STATUS_TOO_LOW; + return LedStatus.STATUS_OK; + }; + private static final IStatusFunction<MTETeslaTower> SCAN_TIME_MIN_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value < 100) return LedStatus.STATUS_TOO_LOW; + if (value == 100) return LedStatus.STATUS_OK; + return LedStatus.STATUS_HIGH; + }; + private static final IStatusFunction<MTETeslaTower> OVERDRIVE_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value < 0) return LedStatus.STATUS_TOO_LOW; + if (value == 0) return LedStatus.STATUS_LOW; + return LedStatus.STATUS_HIGH; + }; + private static final IStatusFunction<MTETeslaTower> POPOGA_STATUS = (base, p) -> { + if (base.getBaseMetaTileEntity() + .getWorld() + .isThundering()) { + return LedStatus.STATUS_WTF; + } + return LedStatus.STATUS_NEUTRAL; + }; + private static final IStatusFunction<MTETeslaTower> SCAN_TIME_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (int) value; + if (value == 0) return LedStatus.STATUS_HIGH; + return LedStatus.STATUS_LOW; + }; + private static final IStatusFunction<MTETeslaTower> POWER_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + value = (long) value; + if (value > 0) { + return LedStatus.STATUS_OK; + } else { + return LedStatus.STATUS_LOW; + } + }; + private static final IStatusFunction<MTETeslaTower> ENERGY_STATUS = (base, p) -> { + double value = p.get(); + if (Double.isNaN(value)) return LedStatus.STATUS_WRONG; + if (base.energyFractionDisplay.get() > base.histHighSetting.get()) { + return LedStatus.STATUS_HIGH; + } else if (base.energyFractionDisplay.get() < base.histLowSetting.get()) { + return LedStatus.STATUS_LOW; + } else { + return LedStatus.STATUS_OK; + } + }; + // endregion + + public MTETeslaTower(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTETeslaTower(String aName) { + super(aName); + } + + private float getRangeMulti(int mTier, int vTier) { + // By Default: + // Helium and Nitrogen Plasmas will double the range + // Radon will quadruple the range + int plasmaBoost; + switch (plasmaTier) { + case 2: + plasmaBoost = plasmaRangeMultiT2; + break; + case 1: + plasmaBoost = plasmaRangeMultiT1; + break; + default: + plasmaBoost = 1; + } + + // Over-tiered coils will add +25% range + if (vTier > mTier) { + return 1.25F * plasmaBoost; + } + return 1F * plasmaBoost; + } + + private void checkPlasmaBoost() { + // If there's fluid in the queue, try to output it + // That way it takes at least a second to 'process' the plasma + if (mOutputFluidsQueue != null) { + mOutputFluids = mOutputFluidsQueue; + mOutputFluidsQueue = null; + } + + for (MTEHatchInput fluidHatch : mInputHatches) { + if (fluidHatch.mFluid != null) { + if (fluidHatch.mFluid.isFluidEqual(Materials.Helium.getPlasma(1)) + && fluidHatch.mFluid.amount >= heliumUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - heliumUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Helium.getGas(heliumUse) }; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Nitrogen.getPlasma(1)) + && fluidHatch.mFluid.amount >= nitrogenUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - nitrogenUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Nitrogen.getGas(nitrogenUse) }; + } + plasmaTier = 1; + return; + } else if (fluidHatch.mFluid.isFluidEqual(Materials.Radon.getPlasma(1)) + && fluidHatch.mFluid.amount >= radonUse) { + fluidHatch.mFluid.amount = fluidHatch.mFluid.amount - radonUse; + if (doFluidOutput) { + mOutputFluidsQueue = new FluidStack[] { Materials.Radon.getGas(radonUse) }; + } + plasmaTier = 2; + return; + } + } + } + plasmaTier = 0; + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTETeslaTower(mName); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + eCapacitorHatches.clear(); + + mTier = -1; + + if (structureCheck_EM("main", 3, 16, 0)) { + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(iGregTechTileEntity.isActive()); + } + + // Only recalculate offsets on orientation or rotation change + if (oldRotation != getExtendedFacing().ordinal() + || oldOrientation != iGregTechTileEntity.getFrontFacing()) { + oldRotation = (byte) getExtendedFacing().ordinal(); + oldOrientation = iGregTechTileEntity.getFrontFacing(); + + Vec3Impl posBMTE = new Vec3Impl( + getBaseMetaTileEntity().getXCoord(), + getBaseMetaTileEntity().getYCoord(), + getBaseMetaTileEntity().getZCoord()); + + // Calculate coordinates of the middle bottom + posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, 0, 2)) + .add(posBMTE); + + // Calculate coordinates of the top sphere + posTop = getExtendedFacing().getWorldOffset(new Vec3Impl(0, -14, 2)) + .add(posBMTE); + } + // Generate node map + if (!getBaseMetaTileEntity().isClientSide()) { + TeslaUtil.teslaSimpleNodeSetAdd(this); + TeslaUtil.generateTeslaNodeMap(this); + } + return true; + } + return false; + } + + @Override + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + checkPlasmaBoost(); + + if (!histHighSetting.getStatus(false).isOk || !histLowSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_hysteresis"); + if (!transferRadiusTowerSetting.getStatus(false).isOk || !transferRadiusTransceiverSetting.getStatus(false).isOk + || !transferRadiusCoverUltimateSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_transfer_radius"); + if (!outputVoltageSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_voltage_setting"); + if (!outputCurrentSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_current_setting"); + if (!sortTimeMinSetting.getStatus(false).isOk) return SimpleCheckRecipeResult.ofFailure("invalid_time_setting"); + if (!overDriveSetting.getStatus(false).isOk) + return SimpleCheckRecipeResult.ofFailure("invalid_overdrive_setting"); + + mEfficiencyIncrease = 10000; + mMaxProgresstime = 20; + vTier = -1; + long[] capacitorData; + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + if (cap.getCapacitors()[0] > vTier) { + vTier = (int) cap.getCapacitors()[0]; + } + } + + energyCapacity = 0; + outputCurrentMax = 0; + + if (vTier < 0) { + // Returning true to allow for 'passive running' + outputVoltageMax = 0; + return SimpleCheckRecipeResult.ofSuccess("routing"); + } else if (vTier > mTier && getEUVar() > 0) { + explodeMultiblock(); + } + + outputVoltageMax = V[vTier + 1]; + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(true); + capacitorData = cap.getCapacitors(); + if (capacitorData[0] < vTier) { + if (getEUVar() > 0 && capacitorData[0] != 0) { + cap.getBaseMetaTileEntity() + .setToFire(); + } + eCapacitorHatches.remove(cap); + } else { + outputCurrentMax += capacitorData[1]; + energyCapacity += capacitorData[2]; + } + } + return SimpleCheckRecipeResult.ofSuccess("routing"); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.name")) // Machine Type: Tesla + // Tower + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.0")) // Controller block of + // the Tesla Tower + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.1")) // Used to transmit + // power to Tesla + // Coil Covers and Tesla + // Transceivers + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.2")) // Can be fed with + // Helium/Nitrogen/Radon Plasma to + // increase the range + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.3")) // Transmitted voltage + // depends on + // the used Tesla Capacitor tier + .addInfo(translateToLocal("gt.blockmachines.multimachine.tm.teslaCoil.desc.4")) // Primary Tesla + // Windings need to + // be at least the same tier as + // the Tesla Capacitor + .addInfo(translateToLocal("tt.keyword.Structure.StructureTooComplex")) // The structure is too complex! + .addSeparator() + .beginStructureBlock(7, 17, 7, false) + .addOtherStructurePart( + translateToLocal("gt.blockmachines.hatch.capacitor.tier.03.name"), + translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), + 1) // Capacitor Hatch: Any outer Tesla Base Casing + .addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), 1) // Energy Hatch: + // Any outer Tesla + // Base Casing + .addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyTeslaBaseCasingOuter"), 1) // Maintenance + // Hatch: Any + // outer Tesla + // Base Casing + .toolTipFinisher(CommonValues.THETA_MOVEMENT); + return tt; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_TOWER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/TM_TESLA_TOWER_ACTIVE"); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][16 + 6], + new TTRenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[BlockGTCasingsTT.texturePage][16 + 6] }; + } + + @Override + public void onRemoval() { + super.onRemoval(); + if (!getBaseMetaTileEntity().isClientSide()) { + TeslaUtil.teslaSimpleNodeSetRemove(this); + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + } + } + + @Override + public void onUnload() { + if (!getBaseMetaTileEntity().isClientSide()) { + TeslaUtil.teslaSimpleNodeSetRemove(this); + } + } + + @Override + protected void parametersInstantiation_EM() { + Parameters.Group hatch_0 = parametrization.getGroup(0, true); + Parameters.Group hatch_1 = parametrization.getGroup(1, true); + Parameters.Group hatch_2 = parametrization.getGroup(2, true); + Parameters.Group hatch_3 = parametrization.getGroup(3, true); + Parameters.Group hatch_4 = parametrization.getGroup(4, true); + Parameters.Group hatch_5 = parametrization.getGroup(5, true); + Parameters.Group hatch_6 = parametrization.getGroup(6, true); + Parameters.Group hatch_7 = parametrization.getGroup(7, true); + Parameters.Group hatch_8 = parametrization.getGroup(8, true); + Parameters.Group hatch_9 = parametrization.getGroup(9, true); + + histLowSetting = hatch_0.makeInParameter(0, 0.25, HYSTERESIS_LOW_SETTING_NAME, HYSTERESIS_LOW_STATUS); + popogaSetting = hatch_0.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + histHighSetting = hatch_1.makeInParameter(0, 0.75, HYSTERESIS_HIGH_SETTING_NAME, HYSTERESIS_HIGH_STATUS); + popogaSetting = hatch_1.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTowerSetting = hatch_2.makeInParameter( + 0, + transferRadiusTowerFromConfig, + TRANSFER_RADIUS_TOWER_SETTING_NAME, + TRANSFER_RADIUS_TOWER_STATUS); + popogaSetting = hatch_2.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTransceiverSetting = hatch_3.makeInParameter( + 0, + transferRadiusTransceiverFromConfig, + TRANSFER_RADIUS_TRANSCEIVER_SETTING_NAME, + TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateSetting = hatch_3.makeInParameter( + 1, + transferRadiusCoverUltimateFromConfig, + TRANSFER_RADIUS_COVER_ULTIMATE_SETTING_NAME, + TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); + outputVoltageSetting = hatch_4 + .makeInParameter(0, -1, OUTPUT_VOLTAGE_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); + popogaSetting = hatch_4.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + outputCurrentSetting = hatch_5 + .makeInParameter(0, -1, OUTPUT_CURRENT_SETTING_NAME, OUTPUT_VOLTAGE_OR_CURRENT_STATUS); + popogaSetting = hatch_5.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_6.makeInParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_6.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + sortTimeMinSetting = hatch_7.makeInParameter(0, 100, SCAN_TIME_MIN_SETTING_NAME, SCAN_TIME_MIN_STATUS); + popogaSetting = hatch_7.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + overDriveSetting = hatch_8.makeInParameter(0, 0, OVERDRIVE_SETTING_NAME, OVERDRIVE_STATUS); + popogaSetting = hatch_8.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_9.makeInParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaSetting = hatch_9.makeInParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + + popogaDisplay = hatch_0.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_0.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_1.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_1.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTowerDisplay = hatch_2 + .makeOutParameter(0, 0, TRANSFER_RADIUS_TOWER_DISPLAY_NAME, TRANSFER_RADIUS_TOWER_STATUS); + popogaDisplay = hatch_2.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + transferRadiusTransceiverDisplay = hatch_3 + .makeOutParameter(0, 0, TRANSFER_RADIUS_TRANSCEIVER_DISPLAY_NAME, TRANSFER_RADIUS_TRANSCEIVER_STATUS); + transferRadiusCoverUltimateDisplay = hatch_3 + .makeOutParameter(1, 0, TRANSFER_RADIUS_COVER_ULTIMATE_DISPLAY_NAME, TRANSFER_RADIUS_COVER_ULTIMATE_STATUS); + outputVoltageDisplay = hatch_4.makeOutParameter(0, 0, OUTPUT_VOLTAGE_DISPLAY_NAME, POWER_STATUS); + outputMaxDisplay = hatch_4.makeOutParameter(1, 0, OUTPUT_MAX_DISPLAY_NAME, POWER_STATUS); + outputCurrentDisplay = hatch_5.makeOutParameter(0, 0, OUTPUT_CURRENT_DISPLAY_NAME, POWER_STATUS); + energyCapacityDisplay = hatch_5.makeOutParameter(1, 0, ENERGY_CAPACITY_DISPLAY_NAME, ENERGY_STATUS); + energyStoredDisplay = hatch_6.makeOutParameter(0, 0, ENERGY_STORED_DISPLAY_NAME, ENERGY_STATUS); + energyFractionDisplay = hatch_6.makeOutParameter(1, 0, ENERGY_FRACTION_DISPLAY_NAME, ENERGY_STATUS); + sortTimeDisplay = hatch_7.makeOutParameter(0, 0, SCAN_TIME_DISPLAY_NAME, SCAN_TIME_STATUS); + popogaDisplay = hatch_7.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_8.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_8.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_9.makeOutParameter(0, 0, POPOGA_NAME, POPOGA_STATUS); + popogaDisplay = hatch_9.makeOutParameter(1, 0, POPOGA_NAME, POPOGA_STATUS); + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eEnergyCapacity", energyCapacity); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + energyCapacity = aNBT.getLong("eEnergyCapacity"); + TeslaUtil.teslaSimpleNodeSetAdd(this); + } + + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + super.stopMachine(reason); + for (MTEHatchCapacitor cap : filterValidMTEs(eCapacitorHatches)) { + cap.getBaseMetaTileEntity() + .setActive(false); + } + + ePowerPass = false; + setEUVar(0); + energyStoredDisplay.set(0); + energyFractionDisplay.set(0); + outputMaxDisplay.set(0); + } + + @Override + public boolean onRunningTick(ItemStack aStack) { + // Hysteresis based ePowerPass setting + float energyFrac = (float) getEUVar() / energyCapacity; + + energyCapacityDisplay.set(energyCapacity); + energyStoredDisplay.set(getEUVar()); + energyFractionDisplay.set(energyFrac); + + if (!ePowerPass && energyFrac > histHighSetting.get()) { + ePowerPass = true; + } else if (ePowerPass && energyFrac < histLowSetting.get()) { + ePowerPass = false; + } + + // Power Limit Settings + if (outputVoltageSetting.get() > 0) { + outputVoltage = min(outputVoltageMax, (long) outputVoltageSetting.get()); + } else { + outputVoltage = outputVoltageMax; + } + outputVoltageDisplay.set(outputVoltage); + + if (outputCurrentSetting.get() > 0) { + outputCurrent = min(outputCurrentMax, (long) outputCurrentSetting.get()); + } else { + outputCurrent = outputCurrentMax; + } + + // Range calculation and display + int transferRadiusTower = getTeslaTransmissionRange(); + transferRadiusTowerDisplay.set(transferRadiusTower); + transferRadiusTransceiverDisplay.set(transferRadiusTower * 2); + transferRadiusCoverUltimateDisplay.set(transferRadiusTower); + + // Power transfer + outputCurrentDisplay.set(TeslaUtil.powerTeslaNodeMap(this)); + outputMaxDisplay.set(Math.max(outputCurrentDisplay.get(), outputMaxDisplay.get())); + // TODO Encapsulate the spark sender + sparkCount--; + if (sparkCount == 0 && visualEffect) { + IGregTechTileEntity mte = getBaseMetaTileEntity(); + sparkCount = 10; + if (!sparkList.isEmpty()) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new RendererMessage.RendererData(sparkList), + mte.getWorld().provider.dimensionId, + mte.getXCoord(), + mte.getYCoord(), + mte.getZCoord(), + 256); + sparkList.clear(); + } + } + return true; + } + + @Override + public long maxEUStore() { + // Setting the power here so that the tower looses all it's charge once disabled + // This also stops it from exploding + return getBaseMetaTileEntity().isActive() ? energyCapacity * 2 : 0; + } + + @Override + public long getEUVar() { + // Same reason as maxEUStore, set to 1 instead of zero so it doesn't drain constantly + return getBaseMetaTileEntity().isActive() ? super.getEUVar() : 1; + } + + private boolean addCapacitorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchCapacitor) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eCapacitorHatches.add((MTEHatchCapacitor) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergy) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergyMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamo) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamoMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchParam) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((MTEHatchParam) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity); + } + return false; + } + + @Override + public IStructureDefinition<MTETeslaTower> getStructure_EM() { + return STRUCTURE_DEFINITION; + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM("main", 3, 16, 0, stackSize, hintsOnly); + } + + @Override + public int survivalConstruct(ItemStack stackSize, int elementBudget, IItemSource source, EntityPlayerMP actor) { + if (mMachine) return -1; + return survivialBuildPiece("main", stackSize, 3, 16, 0, elementBudget, source, actor, false, true); + } + + @Override + public String[] getStructureDescription(ItemStack stackSize) { + return description; + } + + @Override + public byte getTeslaReceptionCapability() { + return 0; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 0; + } + + @Override + public Multimap<Integer, ITeslaConnectableSimple> getTeslaNodeMap() { + return teslaNodeMap; + } + + @Override + public HashSet<ThaumSpark> getSparkList() { + return sparkList; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 1; + } + + @Override + public int getTeslaTransmissionRange() { + return (int) (transferRadiusTowerSetting.get() * getRangeMulti(mTier, vTier)); + } + + @Override + public boolean isOverdriveEnabled() { + return overDriveSetting.get() > 0; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return plasmaTierLoss[plasmaTier]; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return outputCurrent; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.ePowerPass; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return posTop; + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + if (this.getEUVar() + teslaVoltageInjected <= (this.maxEUStore() / 2)) { + this.getBaseMetaTileEntity() + .increaseStoredEnergyUnits(teslaVoltageInjected, true); + return true; + } + return false; + } + + private enum CapacitorHatchElement implements IHatchElement<MTETeslaTower> { + + INSTANCE; + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return Collections.singletonList(MTEHatchCapacitor.class); + } + + @Override + public IGTHatchAdder<? super MTETeslaTower> adder() { + return MTETeslaTower::addCapacitorToMachineList; + } + + @Override + public long count(MTETeslaTower MTETeslaTower) { + return MTETeslaTower.eCapacitorHatches.size(); + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/INameFunction.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/INameFunction.java new file mode 100644 index 0000000000..697c748ba4 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/INameFunction.java @@ -0,0 +1,6 @@ +package tectech.thing.metaTileEntity.multi.base; + +public interface INameFunction<T extends TTMultiblockBase> { + + String apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java new file mode 100644 index 0000000000..b051f0dfa3 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/IStatusFunction.java @@ -0,0 +1,6 @@ +package tectech.thing.metaTileEntity.multi.base; + +public interface IStatusFunction<T extends TTMultiblockBase> { + + LedStatus apply(T t, Parameters.IParameter iParameter); +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/LedStatus.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/LedStatus.java new file mode 100644 index 0000000000..022408f688 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/LedStatus.java @@ -0,0 +1,64 @@ +package tectech.thing.metaTileEntity.multi.base; + +import java.util.function.Supplier; + +import net.minecraft.util.EnumChatFormatting; + +import tectech.TecTech; + +public enum LedStatus { + + STATUS_UNUSED(() -> EnumChatFormatting.DARK_GRAY + "Unused", true), // + STATUS_TOO_LOW(() -> EnumChatFormatting.BLUE + "Too Low", false), // + STATUS_LOW(() -> EnumChatFormatting.AQUA + "Low", true), // + STATUS_WRONG(() -> EnumChatFormatting.DARK_PURPLE + "Wrong", false), // + STATUS_OK(() -> EnumChatFormatting.GREEN + "Valid", true), // + STATUS_TOO_HIGH(() -> EnumChatFormatting.RED + "Too High", false), // + STATUS_HIGH(() -> EnumChatFormatting.GOLD + "High", true), // + STATUS_UNDEFINED(() -> EnumChatFormatting.GRAY + "Unknown", false), + STATUS_NEUTRAL(() -> EnumChatFormatting.WHITE + "Neutral", true), + STATUS_WTF(() -> LedStatus.values()[TecTech.RANDOM.nextInt(9)].name.get(), false); + + public final Supplier<String> name; + public final boolean isOk; + + LedStatus(Supplier<String> name, boolean ok) { + this.name = name; + this.isOk = ok; + } + + public byte getOrdinalByte() { + return (byte) ordinal(); + } + + public static LedStatus getStatus(byte value) { + try { + return LedStatus.values()[value]; + } catch (Exception e) { + return STATUS_UNDEFINED; + } + } + + public static LedStatus[] makeArray(int count, LedStatus defaultValue) { + LedStatus[] statuses = new LedStatus[count]; + for (int i = 0; i < count; i++) { + statuses[i] = defaultValue; + } + return statuses; + } + + public static LedStatus fromLimitsInclusiveOuterBoundary(double value, double min, double low, double high, + double max, double... excludedNumbers) { + if (value < min) return STATUS_TOO_LOW; + if (value > max) return STATUS_TOO_HIGH; + + if (value < low) return STATUS_LOW; + if (value > high) return STATUS_HIGH; + for (double val : excludedNumbers) { + if (val == value) return STATUS_WRONG; + } + if (Double.isNaN(value)) return STATUS_WRONG; + return STATUS_OK; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/Parameters.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/Parameters.java new file mode 100644 index 0000000000..27eb961166 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/Parameters.java @@ -0,0 +1,327 @@ +package tectech.thing.metaTileEntity.multi.base; + +import java.util.ArrayList; + +/** + * Instantiate parameters as field in parametersInstantiation_EM(); + */ +public class Parameters { + + private static final IStatusFunction<?> LED_STATUS_FUNCTION_DEFAULT = (b, p) -> LedStatus.STATUS_UNDEFINED; + private static final INameFunction<?> NAME_FUNCTION_DEFAULT = (b, p) -> "Undefined"; + + final Group[] groups = new Group[10]; + + double[] iParamsIn = new double[20]; // number I from parametrizers + double[] iParamsOut = new double[20]; // number O to parametrizers + final ArrayList<Group.ParameterIn> parameterInArrayList = new ArrayList<>(); + final ArrayList<Group.ParameterOut> parameterOutArrayList = new ArrayList<>(); + + // package private for use in gui + LedStatus[] eParamsInStatus = LedStatus.makeArray(20, LedStatus.STATUS_UNUSED); // LED status for I + LedStatus[] eParamsOutStatus = LedStatus.makeArray(20, LedStatus.STATUS_UNUSED); // LED status for O + + double getIn(int hatchNo, int parameterId) { + return iParamsIn[hatchNo + 10 * parameterId]; + } + + double getOut(int hatchNo, int parameterId) { + return iParamsOut[hatchNo + 10 * parameterId]; + } + + LedStatus getStatusIn(int hatchNo, int parameterId) { + return eParamsInStatus[hatchNo + 10 * parameterId]; + } + + LedStatus getStatusOut(int hatchNo, int parameterId) { + return eParamsOutStatus[hatchNo + 10 * parameterId]; + } + + private final TTMultiblockBase parent; + + Parameters(TTMultiblockBase parent) { + this.parent = parent; + } + + public boolean trySetParameters(int hatch, double parameter0, double parameter1) { + Group p = groups[hatch]; + if (parent.mMaxProgresstime <= 0 || (p != null && p.updateWhileRunning)) { + iParamsIn[hatch] = parameter0; + iParamsIn[hatch + 10] = parameter1; + return true; + } + return false; + } + + @SuppressWarnings("unused") // Used in GTNH-Intergalactic, do not delete. + public boolean trySetParameters(int hatchNo, int parameterId, double parameter) { + Group p = groups[hatchNo]; + if (parent.mMaxProgresstime <= 0 || (p != null && p.updateWhileRunning)) { + iParamsIn[hatchNo + 10 * parameterId] = parameter; + return true; + } + return false; + } + + public void setToDefaults(int hatch, boolean defaultIn, boolean defaultOut) { + Group p = groups[hatch]; + if (p == null) { + if (defaultIn) { + iParamsIn[hatch] = 0; + iParamsIn[hatch + 10] = 0; + } + if (defaultOut) { + iParamsOut[hatch] = 0; + iParamsOut[hatch + 10] = 0; + } + } else { + p.setToDefaults(defaultIn, defaultOut); + } + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut) { + for (int hatch = 0; hatch < 10; hatch++) { + setToDefaults(hatch, defaultIn, defaultOut); + } + } + + public Group getGroup(int hatchNo, boolean updateWhileRunning) { + return groups[hatchNo] != null ? groups[hatchNo] : new Group(hatchNo, updateWhileRunning); + } + + public Group getGroup(int hatchNo) { + return groups[hatchNo] != null ? groups[hatchNo] : new Group(hatchNo, false); + } + + public interface IParameter { + + double get(); + + double getDefault(); + + void updateStatus(); + + LedStatus getStatus(boolean update); + + int id(); + + int hatchId(); + + int parameterId(); + + String getBrief(); + } + + /** + * most likely used locally in parametersInstantiation_EM() + */ + public class Group { + + private final int hatchNo; + public final ParameterIn[] parameterIn = new ParameterIn[2]; + public final ParameterOut[] parameterOut = new ParameterOut[2]; + public boolean updateWhileRunning; + + private Group(int hatchNo, boolean updateWhileRunning) { + if (hatchNo < 0 || hatchNo >= 10) { + throw new IllegalArgumentException("Hatch id must be in 0 to 9 range"); + } + this.hatchNo = hatchNo; + this.updateWhileRunning = updateWhileRunning; + groups[hatchNo] = this; + } + + public ParameterIn makeInParameter(int paramID, double defaultValue, INameFunction<?> name, + IStatusFunction<?> status) { + return new ParameterIn(paramID, defaultValue, name, status); + } + + public ParameterOut makeOutParameter(int paramID, double defaultValue, INameFunction<?> name, + IStatusFunction<?> status) { + return new ParameterOut(paramID, defaultValue, name, status); + } + + public void setToDefaults(boolean defaultIn, boolean defaultOut) { + if (defaultIn) { + if (this.parameterIn[0] != null) { + this.parameterIn[0].setDefault(); + } else { + iParamsIn[hatchNo] = 0; + } + if (this.parameterIn[1] != null) { + this.parameterIn[1].setDefault(); + } else { + iParamsIn[hatchNo + 10] = 0; + } + } + if (defaultOut) { + if (this.parameterOut[0] != null) { + this.parameterOut[0].setDefault(); + } else { + iParamsOut[hatchNo] = 0; + } + if (this.parameterOut[1] != null) { + this.parameterOut[1].setDefault(); + } else { + iParamsOut[hatchNo + 10] = 0; + } + } + } + + /** + * Make a field out of this... + */ + public class ParameterOut implements IParameter { + + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterOut(int paramID, double defaultValue, INameFunction<?> name, IStatusFunction<?> status) { + this.name = name == null ? NAME_FUNCTION_DEFAULT : name; + if (paramID < 0 || paramID > 2) { + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if (parameterOut[paramID] != null) { + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.id = hatchNo + 10 * paramID; + this.defaultValue = defaultValue; + this.status = status == null ? LED_STATUS_FUNCTION_DEFAULT : status; + parameterOutArrayList.add(this); + parameterOut[paramID] = this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get() { + return iParamsOut[id]; + } + + @Override + public double getDefault() { + return defaultValue; + } + + public void set(double value) { + iParamsOut[id] = value; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus() { + eParamsOutStatus[id] = status.apply(parent, this); + } + + @Override + public LedStatus getStatus(boolean update) { + if (update) { + updateStatus(); + } + return eParamsOutStatus[id]; + } + + @Override + public String getBrief() { + return name.apply(parent, this); + } + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id % 10; + } + + @Override + public int parameterId() { + return id / 10; + } + } + + /** + * Make a field out of this... + */ + public class ParameterIn implements IParameter { + + public final int id; + public final double defaultValue; + IStatusFunction status; + INameFunction name; + + private ParameterIn(int paramID, double defaultValue, INameFunction<?> name, IStatusFunction<?> status) { + this.name = name == null ? NAME_FUNCTION_DEFAULT : name; + this.id = hatchNo + 10 * paramID; + if (paramID < 0 || paramID > 2) { + throw new IllegalArgumentException("Parameter id must be in 0 to 1 range"); + } + if (parameterIn[paramID] != null) { + throw new IllegalArgumentException("Parameter id already occupied"); + } + this.defaultValue = defaultValue; + this.status = status == null ? LED_STATUS_FUNCTION_DEFAULT : status; + parameterInArrayList.add(this); + parameterIn[paramID] = this; + } + + void setDefault() { + set(defaultValue); + } + + @Override + public double get() { + return iParamsIn[id]; + } + + void set(double value) { + iParamsIn[id] = value; + } + + @Override + public double getDefault() { + return defaultValue; + } + + @SuppressWarnings("unchecked") + @Override + public void updateStatus() { + eParamsInStatus[id] = status.apply(parent, this); + } + + @Override + public LedStatus getStatus(boolean update) { + if (update) { + updateStatus(); + } + return eParamsInStatus[id]; + } + + @Override + public String getBrief() { + return name.apply(parent, this); + } + + @Override + public int id() { + return id; + } + + @Override + public int hatchId() { + return id % 10; + } + + @Override + public int parameterId() { + return id / 10; + } + } + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java new file mode 100644 index 0000000000..c337f5093e --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/SoundLoop.java @@ -0,0 +1,59 @@ +package tectech.thing.metaTileEntity.multi.base; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.MovingSound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +@SideOnly(Side.CLIENT) +public class SoundLoop extends MovingSound { + + private final boolean whileActive; + private final boolean whileInactive; + private final int worldID; + private boolean fadeMe = false; + + public SoundLoop(ResourceLocation p_i45104_1_, IGregTechTileEntity base, boolean stopWhenActive, + boolean stopWhenInactive) { + super(p_i45104_1_); + this.whileActive = stopWhenActive; + this.whileInactive = stopWhenInactive; + xPosF = base.getXCoord(); + yPosF = base.getYCoord(); + zPosF = base.getZCoord(); + worldID = base.getWorld().provider.dimensionId; + repeat = true; + volume = 0.0625f; + } + + @Override + public void update() { + if (donePlaying) { + return; + } + if (fadeMe) { + volume -= 0.0625f; + if (volume <= 0) { + volume = 0; + donePlaying = true; + } + } else if (volume < 1) { + volume += 0.0625f; + } + World world = Minecraft.getMinecraft().thePlayer.worldObj; + donePlaying = world.provider.dimensionId != worldID + || !world.checkChunksExist((int) xPosF, (int) yPosF, (int) zPosF, (int) xPosF, (int) yPosF, (int) zPosF); + if (donePlaying) return; + TileEntity tile = world.getTileEntity((int) xPosF, (int) yPosF, (int) zPosF); + if (!(tile instanceof IGregTechTileEntity)) { + donePlaying = true; + return; + } + fadeMe |= ((IGregTechTileEntity) tile).isActive() ? whileActive : whileInactive; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java new file mode 100644 index 0000000000..22a2d38c0a --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/TTMultiblockBase.java @@ -0,0 +1,2760 @@ +package tectech.thing.metaTileEntity.multi.base; + +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.GTValues.VN; +import static gregtech.api.enums.HatchElement.InputBus; +import static gregtech.api.enums.HatchElement.InputHatch; +import static gregtech.api.enums.HatchElement.Maintenance; +import static gregtech.api.enums.HatchElement.Muffler; +import static gregtech.api.enums.HatchElement.OutputBus; +import static gregtech.api.enums.HatchElement.OutputHatch; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTUtility.filterValidMTEs; +import static java.lang.Math.min; +import static tectech.thing.casing.BlockGTCasingsTT.texturePage; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +import org.jetbrains.annotations.NotNull; +import org.lwjgl.opengl.GL11; + +import com.google.common.collect.Iterables; +import com.gtnewhorizon.structurelib.StructureLibAPI; +import com.gtnewhorizon.structurelib.alignment.IAlignment; +import com.gtnewhorizon.structurelib.alignment.IAlignmentProvider; +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.IStructureElement; +import com.gtnewhorizon.structurelib.util.Vec3Impl; +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.internal.wrapper.BaseSlot; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.IHatchElement; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IBindPlayerInventoryUI; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEExtendedPowerMultiBlockBase; +import gregtech.api.metatileentity.implementations.MTEHatch; +import gregtech.api.metatileentity.implementations.MTEHatchDynamo; +import gregtech.api.metatileentity.implementations.MTEHatchEnergy; +import gregtech.api.metatileentity.implementations.MTEHatchInput; +import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.metatileentity.implementations.MTEHatchMaintenance; +import gregtech.api.metatileentity.implementations.MTEHatchMuffler; +import gregtech.api.metatileentity.implementations.MTEHatchOutput; +import gregtech.api.metatileentity.implementations.MTEHatchOutputBus; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTUtility; +import gregtech.api.util.HatchElementBuilder; +import gregtech.api.util.IGTHatchAdder; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.shutdown.ShutDownReason; +import gregtech.api.util.shutdown.ShutDownReasonRegistry; +import gregtech.api.util.shutdown.SimpleShutDownReason; +import gregtech.common.Pollution; +import gregtech.common.tileentities.machines.IDualInputHatch; +import tectech.Reference; +import tectech.TecTech; +import tectech.loader.TecTechConfig; +import tectech.thing.gui.TecTechUITextures; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataConnector; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataInput; +import tectech.thing.metaTileEntity.hatch.MTEHatchDataOutput; +import tectech.thing.metaTileEntity.hatch.MTEHatchDynamoMulti; +import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyMulti; +import tectech.thing.metaTileEntity.hatch.MTEHatchParam; +import tectech.thing.metaTileEntity.hatch.MTEHatchUncertainty; +import tectech.thing.metaTileEntity.multi.base.render.TTRenderedExtendedFacingTexture; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by danie_000 on 27.10.2016. + */ +public abstract class TTMultiblockBase extends MTEExtendedPowerMultiBlockBase<TTMultiblockBase> + implements IAlignment, IBindPlayerInventoryUI { + // region Client side variables (static - one per class) + + // Front icon holders - static so it is default one for my blocks + // just add new static ones in your class and and override getTexture + protected static Textures.BlockIcons.CustomIcon ScreenOFF; + protected static Textures.BlockIcons.CustomIcon ScreenON; + + /** Base ID for the LED window popup. LED 1 I0 will have ID 100, LED 1 I1 101... */ + protected static int LED_WINDOW_BASE_ID = 100; + + // Sound resource - same as with screen but override getActivitySound + public static final ResourceLocation activitySound = new ResourceLocation(Reference.MODID + ":fx_lo_freq"); + + @SideOnly(Side.CLIENT) + private SoundLoop activitySoundLoop; + // endregion + + // region HATCHES ARRAYS - they hold info about found hatches, add hatches to them... (auto structure magic does it + // tho) + + // HATCHES!!!, should be added and removed in check machine + protected ArrayList<MTEHatchParam> eParamHatches = new ArrayList<>(); + protected ArrayList<MTEHatchUncertainty> eUncertainHatches = new ArrayList<>(); + // multi amp hatches in/out + protected ArrayList<MTEHatchEnergyMulti> eEnergyMulti = new ArrayList<>(); + protected ArrayList<MTEHatchDynamoMulti> eDynamoMulti = new ArrayList<>(); + // data hatches + protected ArrayList<MTEHatchDataInput> eInputData = new ArrayList<>(); + protected ArrayList<MTEHatchDataOutput> eOutputData = new ArrayList<>(); + + // endregion + + // region parameters + public final Parameters parametrization; + // endregion + + // region Control variables + + // should explode on dismatle?, set it in constructor, if true machine will explode if invalidated structure while + // active + protected boolean eDismantleBoom = false; + + // what is the amount of A required + public long eAmpereFlow = 1; // analogue of EU/t but for amperes used (so eu/t is actually eu*A/t) USE ONLY POSITIVE + // NUMBERS! + + // set to what you need it to be in check recipe + // data required to operate + protected long eRequiredData = 0; + + // Counter for the computation timeout. Will be initialized one to the max time and then only decreased. + protected int eComputationTimeout = MAX_COMPUTATION_TIMEOUT; + + // Max timeout of computation in ticks + protected static int MAX_COMPUTATION_TIMEOUT = 100; + + // are parameters correct - change in check recipe/output/update params etc. (maintenance status boolean) + protected boolean eParameters = true; + + // what type of certainty inconvenience is used - can be used as in Computer - more info in uncertainty hatch + protected byte eCertainMode = 0, eCertainStatus = 0; + + // minimal repair status to make the machine even usable (how much unfixed fixed stuff is needed) + // if u need to force some things to be fixed - u might need to override doRandomMaintenanceDamage + protected byte minRepairStatus = 3; + + // whether there is a maintenance hatch in the multi and whether checks are necessary (for now only used in a + // transformer) + protected boolean hasMaintenanceChecks = true; + + // is power pass cover present + public boolean ePowerPassCover = false; + + // functionality toggles - changed by buttons in gui also + public boolean ePowerPass = false, eSafeVoid = false; + + // endregion + + // region READ ONLY unless u really need to change it + + // max amperes machine can take in after computing it to the lowest tier (exchange packets to min tier count) + protected long eMaxAmpereFlow = 0, eMaxAmpereGen = 0; + + // What is the max and minimal tier of eu hatches installed + private long maxEUinputMin = 0, maxEUinputMax = 0, maxEUoutputMin = 0, maxEUoutputMax = 0; + + // read only unless you are making computation generator - read computer class + protected long eAvailableData = 0; // data being available + + // just some info - private so hidden + private boolean explodedThisTick = false; + + /** Flag if the new long power variable should be used */ + protected boolean useLongPower = false; + + // Locale-aware formatting of numbers. + protected static NumberFormatMUI numberFormat; + static { + numberFormat = new NumberFormatMUI(); + numberFormat.setMaximumFractionDigits(8); + } + + // endregion + + protected TTMultiblockBase(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + parametrization = new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true, true); + } + + protected TTMultiblockBase(String aName) { + super(aName); + parametrization = new Parameters(this); + parametersInstantiation_EM(); + parametrization.setToDefaults(true, true); + } + + // region SUPER STRUCT + + /** + * Gets structure + * + * @return STATIC INSTANCE OF STRUCTURE + */ + public abstract IStructureDefinition<? extends TTMultiblockBase> getStructure_EM(); + + @SuppressWarnings("unchecked") + private IStructureDefinition<TTMultiblockBase> getStructure_EM_Internal() { + return (IStructureDefinition<TTMultiblockBase>) getStructure_EM(); + } + + @Override + public IStructureDefinition<TTMultiblockBase> getStructureDefinition() { + return getStructure_EM_Internal(); + } + + public final boolean structureCheck_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset) { + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + return getStructure_EM_Internal().check( + this, + piece, + baseMetaTileEntity.getWorld(), + getExtendedFacing(), + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + !mMachine); + } + + public final boolean structureBuild_EM(String piece, int horizontalOffset, int verticalOffset, int depthOffset, + ItemStack trigger, boolean hintsOnly) { + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + return getStructure_EM_Internal().buildOrHints( + this, + trigger, + piece, + baseMetaTileEntity.getWorld(), + getExtendedFacing(), + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord(), + horizontalOffset, + verticalOffset, + depthOffset, + hintsOnly); + } + // endregion + + // region METHODS TO OVERRIDE - general functionality, recipe check, output + + /** + * Check structure here, also add hatches + * + * @param iGregTechTileEntity - the tile entity + * @param itemStack - what is in the controller input slot + * @return is structure valid + */ + protected boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return false; + } + + /** + * Checks Recipes (when all machine is complete and can work) + * <p> + * can get/set Parameters here also + * + * @deprecated Use {@link #createProcessingLogic()} ()} or {@link #checkProcessing_EM()} + * + * @param itemStack item in the controller + * @return is recipe is valid + */ + @Deprecated + public boolean checkRecipe_EM(ItemStack itemStack) { + return false; + } + + @NotNull + protected CheckRecipeResult checkProcessing_EM() { + if (processingLogic == null) { + return checkRecipe_EM(getControllerSlot()) ? CheckRecipeResultRegistry.SUCCESSFUL + : CheckRecipeResultRegistry.NO_RECIPE; + } + return super.checkProcessing(); + } + + /** + * Put EM stuff from outputEM into EM output hatches here or do other stuff - it is basically on recipe succeded + * <p> + * based on "machine state" do output, this must move to outputEM to EM output hatches and can also modify output + * items/fluids/EM, remaining EM is NOT overflowed. (Well it can be overflowed if machine didn't finished, + * soft-hammered/disabled/not enough EU) Setting available data processing + */ + public void outputAfterRecipe_EM() {} + // endregion + + // region tooltip and scanner result + + public ArrayList<String> getFullLedDescriptionIn(int hatchNo, int paramID) { + ArrayList<String> list = new ArrayList<>(); + list.add( + EnumChatFormatting.WHITE + "ID: " + + EnumChatFormatting.AQUA + + hatchNo + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + paramID + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + "I " + + parametrization.getStatusIn(hatchNo, paramID).name.get()); + list.add( + EnumChatFormatting.WHITE + "Value: " + + EnumChatFormatting.AQUA + + numberFormat.format(parametrization.getIn(hatchNo, paramID))); + try { + list.add(parametrization.groups[hatchNo].parameterIn[paramID].getBrief()); + } catch (NullPointerException | IndexOutOfBoundsException e) { + list.add("Unused"); + } + return list; + } + + public ArrayList<String> getFullLedDescriptionOut(int hatchNo, int paramID) { + ArrayList<String> list = new ArrayList<>(); + list.add( + EnumChatFormatting.WHITE + "ID: " + + EnumChatFormatting.AQUA + + hatchNo + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + paramID + + EnumChatFormatting.YELLOW + + ":" + + EnumChatFormatting.AQUA + + "O " + + parametrization.getStatusOut(hatchNo, paramID).name.get()); + list.add( + EnumChatFormatting.WHITE + "Value: " + + EnumChatFormatting.AQUA + + numberFormat.format(parametrization.getOut(hatchNo, paramID))); + try { + list.add(parametrization.groups[hatchNo].parameterOut[paramID].getBrief()); + } catch (NullPointerException | IndexOutOfBoundsException e) { + list.add("Unused"); + } + return list; + } + + @Override + protected MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addInfo("Nothing special just override me") + .toolTipFinisher(CommonValues.TEC_MARK_GENERAL); + return tt; + } + + /** + * scanner gives it + */ + @Override + public String[] getInfoData() { // TODO Do it + long storedEnergy = 0; + long maxEnergy = 0; + for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + storedEnergy += tHatch.getBaseMetaTileEntity() + .getStoredEU(); + maxEnergy += tHatch.getBaseMetaTileEntity() + .getEUCapacity(); + } + + return new String[] { "Progress:", + EnumChatFormatting.GREEN + GTUtility.formatNumbers(mProgresstime / 20) + + EnumChatFormatting.RESET + + " s / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(mMaxProgresstime / 20) + + EnumChatFormatting.RESET + + " s", + "Energy Hatches:", + EnumChatFormatting.GREEN + GTUtility.formatNumbers(storedEnergy) + + EnumChatFormatting.RESET + + " EU / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(maxEnergy) + + EnumChatFormatting.RESET + + " EU", + (getPowerFlow() * eAmpereFlow <= 0 ? "Probably uses: " : "Probably makes: ") + EnumChatFormatting.RED + + GTUtility.formatNumbers(Math.abs(getPowerFlow())) + + EnumChatFormatting.RESET + + " EU/t at " + + EnumChatFormatting.RED + + GTUtility.formatNumbers(eAmpereFlow) + + EnumChatFormatting.RESET + + " A", + "Tier Rating: " + EnumChatFormatting.YELLOW + + VN[getMaxEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.GREEN + + VN[getMinEnergyInputTier_EM()] + + EnumChatFormatting.RESET + + " Amp Rating: " + + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(eMaxAmpereFlow) + + EnumChatFormatting.RESET + + " A", + "Problems: " + EnumChatFormatting.RED + + (getIdealStatus() - getRepairStatus()) + + EnumChatFormatting.RESET + + " Efficiency: " + + EnumChatFormatting.YELLOW + + mEfficiency / 100.0F + + EnumChatFormatting.RESET + + " %", + "PowerPass: " + EnumChatFormatting.BLUE + + ePowerPass + + EnumChatFormatting.RESET + + " SafeVoid: " + + EnumChatFormatting.BLUE + + eSafeVoid, + "Computation: " + EnumChatFormatting.GREEN + + GTUtility.formatNumbers(eAvailableData) + + EnumChatFormatting.RESET + + " / " + + EnumChatFormatting.YELLOW + + GTUtility.formatNumbers(eRequiredData) + + EnumChatFormatting.RESET }; + } + + /** + * should it work with scanner? HELL YES + */ + @Override + public boolean isGivingInformation() { + return true; + } + + // endregion + + // region GUI/SOUND/RENDER + + /** + * add more textures + */ + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER"); + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/EM_CONTROLLER_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + /** + * actually use textures + */ + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4], + new TTRenderedExtendedFacingTexture(aActive ? ScreenON : ScreenOFF) }; + } + return new ITexture[] { Textures.BlockIcons.casingTexturePages[texturePage][4] }; + } + + /** + * should return your activity sound + */ + @SideOnly(Side.CLIENT) + protected ResourceLocation getActivitySound() { + return activitySound; + } + + /** + * plays the sounds auto magically + */ + @SideOnly(Side.CLIENT) + protected void soundMagic(ResourceLocation activitySound) { + if (getBaseMetaTileEntity().isActive()) { + if (activitySoundLoop == null) { + activitySoundLoop = new SoundLoop(activitySound, getBaseMetaTileEntity(), false, true); + Minecraft.getMinecraft() + .getSoundHandler() + .playSound(activitySoundLoop); + } + } else { + if (activitySoundLoop != null) { + activitySoundLoop = null; + } + } + } + + // endregion + + // region Methods to maybe override (if u implement certain stuff) + + /** + * is the thing inside controller a valid item to make the machine work + */ + @Override + public boolean isCorrectMachinePart(ItemStack itemStack) { + return true; + } + + /** + * how much damage to apply to thing in controller - not sure how it does it + */ + @Override + public int getDamageToComponent(ItemStack itemStack) { + return 0; + } + + /** + * called when removing from map - not when unloading? //todo check + */ + @Override + public void onRemoval() { + try { + if (ePowerPass && getEUVar() > V[3] + || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { + explodeMultiblock(); + } + } catch (Exception e) { + if (TecTechConfig.DEBUG_MODE) { + e.printStackTrace(); + } + } + } + + /** + * prevents spontaneous explosions when the chunks unloading would cause them should cover 3 chunks radius + */ + protected boolean areChunksAroundLoaded_EM() { + if (this.isValid() && getBaseMetaTileEntity().isServerSide()) { + IGregTechTileEntity base = getBaseMetaTileEntity(); + return base.getWorld() + .doChunksNearChunkExist(base.getXCoord(), base.getYCoord(), base.getZCoord(), 3); + // todo check if it is actually checking if chunks are loaded + } else { + return false; + } + } + + /** + * instantiate parameters in CONSTRUCTOR! CALLED ONCE on creation, don't call it in your classes + */ + protected void parametersInstantiation_EM() {} + + /** + * It is automatically called OFTEN update status of parameters in guis (and "machine state" if u wish) Called + * before check recipe, before outputting, and every second the machine is complete + * <p> + * good place to update parameter statuses, default implementation handles it well + * + * @param machineBusy is machine doing stuff + */ + protected void parametersStatusesWrite_EM(boolean machineBusy) { // todo unimplement? + if (!machineBusy) { + for (Parameters.Group.ParameterIn parameterIn : parametrization.parameterInArrayList) { + if (parameterIn != null) { + parameterIn.updateStatus(); + } + } + } else { + for (Parameters.Group hatch : parametrization.groups) { + if (hatch != null && hatch.updateWhileRunning) { + for (Parameters.Group.ParameterIn in : hatch.parameterIn) { + if (in != null) { + in.updateStatus(); + } + } + } + } + } + for (Parameters.Group.ParameterOut parameterOut : parametrization.parameterOutArrayList) { + if (parameterOut != null) { + parameterOut.updateStatus(); + } + } + } + + /** + * For extra types of hatches initiation, LOOK HOW IT IS CALLED! in onPostTick + * + * @param mMachine was the machine considered complete at that point in onPostTick + */ + protected void hatchInit_EM(boolean mMachine) {} + + /** + * called when the multiblock is exploding - if u want to add more EXPLOSIONS, for ex. new types of hatches also + * have to explode + */ + protected void extraExplosions_EM() {} // For that extra hatches explosions, and maybe some MOORE EXPLOSIONS + + /** + * Get Available data, Override only on data outputters should return mAvailableData that is set in check recipe + * + * @return available data + */ + protected long getAvailableData_EM() { + long result = 0; + IGregTechTileEntity baseMetaTileEntity = getBaseMetaTileEntity(); + Vec3Impl pos = new Vec3Impl( + baseMetaTileEntity.getXCoord(), + baseMetaTileEntity.getYCoord(), + baseMetaTileEntity.getZCoord()); + for (MTEHatchDataInput in : eInputData) { + if (in.q != null) { + Long value = in.q.contentIfNotInTrace(pos); + if (value != null) { + result += value; + } + } + } + return result; + } + + protected long getPowerFlow() { + return useLongPower ? lEUt : mEUt; + } + + protected void setPowerFlow(long lEUt) { + if (useLongPower) { + this.lEUt = lEUt; + } else { + mEUt = (int) Math.min(Integer.MAX_VALUE, lEUt); + } + } + + @Override + protected long getActualEnergyUsage() { + return -(useLongPower ? lEUt : mEUt) * eAmpereFlow * 10_000 / Math.max(1_000, mEfficiency); + } + + /** + * Extra hook on cyclic updates (not really needed for machines smaller than 1 chunk) BUT NEEDED WHEN - machine + * blocks are not touching each other or they don't implement IMachineBlockUpdateable (ex. air,stone,weird TE's) + */ + protected boolean cyclicUpdate_EM() { + return mUpdate <= -1000; // set to false to disable cyclic update + // default is once per 50s; mUpdate is decremented every tick + } + + /** + * get pollution per tick + * + * @param itemStack what is in controller + * @return how much pollution is produced + */ + @Override + public int getPollutionPerTick(ItemStack itemStack) { + return 0; + } + + /** + * EM pollution per tick + * + * @param itemStack - item in controller + * @return how much excess matter is there + */ + public float getExcessMassPerTick_EM(ItemStack itemStack) { + return 0f; + } + + /** + * triggered if machine is not allowed to work after completing a recipe, override to make it not shutdown for + * instance (like turbines). bu just replacing it with blank - active transformer is doing it + * <p> + * CALLED DIRECTLY when soft hammered to offline state - usually should stop the machine unless some other mechanics + * should do it + */ + protected void notAllowedToWork_stopMachine_EM() { + stopMachine(); + } + + /** + * store data + */ + @Override + public void saveNBTData(NBTTagCompound aNBT) { + super.saveNBTData(aNBT); + aNBT.setLong("eMaxGenEUmin", maxEUoutputMin); + aNBT.setLong("eMaxGenEUmax", maxEUoutputMax); + aNBT.setLong("eGenRating", eMaxAmpereGen); + aNBT.setLong("eMaxEUmin", maxEUinputMin); + aNBT.setLong("eMaxEUmax", maxEUinputMax); + aNBT.setLong("eRating", eAmpereFlow); + aNBT.setLong("eMaxA", eMaxAmpereFlow); + aNBT.setLong("eDataR", eRequiredData); + aNBT.setLong("eDataA", eAvailableData); + aNBT.setByte("eCertainM", eCertainMode); + aNBT.setByte("eCertainS", eCertainStatus); + aNBT.setByte("eMinRepair", minRepairStatus); + aNBT.setBoolean("eParam", eParameters); + aNBT.setBoolean("ePass", ePowerPass); + aNBT.setBoolean("ePowerPassCover", ePowerPassCover); + aNBT.setBoolean("eVoid", eSafeVoid); + aNBT.setBoolean("eBoom", eDismantleBoom); + aNBT.setBoolean("eOK", mMachine); + // Ensures compatibility + if (mOutputItems != null) { + aNBT.setInteger("mOutputItemsLength", mOutputItems.length); + for (int i = 0; i < mOutputItems.length; i++) { + if (mOutputItems[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputItems[i].writeToNBT(tNBT); + aNBT.setTag("mOutputItem" + i, tNBT); + } + } + } + + // Ensures compatibility + if (mOutputFluids != null) { + aNBT.setInteger("mOutputFluidsLength", mOutputFluids.length); + for (int i = 0; i < mOutputFluids.length; i++) { + if (mOutputFluids[i] != null) { + NBTTagCompound tNBT = new NBTTagCompound(); + mOutputFluids[i].writeToNBT(tNBT); + aNBT.setTag("mOutputFluids" + i, tNBT); + } + } + } + + aNBT.setInteger("eOutputStackCount", 0); + aNBT.removeTag("outputEM"); + + NBTTagCompound paramI = new NBTTagCompound(); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + paramI.setDouble(Integer.toString(i), parametrization.iParamsIn[i]); + } + aNBT.setTag("eParamsInD", paramI); + + NBTTagCompound paramO = new NBTTagCompound(); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + paramO.setDouble(Integer.toString(i), parametrization.iParamsOut[i]); + } + aNBT.setTag("eParamsOutD", paramO); + + NBTTagCompound paramIs = new NBTTagCompound(); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + paramIs.setByte(Integer.toString(i), parametrization.eParamsInStatus[i].getOrdinalByte()); + } + aNBT.setTag("eParamsInS", paramIs); + + NBTTagCompound paramOs = new NBTTagCompound(); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + paramOs.setByte(Integer.toString(i), parametrization.eParamsOutStatus[i].getOrdinalByte()); + } + aNBT.setTag("eParamsOutS", paramOs); + } + + /** + * load data + */ + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + maxEUoutputMin = aNBT.getLong("eMaxGenEUmin"); + maxEUoutputMax = aNBT.getLong("eMaxGenEUmax"); + eMaxAmpereGen = aNBT.getLong("eGenRating"); + maxEUinputMin = aNBT.getLong("eMaxEUmin"); + maxEUinputMax = aNBT.getLong("eMaxEUmax"); + eAmpereFlow = aNBT.hasKey("eRating") ? aNBT.getLong("eRating") : 1; + eMaxAmpereFlow = aNBT.getLong("eMaxA"); + eRequiredData = aNBT.getLong("eDataR"); + eAvailableData = aNBT.getLong("eDataA"); + eCertainMode = aNBT.getByte("eCertainM"); + eCertainStatus = aNBT.getByte("eCertainS"); + minRepairStatus = aNBT.hasKey("eMinRepair") ? aNBT.getByte("eMinRepair") : 3; + eParameters = !aNBT.hasKey("eParam") || aNBT.getBoolean("eParam"); + ePowerPass = aNBT.getBoolean("ePass"); + ePowerPassCover = aNBT.getBoolean("ePowerPassCover"); + eSafeVoid = aNBT.getBoolean("eVoid"); + eDismantleBoom = aNBT.getBoolean("eBoom"); + mMachine = aNBT.getBoolean("eOK"); + + // Ensures compatibility + int aOutputItemsLength = aNBT.getInteger("mOutputItemsLength"); + if (aOutputItemsLength > 0) { + mOutputItems = new ItemStack[aOutputItemsLength]; + for (int i = 0; i < mOutputItems.length; i++) { + mOutputItems[i] = GTUtility.loadItem(aNBT, "mOutputItem" + i); + } + } + + // Ensures compatibility + int aOutputFluidsLength = aNBT.getInteger("mOutputFluidsLength"); + if (aOutputFluidsLength > 0) { + mOutputFluids = new FluidStack[aOutputFluidsLength]; + for (int i = 0; i < mOutputFluids.length; i++) { + mOutputFluids[i] = GTUtility.loadFluid(aNBT, "mOutputFluids" + i); + } + } + + if (aNBT.hasKey("eParamsIn") && aNBT.hasKey("eParamsOut") && aNBT.hasKey("eParamsB")) { + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsIn"); + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOut"); + NBTTagCompound paramB = aNBT.getCompoundTag("eParamsB"); + for (int i = 0; i < 10; i++) { + if (paramB.getBoolean(Integer.toString(i))) { + parametrization.iParamsIn[i] = Float.intBitsToFloat(paramI.getInteger(Integer.toString(i))); + parametrization.iParamsOut[i] = Float.intBitsToFloat(paramO.getInteger(Integer.toString(i))); + } else { + parametrization.iParamsIn[i] = paramI.getInteger(Integer.toString(i)); + parametrization.iParamsOut[i] = paramO.getInteger(Integer.toString(i)); + } + } + } else { + NBTTagCompound paramI = aNBT.getCompoundTag("eParamsInD"); + for (int i = 0; i < parametrization.iParamsIn.length; i++) { + parametrization.iParamsIn[i] = paramI.getDouble(Integer.toString(i)); + } + NBTTagCompound paramO = aNBT.getCompoundTag("eParamsOutD"); + for (int i = 0; i < parametrization.iParamsOut.length; i++) { + parametrization.iParamsOut[i] = paramO.getDouble(Integer.toString(i)); + } + } + + NBTTagCompound paramIs = aNBT.getCompoundTag("eParamsInS"); + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + parametrization.eParamsInStatus[i] = LedStatus.getStatus(paramIs.getByte(Integer.toString(i))); + } + + NBTTagCompound paramOs = aNBT.getCompoundTag("eParamsOutS"); + for (int i = 0; i < parametrization.eParamsOutStatus.length; i++) { + parametrization.eParamsOutStatus[i] = LedStatus.getStatus(paramOs.getByte(Integer.toString(i))); + } + } + + /** + * Override if needed but usually call super method at start! On machine stop - NOT called directly when soft + * hammered to offline state! - it SHOULD cause a full stop like power failure does + */ + @Override + public void stopMachine(@Nonnull ShutDownReason reason) { + if (!ShutDownReasonRegistry.isRegistered(reason.getID())) { + throw new RuntimeException(String.format("Reason %s is not registered for registry", reason.getID())); + } + for (MTEHatchDataOutput data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + eAvailableData = 0; + hatchesStatusUpdate_EM(); + getBaseMetaTileEntity().disableWorking(); + getBaseMetaTileEntity().setShutDownReason(reason); + getBaseMetaTileEntity().setShutdownStatus(true); + if (reason.wasCritical()) { + sendSound(INTERRUPT_SOUND_INDEX); + } + } + + /** + * After recipe check failed helper method so i don't have to set that params to nothing at all times + */ + protected void afterRecipeCheckFailed() { + + for (MTEHatchDataOutput data : eOutputData) { + data.q = null; + } + + mOutputItems = null; + mOutputFluids = null; + mEfficiency = 0; + mEfficiencyIncrease = 0; + mProgresstime = 0; + mMaxProgresstime = 0; + eAvailableData = 0; + } + + /** + * cyclic check even when not working, called LESS frequently + */ + private boolean cyclicUpdate() { + if (cyclicUpdate_EM()) { + mUpdate = 0; + return true; + } + return false; + } + + /** + * mining level... + */ + @Override + public byte getTileEntityBaseType() { + return 3; + } + + // endregion + + // region internal + + /** + * internal check machine + */ + @Override + public final boolean checkMachine(IGregTechTileEntity iGregTechTileEntity, ItemStack itemStack) { + return checkMachine_EM(iGregTechTileEntity, itemStack); + } + + /** + * internal check recipe + */ + @Override + public final boolean checkRecipe(ItemStack itemStack) { // do recipe checks, based on "machine content and state" + hatchesStatusUpdate_EM(); + startRecipeProcessing(); + boolean result = checkRecipe_EM(itemStack); // if had no - set default params + endRecipeProcessing(); + hatchesStatusUpdate_EM(); + return result; + } + + @NotNull + @Override + public final CheckRecipeResult checkProcessing() { + hatchesStatusUpdate_EM(); + CheckRecipeResult result = checkProcessing_EM(); + hatchesStatusUpdate_EM(); + return result; + } + + /** + * callback for updating parameters and new hatches + */ + protected void hatchesStatusUpdate_EM() { + if (getBaseMetaTileEntity().isClientSide()) { + return; + } + boolean busy = mMaxProgresstime > 0; + if (busy) { // write from buffer to hatches only + for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) { + if (hatch.param < 0) { + continue; + } + int hatchId = hatch.param; + if (parametrization.groups[hatchId] != null && parametrization.groups[hatchId].updateWhileRunning) { + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; + } + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; + } + } else { // if has nothing to do update all + for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) { + if (hatch.param < 0) { + continue; + } + int hatchId = hatch.param; + parametrization.iParamsIn[hatchId] = hatch.value0D; + parametrization.iParamsIn[hatchId + 10] = hatch.value1D; + hatch.input0D = parametrization.iParamsOut[hatchId]; + hatch.input1D = parametrization.iParamsOut[hatchId + 10]; + } + } + for (MTEHatchUncertainty uncertainty : eUncertainHatches) { + eCertainStatus = uncertainty.update(eCertainMode); + } + eAvailableData = getAvailableData_EM(); + parametersStatusesWrite_EM(busy); + } + + @Deprecated + public final int getAmountOfOutputs() { + throw new NoSuchMethodError("Deprecated Do not use"); + } + // endregion + + // region TICKING functions + + public void onFirstTick_EM(IGregTechTileEntity aBaseMetaTileEntity) {} + + @Override + public final void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + isFacingValid(aBaseMetaTileEntity.getFrontFacing()); + if (getBaseMetaTileEntity().isClientSide()) { + StructureLibAPI.queryAlignment((IAlignmentProvider) aBaseMetaTileEntity); + } + onFirstTick_EM(aBaseMetaTileEntity); + } + + /** + * called every tick the machines is active + */ + @Override + public boolean onRunningTick(ItemStack aStack) { + return onRunningTickCheck(aStack); + } + + public boolean onRunningTickCheck_EM(ItemStack aStack) { + if (eRequiredData > eAvailableData) { + if (!checkComputationTimeout()) { + if (energyFlowOnRunningTick_EM(aStack, false)) { + stopMachine(SimpleShutDownReason.ofCritical("computation_loss")); + } + return false; + } + } + return energyFlowOnRunningTick_EM(aStack, true); + } + + public boolean onRunningTickCheck(ItemStack aStack) { + if (eRequiredData > eAvailableData) { + if (!checkComputationTimeout()) { + if (energyFlowOnRunningTick(aStack, false)) { + stopMachine(SimpleShutDownReason.ofCritical("computation_loss")); + } + return false; + } + } + return energyFlowOnRunningTick(aStack, true); + } + + /** + * CAREFUL!!! it calls most of the callbacks, like everything else in here + */ + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + mTotalRunTime++; + explodedThisTick = false; + if (mEfficiency < 0) { + mEfficiency = 0; + } + + if (--mUpdate == 0 || --mStartUpCheck == 0 + || cyclicUpdate() + || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + clearHatches_EM(); + + if (aBaseMetaTileEntity instanceof BaseTileEntity) { + ((BaseTileEntity) aBaseMetaTileEntity).ignoreUnloadedChunks = mMachine; + } + mMachine = checkMachine(aBaseMetaTileEntity, mInventory[1]); + + if (!mMachine) { + if (ePowerPass && getEUVar() > V[3] + || eDismantleBoom && mMaxProgresstime > 0 && areChunksAroundLoaded_EM()) { + explodeMultiblock(); + } + } + + if (eUncertainHatches.size() > 1) { + mMachine = false; + } + + if (mMachine) { + setupHatches_EM(); + + setupEnergyHatchesVariables_EM(); + + if (getEUVar() > maxEUStore()) { + setEUVar(maxEUStore()); + } + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + setEUVar(0); + } + hatchInit_EM(mMachine); + } + + if (mStartUpCheck < 0) { // E + if (mMachine) { // S + byte Tick = (byte) (aTick % 20); + if (CommonValues.MULTI_CHECK_AT == Tick) { + checkMaintenance(); + } + + if (getRepairStatus() >= minRepairStatus) { // S + if (CommonValues.MULTI_CHECK_AT == Tick) { + hatchesStatusUpdate_EM(); + } + + dischargeController_EM(aBaseMetaTileEntity); + chargeController_EM(aBaseMetaTileEntity); + + if (mMaxProgresstime > 0 && doRandomMaintenanceDamage()) { // Start + if (onRunningTick(mInventory[1])) { // Compute EU + if (!polluteEnvironment(getPollutionPerTick(mInventory[1]))) { + stopMachine(ShutDownReasonRegistry.POLLUTION_FAIL); + } + + if (mMaxProgresstime > 0 && ++mProgresstime >= mMaxProgresstime) { // progress increase + // and done + hatchesStatusUpdate_EM(); + + outputAfterRecipe_EM(); + + addClassicOutputs_EM(); + + updateSlots(); + mProgresstime = 0; + mMaxProgresstime = 0; + mEfficiencyIncrease = 0; + + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe()) { + mEfficiency = Math.max( + 0, + min( + mEfficiency + mEfficiencyIncrease, + getMaxEfficiency(mInventory[1]) + - (getIdealStatus() - getRepairStatus()) * 1000)); + } else { + afterRecipeCheckFailed(); + } + updateSlots(); + } else { + notAllowedToWork_stopMachine_EM(); + } + } + } // else {//failed to consume power/resources - inside on running tick + // stopMachine(); + // } + } else if (CommonValues.RECIPE_AT == Tick || aBaseMetaTileEntity.hasWorkJustBeenEnabled()) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + if (checkRecipe()) { + mEfficiency = Math.max( + 0, + min( + mEfficiency + mEfficiencyIncrease, + getMaxEfficiency(mInventory[1]) + - (getIdealStatus() - getRepairStatus()) * 1000)); + } else { + afterRecipeCheckFailed(); + } + updateSlots(); + } // else notAllowedToWork_stopMachine_EM(); //it is already stopped here + } + } else { // not repaired + stopMachine(ShutDownReasonRegistry.NO_REPAIR); + } + } else { // not complete + stopMachine(ShutDownReasonRegistry.STRUCTURE_INCOMPLETE); + } + } + + aBaseMetaTileEntity.setErrorDisplayID( + aBaseMetaTileEntity.getErrorDisplayID() & -512 | (mWrench ? 0 : 1) + | (mScrewdriver ? 0 : 2) + | (mSoftHammer ? 0 : 4) + | (mHardHammer ? 0 : 8) + | (mSolderingTool ? 0 : 16) + | (mCrowbar ? 0 : 32) + | (mMachine ? 0 : 64) + | (eCertainStatus == 0 ? 0 : 128) + | (eParameters ? 0 : 256)); + aBaseMetaTileEntity.setActive(mMaxProgresstime > 0); + boolean active = aBaseMetaTileEntity.isActive() && mPollution > 0; + setMufflers(active); + } else { + soundMagic(getActivitySound()); + } + } + + protected void addClassicOutputs_EM() { + if (mOutputItems != null) { + for (ItemStack tStack : mOutputItems) { + if (tStack != null) { + addOutput(tStack); + } + } + } + mOutputItems = null; + + if (mOutputFluids != null) { + if (mOutputFluids.length == 1) { + for (FluidStack tStack : mOutputFluids) { + if (tStack != null) { + addOutput(tStack); + } + } + } else if (mOutputFluids.length > 1) { + addFluidOutputs(mOutputFluids); + } + } + mOutputFluids = null; + } + + protected void clearHatches_EM() { + mDualInputHatches.clear(); + mInputHatches.clear(); + mInputBusses.clear(); + mOutputHatches.clear(); + mOutputBusses.clear(); + mDynamoHatches.clear(); + mEnergyHatches.clear(); + mMufflerHatches.clear(); + mMaintenanceHatches.clear(); + + for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eOutputData)) { + hatch_data.id = -1; + } + for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eInputData)) { + hatch_data.id = -1; + } + + for (MTEHatchUncertainty hatch : filterValidMTEs(eUncertainHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(false); + } + for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(false); + } + + eUncertainHatches.clear(); + eEnergyMulti.clear(); + eParamHatches.clear(); + eDynamoMulti.clear(); + eOutputData.clear(); + eInputData.clear(); + } + + protected void setupHatches_EM() { + short id = 1; + + for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eOutputData)) { + hatch_data.id = id++; + } + id = 1; + for (MTEHatchDataConnector<?> hatch_data : filterValidMTEs(eInputData)) { + hatch_data.id = id++; + } + + for (MTEHatchUncertainty hatch : filterValidMTEs(eUncertainHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(true); + } + for (MTEHatchParam hatch : filterValidMTEs(eParamHatches)) { + hatch.getBaseMetaTileEntity() + .setActive(true); + } + } + + protected void setupEnergyHatchesVariables_EM() { + if (!mEnergyHatches.isEmpty() || !eEnergyMulti.isEmpty() + || !mDynamoHatches.isEmpty() + || !eDynamoMulti.isEmpty()) { + maxEUinputMin = V[15]; + maxEUinputMax = V[0]; + maxEUoutputMin = V[15]; + maxEUoutputMax = V[0]; + for (MTEHatchEnergy hatch : filterValidMTEs(mEnergyHatches)) { + if (hatch.maxEUInput() < maxEUinputMin) { + maxEUinputMin = hatch.maxEUInput(); + } + if (hatch.maxEUInput() > maxEUinputMax) { + maxEUinputMax = hatch.maxEUInput(); + } + } + for (MTEHatchEnergyMulti hatch : filterValidMTEs(eEnergyMulti)) { + if (hatch.maxEUInput() < maxEUinputMin) { + maxEUinputMin = hatch.maxEUInput(); + } + if (hatch.maxEUInput() > maxEUinputMax) { + maxEUinputMax = hatch.maxEUInput(); + } + } + for (MTEHatchDynamo hatch : filterValidMTEs(mDynamoHatches)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + for (MTEHatchDynamoMulti hatch : filterValidMTEs(eDynamoMulti)) { + if (hatch.maxEUOutput() < maxEUoutputMin) { + maxEUoutputMin = hatch.maxEUOutput(); + } + if (hatch.maxEUOutput() > maxEUoutputMax) { + maxEUoutputMax = hatch.maxEUOutput(); + } + } + eMaxAmpereFlow = 0; + eMaxAmpereGen = 0; + // counts only full amps + for (MTEHatchEnergy hatch : filterValidMTEs(mEnergyHatches)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin; + } + for (MTEHatchEnergyMulti hatch : filterValidMTEs(eEnergyMulti)) { + eMaxAmpereFlow += hatch.maxEUInput() / maxEUinputMin * hatch.Amperes; + } + for (MTEHatchDynamo hatch : filterValidMTEs(mDynamoHatches)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin; + } + for (MTEHatchDynamoMulti hatch : filterValidMTEs(eDynamoMulti)) { + eMaxAmpereGen += hatch.maxEUOutput() / maxEUoutputMin * hatch.Amperes; + } + } else { + maxEUinputMin = 0; + maxEUinputMax = 0; + eMaxAmpereFlow = 0; + maxEUoutputMin = 0; + maxEUoutputMax = 0; + eMaxAmpereGen = 0; + } + } + + protected void dischargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) { + if (ePowerPass && getEUVar() > getMinimumStoredEU()) { + powerPass(aBaseMetaTileEntity); + } + } + + protected final void powerPass(IGregTechTileEntity aBaseMetaTileEntity) { + long euVar; + for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) { + euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + euVar = tHatch.maxEUOutput() * tHatch.maxAmperesOut(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.maxAmperesOut()), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + } + + protected final void powerPass_EM(IGregTechTileEntity aBaseMetaTileEntity) { + long euVar; + for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) { + euVar = tHatch.maxEUOutput(); + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity.decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, 1), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + euVar = tHatch.maxEUOutput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity() + .getStoredEU() <= tHatch.maxEUStore() - euVar + && aBaseMetaTileEntity + .decreaseStoredEnergyUnits(euVar + Math.max(euVar / 24576, tHatch.Amperes), false)) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + } + } + } + + protected void chargeController_EM(IGregTechTileEntity aBaseMetaTileEntity) { + powerInput(); + } + + protected final void powerInput() { + long euVar; + for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = Math.min(tHatch.maxEUInput() * tHatch.maxAmperesIn(), tHatch.getEUVar()); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + } + + protected final void powerInput_EM() { + long euVar; + for (MTEHatchEnergy tHatch : filterValidMTEs(mEnergyHatches)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = tHatch.maxEUInput(); + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + for (MTEHatchEnergyMulti tHatch : filterValidMTEs(eEnergyMulti)) { + if (getEUVar() > getMinimumStoredEU()) { + break; + } + euVar = tHatch.maxEUInput() * tHatch.Amperes; + if (tHatch.getBaseMetaTileEntity() + .decreaseStoredEnergyUnits(euVar, false)) { + setEUVar(getEUVar() + euVar); + } + } + } + + // endregion + + // region EFFICIENCY AND FIXING LIMITS + + @Override + public int getMaxEfficiency(ItemStack itemStack) { + return 10000; + } + + @Override + public int getIdealStatus() { + return super.getIdealStatus() + 2; + } + + @Override + public int getRepairStatus() { + return super.getRepairStatus() + (eCertainStatus == 0 ? 1 : 0) + (eParameters ? 1 : 0); + } + + // endregion + + // region ENERGY!!!! + + // new method + public boolean energyFlowOnRunningTick_EM(ItemStack aStack, boolean allowProduction) { + long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign + if (allowProduction && euFlow > 0) { + addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (euFlow < 0) { + if (TecTechConfig.POWERLESS_MODE) { + return true; + } + if (!drainEnergyInput_EM( + getPowerFlow(), + getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), + eAmpereFlow)) { + criticalStopMachine(); + return false; + } + } + return true; + } + + public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { + long euFlow = getPowerFlow() * eAmpereFlow; // quick scope sign + if (allowProduction && euFlow > 0) { + addEnergyOutput_EM(getPowerFlow() * (long) mEfficiency / getMaxEfficiency(aStack), eAmpereFlow); + } else if (euFlow < 0) { + if (TecTechConfig.POWERLESS_MODE) { + return true; + } + if (!drainEnergyInput( + getPowerFlow() * getMaxEfficiency(aStack) / Math.max(1000L, mEfficiency), + eAmpereFlow)) { + stopMachine(ShutDownReasonRegistry.POWER_LOSS); + return false; + } + } + return true; + } + + @Override + public long maxEUStore() { + return Math.max(maxEUinputMin * (eMaxAmpereFlow << 3), maxEUoutputMin * (eMaxAmpereGen << 3)); + } + + @Override + public final long getMinimumStoredEU() { + return maxEUStore() >> 1; + } + + @Override + public final long maxAmperesIn() { + return 0L; + } + + @Override + public final long maxAmperesOut() { + return 0L; + } + + @Deprecated + @Override + public final boolean addEnergyOutput(long eu) { + return addEnergyOutput_EM(eu, 1); + } + + public boolean addEnergyOutput_EM(long EU, long Amperes) { + if (EU < 0) { + EU = -EU; + } + if (Amperes < 0) { + Amperes = -Amperes; + } + long euVar = EU * Amperes; + long diff; + for (MTEHatchDynamo tHatch : filterValidMTEs(mDynamoHatches)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity() + .getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + return true; + } + } + } + for (MTEHatchDynamoMulti tHatch : filterValidMTEs(eDynamoMulti)) { + if (tHatch.maxEUOutput() < EU) { + explodeMultiblock(); + } + diff = tHatch.maxEUStore() - tHatch.getBaseMetaTileEntity() + .getStoredEU(); + if (diff > 0) { + if (euVar > diff) { + tHatch.setEUVar(tHatch.maxEUStore()); + euVar -= diff; + } else if (euVar <= diff) { + tHatch.setEUVar( + tHatch.getBaseMetaTileEntity() + .getStoredEU() + euVar); + return true; + } + } + } + setEUVar(min(getEUVar() + euVar, maxEUStore())); + return false; + } + + @Deprecated + @Override + public final boolean drainEnergyInput(long eu) { + return drainEnergyInput_EM(0, eu, 1); + } + + public boolean drainEnergyInput_EM(long EUtTierVoltage, long EUtEffective, long Amperes) { + long EUuse = EUtEffective * Amperes; + if (EUuse == 0) { + return true; + } + if (maxEUinputMin == 0) { + return false; + } + if (EUuse < 0) { + EUuse = -EUuse; + } + if (EUuse > getEUVar() || // not enough power + (EUtTierVoltage == 0 ? EUuse > getMaxInputEnergy() : (EUtTierVoltage > maxEUinputMax) || // TIER IS + // BASED ON + // BEST HATCH! + // not total + // EUtEffective + // input + (EUtTierVoltage * Amperes - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)) { // EUuse==0? --> (EUuse + // - 1) / maxEUinputMin + // + 1 = 1! //if + // not too much A + if (TecTechConfig.DEBUG_MODE) { + TecTech.LOGGER.debug("L1 " + EUuse + ' ' + getEUVar() + ' ' + (EUuse > getEUVar())); + TecTech.LOGGER.debug("L2 " + EUtEffective + ' ' + maxEUinputMax + ' ' + (EUtEffective > maxEUinputMax)); + TecTech.LOGGER.debug("L3 " + Amperes + ' ' + getMaxInputEnergy()); + TecTech.LOGGER.debug( + "L4 " + ((EUuse - 1) / maxEUinputMin + 1) + + ' ' + + eMaxAmpereFlow + + ' ' + + ((EUuse - 1) / maxEUinputMin + 1 > eMaxAmpereFlow)); + } + return false; + } + // sub eu + setEUVar(getEUVar() - EUuse); + return true; + } + + public boolean drainEnergyInput(long EUtEffective, long Amperes) { + long EUuse = EUtEffective * Amperes; + if (EUuse == 0) { + return true; + } + if (maxEUinputMin == 0) { + return false; + } + if (EUuse < 0) { + EUuse = -EUuse; + } + // not enough power + if (EUuse > getEUVar() || EUuse > getMaxInputEnergy()) { // EUuse==0? --> (EUuse - 1) / maxEUinputMin + 1 = 1! + // //if not too much + // A + return false; + } + // sub eu + setEUVar(getEUVar() - EUuse); + return true; + } + + // new method + public final boolean overclockAndPutValuesIn_EM(long EU, int time) { // TODO revise + if (EU == 0L) { + setPowerFlow(0); + mMaxProgresstime = time; + return true; + } + long tempEUt = Math.max(EU, V[1]); + long tempTier = maxEUinputMax >> 2; + while (tempEUt < tempTier) { + tempEUt <<= 2; + time >>= 1; + EU = time == 0 ? EU >> 1 : EU << 2; // U know, if the time is less than 1 tick make the machine use less + // power + } + if (EU > Integer.MAX_VALUE || EU < Integer.MIN_VALUE) { + setPowerFlow(Integer.MAX_VALUE - 1); + mMaxProgresstime = Integer.MAX_VALUE - 1; + return false; + } + setPowerFlow(EU); + mMaxProgresstime = time == 0 ? 1 : time; + return true; + } // Use in EM check recipe return statement if you want overclocking + + /** + * Use {@link #getMaxInputVoltage()} + */ + @Deprecated + public final long getMaxInputVoltageSum() { + return getMaxInputVoltage(); + } + + /** + * Use {@link #getMaxInputEu()} + */ + @Deprecated + public final long getMaxInputEnergy() { + return getMaxInputEu(); + } + + /** + * Use {@link #getMaxInputEu()} + */ + @Deprecated + public final long getMaxInputEnergy_EM() { + return getMaxInputEu(); + } + + // new Method + public final int getMaxEnergyInputTier_EM() { + return TTUtility.getTier(maxEUinputMax); + } + + // new Method + public final int getMinEnergyInputTier_EM() { + return TTUtility.getTier(maxEUinputMin); + } + + public final long getMaxAmpereFlowAtMinTierOfEnergyHatches() { + return eAmpereFlow; + } + + @Override + public List<MTEHatch> getExoticAndNormalEnergyHatchList() { + List<MTEHatch> list = new ArrayList<>(); + list.addAll(mEnergyHatches); + list.addAll(eEnergyMulti); + return list; + } + + @Override + public List<MTEHatch> getExoticEnergyHatches() { + List<MTEHatch> list = new ArrayList<>(); + list.addAll(eEnergyMulti); + return list; + } + + @Override + public boolean explodesOnComponentBreak(ItemStack itemStack) { + return false; + } + + @Override + public final void explodeMultiblock() { + if (explodedThisTick) { + return; + } + explodedThisTick = true; + if (!TecTech.configTecTech.BOOM_ENABLE) { + TecTech.proxy.broadcast( + "Multi Explode BOOM! " + getBaseMetaTileEntity().getXCoord() + + ' ' + + getBaseMetaTileEntity().getYCoord() + + ' ' + + getBaseMetaTileEntity().getZCoord()); + StackTraceElement[] ste = Thread.currentThread() + .getStackTrace(); + TecTech.proxy.broadcast("Multi Explode BOOM! " + ste[2].toString()); + return; + } + extraExplosions_EM(); + Pollution.addPollution(getBaseMetaTileEntity(), 600000); + mInventory[1] = null; + @SuppressWarnings("unchecked") + Iterable<MetaTileEntity> allHatches = Iterables.concat( + mInputBusses, + mOutputBusses, + mInputHatches, + mOutputHatches, + mDynamoHatches, + mMufflerHatches, + mEnergyHatches, + mMaintenanceHatches, + eParamHatches, + eEnergyMulti, + eUncertainHatches, + eDynamoMulti, + eInputData, + eOutputData); + for (MetaTileEntity tTileEntity : allHatches) { + if (tTileEntity != null && tTileEntity.getBaseMetaTileEntity() != null) { + tTileEntity.getBaseMetaTileEntity() + .doExplosion(V[9]); + } + } + getBaseMetaTileEntity().doExplosion(V[15]); + } + + @Override + public void doExplosion(long aExplosionPower) { + if (!TecTech.configTecTech.BOOM_ENABLE) { + TecTech.proxy.broadcast( + "Multi DoExplosion BOOM! " + getBaseMetaTileEntity().getXCoord() + + ' ' + + getBaseMetaTileEntity().getYCoord() + + ' ' + + getBaseMetaTileEntity().getZCoord()); + StackTraceElement[] ste = Thread.currentThread() + .getStackTrace(); + TecTech.proxy.broadcast("Multi DoExplosion BOOM! " + ste[2].toString()); + return; + } + explodeMultiblock(); + super.doExplosion(aExplosionPower); + } // Redirecting to explodemultiblock + // endregion + + // region adder methods + @Override + public final boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatch) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof IDualInputHatch) { + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInput) { + return mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInputBus) { + return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutputBus) { + return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergy) { + return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamo) { + return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchMuffler) { + return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchParam) { + return eParamHatches.add((MTEHatchParam) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchUncertainty) { + return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergyMulti) { + return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamoMulti) { + return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataInput) { + return eInputData.add((MTEHatchDataInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataOutput) { + return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity); + } + return false; + } + + public final boolean addClassicToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatch) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + if (aMetaTileEntity instanceof IDualInputHatch) { + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInput) { + return mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInputBus) { + return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutputBus) { + return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergy) { + return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamo) { + return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchMuffler) { + return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchParam) { + return eParamHatches.add((MTEHatchParam) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchUncertainty) { + return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergyMulti) { + return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamoMulti) { + return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataInput) { + return eInputData.add((MTEHatchDataInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataOutput) { + return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity); + } + return false; + } + + public final boolean addElementalToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatch) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + } + + return false; + } + + public final boolean addElementalMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + @Override + public final boolean addMufflerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchMuffler) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMufflerHatches.add((MTEHatchMuffler) aMetaTileEntity); + } + + return false; + } + + @Override + public final boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof IDualInputHatch) { + ((IDualInputHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDualInputHatches.add((IDualInputHatch) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInput) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputHatches.add((MTEHatchInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchInputBus) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + ((MTEHatchInputBus) aMetaTileEntity).mRecipeMap = getRecipeMap(); + return mInputBusses.add((MTEHatchInputBus) aMetaTileEntity); + } + + return false; + } + + @Override + public final boolean addOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputHatches.add((MTEHatchOutput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchOutputBus) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mOutputBusses.add((MTEHatchOutputBus) aMetaTileEntity); + } + + return false; + } + + @Deprecated + @Override + public final boolean addEnergyInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchEnergy) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergyMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity); + } + return false; + } + + @Deprecated + @Override + public final boolean addDynamoToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchDynamo) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamoMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity); + } + return false; + } + + // New Method + public final boolean addEnergyIOToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchEnergy) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mEnergyHatches.add((MTEHatchEnergy) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchEnergyMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eEnergyMulti.add((MTEHatchEnergyMulti) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamo) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mDynamoHatches.add((MTEHatchDynamo) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDynamoMulti) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eDynamoMulti.add((MTEHatchDynamoMulti) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addElementalInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + // NEW METHOD + public final boolean addElementalOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + + return false; + } + + // NEW METHOD + public final boolean addParametrizerToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchParam) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((MTEHatchParam) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addUncertainToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchUncertainty) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity); + } + return false; + } + + @Override + public final boolean addMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchParam) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eParamHatches.add((MTEHatchParam) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchUncertainty) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eUncertainHatches.add((MTEHatchUncertainty) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchMaintenance) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return mMaintenanceHatches.add((MTEHatchMaintenance) aMetaTileEntity); + } + return false; + } + + // NEW METHOD + public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { + if (aTileEntity == null) { + return false; + } + IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity(); + if (aMetaTileEntity == null) { + return false; + } + if (aMetaTileEntity instanceof MTEHatchDataInput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eInputData.add((MTEHatchDataInput) aMetaTileEntity); + } + if (aMetaTileEntity instanceof MTEHatchDataOutput) { + ((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex); + return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity); + } + return false; + } + // endregion + + protected static <T extends TTMultiblockBase> IStructureElement<T> classicHatches(int casingIndex, int dot, + Block casingBlock, int casingMeta) { + return HatchElementBuilder.<T>builder() + .atLeast( + InputBus, + InputHatch, + OutputHatch, + OutputBus, + Maintenance, + Muffler, + HatchElement.EnergyMulti, + HatchElement.DynamoMulti, + HatchElement.InputData, + HatchElement.OutputData, + HatchElement.Uncertainty) + .casingIndex(casingIndex) + .dot(dot) + .buildAndChain(casingBlock, casingMeta); + } + + protected static <T extends TTMultiblockBase> IStructureElement<T> allHatches(int casingIndex, int dot, + Block casingBlock, int casingMeta) { + return HatchElementBuilder.<T>builder() + .atLeast( + InputBus, + InputHatch, + OutputHatch, + OutputBus, + Maintenance, + Muffler, + HatchElement.EnergyMulti, + HatchElement.DynamoMulti, + HatchElement.InputData, + HatchElement.OutputData, + HatchElement.Uncertainty) + .casingIndex(casingIndex) + .dot(dot) + .buildAndChain(casingBlock, casingMeta); + } + + public enum HatchElement implements IHatchElement<TTMultiblockBase> { + + Param(TTMultiblockBase::addParametrizerToMachineList, MTEHatchParam.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eParamHatches.size(); + } + }, + Uncertainty(TTMultiblockBase::addUncertainToMachineList, MTEHatchUncertainty.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eUncertainHatches.size(); + } + }, + EnergyMulti(TTMultiblockBase::addEnergyInputToMachineList, MTEHatchEnergyMulti.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eEnergyMulti.size(); + } + }, + DynamoMulti(TTMultiblockBase::addDynamoToMachineList, MTEHatchDynamoMulti.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eDynamoMulti.size(); + } + }, + InputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataInput.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eInputData.size(); + } + }, + OutputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataOutput.class) { + + @Override + public long count(TTMultiblockBase t) { + return t.eOutputData.size(); + } + },; + + private final List<Class<? extends IMetaTileEntity>> mteClasses; + private final IGTHatchAdder<TTMultiblockBase> adder; + + @SafeVarargs + HatchElement(IGTHatchAdder<TTMultiblockBase> adder, Class<? extends IMetaTileEntity>... mteClasses) { + this.mteClasses = Collections.unmodifiableList(Arrays.asList(mteClasses)); + this.adder = adder; + } + + @Override + public List<? extends Class<? extends IMetaTileEntity>> mteClasses() { + return mteClasses; + } + + public IGTHatchAdder<? super TTMultiblockBase> adder() { + return adder; + } + } + + /** + * Check if the computation timeout is still active + * + * @return True if the timeout is still active or false if the machine should fail + */ + protected boolean checkComputationTimeout() { + if (eComputationTimeout > 0) { + return --eComputationTimeout > 0; + } + return false; + } + + // region ModularUI + + @Override + public int getGUIWidth() { + return 198; + } + + @Override + public int getGUIHeight() { + return 192; + } + + @Override + public void bindPlayerInventoryUI(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.bindPlayerInventory(buildContext.getPlayer(), new Pos2d(7, 109), getGUITextureSet().getItemSlot()); + } + + public boolean isPowerPassButtonEnabled() { + return true; + } + + public boolean isSafeVoidButtonEnabled() { + return true; + } + + public boolean isAllowedToWorkButtonEnabled() { + return true; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_TECTECH_LOGO_DARK) + .setSize(18, 18) + .setPos(173, 74)); + } + + private static byte LEDCounter = 0; + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 91)); + } else { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY) + .setPos(4, 4) + .setSize(190, 171)); + } + final SlotWidget inventorySlot = new SlotWidget(new BaseSlot(inventoryHandler, 1) { + + @Override + public int getSlotStackLimit() { + return getInventoryStackLimit(); + } + }); + if (doesBindPlayerInventory()) { + builder + .widget( + inventorySlot.setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_MESH) + .setPos(173, 167)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + .setPos(173, 185) + .setSize(18, 6)); + } + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, inventorySlot); + builder.widget(screenElements.setPos(7, 8)); + + Widget powerPassButton = createPowerPassButton(); + builder.widget(powerPassButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPass, val -> ePowerPass = val)) + .widget(new FakeSyncWidget.BooleanSyncer(() -> ePowerPassCover, val -> ePowerPassCover = val)); + Widget safeVoidButton = createSafeVoidButton(); + builder.widget(safeVoidButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> eSafeVoid, val -> eSafeVoid = val)); + Widget powerSwitchButton = createPowerSwitchButton(); + builder.widget(powerSwitchButton) + .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { + if (val) getBaseMetaTileEntity().enableWorking(); + else getBaseMetaTileEntity().disableWorking(); + })); + + builder.widget(new DrawableWidget() { + + @Override + public void draw(float partialTicks) { + super.draw(partialTicks); + LEDCounter = (byte) ((1 + LEDCounter) % 6); + } + }.setDrawable(TecTechUITextures.PICTURE_PARAMETER_BLANK) + .setPos(5, doesBindPlayerInventory() ? 96 : 176) + .setSize(166, 12)); + for (int hatch = 0; hatch < 10; hatch++) { + for (int param = 0; param < 2; param++) { + int ledID = hatch + param * 10; + buildContext + .addSyncedWindow(LED_WINDOW_BASE_ID + ledID, (player) -> createLEDConfigurationWindow(ledID)); + addParameterLED(builder, hatch, param, true); + addParameterLED(builder, hatch, param, false); + } + } + + if (doesBindPlayerInventory()) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UNCERTAINTY_MONITOR_MULTIMACHINE) + .setPos(173, 96) + .setSize(18, 18)); + for (int i = 0; i < 9; i++) { + final int index = i; + builder.widget(new DrawableWidget().setDrawable(() -> { + UITexture valid = TecTechUITextures.PICTURE_UNCERTAINTY_VALID[index]; + UITexture invalid = TecTechUITextures.PICTURE_UNCERTAINTY_INVALID[index]; + switch (eCertainMode) { + case 1: // ooo oxo ooo + if (index == 4) return eCertainStatus == 0 ? valid : invalid; + break; + case 2: // ooo xox ooo + if (index == 3) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 2) == 0 ? valid : invalid; + break; + case 3: // oxo xox oxo + if (index == 1) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 3) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 5) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 7) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 4: // xox ooo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 8) == 0 ? valid : invalid; + break; + case 5: // xox oxo xox + if (index == 0) return (eCertainStatus & 1) == 0 ? valid : invalid; + if (index == 2) return (eCertainStatus & 2) == 0 ? valid : invalid; + if (index == 4) return (eCertainStatus & 4) == 0 ? valid : invalid; + if (index == 6) return (eCertainStatus & 8) == 0 ? valid : invalid; + if (index == 8) return (eCertainStatus & 16) == 0 ? valid : invalid; + break; + } + return null; + }) + .setPos(174 + (index % 3) * 6, 97 + (index / 3) * 6) + .setSize(4, 4)); + } + builder.widget(new FakeSyncWidget.ByteSyncer(() -> eCertainMode, val -> eCertainMode = val)) + .widget(new FakeSyncWidget.ByteSyncer(() -> eCertainStatus, val -> eCertainStatus = val)); + } + } + + protected ButtonWidget createPowerPassButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isPowerPassButtonEnabled() || ePowerPassCover) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + ePowerPass = !ePowerPass; + if (!isAllowedToWorkButtonEnabled()) { // TRANSFORMER HACK + if (ePowerPass) { + getBaseMetaTileEntity().enableWorking(); + } else { + getBaseMetaTileEntity().disableWorking(); + } + } + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isPowerPassButtonEnabled() && !ePowerPassCover) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_DISABLED); + } else { + if (ePowerPass) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 116 : 140) + .setSize(16, 16); + if (isPowerPassButtonEnabled()) { + button.addTooltip("Power Pass") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + protected ButtonWidget createSafeVoidButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isSafeVoidButtonEnabled()) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + eSafeVoid = !eSafeVoid; + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isSafeVoidButtonEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_DISABLED); + } else { + if (eSafeVoid) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_SAFE_VOID_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 132 : 156) + .setSize(16, 16); + if (isSafeVoidButtonEnabled()) { + button.addTooltip("Safe Void") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + protected ButtonWidget createPowerSwitchButton() { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isAllowedToWorkButtonEnabled()) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (getBaseMetaTileEntity().isAllowedToWork()) { + getBaseMetaTileEntity().disableWorking(); + } else { + getBaseMetaTileEntity().enableWorking(); + } + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_STANDARD_16x16); + if (!isAllowedToWorkButtonEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); + } else { + if (getBaseMetaTileEntity().isAllowedToWork()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF); + } + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, doesBindPlayerInventory() ? 148 : 172) + .setSize(16, 16); + if (isAllowedToWorkButtonEnabled()) { + button.addTooltip("Power Switch") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + } + return (ButtonWidget) button; + } + + private ModularWindow createLEDConfigurationWindow(int ledID) { + return ModularWindow.builder(100, 40) + .setBackground(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos( + (screenSize, mainWindow) -> new Pos2d( + (screenSize.width / 2 - mainWindow.getSize().width / 2) - 110, + (screenSize.height / 2 - mainWindow.getSize().height / 2))) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(85, 3)) + .widget( + new NumericWidget().setGetter(() -> parametrization.iParamsIn[ledID]) + .setSetter(val -> parametrization.iParamsIn[ledID] = val) + .setIntegerOnly(false) + .modifyNumberFormat(format -> format.setMaximumFractionDigits(8)) + .setTextColor(Color.LIGHT_BLUE.normal) + .setTextAlignment(Alignment.CenterLeft) + .setFocusOnGuiOpen(true) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .setPos(5, 20) + .setSize(90, 15)) + .widget( + new TextWidget((ledID % 10) + ":" + (ledID / 10) + ":I").setDefaultColor(Color.WHITE.normal) + .setTextAlignment(Alignment.Center) + .setPos(5, 5)) + .build(); + } + + private void addParameterLED(ModularWindow.Builder builder, int hatch, int param, boolean input) { + final int parameterIndex = hatch + param * 10; + final int posIndex = hatch * 2 + param; + ButtonWidget ledWidget = new ButtonWidget() { + + @Override + public void draw(float partialTicks) { + IDrawable texture = null; + final LedStatus status = input ? parametrization.eParamsInStatus[parameterIndex] + : parametrization.eParamsOutStatus[parameterIndex]; + switch (status) { + case STATUS_WTF: { + int c = LEDCounter; + if (c > 4) { + c = TecTech.RANDOM.nextInt(5); + } + switch (c) { + case 0: + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + case 1: + texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex]; + break; + case 2: + texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex]; + break; + case 3: + texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex]; + break; + case 4: + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + break; + } + case STATUS_WRONG: // fallthrough + if (LEDCounter < 2) { + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + } else if (LEDCounter < 4) { + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + case STATUS_OK: // ok + texture = TecTechUITextures.PICTURE_PARAMETER_GREEN[posIndex]; + break; + case STATUS_TOO_LOW: // too low blink + if (LEDCounter < 3) { + texture = TecTechUITextures.PICTURE_PARAMETER_BLUE[posIndex]; + break; + } + case STATUS_LOW: // too low + texture = TecTechUITextures.PICTURE_PARAMETER_CYAN[posIndex]; + break; + case STATUS_TOO_HIGH: // too high blink + if (LEDCounter < 3) { + texture = TecTechUITextures.PICTURE_PARAMETER_RED[posIndex]; + break; + } + case STATUS_HIGH: // too high + texture = TecTechUITextures.PICTURE_PARAMETER_ORANGE[posIndex]; + break; + case STATUS_NEUTRAL: + if (LEDCounter < 3) { + GL11.glColor4f(.85f, .9f, .95f, .5F); + } else { + GL11.glColor4f(.8f, .9f, 1f, .5F); + } + texture = TecTechUITextures.PICTURE_PARAMETER_GRAY; + break; + case STATUS_UNDEFINED: + if (LEDCounter < 3) { + GL11.glColor4f(.5f, .1f, .15f, .5F); + } else { + GL11.glColor4f(0f, .1f, .2f, .5F); + } + texture = TecTechUITextures.PICTURE_PARAMETER_GRAY; + break; + case STATUS_UNUSED: + default: + // no-op + break; + } + setBackground(texture); + super.draw(partialTicks); + GL11.glColor4f(1f, 1f, 1f, 1f); + } + }.setOnClick((clickData, widget) -> { + if (!widget.isClient() && input + && parametrization.eParamsInStatus[parameterIndex] != LedStatus.STATUS_UNUSED) { + // We don't use CloseAllButMain here in case MB implementation adds their own window + for (int i = 0; i < parametrization.eParamsInStatus.length; i++) { + if (widget.getContext() + .isWindowOpen(LED_WINDOW_BASE_ID + i)) { + widget.getContext() + .closeWindow(LED_WINDOW_BASE_ID + i); + } + } + widget.getContext() + .openSyncedWindow(LED_WINDOW_BASE_ID + parameterIndex); + } + }); + builder.widget(ledWidget.dynamicTooltip(() -> { + if (input) { + return getFullLedDescriptionIn(hatch, param); + } else { + return getFullLedDescriptionOut(hatch, param); + } + }) + .setPos(12 + posIndex * 8, (doesBindPlayerInventory() ? 97 : 177) + (input ? 0 : 1) * 6) + .setSize(6, 4)); + if (input) { + builder + .widget( + new FakeSyncWidget.ByteSyncer( + () -> parametrization.eParamsInStatus[parameterIndex].getOrdinalByte(), + val -> parametrization.eParamsInStatus[parameterIndex] = LedStatus.getStatus(val)) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())) + .widget( + new FakeSyncWidget.DoubleSyncer( + () -> parametrization.iParamsIn[parameterIndex], + val -> parametrization.iParamsIn[parameterIndex] = val) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())); + } else { + builder + .widget( + new FakeSyncWidget.ByteSyncer( + () -> parametrization.eParamsOutStatus[parameterIndex].getOrdinalByte(), + val -> parametrization.eParamsOutStatus[parameterIndex] = LedStatus.getStatus(val)) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())) + .widget( + new FakeSyncWidget.DoubleSyncer( + () -> parametrization.iParamsOut[parameterIndex], + val -> parametrization.iParamsOut[parameterIndex] = val) + .setOnClientUpdate(val -> ledWidget.notifyTooltipChange())); + } + } + + // endregion +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/base/render/TTRenderedExtendedFacingTexture.java b/src/main/java/tectech/thing/metaTileEntity/multi/base/render/TTRenderedExtendedFacingTexture.java new file mode 100644 index 0000000000..8d41fcb0ff --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/base/render/TTRenderedExtendedFacingTexture.java @@ -0,0 +1,25 @@ +package tectech.thing.metaTileEntity.multi.base.render; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.common.render.GTRenderedTexture; + +public class TTRenderedExtendedFacingTexture extends GTRenderedTexture { + + public TTRenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha, boolean glow, + boolean stdOrient, boolean extFacing) { + super(aIcon, aRGBa, allowAlpha, glow, stdOrient, extFacing); + } + + public TTRenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa, boolean aAllowAlpha) { + this(aIcon, aRGBa, aAllowAlpha, false, false, true); + } + + public TTRenderedExtendedFacingTexture(IIconContainer aIcon, short[] aRGBa) { + this(aIcon, aRGBa, true); + } + + public TTRenderedExtendedFacingTexture(IIconContainer aIcon) { + this(aIcon, Dyes._NULL.mRGBa); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEBaseModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEBaseModule.java new file mode 100644 index 0000000000..be81bad80e --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEBaseModule.java @@ -0,0 +1,510 @@ +package tectech.thing.metaTileEntity.multi.godforge_modules; + +import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.processInitialSettings; +import static net.minecraft.util.StatCollector.translateToLocal; +import static tectech.thing.casing.TTCasingsContainer.GodforgeCasings; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.structure.IStructureDefinition; +import com.gtnewhorizon.structurelib.structure.StructureDefinition; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicPositionedColumn; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.GregTechAPI; +import gregtech.api.enums.GTValues; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMaps; +import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTStructureUtility; +import tectech.thing.gui.TecTechUITextures; +import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; + +public class MTEBaseModule extends TTMultiblockBase { + + protected final int tier = getTier(); + protected boolean isConnected = false; + protected double overclockTimeFactor = 2d; + protected boolean isUpgrade83Unlocked = false; + protected boolean isMultiStepPlasmaCapable = false; + protected boolean isMagmatterCapable = false; + private boolean isVoltageConfigUnlocked = false; + protected UUID userUUID; + protected int machineHeat = 0; + protected int overclockHeat = 0; + protected int maximumParallel = 0; + protected int plasmaTier = 0; + protected float processingSpeedBonus = 0; + protected float energyDiscount = 0; + protected long processingVoltage = 2_000_000_000; + protected BigInteger powerTally = BigInteger.ZERO; + protected long recipeTally = 0; + private static Textures.BlockIcons.CustomIcon ScreenON; + private static Textures.BlockIcons.CustomIcon ScreenOFF; + + private static final String STRUCTURE_PIECE_MAIN = "main"; + private static final int VOLTAGE_WINDOW_ID = 9; + private static final int TEXTURE_INDEX = 960; + protected static final String TOOLTIP_BAR = EnumChatFormatting.AQUA + + "--------------------------------------------------------------------------"; + + public MTEBaseModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEBaseModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBaseModule(mName); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && isConnected) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (mEfficiency < 0) mEfficiency = 0; + } + } + + @Override + public RecipeMap<?> getRecipeMap() { + return RecipeMaps.blastFurnaceRecipes; + } + + @Override + public boolean drainEnergyInput(long EUtEffective, long Amperes) { + long EU_drain = EUtEffective * Amperes; + if (EU_drain == 0L) { + return true; + } else { + if (EU_drain > 0L) { + EU_drain = -EU_drain; + } + return addEUToGlobalEnergyMap(userUUID, EU_drain); + } + } + + public void connect() { + isConnected = true; + } + + public void disconnect() { + isConnected = false; + } + + public void setHeat(int heat) { + machineHeat = heat; + } + + public int getHeat() { + return machineHeat; + } + + public void setHeatForOC(int heat) { + overclockHeat = heat; + } + + public int getHeatForOC() { + return overclockHeat; + } + + public void setMaxParallel(int parallel) { + maximumParallel = parallel; + } + + public int getMaxParallel() { + return maximumParallel; + } + + public void setSpeedBonus(float bonus) { + processingSpeedBonus = bonus; + } + + public float getSpeedBonus() { + return processingSpeedBonus; + } + + public void setEnergyDiscount(float discount) { + energyDiscount = discount; + } + + public float getEnergyDiscount() { + return energyDiscount; + } + + public void setUpgrade83(boolean unlocked) { + isUpgrade83Unlocked = unlocked; + } + + public void setOverclockTimeFactor(double factor) { + overclockTimeFactor = factor; + } + + public double getOverclockTimeFactor() { + return overclockTimeFactor; + } + + public void setMultiStepPlasma(boolean isCapable) { + isMultiStepPlasmaCapable = isCapable; + } + + public void setProcessingVoltage(long Voltage) { + processingVoltage = Voltage; + } + + public long getProcessingVoltage() { + return processingVoltage; + } + + public void setMagmatterCapable(boolean isCapable) { + isMagmatterCapable = isCapable; + } + + public float getHeatEnergyDiscount() { + return isUpgrade83Unlocked ? 0.92f : 0.95f; + } + + public void setPlasmaTier(int tier) { + plasmaTier = tier; + } + + public int getPlasmaTier() { + return plasmaTier; + } + + public void setVoltageConfig(boolean unlocked) { + isVoltageConfigUnlocked = unlocked; + } + + public void setPowerTally(BigInteger amount) { + powerTally = amount; + } + + public BigInteger getPowerTally() { + return powerTally; + } + + public void addToPowerTally(BigInteger amount) { + powerTally = powerTally.add(amount); + } + + public void setRecipeTally(long amount) { + recipeTally = amount; + } + + public long getRecipeTally() { + return recipeTally; + } + + public void addToRecipeTally(long amount) { + recipeTally += amount; + } + + public int getTier() { + return tier; + } + + @Override + public long getMaxInputVoltage() { + return GTValues.V[tier]; + } + + @Override + public IStructureDefinition<? extends TTMultiblockBase> getStructure_EM() { + if (this instanceof MTESmeltingModule) { + return getStructureDefinition(GregTechAPI.sBlockCasings5, 12); + } + return getStructureDefinition(GodforgeCasings, 8); + } + + @Override + public void construct(ItemStack stackSize, boolean hintsOnly) { + structureBuild_EM(STRUCTURE_PIECE_MAIN, 3, 3, 0, stackSize, hintsOnly); + } + + @Override + public boolean checkMachine_EM(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + return structureCheck_EM(STRUCTURE_PIECE_MAIN, 3, 3, 0); + } + + @Override + public void onPreTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPreTick(aBaseMetaTileEntity, aTick); + + if (aBaseMetaTileEntity.isServerSide() && (aTick == 1)) { + userUUID = processInitialSettings(aBaseMetaTileEntity); + } + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setPos(4, 4) + .setSize(190, 85)); + final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); + builder.widget( + inventorySlot.setPos(173, 167) + .setBackground(GTUITextures.SLOT_DARK_GRAY)); + + final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + drawTexts(screenElements, inventorySlot); + builder.widget(screenElements); + + buildContext.addSyncedWindow(VOLTAGE_WINDOW_ID, this::createVoltageWindow); + + builder.widget( + TextWidget.dynamicText(this::connectionStatus) + .setDefaultColor(EnumChatFormatting.BLACK) + .setPos(75, 94) + .setSize(100, 10)); + + builder.widget(createPowerSwitchButton(builder)) + .widget(createVoidExcessButton(builder)) + .widget(createInputSeparationButton(builder)) + .widget(createBatchModeButton(builder)) + .widget(createLockToSingleRecipeButton(builder)) + .widget(createVoltageButton(builder)) + .widget(createStructureUpdateButton(builder)); + } + + protected Widget createVoltageButton(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isVoltageConfigUnlocked) { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(VOLTAGE_WINDOW_ID); + } + } + }) + .setPlayClickSound(isVoltageConfigUnlocked) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(GTUITextures.BUTTON_STANDARD); + if (isVoltageConfigUnlocked) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_DISABLED); + } + return ret.toArray(new IDrawable[0]); + }) + .addTooltip(translateToLocal("fog.button.voltageconfig.tooltip.01")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 112) + .setSize(16, 16) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> isVoltageConfigUnlocked, val -> isVoltageConfigUnlocked = val), + builder); + if (!isVoltageConfigUnlocked) { + button.addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.voltageconfig.tooltip.02")); + } + return button; + } + + protected ModularWindow createVoltageWindow(final EntityPlayer player) { + final int WIDTH = 158; + final int HEIGHT = 52; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.BottomRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0) + .subtract(0, 10))); + builder.widget( + TextWidget.localised("gt.blockmachines.multimachine.FOG.voltageinfo") + .setPos(3, 4) + .setSize(150, 20)) + .widget( + new NumericWidget().setSetter(val -> processingVoltage = (long) val) + .setGetter(() -> processingVoltage) + .setBounds(2_000_000_000, Long.MAX_VALUE) + .setDefaultValue(2_000_000_000) + .setScrollValues(1, 4, 64) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(150, 18) + .setPos(4, 25) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .attachSyncer( + new FakeSyncWidget.LongSyncer(this::getProcessingVoltage, this::setProcessingVoltage), + builder)); + return builder.build(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(172, 67)); + } + + @Override + public boolean supportsInputSeparation() { + return true; + } + + @Override + public boolean supportsBatchMode() { + return true; + } + + @Override + public boolean supportsVoidProtection() { + return true; + } + + @Override + public boolean supportsSingleRecipeLocking() { + return true; + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public boolean willExplodeInRain() { + return false; + } + + private static IStructureDefinition<MTEBaseModule> getStructureDefinition(Block coilBlock, int meta) { + return StructureDefinition.<MTEBaseModule>builder() + .addShape( + STRUCTURE_PIECE_MAIN, + new String[][] { { " ", " BBB ", " BBBBB ", " BB~BB ", " BBBBB ", " BBB ", " " }, + { " CCC ", " CFFFC ", "CFFFFFC", "CFFFFFC", "CFFFFFC", " CFFFC ", " CCC " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " E ", " EAE ", " E ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " D ", " ", " ", " " }, + { " ", " ", " ", " G ", " ", " ", " " } }) + .addElement('A', ofBlock(coilBlock, meta)) + .addElement( + 'B', + GTStructureUtility + .ofHatchAdderOptional(MTEBaseModule::addClassicToMachineList, TEXTURE_INDEX, 1, GodforgeCasings, 0)) + .addElement('C', ofBlock(GodforgeCasings, 0)) + .addElement('D', ofBlock(GodforgeCasings, 1)) + .addElement('E', ofBlock(GodforgeCasings, 2)) + .addElement('F', ofBlock(GodforgeCasings, 3)) + .addElement('G', ofBlock(GodforgeCasings, 4)) + .build(); + } + + private Text connectionStatus() { + String status = EnumChatFormatting.RED + + translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus.false"); + if (isConnected) { + status = EnumChatFormatting.GREEN + translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus.true"); + } + return new Text(translateToLocal("gt.blockmachines.multimachine.FOG.modulestatus") + " " + status); + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setBoolean("isConnected", isConnected); + NBT.setBoolean("isVoltageConfigUnlocked", isVoltageConfigUnlocked); + NBT.setLong("processingVoltage", processingVoltage); + NBT.setLong("recipeTally", recipeTally); + NBT.setByteArray("powerTally", powerTally.toByteArray()); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + isConnected = NBT.getBoolean("isConnected"); + isVoltageConfigUnlocked = NBT.getBoolean("isVoltageConfigUnlocked"); + processingVoltage = NBT.getLong("processingVoltage"); + recipeTally = NBT.getLong("recipeTally"); + powerTally = new BigInteger(NBT.getByteArray("powerTally")); + super.loadNBTData(NBT); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + ScreenON = new Textures.BlockIcons.CustomIcon("iconsets/GODFORGE_MODULE_ACTIVE"); + ScreenOFF = new Textures.BlockIcons.CustomIcon("iconsets/SCREEN_OFF"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + if (side == facing) { + if (aActive) return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX), + TextureFactory.builder() + .addIcon(ScreenON) + .extFacing() + .build(), + TextureFactory.builder() + .addIcon(ScreenON) + .extFacing() + .glow() + .build() }; + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX), TextureFactory.builder() + .addIcon(ScreenOFF) + .extFacing() + .build() }; + } + return new ITexture[] { Textures.BlockIcons.getCasingTextureForId(TEXTURE_INDEX) }; + } + + @Override + public boolean getDefaultHasMaintenanceChecks() { + return false; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEExoticModule.java new file mode 100644 index 0000000000..c94549a575 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEExoticModule.java @@ -0,0 +1,547 @@ +package tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTRecipeBuilder.INGOTS; +import static gregtech.api.util.GTRecipeBuilder.SECONDS; +import static gregtech.api.util.GTUtility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; +import static net.minecraft.util.StatCollector.translateToLocal; +import static tectech.loader.recipe.Godforge.exoticModuleMagmatterItemMap; +import static tectech.loader.recipe.Godforge.exoticModulePlasmaFluidMap; +import static tectech.loader.recipe.Godforge.exoticModulePlasmaItemMap; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.TierEU; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.RecipeMapBackend; +import gregtech.api.recipe.RecipeMapBuilder; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import tectech.recipe.TecTechRecipeMaps; +import tectech.util.CommonValues; +import tectech.util.GodforgeMath; + +public class MTEExoticModule extends MTEBaseModule { + + private int numberOfFluids = 0; + private int numberOfItems = 0; + private long wirelessEUt = 0; + private long EUt = 0; + private long actualParallel = 0; + private boolean recipeInProgress = false; + private boolean magmatterMode = false; + private FluidStack[] randomizedFluidInput = new FluidStack[] {}; + private ItemStack[] randomizedItemInput = new ItemStack[] {}; + List<FluidStack> inputPlasmas = new ArrayList<>(); + private GTRecipe plasmaRecipe = null; + private static RecipeMap<RecipeMapBackend> tempRecipeMap = RecipeMapBuilder.of("bye") + .maxIO(0, 0, 7, 2) + .disableRegisterNEI() + .build(); + private static final RecipeMap<RecipeMapBackend> emptyRecipeMap = RecipeMapBuilder.of("hey") + .maxIO(0, 0, 7, 2) + .disableRegisterNEI() + .build(); + private static final int NUMBER_OF_INPUTS = 7; + + public MTEExoticModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEExoticModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEExoticModule(mName); + } + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected Stream<GTRecipe> findRecipeMatches(@Nullable RecipeMap<?> map) { + if (!recipeInProgress) { + actualParallel = getMaxParallel(); + FluidStack outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000 * actualParallel); + tempRecipeMap = emptyRecipeMap; + if (magmatterMode) { + randomizedItemInput = getRandomItemInputs(exoticModuleMagmatterItemMap, 1); + numberOfItems = 1; + numberOfFluids = 2; + int timeAmount = GodforgeMath.getRandomIntInRange(1, 50); + int spaceAmount = GodforgeMath.getRandomIntInRange(51, 100); + randomizedFluidInput = new FluidStack[] { MaterialsUEVplus.Time.getMolten(timeAmount * 1000L), + MaterialsUEVplus.Space.getMolten(spaceAmount * 1000L) }; + inputPlasmas = new ArrayList<>( + Arrays.asList( + convertItemToPlasma(randomizedItemInput, (spaceAmount - timeAmount) * actualParallel))); + inputPlasmas.add(MaterialsUEVplus.Time.getMolten(timeAmount * actualParallel)); + inputPlasmas.add(MaterialsUEVplus.Space.getMolten(spaceAmount * actualParallel)); + outputFluid = MaterialsUEVplus.MagMatter.getMolten(144 * actualParallel); + } else { + numberOfFluids = GodforgeMath.getRandomIntInRange(0, NUMBER_OF_INPUTS); + numberOfItems = NUMBER_OF_INPUTS - numberOfFluids; + randomizedFluidInput = getRandomFluidInputs(exoticModulePlasmaFluidMap, numberOfFluids); + randomizedItemInput = getRandomItemInputs(exoticModulePlasmaItemMap, numberOfItems); + + if (numberOfFluids != 0) { + for (FluidStack fluidStack : randomizedFluidInput) { + fluidStack.amount = 1000 * GodforgeMath.getRandomIntInRange(1, 64); + } + } + + if (numberOfItems != 0) { + for (ItemStack itemStack : randomizedItemInput) { + itemStack.stackSize = GodforgeMath.getRandomIntInRange(1, 64); + } + } + + inputPlasmas = new ArrayList<>( + Arrays.asList(convertItemToPlasma(randomizedItemInput, actualParallel))); + inputPlasmas.addAll(Arrays.asList(convertFluidToPlasma(randomizedFluidInput, actualParallel))); + } + plasmaRecipe = new GTRecipe( + false, + null, + null, + null, + null, + inputPlasmas.toArray(new FluidStack[0]), + new FluidStack[] { outputFluid }, + 10 * SECONDS * (int) actualParallel, + (int) TierEU.RECIPE_MAX, + 0); + + tempRecipeMap.add(plasmaRecipe); + } + return tempRecipeMap.getAllRecipes() + .parallelStream(); + } + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + if (!recipeInProgress) { + maxParallel = 1; + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + tempRecipeMap = emptyRecipeMap; + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + + if (numberOfFluids != 0) { + for (FluidStack fluidStack : randomizedFluidInput) { + dumpFluid( + mOutputHatches, + new FluidStack( + fluidStack.getFluid(), + (int) (fluidStack.amount / 1000 * actualParallel)), + false); + } + } + + if (numberOfItems != 0) { + long multiplier = actualParallel; + if (magmatterMode) { + multiplier = 1; + } + for (ItemStack itemStack : randomizedItemInput) { + int stacksize = (int) (itemStack.stackSize * multiplier); + ItemStack tmpItem = itemStack.copy(); + // split itemStacks > 64 + while (stacksize >= 64) { + tmpItem.stackSize = 64; + addOutput(tmpItem); + stacksize -= 64; + } + tmpItem.stackSize = stacksize; + addOutput(tmpItem); + + } + } + + recipeInProgress = true; + } + if (new HashSet<>(Arrays.asList(inputFluids)).containsAll(inputPlasmas)) { + return CheckRecipeResultRegistry.SUCCESSFUL; + } + return SimpleCheckRecipeResult.ofFailure("waiting_for_inputs"); + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + EUt = calculatedEut; + setCalculatedEut(0); + tempRecipeMap = emptyRecipeMap; + recipeInProgress = false; + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public RecipeMap<?> getRecipeMap() { + return TecTechRecipeMaps.godforgeExoticMatterRecipes; + } + + private FluidStack[] getRandomFluidInputs(HashMap<FluidStack, Integer> fluidMap, int numberOfFluids) { + int cumulativeWeight = 0; + + List<Map.Entry<FluidStack, Integer>> fluidEntryList = new ArrayList<>(fluidMap.entrySet()); + + List<Integer> cumulativeWeights = new ArrayList<>(); + for (Map.Entry<FluidStack, Integer> entry : fluidEntryList) { + cumulativeWeight += entry.getValue(); + cumulativeWeights.add(cumulativeWeight); + } + + List<FluidStack> pickedFluids = new ArrayList<>(); + for (int i = 0; i < numberOfFluids; i++) { + int randomWeight = GodforgeMath.getRandomIntInRange(1, cumulativeWeight); + // Find the corresponding FluidStack based on randomWeight + for (int j = 0; j < cumulativeWeights.size(); j++) { + if (randomWeight <= cumulativeWeights.get(j)) { + FluidStack pickedFluid = fluidEntryList.get(j) + .getKey(); + // prevent duplicates + if (pickedFluids.contains(pickedFluid)) { + i--; + break; + } + pickedFluids.add(pickedFluid); + break; + } + } + } + + return pickedFluids.toArray(new FluidStack[0]); + + } + + private ItemStack[] getRandomItemInputs(HashMap<ItemStack, Integer> itemMap, int numberOfItems) { + int cumulativeWeight = 0; + + List<Map.Entry<ItemStack, Integer>> itemEntryList = new ArrayList<>(itemMap.entrySet()); + + List<Integer> cumulativeWeights = new ArrayList<>(); + for (Map.Entry<ItemStack, Integer> entry : itemEntryList) { + cumulativeWeight += entry.getValue(); + cumulativeWeights.add(cumulativeWeight); + } + + List<ItemStack> pickedItems = new ArrayList<>(); + for (int i = 0; i < numberOfItems; i++) { + int randomWeight = GodforgeMath.getRandomIntInRange(1, cumulativeWeight); + // Find the corresponding ItemStack based on randomWeight + for (int j = 0; j < cumulativeWeights.size(); j++) { + if (randomWeight <= cumulativeWeights.get(j)) { + ItemStack pickedItem = itemEntryList.get(j) + .getKey(); + // prevent duplicates + if (pickedItems.contains(pickedItem)) { + i--; + break; + } + pickedItems.add(pickedItem); + break; + } + } + } + return pickedItems.toArray(new ItemStack[0]); + + } + + private FluidStack[] convertItemToPlasma(ItemStack[] items, long multiplier) { + List<FluidStack> plasmas = new ArrayList<>(); + + for (ItemStack itemStack : items) { + String dict = OreDictionary.getOreName(OreDictionary.getOreIDs(itemStack)[0]); + // substring 8 because dustTiny is 8 characters long and there is no other possible oreDict + String strippedOreDict = dict.substring(8); + plasmas.add( + FluidRegistry.getFluidStack( + "plasma." + strippedOreDict.toLowerCase(), + (int) (INGOTS * multiplier * itemStack.stackSize))); + } + + return plasmas.toArray(new FluidStack[0]); + } + + private FluidStack[] convertFluidToPlasma(FluidStack[] fluids, long multiplier) { + List<FluidStack> plasmas = new ArrayList<>(); + + for (FluidStack fluidStack : fluids) { + String[] fluidName = fluidStack.getUnlocalizedName() + .split("\\."); + plasmas.add( + FluidRegistry.getFluidStack( + "plasma." + fluidName[fluidName.length - 1], + (int) (multiplier * fluidStack.amount))); + } + + return plasmas.toArray(new FluidStack[0]); + } + + @Override + public boolean supportsSingleRecipeLocking() { + return false; + } + + @Override + public boolean supportsBatchMode() { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + + NBT.setBoolean("recipeInProgress", recipeInProgress); + NBT.setBoolean("magmatterMode", magmatterMode); + + // Store damage values/stack sizes of input plasmas + NBTTagCompound fluidStackListNBTTag = new NBTTagCompound(); + fluidStackListNBTTag.setLong("numberOfPlasmas", inputPlasmas.size()); + + int indexFluids = 0; + for (FluidStack fluidStack : inputPlasmas) { + // Save fluid amount to NBT + fluidStackListNBTTag.setLong(indexFluids + "fluidAmount", fluidStack.amount); + + // Save FluidStack to NBT + NBT.setTag(indexFluids + "fluidStack", fluidStack.writeToNBT(new NBTTagCompound())); + + indexFluids++; + } + + NBT.setTag("inputPlasmas", fluidStackListNBTTag); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + + recipeInProgress = NBT.getBoolean("recipeInProgress"); + magmatterMode = NBT.getBoolean("magmatterMode"); + + // Load damage values/fluid amounts of input plasmas and convert back to fluids + NBTTagCompound tempFluidTag = NBT.getCompoundTag("inputPlasmas"); + + // Iterate over all stored fluids + for (int indexFluids = 0; indexFluids < tempFluidTag.getLong("numberOfPlasmas"); indexFluids++) { + + // Load fluid amount from NBT + int fluidAmount = tempFluidTag.getInteger(indexFluids + "fluidAmount"); + + // Load FluidStack from NBT + FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(NBT.getCompoundTag(indexFluids + "fluidStack")); + + inputPlasmas.add(new FluidStack(fluidStack, fluidAmount)); + } + FluidStack outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000); + + if (magmatterMode) { + outputFluid = MaterialsUEVplus.MagMatter.getMolten(144); + } + + tempRecipeMap.add( + new GTRecipe( + false, + null, + null, + null, + null, + inputPlasmas.toArray(new FluidStack[0]), + new FluidStack[] { outputFluid }, + 10 * SECONDS, + (int) TierEU.RECIPE_MAX, + 0)); + + super.loadNBTData(NBT); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(magmatterSwitch(builder)); + + } + + protected ButtonWidget magmatterSwitch(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + if (isMagmatterCapable) { + magmatterMode = !magmatterMode; + } + }) + .setPlayClickSound(isMagmatterCapable) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (isMagmatterModeOn()) { + ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); + if (isMagmatterCapable) { + ret.add(GTUITextures.OVERLAY_BUTTON_CHECKMARK); + } else { + ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); + } + } else { + ret.add(GTUITextures.BUTTON_STANDARD); + if (isMagmatterCapable) { + ret.add(GTUITextures.OVERLAY_BUTTON_CROSS); + } else { + ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); + } + } + if (!isMagmatterCapable) { + ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isMagmatterModeOn, this::setMagmatterMode), builder) + .addTooltip(translateToLocal("fog.button.magmattermode.tooltip.01")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91) + .setSize(16, 16) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(() -> isMagmatterCapable, this::setMagmatterCapable), + builder); + if (!isMagmatterCapable) { + button.addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.magmattermode.tooltip.02")); + } + return (ButtonWidget) button; + } + + public boolean isMagmatterModeOn() { + return magmatterMode; + } + + private void setMagmatterMode(boolean enabled) { + magmatterMode = enabled; + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Exotic Matter Producer") + .addInfo("Controller block for the Heliofusion Exoticizer, a module of the Godforge.") + .addInfo("Must be part of a Godforge to function.") + .addInfo("Used for ultra high temperature matter degeneration.") + .addInfo(TOOLTIP_BAR) + .addInfo("The fourth and final module of the Godforge, this module breaks apart the very") + .addInfo("building blocks of matter, producing exotic mixtures in the process. Quark-Gluon Plasma") + .addInfo("can be manufactured right away, but production of Magnetic Monopole Matter (Magmatter)") + .addInfo("requires a fully upgraded Godforge.") + .addInfo("This module is specialized towards acquisition of unique materials.") + .addInfo(TOOLTIP_BAR) + .beginStructureBlock(7, 7, 13, false) + .addStructureInfo("The structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Boundless Gravitationally Severed Structure Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Harmonic Phonon Transmission Conduit") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Celestial Matter Guidance Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEMoltenModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEMoltenModule.java new file mode 100644 index 0000000000..5cdb0bc95c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEMoltenModule.java @@ -0,0 +1,244 @@ +package tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.util.GTOreDictUnificator.getAssociation; +import static gregtech.api.util.GTRecipeBuilder.BUCKETS; +import static gregtech.api.util.GTRecipeBuilder.INGOTS; +import static gregtech.api.util.GTUtility.formatNumbers; +import static gregtech.api.util.ParallelHelper.addFluidsLong; +import static gregtech.api.util.ParallelHelper.addItemsLong; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; + +import javax.annotation.Nonnull; + +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.jetbrains.annotations.NotNull; + +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.objects.ItemData; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import gregtech.api.util.ParallelHelper; +import tectech.util.CommonValues; + +public class MTEMoltenModule extends MTEBaseModule { + + private long EUt = 0; + private int currentParallel = 0; + + public MTEMoltenModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEMoltenModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEMoltenModule(mName); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + private FluidStack[] meltableItems; + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + + if (recipe.mSpecialValue > getHeat()) { + return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + + meltableItems = new FluidStack[recipe.mOutputs.length]; + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null) { + continue; + } + // if this is null it has to be a gt++ material + ItemData data = getAssociation(item); + Materials mat = data == null ? null : data.mMaterial.mMaterial; + if (mat != null) { + if (mat.mStandardMoltenFluid != null) { + meltableItems[i] = mat.getMolten(INGOTS); + } else if (mat.mFluid != null) { + meltableItems[i] = mat.getFluid(BUCKETS); + } + } else { + String dict = OreDictionary.getOreName(OreDictionary.getOreIDs(item)[0]); + // substring 8 because ingotHot is 8 characters long + String strippedOreDict = dict.substring(8); + meltableItems[i] = FluidRegistry + .getFluidStack("molten." + strippedOreDict.toLowerCase(), INGOTS); + } + } + + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setRecipeHeat(recipe.mSpecialValue) + .setHeatOC(true) + .setHeatDiscount(true) + .setMachineHeat(getHeatForOC()) + .setHeatDiscountMultiplier(getHeatEnergyDiscount()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected ParallelHelper createParallelHelper(@Nonnull GTRecipe recipe) { + return super.createParallelHelper(recipe).setCustomItemOutputCalculation(currentParallel -> { + ArrayList<ItemStack> outputItems = new ArrayList<>(); + for (int i = 0; i < recipe.mOutputs.length; i++) { + ItemStack item = recipe.getOutput(i); + if (item == null || meltableItems[i] != null) { + continue; + } + ItemStack itemToAdd = item.copy(); + addItemsLong(outputItems, itemToAdd, (long) item.stackSize * currentParallel); + } + return outputItems.toArray(new ItemStack[0]); + }) + .setCustomFluidOutputCalculation(currentParallel -> { + ArrayList<FluidStack> fluids = new ArrayList<>(); + + for (int i = 0; i < recipe.mOutputs.length; i++) { + FluidStack fluid = meltableItems[i]; + if (fluid == null) { + continue; + } + FluidStack fluidToAdd = fluid.copy(); + long fluidAmount = (long) fluidToAdd.amount * recipe.mOutputs[i].stackSize + * currentParallel; + addFluidsLong(fluids, fluidToAdd, fluidAmount); + } + + for (int i = 0; i < recipe.mFluidOutputs.length; i++) { + FluidStack fluid = recipe.getFluidOutput(i); + if (fluid == null) { + continue; + } + FluidStack fluidToAdd = fluid.copy(); + addFluidsLong(fluids, fluidToAdd, (long) fluidToAdd.amount * currentParallel); + } + return fluids.toArray(new FluidStack[0]); + }); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Heat Capacity: " + RESET + formatNumbers(getHeat())); + str.add(YELLOW + "Effective Heat Capacity: " + RESET + formatNumbers(getHeatForOC())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Blast Smelter") + .addInfo("Controller block for the Helioflux Meltig Core, a module of the Godforge.") + .addInfo("Must be part of a Godforge to function.") + .addInfo("Used for high temperature material liquefaction.") + .addInfo(TOOLTIP_BAR) + .addInfo("The second module of the Godforge, this module melts materials directly into") + .addInfo("their liquid form. If an output material does not have a liquid form, it will be output") + .addInfo("as a regular solid instead.") + .addInfo("This module is specialized towards parallel processing.") + .addInfo(TOOLTIP_BAR) + .beginStructureBlock(7, 7, 13, false) + .addStructureInfo("The structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Boundless Gravitationally Severed Structure Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Harmonic Phonon Transmission Conduit") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Celestial Matter Guidance Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEPlasmaModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEPlasmaModule.java new file mode 100644 index 0000000000..806f3f7f04 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEPlasmaModule.java @@ -0,0 +1,245 @@ +package tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTUtility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Objects; + +import javax.annotation.Nonnull; + +import net.minecraft.util.EnumChatFormatting; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; + +import gregtech.api.enums.SoundResource; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +import gregtech.api.recipe.RecipeMap; +import gregtech.api.recipe.check.CheckRecipeResult; +import gregtech.api.recipe.check.CheckRecipeResultRegistry; +import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import tectech.recipe.TecTechRecipeMaps; +import tectech.util.CommonValues; + +public class MTEPlasmaModule extends MTEBaseModule { + + private long EUt = 0; + private int currentParallel = 0; + private boolean debug = true; + private int inputMaxParallel = 0; + + public MTEPlasmaModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEPlasmaModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEPlasmaModule(mName); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + if (recipe.mSpecialValue > getPlasmaTier() + || Objects.equals(recipe.mSpecialItems.toString(), "true") && !isMultiStepPlasmaCapable) { + return SimpleCheckRecipeResult.ofFailure("missing_upgrades"); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + wirelessEUt = (long) recipe.mEUt * maxParallel; + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + addToRecipeTally(calculatedParallels); + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + if (debug) { + builder.widget(createTestButton(builder)) + .widget(createTestButton2()) + .widget(createTestButton3()); + } + } + + protected Widget createTestButton(IWidgetBuilder<?> builder) { + return new ButtonWidget() + .setOnClick((clickData, widget) -> isMultiStepPlasmaCapable = !isMultiStepPlasmaCapable) + .setPlayClickSoundResource( + () -> isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation + : SoundResource.GUI_BUTTON_DOWN.resourceLocation) + .setBackground(() -> { + if (isMultiStepPlasmaCapable) { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED, + GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; + } else { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD, + GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isAllowedToWork, val -> { + if (val) enableWorking(); + else disableWorking(); + }), builder) + .addTooltip("multi-step") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 100) + .setSize(16, 16); + } + + protected Widget createTestButton2() { + return new TextFieldWidget().setSetterInt(this::setPlasmaTier) + .setGetterInt(this::getPlasmaTier) + .setNumbers(0, 2) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("fusion tier") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(16, 16) + .setPos(174, 80) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + } + + protected Widget createTestButton3() { + return new TextFieldWidget().setSetterInt(val -> inputMaxParallel = val) + .setGetterInt(() -> inputMaxParallel) + .setNumbers(0, Integer.MAX_VALUE) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("parallel") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(70, 16) + .setPos(174, 60) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + } + + @Override + public RecipeMap<?> getRecipeMap() { + return TecTechRecipeMaps.godforgePlasmaRecipes; + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Plasma Fabricator") + .addInfo("Controller block for the Heliothermal Plasma Fabricator, a module of the Godforge.") + .addInfo("Must be part of a Godforge to function.") + .addInfo("Used for extreme temperature matter ionization.") + .addInfo(TOOLTIP_BAR) + .addInfo("The third module of the Godforge, this module infuses materials with extreme amounts") + .addInfo("of heat, ionizing and turning them into plasma directly. Not all plasmas can be produced") + .addInfo("right away, some of them require certain upgrades to be unlocked.") + .addInfo("This module is specialized towards energy and overclock efficiency.") + .addInfo(TOOLTIP_BAR) + .beginStructureBlock(7, 7, 13, false) + .addStructureInfo("The structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Boundless Gravitationally Severed Structure Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Harmonic Phonon Transmission Conduit") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Celestial Matter Guidance Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTESmeltingModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTESmeltingModule.java new file mode 100644 index 0000000000..8c45060653 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTESmeltingModule.java @@ -0,0 +1,245 @@ +package tectech.thing.metaTileEntity.multi.godforge_modules; + +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static gregtech.api.util.GTUtility.formatNumbers; +import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; +import static gregtech.common.misc.WirelessNetworkManager.getUserEU; +import static net.minecraft.util.EnumChatFormatting.GREEN; +import static net.minecraft.util.EnumChatFormatting.RED; +import static net.minecraft.util.EnumChatFormatting.RESET; +import static net.minecraft.util.EnumChatFormatting.YELLOW; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import javax.annotation.Nonnull; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; + +import org.jetbrains.annotations.NotNull; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.ProcessingLogic; +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.util.GTRecipe; +import gregtech.api.util.MultiblockTooltipBuilder; +import gregtech.api.util.OverclockCalculator; +import tectech.util.CommonValues; + +public class MTESmeltingModule extends MTEBaseModule { + + private long EUt = 0; + private long currentParallel = 0; + private boolean furnaceMode = false; + + public MTESmeltingModule(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTESmeltingModule(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTESmeltingModule(mName); + } + + @Override + public RecipeMap<?> getRecipeMap() { + return furnaceMode ? RecipeMaps.furnaceRecipes : RecipeMaps.blastFurnaceRecipes; + } + + @Nonnull + @Override + public Collection<RecipeMap<?>> getAvailableRecipeMaps() { + return Arrays.asList(RecipeMaps.blastFurnaceRecipes, RecipeMaps.furnaceRecipes); + } + + long wirelessEUt = 0; + + @Override + protected ProcessingLogic createProcessingLogic() { + return new ProcessingLogic() { + + @NotNull + @Override + protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + + if (recipe.mSpecialValue > getHeat()) { + return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); + } + + wirelessEUt = (long) recipe.mEUt * getMaxParallel(); + if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { + return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); + } + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @NotNull + @Override + protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { + return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); + } + addToPowerTally( + BigInteger.valueOf(calculatedEut) + .multiply(BigInteger.valueOf(duration))); + if (!furnaceMode) { + addToRecipeTally(calculatedParallels); + } + currentParallel = calculatedParallels; + EUt = calculatedEut; + setCalculatedEut(0); + return CheckRecipeResultRegistry.SUCCESSFUL; + } + + @Nonnull + @Override + protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) + .setRecipeHeat(recipe.mSpecialValue) + .setHeatOC(true) + .setHeatDiscount(true) + .setMachineHeat(getHeatForOC()) + .setHeatDiscountMultiplier(getHeatEnergyDiscount()) + .setDurationDecreasePerOC(getOverclockTimeFactor()); + } + }; + } + + @Override + protected void setProcessingLogicPower(ProcessingLogic logic) { + logic.setAvailableVoltage(Long.MAX_VALUE); + logic.setAvailableAmperage(Integer.MAX_VALUE); + logic.setAmperageOC(false); + logic.setMaxParallel(getMaxParallel()); + logic.setSpeedBonus(getSpeedBonus()); + logic.setEuModifier(getEnergyDiscount()); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + super.addUIWidgets(builder, buildContext); + builder.widget(furnaceSwitch(builder)); + + } + + protected ButtonWidget furnaceSwitch(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> furnaceMode = !furnaceMode) + .setPlayClickSound(true) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + if (isFurnaceModeOn()) { + ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); + ret.add(GTUITextures.OVERLAY_BUTTON_CHECKMARK); + } else { + ret.add(GTUITextures.BUTTON_STANDARD); + ret.add(GTUITextures.OVERLAY_BUTTON_CROSS); + + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isFurnaceModeOn, this::setFurnaceMode), builder) + .addTooltip(translateToLocal("fog.button.furnacemode.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(174, 91) + .setSize(16, 16); + return (ButtonWidget) button; + } + + private boolean isFurnaceModeOn() { + return furnaceMode; + } + + private void setFurnaceMode(boolean enabled) { + furnaceMode = enabled; + } + + @Override + public void saveNBTData(NBTTagCompound NBT) { + NBT.setBoolean("furnaceMode", furnaceMode); + super.saveNBTData(NBT); + } + + @Override + public void loadNBTData(final NBTTagCompound NBT) { + furnaceMode = NBT.getBoolean("furnaceMode"); + super.loadNBTData(NBT); + } + + @Override + public String[] getInfoData() { + ArrayList<String> str = new ArrayList<>(); + str.add( + "Progress: " + GREEN + + formatNumbers(mProgresstime / 20) + + RESET + + " s / " + + YELLOW + + formatNumbers(mMaxProgresstime / 20) + + RESET + + " s"); + str.add("Currently using: " + RED + formatNumbers(EUt) + RESET + " EU/t"); + str.add(YELLOW + "Max Parallel: " + RESET + formatNumbers(getMaxParallel())); + str.add(YELLOW + "Current Parallel: " + RESET + formatNumbers(currentParallel)); + str.add(YELLOW + "Heat Capacity: " + RESET + formatNumbers(getHeat())); + str.add(YELLOW + "Effective Heat Capacity: " + RESET + formatNumbers(getHeatForOC())); + str.add(YELLOW + "Recipe time multiplier: " + RESET + formatNumbers(getSpeedBonus())); + str.add(YELLOW + "Energy multiplier: " + RESET + formatNumbers(getEnergyDiscount())); + str.add(YELLOW + "Recipe time divisor per non-perfect OC: " + RESET + formatNumbers(getOverclockTimeFactor())); + return str.toArray(new String[0]); + } + + @Override + public MultiblockTooltipBuilder createTooltip() { + final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); + tt.addMachineType("Blast Furnace, Furnace") + .addInfo("Controller block for the Helioflare Power Forge, a module of the Godforge.") + .addInfo("Must be part of a Godforge to function.") + .addInfo("Used for basic smelting operations at various temperatures.") + .addInfo(TOOLTIP_BAR) + .addInfo("As the first of the Godforge modules, this module performs the most basic") + .addInfo("thermal processing, namely smelting materials identically to a furnace or blast furnace.") + .addInfo("The desired method of processing can be selected in the gui.") + .addInfo("This module is specialized towards speed and high heat levels.") + .addInfo(TOOLTIP_BAR) + .beginStructureBlock(7, 7, 13, false) + .addStructureInfo("The structure is too complex! See schematic for details.") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo( + EnumChatFormatting.GOLD + "20" + + EnumChatFormatting.GRAY + + " Boundless Gravitationally Severed Structure Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Hypogen Coil Block") + .addStructureInfo( + EnumChatFormatting.GOLD + "5" + EnumChatFormatting.GRAY + " Celestial Matter Guidance Casing") + .addStructureInfo(EnumChatFormatting.GOLD + "1" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") + .toolTipFinisher(CommonValues.GODFORGE_MARK); + return tt; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockData.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockData.java new file mode 100644 index 0000000000..803f38eda5 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockData.java @@ -0,0 +1,52 @@ +package tectech.thing.metaTileEntity.pipe; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class MTEPipeBlockData extends MTEPipeData { + + public MTEPipeBlockData(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEPipeBlockData(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEPipeBlockData(mName); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + } + + @Override + public float getThickNess() { + return 1f; + } + + @Override + public float getExplosionResistance(ForgeDirection side) { + return 1000.0f; + } + + @Override + public String[] getDescription() { + return ArrayUtils.add( + super.getDescription(), + EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.desc.4")); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockEnergy.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockEnergy.java new file mode 100644 index 0000000000..20cc2af16e --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeBlockEnergy.java @@ -0,0 +1,52 @@ +package tectech.thing.metaTileEntity.pipe; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; + +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class MTEPipeBlockEnergy extends MTEPipeEnergy { + + public MTEPipeBlockEnergy(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEPipeBlockEnergy(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEPipeBlockEnergy(mName); + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + return AxisAlignedBB.getBoundingBox(aX, aY, aZ, aX + 1, aY + 1, aZ + 1); + } + + @Override + public float getThickNess() { + return 1f; + } + + @Override + public float getExplosionResistance(ForgeDirection side) { + return 1000.0f; + } + + @Override + public String[] getDescription() { + return ArrayUtils.add( + super.getDescription(), + EnumChatFormatting.DARK_AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.desc.4")); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeData.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeData.java new file mode 100644 index 0000000000..cd9d583c1b --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeData.java @@ -0,0 +1,312 @@ +package tectech.thing.metaTileEntity.pipe; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.GTClient; +import tectech.TecTech; +import tectech.loader.NetworkDispatcher; +import tectech.mechanics.pipe.IActivePipe; +import tectech.mechanics.pipe.IConnectsToDataPipe; +import tectech.mechanics.pipe.PipeActivityMessage; +import tectech.util.CommonValues; + +/** + * Created by Tec on 26.02.2017. + */ +public class MTEPipeData extends MetaPipeEntity implements IConnectsToDataPipe, IActivePipe { + + private static Textures.BlockIcons.CustomIcon EMpipe; + private static Textures.BlockIcons.CustomIcon EMbar, EMbarActive; + public byte connectionCount = 0; + + private boolean active; + + public MTEPipeData(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + } + + public MTEPipeData(String aName) { + super(aName, 0); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEPipeData(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_DATA"); + EMbar = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR"); + EMbarActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_BAR_ACTIVE"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { new GTRenderedTexture(EMpipe), + new GTRenderedTexture( + getActive() ? EMbarActive : EMbar, + Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) }; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + active = nbtTagCompound.getBoolean("eActive"); + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive", active); + } + + @Override + public boolean renderInside(ForgeDirection side) { + return false; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.datastream.desc.0"), // Advanced + // data + // transmission + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.datastream.desc.1"), // Don't stare at the beam! + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.datastream.desc.2"), // Must be + // painted to + // work + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.datastream.desc.3") // Do not cross or + // split + }; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + onPostTick(aBaseMetaTileEntity, 31); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + if (TecTech.RANDOM.nextInt(15) == 0) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + if (active) { + active = false; + } + mConnections = 0; + connectionCount = 0; + byte myColor = aBaseMetaTileEntity.getColorization(); + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final ForgeDirection oppositeSide = side.getOpposite(); + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IConnectsToDataPipe) { + byte tColor = ((IConnectsToDataPipe) tTileEntity).getColorization(); + if (tColor != myColor) { + continue; + } + if (((IConnectsToDataPipe) tTileEntity).canConnectData(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } else if (tTileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) tTileEntity).getMetaTileEntity(); + if (meta instanceof IConnectsToDataPipe) { + byte tColor = ((IConnectsToDataPipe) meta).getColorization(); + if (tColor != myColor) { + continue; + } + if (((IConnectsToDataPipe) meta).canConnectData(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } + } + } + } + } else if (aBaseMetaTileEntity.isClientSide() && GTClient.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + @Override + public boolean canConnectData(ForgeDirection side) { + return true; + } + + @Override + public IConnectsToDataPipe getNext(IConnectsToDataPipe source) { + if (connectionCount != 2) { + return null; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if ((mConnections & 1 << side.ordinal()) == 0) { + continue; // if not connected continue + } + TileEntity next = getBaseMetaTileEntity().getTileEntityAtSide(side); + if (next instanceof IConnectsToDataPipe && next != source) { + if (((IConnectsToDataPipe) next).isDataInputFacing(side.getOpposite())) { + return (IConnectsToDataPipe) next; + } + } else if (next instanceof IGregTechTileEntity) { + IMetaTileEntity meta = ((IGregTechTileEntity) next).getMetaTileEntity(); + if (meta instanceof IConnectsToDataPipe connecsToPipe && meta != source) { + if (meta instanceof MTEPipeData pipeData && pipeData.connectionCount == 2) { + pipeData.markUsed(); + return connecsToPipe; + } + if (connecsToPipe.isDataInputFacing(side.getOpposite())) { + return connecsToPipe; + } + } + } + } + return null; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + float tSpace = (1f - 0.375f) / 2; + float tSide0 = tSpace; + float tSide1 = 1f - tSpace; + float tSide2 = tSpace; + float tSide3 = 1f - tSpace; + float tSide4 = tSpace; + float tSide5 = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + tSide2 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + tSide0 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide3 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + tSide0 = tSide2 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + + byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + if ((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if ((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if ((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if ((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if ((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if ((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } + + return AxisAlignedBB + .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + } + + @Override + public float getThickNess() { + if (GTMod.instance.isClientSide() && GTClient.hideValue == 1) { + return 0.0625F; + } + return 0.375f; + } + + @Override + public boolean isDataInputFacing(ForgeDirection side) { + return true; + } + + @Override + public byte getColorization() { + return getBaseMetaTileEntity().getColorization(); + } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public void setActive(boolean state) { + if (state != active) { + active = state; + getBaseMetaTileEntity().issueTextureUpdate(); + } + } + + @Override + public boolean getActive() { + return active; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java new file mode 100644 index 0000000000..fcd23e5085 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergy.java @@ -0,0 +1,281 @@ +package tectech.thing.metaTileEntity.pipe; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.metatileentity.BaseMetaPipeEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.GTClient; +import tectech.TecTech; +import tectech.loader.NetworkDispatcher; +import tectech.mechanics.pipe.IActivePipe; +import tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import tectech.mechanics.pipe.PipeActivityMessage; +import tectech.util.CommonValues; + +public class MTEPipeEnergy extends MetaPipeEntity implements IConnectsToEnergyTunnel, IActivePipe { + + static Textures.BlockIcons.CustomIcon EMcandy, EMCandyActive; + private static Textures.BlockIcons.CustomIcon EMpipe; + public byte connectionCount = 0; + + private boolean active; + + public MTEPipeEnergy(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional, 0); + } + + public MTEPipeEnergy(String aName) { + super(aName, 0); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEPipeEnergy(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + EMcandy = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY"); + EMCandyActive = new Textures.BlockIcons.CustomIcon("iconsets/EM_CANDY_ACTIVE"); + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_LASER"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { new GTRenderedTexture(EMpipe), + new GTRenderedTexture( + getActive() ? EMCandyActive : EMcandy, + Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) }; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void loadNBTData(NBTTagCompound nbtTagCompound) { + active = nbtTagCompound.getBoolean("eActive"); + } + + @Override + public void saveNBTData(NBTTagCompound nbtTagCompound) { + nbtTagCompound.setBoolean("eActive", active); + } + + @Override + public boolean renderInside(ForgeDirection side) { + return false; + } + + @Override + public byte getTileEntityBaseType() { + return 4; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.energystream.desc.0"), // Laser + // tunneling + // device. + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.energystream.desc.1"), // Bright Vacuum!!! + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energystream.desc.2"), // Must be + // painted to + // work + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energystream.desc.3") // Do not split + // or turn + }; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + onPostTick(aBaseMetaTileEntity, 31); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + if (TecTech.RANDOM.nextInt(15) == 0) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + if (active) { + active = false; + } + mConnections = 0; + connectionCount = 0; + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + final ForgeDirection oppositeSide = side.getOpposite(); + // if (!aBaseMetaTileEntity.getCoverBehaviorAtSide(b0).alwaysLookConnected(b0, + // aBaseMetaTileEntity.getCoverIDAtSide(b0), aBaseMetaTileEntity.getCoverDataAtSide(b0), + // aBaseMetaTileEntity)) { + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IColoredTileEntity) { + // if (aBaseMetaTileEntity.getColorization() >= 0) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } + // } + } + if (tTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tTileEntity).getPowerLogic(oppositeSide); + if (logic != null && logic.canUseLaser()) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + continue; + } + } + if (tTileEntity instanceof IConnectsToEnergyTunnel + && ((IConnectsToEnergyTunnel) tTileEntity).canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } else if (tTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) tTileEntity).getMetaTileEntity() instanceof IConnectsToEnergyTunnel) { + if (((IConnectsToEnergyTunnel) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) + .canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectionCount++; + } + } + } + } + + } else if (aBaseMetaTileEntity.isClientSide() && GTClient.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + @Override + public void setActive(boolean state) { + if (state != active) { + active = state; + getBaseMetaTileEntity().issueTextureUpdate(); + } + } + + @Override + public boolean getActive() { + return active; + } + + @Override + public void markUsed() { + this.active = true; + } + + @Override + public boolean canConnect(ForgeDirection side) { + return true; + } + + @Override + public AxisAlignedBB getCollisionBoundingBoxFromPool(World aWorld, int aX, int aY, int aZ) { + float tSpace = (1f - 0.5f) / 2; + float tSide0 = tSpace; + float tSide1 = 1f - tSpace; + float tSide2 = tSpace; + float tSide3 = 1f - tSpace; + float tSide4 = tSpace; + float tSide5 = 1f - tSpace; + + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.DOWN) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.UP) != 0) { + tSide2 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.NORTH) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.SOUTH) != 0) { + tSide0 = tSide4 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.WEST) != 0) { + tSide0 = tSide2 = tSide4 = 0; + tSide1 = tSide3 = 1; + } + if (getBaseMetaTileEntity().getCoverIDAtSide(ForgeDirection.EAST) != 0) { + tSide0 = tSide2 = 0; + tSide1 = tSide3 = tSide5 = 1; + } + + byte tConn = ((BaseMetaPipeEntity) getBaseMetaTileEntity()).mConnections; + if ((tConn & 1 << ForgeDirection.DOWN.ordinal()) != 0) { + tSide0 = 0f; + } + if ((tConn & 1 << ForgeDirection.UP.ordinal()) != 0) { + tSide1 = 1f; + } + if ((tConn & 1 << ForgeDirection.NORTH.ordinal()) != 0) { + tSide2 = 0f; + } + if ((tConn & 1 << ForgeDirection.SOUTH.ordinal()) != 0) { + tSide3 = 1f; + } + if ((tConn & 1 << ForgeDirection.WEST.ordinal()) != 0) { + tSide4 = 0f; + } + if ((tConn & 1 << ForgeDirection.EAST.ordinal()) != 0) { + tSide5 = 1f; + } + + return AxisAlignedBB + .getBoundingBox(aX + tSide4, aY + tSide0, aZ + tSide2, aX + tSide5, aY + tSide1, aZ + tSide3); + } + + @Override + public float getThickNess() { + if (GTMod.instance.isClientSide() && GTClient.hideValue == 1) { + return 0.0625F; + } + return 0.5f; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java new file mode 100644 index 0000000000..cb9ce4d13d --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/pipe/MTEPipeEnergyMirror.java @@ -0,0 +1,223 @@ +package tectech.thing.metaTileEntity.pipe; + +import static gregtech.api.enums.Dyes.MACHINE_METAL; +import static net.minecraft.util.StatCollector.translateToLocal; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.GTMod; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IColoredTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.logic.PowerLogic; +import gregtech.api.logic.interfaces.PowerLogicHost; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.GTClient; +import tectech.TecTech; +import tectech.loader.NetworkDispatcher; +import tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import tectech.mechanics.pipe.PipeActivityMessage; +import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyTunnel; +import tectech.util.CommonValues; + +public class MTEPipeEnergyMirror extends MTEPipeEnergy { + + private static Textures.BlockIcons.CustomIcon EMpipe; + private ForgeDirection[] connectedSides = { null, null }; + private ForgeDirection chainedFrontFacing = null; + + private boolean active; + + public MTEPipeEnergyMirror(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + public MTEPipeEnergyMirror(String aName) { + super(aName); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MTEPipeEnergyMirror(mName); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + EMpipe = new Textures.BlockIcons.CustomIcon("iconsets/EM_LASERMIRROR"); + super.registerIcons(aBlockIconRegister); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, int aConnections, + int colorIndex, boolean aConnected, boolean aRedstone) { + return new ITexture[] { new GTRenderedTexture(EMpipe), + new GTRenderedTexture( + getActive() ? EMCandyActive : EMcandy, + Dyes.getModulation(colorIndex, MACHINE_METAL.getRGBA())) }; + } + + @Override + public String[] getDescription() { + return new String[] { CommonValues.TEC_MARK_EM, translateToLocal("gt.blockmachines.pipe.energymirror.desc.0"), + EnumChatFormatting.AQUA.toString() + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.pipe.energystream.desc.1"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energystream.desc.2"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.pipe.energymirror.desc.1") }; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if ((aTick & 31) == 31) { + if (TecTech.RANDOM.nextInt(15) == 0) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new PipeActivityMessage.PipeActivityData(this), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + } + if (active) { + active = false; + } + mConnections = 0; + connectedSides[0] = null; + connectedSides[1] = null; + connectionCount = 0; + if (aBaseMetaTileEntity.getColorization() < 0) { + return; + } + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + // We only allow a single bend + if (connectionCount < 2) { + final ForgeDirection oppositeSide = side.getOpposite(); + TileEntity tTileEntity = aBaseMetaTileEntity.getTileEntityAtSide(side); + if (tTileEntity instanceof IColoredTileEntity) { + byte tColor = ((IColoredTileEntity) tTileEntity).getColorization(); + if (tColor != aBaseMetaTileEntity.getColorization()) { + continue; + } + } + if (tTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tTileEntity).getPowerLogic(oppositeSide); + if (logic != null && logic.canUseLaser()) { + mConnections |= 1 << side.ordinal(); + connectedSides[connectionCount] = side; + connectionCount++; + continue; + } + } + if (tTileEntity instanceof IConnectsToEnergyTunnel + && ((IConnectsToEnergyTunnel) tTileEntity).canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectedSides[connectionCount] = side; + connectionCount++; + } else if (tTileEntity instanceof IGregTechTileEntity && ((IGregTechTileEntity) tTileEntity) + .getMetaTileEntity() instanceof IConnectsToEnergyTunnel) { + if (((IConnectsToEnergyTunnel) ((IGregTechTileEntity) tTileEntity).getMetaTileEntity()) + .canConnect(oppositeSide)) { + mConnections |= 1 << side.ordinal(); + connectedSides[connectionCount] = side; + connectionCount++; + } + } + } + } + } + + } else if (aBaseMetaTileEntity.isClientSide() && GTClient.changeDetected == 4) { + aBaseMetaTileEntity.issueTextureUpdate(); + } + } + + public ForgeDirection getBendDirection(ForgeDirection dir) { + for (ForgeDirection bendDir : connectedSides) { + if (bendDir != dir) { + chainedFrontFacing = bendDir.getOpposite(); + return bendDir; + } + } + return null; + } + + public ForgeDirection getChainedFrontFacing() { + return chainedFrontFacing; + } + + public IGregTechTileEntity bendAround(ForgeDirection inputSide) { + byte color = getBaseMetaTileEntity().getColorization(); + if (color < 0) { + return null; + } else { + ForgeDirection direction = getBendDirection(inputSide); + if (direction == null) { + return null; + } + ForgeDirection opposite = direction.getOpposite(); + for (short dist = 1; dist < 1000; dist++) { + + IGregTechTileEntity tGTTileEntity = getBaseMetaTileEntity() + .getIGregTechTileEntityAtSideAndDistance(direction, dist); + if (tGTTileEntity != null && tGTTileEntity.getColorization() == color) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + // If we hit a mirror, use the mirror's view instead + if (aMetaTileEntity instanceof MTEPipeEnergyMirror tMirror) { + tGTTileEntity = tMirror.bendAround(opposite); + if (tGTTileEntity == null) { + break; + } else { + aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + chainedFrontFacing = tMirror.getChainedFrontFacing(); + opposite = chainedFrontFacing; + } + } + + if (aMetaTileEntity instanceof MTEHatchEnergyTunnel + && opposite == tGTTileEntity.getFrontFacing()) { + return tGTTileEntity; + } else if (aMetaTileEntity instanceof MTEPipeEnergy) { + if (((MTEPipeEnergy) aMetaTileEntity).connectionCount < 2) { + return null; + } else { + ((MTEPipeEnergy) aMetaTileEntity).markUsed(); + } + } else { + return null; + } + } else { + if (tGTTileEntity instanceof PowerLogicHost) { + PowerLogic logic = ((PowerLogicHost) tGTTileEntity).getPowerLogic(opposite); + if (logic == null || !logic.canUseLaser() || opposite != tGTTileEntity.getFrontFacing()) { + return tGTTileEntity; + } + } + return null; + } + } else { + return null; + } + } + } + return null; + } + + @Override + public float getThickNess() { + if (GTMod.instance.isClientSide() && GTClient.hideValue == 1) { + return 0.0625F; + } + return 0.6f; + } + +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEBuckConverter.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEBuckConverter.java new file mode 100644 index 0000000000..3f2c66276d --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEBuckConverter.java @@ -0,0 +1,265 @@ +package tectech.thing.metaTileEntity.single; + +import static gregtech.api.enums.GTValues.V; +import static gregtech.api.enums.GTValues.VN; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTEBuckConverter extends MTETieredMachineBlock implements IAddUIWidgets, IAddGregtechLogo { + + private static GTRenderedTexture BUCK, BUCK_ACTIVE; + public int EUT = 0, AMP = 0; + private static NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public MTEBuckConverter(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.machine.tt.buck.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.buck.desc.1"), }); + TTUtility.setTier(aTier, this); + } + + public MTEBuckConverter(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEBuckConverter(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + BUCK = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/BUCK")); + BUCK_ACTIVE = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/BUCK_ACTIVE")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side == facing ? (aActive ? BUCK_ACTIVE : BUCK) + : (side == facing.getOpposite() + ? tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier] + : (aActive ? tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT[mTier] + : tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier])) }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("eEUT", EUT); + aNBT.setInteger("eAMP", AMP); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + EUT = aNBT.getInteger("eEUT"); + AMP = aNBT.getInteger("eAMP"); + getBaseMetaTileEntity().setActive((long) AMP * EUT >= 0); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return side == getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return getBaseMetaTileEntity().isActive() && side != getBaseMetaTileEntity().getFrontFacing() + && side != getBaseMetaTileEntity().getBackFacing(); + } + + @Override + public long maxAmperesIn() { + return 2; + } + + @Override + public long maxAmperesOut() { + return getBaseMetaTileEntity().isActive() ? Math.min(Math.abs(AMP), 64) : 0; + } + + @Override + public long maxEUInput() { + return V[mTier]; + } + + @Override + public long maxEUOutput() { + return getBaseMetaTileEntity().isActive() ? Math.min(Math.abs(EUT), maxEUInput()) : 0; + } + + @Override + public long maxEUStore() { + return V[mTier] << 4; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier] << 2; + } + + @Override + public int getProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> "EUT: " + numberFormat.format(EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)) + .widget( + new TextWidget().setStringSupplier(() -> "TIER: " + VN[TTUtility.getTier(Math.abs(EUT))]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 16)) + .widget( + new TextWidget().setStringSupplier(() -> "AMP: " + numberFormat.format(AMP)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 24)) + .widget( + new TextWidget().setStringSupplier(() -> "SUM: " + numberFormat.format((long) AMP * EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 32)); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT -= val, 512, 64, 7, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT /= val, 512, 64, 7, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP -= val, 512, 64, 7, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP /= val, 512, 64, 7, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT -= val, 16, 1, 25, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT /= val, 16, 2, 25, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP -= val, 16, 1, 25, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP /= val, 16, 2, 25, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT += val, 16, 1, 133, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT *= val, 16, 2, 133, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP += val, 16, 1, 133, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP *= val, 16, 2, 133, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT += val, 512, 64, 151, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT *= val, 512, 64, 151, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP += val, 512, 64, 151, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP *= val, 512, 64, 151, 58); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer<Integer> setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + setter.accept(clickData.shift ? changeNumberShift : changeNumber); + getBaseMetaTileEntity().setActive((long) AMP * EUT >= 0); + }) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPollutor.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPollutor.java new file mode 100644 index 0000000000..d70a0e3c43 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPollutor.java @@ -0,0 +1,217 @@ +package tectech.thing.metaTileEntity.single; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.common.Pollution; +import tectech.TecTech; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 23.03.2017. + */ +public class MTEDebugPollutor extends MTETieredMachineBlock implements IAddUIWidgets, IAddGregtechLogo { + + private static GTRenderedTexture POLLUTOR; + public int pollution = 0; + private static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public MTEDebugPollutor(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.pollutor.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEDebugPollutor(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDebugPollutor(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + POLLUTOR = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/POLLUTOR")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT[mTier][colorIndex + 1], + (side == facing) ? POLLUTOR : tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT[mTier] }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("ePollution", pollution); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + pollution = aNBT.getInteger("ePollution"); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + if (pollution > 0) { + Pollution.addPollution(aBaseMetaTileEntity, pollution); + } + } else if (aBaseMetaTileEntity.isClientSide() && aBaseMetaTileEntity.isActive()) { + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (side != aBaseMetaTileEntity.getFrontFacing()) { + TecTech.proxy.em_particle(aBaseMetaTileEntity, side); + TecTech.proxy.pollutor_particle(aBaseMetaTileEntity, side); + } + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> "Pollution: " + numberFormat.format(pollution)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> pollution -= val, 512, 64, 7, 4); + addChangeNumberButton( + builder, + GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, + val -> pollution /= val, + 512, + 64, + 7, + 22); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> pollution -= val, 16, 1, 25, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> pollution /= val, 16, 2, 25, 22); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> pollution += val, 16, 1, 133, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> pollution *= val, 16, 2, 133, 22); + + addChangeNumberButton( + builder, + GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, + val -> pollution += val, + 512, + 64, + 151, + 4); + addChangeNumberButton( + builder, + GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, + val -> pollution *= val, + 512, + 64, + 151, + 22); + + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer<Integer> setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget( + new ButtonWidget() + .setOnClick((clickData, widget) -> setter.accept(clickData.shift ? changeNumberShift : changeNumber)) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPowerGenerator.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPowerGenerator.java new file mode 100644 index 0000000000..b82e0036c0 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugPowerGenerator.java @@ -0,0 +1,383 @@ +package tectech.thing.metaTileEntity.single; + +import static gregtech.api.enums.GTValues.VN; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; +import java.util.function.IntConsumer; +import java.util.function.IntSupplier; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizons.modularui.api.NumberFormatMUI; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import tectech.mechanics.pipe.IConnectsToEnergyTunnel; +import tectech.thing.metaTileEntity.hatch.MTEHatchEnergyTunnel; +import tectech.thing.metaTileEntity.pipe.MTEPipeEnergy; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 23.03.2017. + */ +public class MTEDebugPowerGenerator extends MTETieredMachineBlock + implements IConnectsToEnergyTunnel, IAddUIWidgets, IAddGregtechLogo { + + public static GTRenderedTexture GENNY; + private boolean LASER = false; + public int EUT = 0, AMP = 0; + public boolean producing = true; + private static final NumberFormatMUI numberFormat = new NumberFormatMUI(); + + public MTEDebugPowerGenerator(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.genny.desc.0"), + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.debug.tt.genny.desc.3"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.genny.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.genny.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEDebugPowerGenerator(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDebugPowerGenerator(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + LASER = !LASER; + GTUtility.sendChatToPlayer( + aPlayer, + String.format(StatCollector.translateToLocal("tt.chat.debug.generator"), LASER ? "ON" : "OFF")); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + GENNY = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/GENNY")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side != facing + ? LASER + ? (aActive ? tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_LASER_TT[mTier] + : tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_LASER_TT[mTier]) + : (aActive ? tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_OUT_POWER_TT[mTier] + : tectech.thing.metaTileEntity.Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier]) + : GENNY }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setInteger("eEUT", EUT); + aNBT.setInteger("eAMP", AMP); + aNBT.setBoolean("eLaser", LASER); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + EUT = aNBT.getInteger("eEUT"); + AMP = aNBT.getInteger("eAMP"); + LASER = aNBT.getBoolean("eLaser"); + producing = (long) AMP * EUT >= 0; + getBaseMetaTileEntity().setActive(producing); + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide()) { + aBaseMetaTileEntity.setActive(producing); + if (!LASER) { + if (aBaseMetaTileEntity.isActive()) { + setEUVar(maxEUStore()); + } else { + setEUVar(0); + } + } else { + byte Tick = (byte) (aTick % 20); + if (aBaseMetaTileEntity.isActive() && CommonValues.TRANSFER_AT == Tick) { + setEUVar(maxEUStore()); + moveAround(aBaseMetaTileEntity); + } else if (CommonValues.TRANSFER_AT == Tick) { + setEUVar(0); + } + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetOutput() { + return !LASER; + } + + @Override + public boolean isEnetInput() { + return !LASER; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return !producing && side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return producing && side != getBaseMetaTileEntity().getFrontFacing(); + } + + @Override + public long maxAmperesIn() { + return producing ? 0 : Math.abs(AMP); + } + + @Override + public long maxAmperesOut() { + return producing ? Math.abs(AMP) : 0; + } + + @Override + public long maxEUInput() { + return producing ? 0 : Integer.MAX_VALUE; + } + + @Override + public long maxEUOutput() { + return producing ? Math.abs(EUT) : 0; + } + + @Override + public long maxEUStore() { + return LASER ? Math.abs((long) EUT * AMP * 24) : Math.abs((long) EUT * AMP) << 2; + } + + @Override + public long getMinimumStoredEU() { + return Math.abs((long) EUT * AMP); + } + + @Override + public int getProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyStored(); + } + + @Override + public int maxProgresstime() { + return (int) getBaseMetaTileEntity().getUniversalEnergyCapacity(); + } + + public int getEUT() { + return EUT; + } + + public void setEUT(int EUT) { + this.EUT = EUT; + } + + public int getAMP() { + return AMP; + } + + public void setAMP(int AMP) { + this.AMP = AMP; + } + + @Override + public boolean canConnect(ForgeDirection side) { + return LASER && side != getBaseMetaTileEntity().getFrontFacing(); + } + + private void moveAround(IGregTechTileEntity aBaseMetaTileEntity) { + for (final ForgeDirection face : ForgeDirection.VALID_DIRECTIONS) { + if (face == aBaseMetaTileEntity.getFrontFacing()) continue; + final ForgeDirection opposite = face.getOpposite(); + for (short dist = 1; dist < 1000; dist++) { + IGregTechTileEntity tGTTileEntity = aBaseMetaTileEntity + .getIGregTechTileEntityAtSideAndDistance(face, dist); + if (tGTTileEntity != null) { + IMetaTileEntity aMetaTileEntity = tGTTileEntity.getMetaTileEntity(); + if (aMetaTileEntity != null) { + if (aMetaTileEntity instanceof MTEHatchEnergyTunnel + && opposite == tGTTileEntity.getFrontFacing()) { + if (maxEUOutput() > ((MTEHatchEnergyTunnel) aMetaTileEntity).maxEUInput()) { + aMetaTileEntity.doExplosion(maxEUOutput()); + } else { + long diff = Math.min( + AMP * 20L * maxEUOutput(), + Math.min( + ((MTEHatchEnergyTunnel) aMetaTileEntity).maxEUStore() + - aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU(), + aBaseMetaTileEntity.getStoredEU())); + ((MTEHatchEnergyTunnel) aMetaTileEntity).setEUVar( + aMetaTileEntity.getBaseMetaTileEntity() + .getStoredEU() + diff); + } + } else if (aMetaTileEntity instanceof MTEPipeEnergy) { + if (((MTEPipeEnergy) aMetaTileEntity).connectionCount < 2) {} else { + ((MTEPipeEnergy) aMetaTileEntity).markUsed(); + } + } + } + } + } + } + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + + .widget( + new TextWidget().setStringSupplier(() -> "TIER: " + VN[TTUtility.getTier(Math.abs(EUT))]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 22)) + + .widget( + new TextWidget().setStringSupplier(() -> "SUM: " + numberFormat.format((long) AMP * EUT)) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 46)); + + addLabelledIntegerTextField(builder, "EUT: ", 24, this::getEUT, this::setEUT, 46, 8); + addLabelledIntegerTextField(builder, "AMP: ", 24, this::getAMP, this::setAMP, 46, 34); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT -= val, 512, 64, 7, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> EUT /= val, 512, 64, 7, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP -= val, 512, 64, 7, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, val -> AMP /= val, 512, 64, 7, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT -= val, 16, 1, 25, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> EUT /= val, 16, 2, 25, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP -= val, 16, 1, 25, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, val -> AMP /= val, 16, 2, 25, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT += val, 16, 1, 133, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> EUT *= val, 16, 2, 133, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP += val, 16, 1, 133, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, val -> AMP *= val, 16, 2, 133, 58); + + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT += val, 512, 64, 151, 4); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> EUT *= val, 512, 64, 151, 22); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP += val, 512, 64, 151, 40); + addChangeNumberButton(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, val -> AMP *= val, 512, 64, 151, 58); + } + + private void addLabelledIntegerTextField(ModularWindow.Builder builder, String label, int labelWidth, + IntSupplier getter, IntConsumer setter, int xPos, int yPos) { + builder.widget( + new TextWidget(label).setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(xPos, yPos)) + .widget( + new NumericWidget().setGetter(getter::getAsInt) + .setSetter(val -> setter.accept((int) val)) + .setTextColor(COLOR_TEXT_WHITE.get()) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD.withOffset(-1, -1, 2, 2)) + .setPos(xPos + labelWidth, yPos - 1) + .setSize(56, 10)); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer<Integer> setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget(new ButtonWidget().setOnClick((clickData, widget) -> { + setter.accept(clickData.shift ? changeNumberShift : changeNumber); + producing = (long) AMP * EUT >= 0; + }) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugStructureWriter.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugStructureWriter.java new file mode 100644 index 0000000000..a03266ac89 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEDebugStructureWriter.java @@ -0,0 +1,292 @@ +package tectech.thing.metaTileEntity.single; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.function.Consumer; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import com.gtnewhorizon.structurelib.alignment.enumerable.ExtendedFacing; +import com.gtnewhorizon.structurelib.structure.StructureUtility; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.screen.UIBuildContext; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.TextWidget; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.modularui.IAddGregtechLogo; +import gregtech.api.interfaces.modularui.IAddUIWidgets; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import tectech.TecTech; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 23.03.2017. + */ +public class MTEDebugStructureWriter extends MTETieredMachineBlock implements IAddUIWidgets, IAddGregtechLogo { + + private static GTRenderedTexture MARK; + public short[] numbers = new short[6]; + public boolean size = false; + public String[] result = new String[] { "Undefined" }; + + public MTEDebugStructureWriter(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, translateToLocal("gt.blockmachines.debug.tt.writer.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.writer.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.debug.tt.writer.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEDebugStructureWriter(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEDebugStructureWriter(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + MARK = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/MARK")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT[mTier][colorIndex + 1], + side != facing ? new GTRenderedTexture(Textures.BlockIcons.OVERLAY_TELEPORTER_ACTIVE) : MARK }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + for (int i = 0; i < numbers.length; i++) { + aNBT.setShort("eData" + i, numbers[i]); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + for (int i = 0; i < numbers.length; i++) { + numbers[i] = aNBT.getShort("eData" + i); + } + } + + @Override + public boolean isSimpleMachine() { + return false; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + aBaseMetaTileEntity.disableWorking(); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isAllowedToWork()) { + + String pseudoJavaCode = StructureUtility.getPseudoJavaCode( + aBaseMetaTileEntity.getWorld(), + ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + numbers[0], + numbers[1], + numbers[2], + te -> te.getClass() + .getCanonicalName(), + numbers[3], + numbers[4], + numbers[5], + false); + TecTech.LOGGER.info(pseudoJavaCode); + result = pseudoJavaCode.split("\\n"); + aBaseMetaTileEntity.disableWorking(); + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + IGregTechTileEntity aBaseMetaTileEntity = getBaseMetaTileEntity(); + + String pseudoJavaCode = StructureUtility.getPseudoJavaCode( + aBaseMetaTileEntity.getWorld(), + ExtendedFacing.of(aBaseMetaTileEntity.getFrontFacing()), + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + numbers[0], + numbers[1], + numbers[2], + te -> te.getClass() + .getCanonicalName(), + numbers[3], + numbers[4], + numbers[5], + false); + TecTech.LOGGER.info(pseudoJavaCode); + result = pseudoJavaCode.split("\\n"); + aBaseMetaTileEntity.disableWorking(); + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + return true; + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isGivingInformation() { + return true; + } + + @Override + public String[] getInfoData() { + return result; + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_GT_LOGO_17x17_TRANSPARENT_GRAY) + .setSize(17, 17) + .setPos(113, 56)); + } + + @Override + public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) + .setSize(90, 72) + .setPos(43, 4)) + .widget( + new TextWidget().setStringSupplier(() -> size ? "Structure size" : "My position") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 8)) + .widget( + new TextWidget().setStringSupplier(() -> size ? "(Changing scan size)" : "(Moving origin)") + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 16)) + .widget( + new TextWidget().setStringSupplier(() -> "A: " + numbers[size ? 3 : 0]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 24)) + .widget( + new TextWidget().setStringSupplier(() -> "B: " + numbers[size ? 4 : 1]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 32)) + .widget( + new TextWidget().setStringSupplier(() -> "C: " + numbers[size ? 5 : 2]) + .setDefaultColor(COLOR_TEXT_WHITE.get()) + .setPos(46, 40)); + + addChangeNumberButtons(builder, GTUITextures.OVERLAY_BUTTON_MINUS_LARGE, -512, -64, 7); + addChangeNumberButtons(builder, GTUITextures.OVERLAY_BUTTON_MINUS_SMALL, -16, -1, 25); + addChangeNumberButtons(builder, GTUITextures.OVERLAY_BUTTON_PLUS_SMALL, 16, 1, 133); + addChangeNumberButtons(builder, GTUITextures.OVERLAY_BUTTON_PLUS_LARGE, 512, 16, 151); + } + + private void addChangeNumberButtons(ModularWindow.Builder builder, IDrawable overlay, int addNumberShift, + int addNumber, int xPos) { + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 3 : 0] += val, + addNumberShift, + addNumber, + xPos, + 4); + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 4 : 1] += val, + addNumberShift, + addNumber, + xPos, + 22); + addChangeNumberButton( + builder, + overlay, + val -> numbers[size ? 5 : 2] += val, + addNumberShift, + addNumber, + xPos, + 40); + builder.widget( + new ButtonWidget().setOnClick((clickData, widget) -> { size = !size; }) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, 58)); + } + + private void addChangeNumberButton(ModularWindow.Builder builder, IDrawable overlay, Consumer<Integer> setter, + int changeNumberShift, int changeNumber, int xPos, int yPos) { + builder.widget( + new ButtonWidget() + .setOnClick( + (clickData, widget) -> { setter.accept(clickData.shift ? changeNumberShift : changeNumber); }) + .setBackground(GTUITextures.BUTTON_STANDARD, overlay) + .setSize(18, 18) + .setPos(xPos, yPos)); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java new file mode 100644 index 0000000000..15cd63d6c9 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEOwnerDetector.java @@ -0,0 +1,237 @@ +package tectech.thing.metaTileEntity.single; + +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.reflect.FieldUtils; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTETieredMachineBlock; +import gregtech.api.objects.GTRenderedTexture; +import gregtech.api.util.GTUtility; +import tectech.TecTech; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +/** + * Created by Tec on 23.03.2017. + */ +public class MTEOwnerDetector extends MTETieredMachineBlock { + + private static GTRenderedTexture OWNER_ONLINE, OWNER_OFFLINE; + private String uuid; + private boolean interdimensional = true; + + public MTEOwnerDetector(int aID, String aName, String aNameRegional, int aTier) { + super( + aID, + aName, + aNameRegional, + aTier, + 0, + new String[] { CommonValues.TEC_MARK_GENERAL, + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.0"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.1"), + EnumChatFormatting.BLUE + translateToLocal("gt.blockmachines.machine.tt.ownerdetector.desc.2") }); + TTUtility.setTier(aTier, this); + } + + public MTEOwnerDetector(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, 0, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEOwnerDetector(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister aBlockIconRegister) { + super.registerIcons(aBlockIconRegister); + OWNER_ONLINE = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/OWNER_ONLINE")); + OWNER_OFFLINE = new GTRenderedTexture(new Textures.BlockIcons.CustomIcon("iconsets/OWNER_OFFLINE")); + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return new ITexture[] { tectech.thing.metaTileEntity.Textures.MACHINE_CASINGS_TT[mTier][colorIndex + 1], + aActive ? OWNER_ONLINE : OWNER_OFFLINE }; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + return null; + } + + @Override + public boolean allowPutStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public boolean allowPullStack(IGregTechTileEntity iGregTechTileEntity, int i, ForgeDirection side, + ItemStack itemStack) { + return false; + } + + @Override + public void saveNBTData(NBTTagCompound aNBT) { + aNBT.setString("eUUID", uuid); + aNBT.setBoolean("eInterDim", interdimensional); + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + uuid = aNBT.getString("eUUID"); + interdimensional = aNBT.getBoolean("eInterDim"); + } + + @Override + public boolean isSimpleMachine() { + return true; + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + if (aBaseMetaTileEntity.isServerSide()) { + if (uuid == null || uuid.length() == 0) { + String name = aBaseMetaTileEntity.getOwnerName(); + if (!("Player".equals(name))) { + uuid = TecTech.proxy.getUUID(name); + } + } + } + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + if (aBaseMetaTileEntity.isServerSide() && aTick % 20 == CommonValues.RECIPE_AT) { + boolean detected = TecTech.proxy.isOnlineUUID(uuid) || (uuid != null && uuid.length() > 0 + && TecTech.proxy.isOnlineName(aBaseMetaTileEntity.getOwnerName())); + aBaseMetaTileEntity.setActive(detected); + aBaseMetaTileEntity.setGenericRedstoneOutput(detected); + byte value = (byte) (detected ? 15 : 0); + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + aBaseMetaTileEntity.setStrongOutputRedstoneSignal(side, value); + } + } + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + String clientLocale; + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + interdimensional ^= true; + GTUtility.sendChatToPlayer( + aPlayer, + interdimensional ? translateToLocalFormatted("tt.keyphrase.Running_interdimensional_scan", clientLocale) + : translateToLocalFormatted("tt.keyphrase.Running_local_dimension_scan", clientLocale)); + } + + @Override + public boolean isFacingValid(ForgeDirection facing) { + return true; + } + + @Override + public boolean isAccessAllowed(EntityPlayer aPlayer) { + return true; + } + + @Override + public boolean isElectric() { + return false; + } + + @Override + public boolean isEnetOutput() { + return false; + } + + @Override + public boolean isEnetInput() { + return false; + } + + @Override + public boolean isInputFacing(ForgeDirection side) { + return false; + } + + @Override + public boolean isOutputFacing(ForgeDirection side) { + return false; + } + + @Override + public long maxAmperesIn() { + return 0; + } + + @Override + public long maxAmperesOut() { + return 0; + } + + @Override + public long maxEUInput() { + return Integer.MAX_VALUE; + } + + @Override + public long maxEUOutput() { + return 0; + } + + @Override + public long maxEUStore() { + return 0; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public int getProgresstime() { + return interdimensional ? 1 : 0; + } + + @Override + public int maxProgresstime() { + return 1; + } + + @Override + public boolean hasSidedRedstoneOutputBehavior() { + return true; + } + + @Override + public boolean allowGeneralRedstoneOutput() { + return true; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java b/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java new file mode 100644 index 0000000000..b053cd656c --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTETeslaCoil.java @@ -0,0 +1,396 @@ +package tectech.thing.metaTileEntity.single; + +import static gregtech.api.enums.GTValues.V; +import static java.lang.Math.round; +import static net.minecraft.util.StatCollector.translateToLocal; +import static net.minecraft.util.StatCollector.translateToLocalFormatted; + +import java.util.Arrays; +import java.util.HashSet; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.lang3.reflect.FieldUtils; + +import com.google.common.collect.Multimap; +import com.google.common.collect.MultimapBuilder; +import com.gtnewhorizon.structurelib.util.Vec3Impl; + +import eu.usrv.yamcore.auxiliary.PlayerChatHelper; +import gregtech.api.gui.modularui.GTUIInfos; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.MTEBasicBatteryBuffer; +import tectech.TecTech; +import tectech.loader.NetworkDispatcher; +import tectech.mechanics.spark.RendererMessage; +import tectech.mechanics.spark.ThaumSpark; +import tectech.mechanics.tesla.ITeslaConnectable; +import tectech.mechanics.tesla.ITeslaConnectableSimple; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTETeslaCoil extends MTEBasicBatteryBuffer implements ITeslaConnectable { + + // Interface fields + private final Multimap<Integer, ITeslaConnectableSimple> teslaNodeMap = MultimapBuilder.treeKeys() + .linkedListValues() + .build(); + private final HashSet<ThaumSpark> sparkList = new HashSet<>(); + private int sparkCount = 10; + + private static final int transferRadiusMax = TecTech.configTecTech.TESLA_SINGLE_RANGE; // Default is 20 + private static final int perBlockLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_PER_BLOCK; // Default is 1 + private static final float overDriveLoss = TecTech.configTecTech.TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE; // Default is + // 0.25F + private static final int transferRadiusMin = 4; // Minimum user configurable + private int transferRadius = transferRadiusMax; // Default transferRadius setting + + public boolean powerPassToggle = false; // Power Pass for public viewing + private static final int histSteps = 20; // Hysteresis Resolution + private int histSettingLow = 3; // Hysteresis Low Limit + private int histSettingHigh = 15; // Hysteresis High Limit + private static final int histLowLimit = 1; // How low can you configure it? + private static final int histHighLimit = 19; // How high can you configure it? + private float histLow = (float) histSettingLow / histSteps; // Power pass is disabled if power is under this + // fraction + private float histHigh = (float) histSettingHigh / histSteps; // Power pass is enabled if power is over this + // fraction + + private final long outputVoltage = V[mTier]; + private boolean overdriveToggle = false; + + private String clientLocale = "en_US"; + + public MTETeslaCoil(int aID, String aName, String aNameRegional, int aTier, int aSlotCount) { + super(aID, aName, aNameRegional, aTier, "", aSlotCount); + TTUtility.setTier(aTier, this); + } + + public MTETeslaCoil(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures, int aSlotCount) { + super(aName, aTier, aDescription, aTextures, aSlotCount); + } + + @Override + public String[] getDescription() { + String[] jargon = new String[] { CommonValues.THETA_MOVEMENT, + translateToLocal("gt.blockmachines.machine.tt.tesla.desc.0"), // Your Tesla I/O machine of choice + EnumChatFormatting.AQUA + translateToLocal("gt.blockmachines.machine.tt.tesla.desc.1") // Lightning + // stoves for the + // rich + }; + String[] sDesc = super.getDescription(); + sDesc = Arrays.copyOfRange(sDesc, 1, sDesc.length); // Removes first element from array + return ArrayUtils.addAll(jargon, sDesc); + } + + @Override + public boolean onSolderingToolRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (overdriveToggle) { + overdriveToggle = false; + PlayerChatHelper + .SendInfo(aPlayer, translateToLocalFormatted("tt.keyphrase.Overdrive_disengaged", clientLocale)); + } else { + overdriveToggle = true; + PlayerChatHelper + .SendInfo(aPlayer, translateToLocalFormatted("tt.keyphrase.Overdrive_engaged", clientLocale)); + } + return true; + } + + @Override + public void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + if (histSettingHigh < histHighLimit) { + histSettingHigh++; + } else { + histSettingHigh = histSettingLow + 1; + } + histHigh = (float) histSettingHigh / histSteps; + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Hysteresis_high_set_to", clientLocale) + " " + + round(histHigh * 100F) + + "%"); + } else { + if (histSettingLow > histLowLimit) { + histSettingLow--; + } else { + histSettingLow = histSettingHigh - 1; + } + histLow = (float) histSettingLow / histSteps; + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Hysteresis_low_set_to", clientLocale) + " " + + round(histLow * 100F) + + "%"); + } + } + + @Override + public boolean onWireCutterRightClick(ForgeDirection side, ForgeDirection wrenchingSide, EntityPlayer aPlayer, + float aX, float aY, float aZ) { + if (aPlayer.isSneaking()) { + if (transferRadius > transferRadiusMin) { + transferRadius--; + } + } else { + if (transferRadius < transferRadiusMax) { + transferRadius++; + } + } + PlayerChatHelper.SendInfo( + aPlayer, + translateToLocalFormatted("tt.keyphrase.Tesla_radius_set_to", clientLocale) + " " + transferRadius + "m"); + return false; + } + + // Cheeky skrub stuff to get machine to switch powerPass on soft mallet + @Override + public boolean hasAlternativeModeText() { + return true; + } + + @Override + public String getAlternativeModeText() { + // Hysteresis based ePowerPass Config + long energyMax = getStoredEnergy()[1]; + long energyStored = getStoredEnergy()[0]; + float energyFrac = (float) energyStored / energyMax; + + // ePowerPass hist toggle + if (energyFrac > histHigh) { + powerPassToggle = true; + } else if (energyFrac < histLow) { + powerPassToggle = false; + } else { + powerPassToggle = !powerPassToggle; + } + + // And after this cheeky-ness, toss the string XD + return powerPassToggle ? translateToLocalFormatted("tt.keyphrase.Sending_power", clientLocale) + "!" + : translateToLocalFormatted("tt.keyphrase.Receiving_power", clientLocale) + "!"; + } + + @Override + public boolean isFacingValid(ForgeDirection side) { + return side != ForgeDirection.UP; + } // Prevents output at the top side + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[3][17][]; + for (byte i = -1; i < 16; ++i) { + rTextures[0][i + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[this.mTier][i + 1] }; + rTextures[1][i + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[this.mTier][i + 1], + Textures.TESLA_TRANSCEIVER_TOP_BA }; + rTextures[2][i + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[this.mTier][i + 1], + this.mInventory.length == 16 ? Textures.OVERLAYS_ENERGY_OUT_POWER_TT[this.mTier] + : (this.mInventory.length > 4 ? Textures.OVERLAYS_ENERGY_OUT_MULTI_TT[this.mTier] + : Textures.OVERLAYS_ENERGY_OUT_TT[this.mTier]) }; + } + return rTextures; + } + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean aActive, boolean aRedstone) { + return this.mTextures[side == facing ? 2 : side == ForgeDirection.UP ? 1 : 0][colorIndex + 1]; + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTETeslaCoil(mName, mTier, mDescriptionArray, mTextures, mInventory.length); + } + + @Override + public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) { + super.onFirstTick(aBaseMetaTileEntity); + if (!aBaseMetaTileEntity.isClientSide()) { + TeslaUtil.teslaSimpleNodeSetAdd(this); + TeslaUtil.generateTeslaNodeMap(this); + } + } + + @Override + public void onRemoval() { + super.onRemoval(); + if (!this.getBaseMetaTileEntity() + .isClientSide()) { + TeslaUtil.teslaSimpleNodeSetRemove(this); + } + } + + @Override + public void onUnload() { + if (!this.getBaseMetaTileEntity() + .isClientSide()) { + TeslaUtil.teslaSimpleNodeSetRemove(this); + } + } + + @Override + public void loadNBTData(NBTTagCompound aNBT) { + super.loadNBTData(aNBT); + TeslaUtil.teslaSimpleNodeSetAdd(this); + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + if (aBaseMetaTileEntity.isClientSide()) { + return; + } + + // Hysteresis based ePowerPass Config + long energyMax = getStoredEnergy()[1]; + long energyStored = getStoredEnergy()[0]; + float energyFrac = (float) energyStored / energyMax; + + // ePowerPass hist toggle + if (!powerPassToggle && energyFrac > histHigh) { + powerPassToggle = true; + } else if (powerPassToggle && energyFrac < histLow) { + powerPassToggle = false; + } + + // Send Power + TeslaUtil.powerTeslaNodeMap(this); + + // TODO Encapsulate the spark sender + sparkCount--; + if (sparkCount == 0) { + sparkCount = 10; + if (!sparkList.isEmpty()) { + NetworkDispatcher.INSTANCE.sendToAllAround( + new RendererMessage.RendererData(sparkList), + aBaseMetaTileEntity.getWorld().provider.dimensionId, + aBaseMetaTileEntity.getXCoord(), + aBaseMetaTileEntity.getYCoord(), + aBaseMetaTileEntity.getZCoord(), + 256); + sparkList.clear(); + } + } + } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (aBaseMetaTileEntity.isServerSide()) { + try { + EntityPlayerMP player = (EntityPlayerMP) aPlayer; + clientLocale = (String) FieldUtils.readField(player, "translator", true); + } catch (Exception e) { + clientLocale = "en_US"; + } + GTUIInfos.openGTTileEntityUI(aBaseMetaTileEntity, aPlayer); + } + return true; + } + + @Override + public byte getTeslaReceptionCapability() { + return 1; + } + + @Override + public float getTeslaReceptionCoefficient() { + return 1; + } + + @Override + public Multimap<Integer, ITeslaConnectableSimple> getTeslaNodeMap() { + return teslaNodeMap; + } + + @Override + public HashSet<ThaumSpark> getSparkList() { + return sparkList; + } + + @Override + public byte getTeslaTransmissionCapability() { + return 2; + } + + @Override + public int getTeslaTransmissionRange() { + return transferRadius; + } + + @Override + public boolean isOverdriveEnabled() { + return overdriveToggle; + } + + @Override + public int getTeslaEnergyLossPerBlock() { + return perBlockLoss; + } + + @Override + public float getTeslaOverdriveLossCoefficient() { + return overDriveLoss; + } + + @Override + public long getTeslaOutputVoltage() { + return outputVoltage; + } + + @Override + public long getTeslaOutputCurrent() { + return mBatteryCount; + } + + @Override + public boolean teslaDrainEnergy(long teslaVoltageDrained) { + if (getEUVar() < teslaVoltageDrained) { + return false; + } + + setEUVar(getEUVar() - teslaVoltageDrained); + return true; + } + + @Override + public boolean isTeslaReadyToReceive() { + return !this.powerPassToggle; + } + + @Override + public long getTeslaStoredEnergy() { + return getEUVar(); + } + + @Override + public Vec3Impl getTeslaPosition() { + return new Vec3Impl( + this.getBaseMetaTileEntity() + .getXCoord(), + this.getBaseMetaTileEntity() + .getYCoord(), + this.getBaseMetaTileEntity() + .getZCoord()); + } + + @Override + public Integer getTeslaDimension() { + return this.getBaseMetaTileEntity() + .getWorld().provider.dimensionId; + } + + @Override + public boolean teslaInjectEnergy(long teslaVoltageInjected) { + return this.getBaseMetaTileEntity() + .injectEnergyUnits(ForgeDirection.UP, teslaVoltageInjected, 1L) > 0L; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTETransformerTT.java b/src/main/java/tectech/thing/metaTileEntity/single/MTETransformerTT.java new file mode 100644 index 0000000000..e0c52e64c7 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTETransformerTT.java @@ -0,0 +1,68 @@ +package tectech.thing.metaTileEntity.single; + +import static net.minecraft.util.StatCollector.translateToLocal; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.implementations.MTETransformer; +import tectech.thing.metaTileEntity.Textures; +import tectech.util.CommonValues; +import tectech.util.TTUtility; + +public class MTETransformerTT extends MTETransformer { + + public MTETransformerTT(int aID, String aName, String aNameRegional, int aTier) { + super(aID, aName, aNameRegional, aTier, ""); + TTUtility.setTier(aTier, this); + } + + public MTETransformerTT(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + TTUtility.setTier(aTier, this); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTETransformerTT(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + ITexture[][][] rTextures = new ITexture[12][17][]; + for (byte b = -1; b < 16; b++) { + rTextures[0][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[1][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[2][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_MULTI_TT[mTier] }; + rTextures[3][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[4][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[5][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_POWER_TT[mTier + 1] }; + rTextures[6][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[7][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[8][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_IN_MULTI_TT[mTier] }; + rTextures[9][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + rTextures[10][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + rTextures[11][b + 1] = new ITexture[] { Textures.MACHINE_CASINGS_TT[mTier][b + 1], + Textures.OVERLAYS_ENERGY_OUT_POWER_TT[mTier + 1] }; + } + return rTextures; + } + + @Override + public String[] getDescription() { + return new String[] { + translateToLocal("gt.blockmachines.tt.transformer.tier." + (mTier > 9 ? "" : "0") + mTier + ".desc"), + CommonValues.TEC_MARK_GENERAL }; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/single/MTEWetTransformer.java b/src/main/java/tectech/thing/metaTileEntity/single/MTEWetTransformer.java new file mode 100644 index 0000000000..4e42619376 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/single/MTEWetTransformer.java @@ -0,0 +1,49 @@ +package tectech.thing.metaTileEntity.single; + +import static gregtech.api.enums.GTValues.V; +import static net.minecraft.util.StatCollector.translateToLocal; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import tectech.util.CommonValues; + +@Deprecated +public class MTEWetTransformer extends MTETransformerTT { + + public MTEWetTransformer(String aName, int aTier, String[] aDescription, ITexture[][][] aTextures) { + super(aName, aTier, aDescription, aTextures); + } + + @Override + public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new MTEWetTransformer(mName, mTier, mDescriptionArray, mTextures); + } + + @Override + public String[] getDescription() { + return new String[] { + translateToLocal("gt.blockmachines.wetransformer.tier." + (mTier > 9 ? "" : "0") + mTier + ".desc"), + "Accepts 16A and outputs 64A", CommonValues.TEC_MARK_GENERAL }; + } + + @Override + public long getMinimumStoredEU() { + return V[mTier + 1]; + } + + @Override + public long maxEUStore() { + return 512L + V[mTier + 1] * 128L; + } + + @Override + public long maxAmperesOut() { + return getBaseMetaTileEntity().isAllowedToWork() ? 64 : 16; + } + + @Override + public long maxAmperesIn() { + return getBaseMetaTileEntity().isAllowedToWork() ? 16 : 64; + } +} diff --git a/src/main/java/tectech/thing/multiTileEntity/GodForge.java b/src/main/java/tectech/thing/multiTileEntity/GodForge.java new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/src/main/java/tectech/thing/multiTileEntity/GodForge.java diff --git a/src/main/java/tectech/thing/tileEntity/TileEntityReactorSim.java b/src/main/java/tectech/thing/tileEntity/TileEntityReactorSim.java new file mode 100644 index 0000000000..ae6ac76f10 --- /dev/null +++ b/src/main/java/tectech/thing/tileEntity/TileEntityReactorSim.java @@ -0,0 +1,142 @@ +package tectech.thing.tileEntity; + +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +import ic2.api.energy.event.EnergyTileUnloadEvent; +import ic2.core.IC2; +import ic2.core.block.reactor.tileentity.TileEntityNuclearReactorElectric; +import ic2.core.init.MainConfig; +import ic2.core.util.ConfigUtil; +import tectech.Reference; + +/** + * Created by danie_000 on 30.09.2017. + */ +public class TileEntityReactorSim extends TileEntityNuclearReactorElectric { + + private boolean hadRedstone = true; + + @Override + public void onLoaded() { + super.onLoaded(); + if (IC2.platform.isSimulating() && addedToEnergyNet) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this)); + // this.addedToEnergyNet = false; + } + } + + @Override + public void onUnloaded() { + addedToEnergyNet = false; + super.onUnloaded(); + } + + @Override + public String getInventoryName() { + return "Nuclear Reactor Simulator"; + } + + @Override + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return false; + } + + @Override + public double getOfferedEnergy() { + return 0; + } + + @Override + public double getReactorEUEnergyOutput() { + return getReactorEnergyOutput() * 5.0F + * ConfigUtil.getDouble(MainConfig.get(), "balance/energy/generator/nuclear"); + } + + @Override + protected void updateEntityServer() { + if (updateTicker++ % getTickRate() == 0) { + if (!worldObj.isRemote && worldObj.doChunksNearChunkExist(xCoord, yCoord, zCoord, 2)) { + if (hadRedstone && !receiveredstone()) { + hadRedstone = false; + } else if (!hadRedstone && receiveredstone()) { + doUpdates(); + hadRedstone = true; + } + markDirty(); + } + } + } + + @Override + public boolean calculateHeatEffects() { + if (heat >= 4000 && IC2.platform.isSimulating()) { + float power = (float) heat / (float) maxHeat; + if (power >= 1.0F) { + explode(); // ding + return true; + } else { + return false; + } + } + return false; + } + + // new method + private void doUpdates() { + heat = 0; + do { + dropAllUnfittingStuff(); + output = 0.0F; + maxHeat = 10000; + hem = 1.0F; + processChambers(); + } while (!calculateHeatEffects() && output > 0); + } + + @Override + public void explode() { + getWorld().playSoundEffect(xCoord, yCoord, zCoord, Reference.MODID + ":microwave_ding", 1, 1); + } + + @Override + public void addEmitHeat(int heat) {} + + @Override + public boolean isFluidCooled() { + return false; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } +} |