From 7c3b73d250e5194693690121c66c0c72d5ddbd7d Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:39:43 -0500 Subject: [PATCH 01/52] Fix https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/17702 --- .../multi/godforge/MTEForgeOfGods.java | 217 +++++++++--------- 1 file changed, 103 insertions(+), 114 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index c7d52215c99..e0b10bd68fb 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -129,36 +129,41 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { + // Field default values for non-zero value defaults for item NBT checks + private static final int DEFAULT_FUEL_CONSUMPTION_FACTOR = 1; + private static final int DEFAULT_MAX_BATTERY_CHARGE = 100; + private static final int DEFAULT_RING_AMOUNT = 1; + 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 int fuelConsumptionFactor = DEFAULT_FUEL_CONSUMPTION_FACTOR; + private int selectedFuelType; + private int internalBattery; + private int maxBatteryCharge = DEFAULT_MAX_BATTERY_CHARGE; + private int gravitonShardsAvailable; + private int gravitonShardsSpent; + private int ringAmount = DEFAULT_RING_AMOUNT; + private int stellarFuelAmount; + private int neededStartupFuel; + private long fuelConsumption; + private long totalRecipesProcessed; + private long totalFuelConsumed; + private float totalExtensionsBuilt; + private float powerMilestonePercentage; + private float recipeMilestonePercentage; + private float fuelMilestonePercentage; + private float structureMilestonePercentage; + private float invertedPowerMilestonePercentage; + private float invertedRecipeMilestonePercentage; + private float invertedFuelMilestonePercentage; + private float invertedStructureMilestonePercentage; private BigInteger totalPowerConsumed = BigInteger.ZERO; - private boolean batteryCharging = false; - private boolean inversion = false; - private boolean gravitonShardEjection = false; + private boolean batteryCharging; + private boolean inversion; + private boolean gravitonShardEjection; private FormattingMode formattingMode = FormattingMode.NONE; - private boolean isRenderActive = false; - private boolean secretUpgrade = false; + private boolean isRenderActive; + private boolean secretUpgrade; private final ItemStack[] storedUpgradeWindowItems = new ItemStack[16]; public ArrayList moduleHatches = new ArrayList<>(); protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); @@ -3922,86 +3927,16 @@ 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); - NBT.setBoolean("secretUpgrde", secretUpgrade); - - // 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); - - starColors.serializeToNBT(NBT); - + saveGeneralNBT(NBT); 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.setInteger("ringAmount", ringAmount); - NBT.setBoolean("secretUpgrade", secretUpgrade); - - // 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); + saveGeneralNBT(NBT); + // Upgrade window stored items NBTTagCompound upgradeWindowStorageNBTTag = new NBTTagCompound(); - int storageIndex = 0; for (ItemStack itemStack : inputSlotHandler.getStacks()) { if (itemStack != null) { @@ -4011,7 +3946,6 @@ public void saveNBTData(NBTTagCompound NBT) { } storageIndex++; } - NBT.setTag("upgradeWindowStorage", upgradeWindowStorageNBTTag); // Renderer information @@ -4019,19 +3953,64 @@ public void saveNBTData(NBTTagCompound NBT) { NBT.setInteger("starSize", starSize); NBT.setString("selectedStarColor", selectedStarColor); NBT.setBoolean("isRenderActive", isRenderActive); - - starColors.serializeToNBT(NBT); + if (ringAmount != DEFAULT_RING_AMOUNT) { + NBT.setInteger("ringAmount", ringAmount); + } super.saveNBTData(NBT); } + private void saveGeneralNBT(NBTTagCompound NBT) { + if (selectedFuelType != 0) NBT.setInteger("selectedFuelType", selectedFuelType); + if (internalBattery != 0) NBT.setInteger("internalBattery", internalBattery); + if (batteryCharging) NBT.setBoolean("batteryCharging", true); + if (gravitonShardsAvailable != 0) NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + if (gravitonShardsSpent != 0) NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + if (!BigInteger.ZERO.equals(totalPowerConsumed)) + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + if (totalRecipesProcessed != 0) NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + if (totalFuelConsumed != 0) NBT.setLong("totalFuelConsumed", totalFuelConsumed); + if (stellarFuelAmount != 0) NBT.setInteger("starFuelStored", stellarFuelAmount); + if (gravitonShardEjection) NBT.setBoolean("gravitonShardEjection", true); + if (secretUpgrade) NBT.setBoolean("secretUpgrade", true); + + // Fields with non-zero defaults + if (fuelConsumptionFactor != DEFAULT_FUEL_CONSUMPTION_FACTOR) { + NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); + } + if (maxBatteryCharge != DEFAULT_MAX_BATTERY_CHARGE) { + NBT.setInteger("batterySize", maxBatteryCharge); + } + + // Upgrades + NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); + boolean hasSomeUpgrade = false; + for (int i = 0; i < upgrades.length; i++) { + boolean value = upgrades[i]; + upgradeBooleanArrayNBTTag.setBoolean("upgrade" + i, value); + if (value) hasSomeUpgrade = true; + } + if (hasSomeUpgrade) NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + + // Upgrade material costs paid + NBTTagCompound upgradeMaterialBooleanArrayNBTTag = new NBTTagCompound(); + boolean someCostPaid = false; + for (int i = 0; i < materialPaidUpgrades.length; i++) { + boolean value = materialPaidUpgrades[i]; + upgradeMaterialBooleanArrayNBTTag.setBoolean("upgradeMaterial" + i, value); + if (value) someCostPaid = true; + } + if (someCostPaid) NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); + + // Custom star colors + starColors.serializeToNBT(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")); @@ -4039,21 +4018,30 @@ public void loadNBTData(NBTTagCompound NBT) { totalFuelConsumed = NBT.getLong("totalFuelConsumed"); stellarFuelAmount = NBT.getInteger("starFuelStored"); gravitonShardEjection = NBT.getBoolean("gravitonShardEjection"); - ringAmount = NBT.getInteger("ringAmount"); secretUpgrade = NBT.getBoolean("secretUpgrade"); - NBTTagCompound tempBooleanTag = NBT.getCompoundTag("upgrades"); - - for (int upgradeIndex = 0; upgradeIndex < 31; upgradeIndex++) { - boolean upgrade = tempBooleanTag.getBoolean("upgrade" + upgradeIndex); - upgrades[upgradeIndex] = upgrade; + // Fields with non-zero defaults + if (NBT.hasKey("fuelConsumptionFactor")) { + fuelConsumptionFactor = NBT.getInteger("fuelConsumptionFactor"); + } + if (NBT.hasKey("batterySize")) { + maxBatteryCharge = NBT.getInteger("batterySize"); } - tempBooleanTag = NBT.getCompoundTag("upgradeMaterials"); + if (NBT.hasKey("upgrades")) { + NBTTagCompound upgradesTag = NBT.getCompoundTag("upgrades"); + for (int i = 0; i < upgrades.length; i++) { + boolean upgrade = upgradesTag.getBoolean("upgrade" + i); + upgrades[i] = upgrade; + } + } - for (int upgradeIndex = 0; upgradeIndex < 7; upgradeIndex++) { - boolean upgrade = tempBooleanTag.getBoolean("upgradeMaterial" + upgradeIndex); - materialPaidUpgrades[upgradeIndex] = upgrade; + if (NBT.hasKey("upgradeMaterials")) { + NBTTagCompound materialsTag = NBT.getCompoundTag("upgradeMaterials"); + for (int i = 0; i < materialPaidUpgrades.length; i++) { + boolean upgrade = materialsTag.getBoolean("upgradeMaterial" + i); + materialPaidUpgrades[i] = upgrade; + } } NBTTagCompound tempItemTag = NBT.getCompoundTag("upgradeWindowStorage"); @@ -4073,6 +4061,7 @@ public void loadNBTData(NBTTagCompound NBT) { starSize = NBT.getInteger("starSize"); selectedStarColor = NBT.getString("selectedStarColor"); isRenderActive = NBT.getBoolean("isRenderActive"); + if (NBT.hasKey("ringAmount")) ringAmount = NBT.getInteger("ringAmount"); starColors.rebuildFromNBT(NBT); From a7b6d38d1945f5062d8b7daf18aff222cedacac6 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 15:12:58 -0500 Subject: [PATCH 02/52] fix nbt saving issue --- .../multi/godforge/MTEForgeOfGods.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index e0b10bd68fb..e5a172bbaea 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -3927,13 +3927,13 @@ protected void setHatchRecipeMap(MTEHatchInput hatch) {} @Override public void setItemNBT(NBTTagCompound NBT) { - saveGeneralNBT(NBT); + saveGeneralNBT(NBT, false); super.saveNBTData(NBT); } @Override public void saveNBTData(NBTTagCompound NBT) { - saveGeneralNBT(NBT); + saveGeneralNBT(NBT, true); // Upgrade window stored items NBTTagCompound upgradeWindowStorageNBTTag = new NBTTagCompound(); @@ -3960,25 +3960,25 @@ public void saveNBTData(NBTTagCompound NBT) { super.saveNBTData(NBT); } - private void saveGeneralNBT(NBTTagCompound NBT) { - if (selectedFuelType != 0) NBT.setInteger("selectedFuelType", selectedFuelType); - if (internalBattery != 0) NBT.setInteger("internalBattery", internalBattery); - if (batteryCharging) NBT.setBoolean("batteryCharging", true); - if (gravitonShardsAvailable != 0) NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); - if (gravitonShardsSpent != 0) NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); - if (!BigInteger.ZERO.equals(totalPowerConsumed)) + private void saveGeneralNBT(NBTTagCompound NBT, boolean force) { + if (force || selectedFuelType != 0) NBT.setInteger("selectedFuelType", selectedFuelType); + if (force || internalBattery != 0) NBT.setInteger("internalBattery", internalBattery); + if (force || batteryCharging) NBT.setBoolean("batteryCharging", true); + if (force || gravitonShardsAvailable != 0) NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); + if (force || gravitonShardsSpent != 0) NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); + if (force || !BigInteger.ZERO.equals(totalPowerConsumed)) NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); - if (totalRecipesProcessed != 0) NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); - if (totalFuelConsumed != 0) NBT.setLong("totalFuelConsumed", totalFuelConsumed); - if (stellarFuelAmount != 0) NBT.setInteger("starFuelStored", stellarFuelAmount); - if (gravitonShardEjection) NBT.setBoolean("gravitonShardEjection", true); - if (secretUpgrade) NBT.setBoolean("secretUpgrade", true); + if (force || totalRecipesProcessed != 0) NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); + if (force || totalFuelConsumed != 0) NBT.setLong("totalFuelConsumed", totalFuelConsumed); + if (force || stellarFuelAmount != 0) NBT.setInteger("starFuelStored", stellarFuelAmount); + if (force || gravitonShardEjection) NBT.setBoolean("gravitonShardEjection", true); + if (force || secretUpgrade) NBT.setBoolean("secretUpgrade", true); // Fields with non-zero defaults - if (fuelConsumptionFactor != DEFAULT_FUEL_CONSUMPTION_FACTOR) { + if (force || fuelConsumptionFactor != DEFAULT_FUEL_CONSUMPTION_FACTOR) { NBT.setInteger("fuelConsumptionFactor", fuelConsumptionFactor); } - if (maxBatteryCharge != DEFAULT_MAX_BATTERY_CHARGE) { + if (force || maxBatteryCharge != DEFAULT_MAX_BATTERY_CHARGE) { NBT.setInteger("batterySize", maxBatteryCharge); } @@ -3990,7 +3990,7 @@ private void saveGeneralNBT(NBTTagCompound NBT) { upgradeBooleanArrayNBTTag.setBoolean("upgrade" + i, value); if (value) hasSomeUpgrade = true; } - if (hasSomeUpgrade) NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); + if (force || hasSomeUpgrade) NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); // Upgrade material costs paid NBTTagCompound upgradeMaterialBooleanArrayNBTTag = new NBTTagCompound(); @@ -4000,7 +4000,7 @@ private void saveGeneralNBT(NBTTagCompound NBT) { upgradeMaterialBooleanArrayNBTTag.setBoolean("upgradeMaterial" + i, value); if (value) someCostPaid = true; } - if (someCostPaid) NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); + if (force || someCostPaid) NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); // Custom star colors starColors.serializeToNBT(NBT); From ae85124459b073c89d1691b501c2c5a8a0f8a231 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:17:57 -0500 Subject: [PATCH 03/52] fix color interpolation on some cycle rate values --- src/main/java/tectech/thing/block/TileEntityForgeOfGods.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java index a8a8992a638..0e18b08667c 100644 --- a/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java +++ b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java @@ -200,7 +200,7 @@ public void incrementColors() { cycleStep = 0; } else { // update interp values to the next set, reset cycleStep then interpolate - cycleStep = -255; + cycleStep -= 255; cycleStarColors(); interpolateColors(); } From 0662f1bc2782606d5aeb4d0778e2a9ccf17fb3c7 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:21:47 -0500 Subject: [PATCH 04/52] fix nbt issue with ring amount --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index e5a172bbaea..77c8b57e655 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -3953,9 +3953,7 @@ public void saveNBTData(NBTTagCompound NBT) { NBT.setInteger("starSize", starSize); NBT.setString("selectedStarColor", selectedStarColor); NBT.setBoolean("isRenderActive", isRenderActive); - if (ringAmount != DEFAULT_RING_AMOUNT) { - NBT.setInteger("ringAmount", ringAmount); - } + NBT.setInteger("ringAmount", ringAmount); super.saveNBTData(NBT); } From ea8ff760ade33c177345c2ec6c844a4350c7a2ac Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:37:23 -0500 Subject: [PATCH 05/52] fix missed localization --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 2 +- src/main/resources/assets/tectech/lang/en_US.lang | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 77c8b57e655..937b24b44ff 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -863,7 +863,7 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont button.add(TecTechUITextures.OVERLAY_BUTTON_ARROW_BLUE_UP); return button.toArray(new IDrawable[0]); }) - .addTooltip("Path of Celestial Transcendence") + .addTooltip(translateToLocal("fog.button.upgradetree.tooltip")) .setPos(174, 167) .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index adadc268b93..6258577f5a6 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1025,6 +1025,7 @@ fog.debug.unlockall.text=Unlock all upgrades fog.debug.gravitonshardsetter.tooltip=Set the amount of availabe graviton shards fog.button.fuelconfig.tooltip=Fuel Configuration Menu +fog.button.upgradetree.tooltip=Path of Celestial Transcendence fog.button.furnacemode.tooltip.01=Blast Mode fog.button.furnacemode.tooltip.02=Furnace Mode fog.button.magmattermode.tooltip.01=Quark-Gluon Plasma Mode From bf1449df49589136aaca06c9a34070f7accb865b Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 20:11:58 -0500 Subject: [PATCH 06/52] fix render data defaults on break+replace --- .../metaTileEntity/multi/godforge/MTEForgeOfGods.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 937b24b44ff..d06094ad903 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -3952,8 +3952,8 @@ public void saveNBTData(NBTTagCompound NBT) { NBT.setInteger("rotationSpeed", rotationSpeed); NBT.setInteger("starSize", starSize); NBT.setString("selectedStarColor", selectedStarColor); - NBT.setBoolean("isRenderActive", isRenderActive); NBT.setInteger("ringAmount", ringAmount); + NBT.setBoolean("isRenderActive", isRenderActive); super.saveNBTData(NBT); } @@ -4055,11 +4055,11 @@ public void loadNBTData(NBTTagCompound NBT) { } // Renderer information - rotationSpeed = NBT.getInteger("rotationSpeed"); - starSize = NBT.getInteger("starSize"); - selectedStarColor = NBT.getString("selectedStarColor"); - isRenderActive = NBT.getBoolean("isRenderActive"); + if (NBT.hasKey("rotationSpeed")) rotationSpeed = NBT.getInteger("rotationSpeed"); + if (NBT.hasKey("starSize")) starSize = NBT.getInteger("starSize"); + if (NBT.hasKey("selectedStarColor")) selectedStarColor = NBT.getString("selectedStarColor"); if (NBT.hasKey("ringAmount")) ringAmount = NBT.getInteger("ringAmount"); + isRenderActive = NBT.getBoolean("isRenderActive"); starColors.rebuildFromNBT(NBT); From b3107b6f21201daf4800dee145f32b560fd6985c Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:01:09 -0500 Subject: [PATCH 07/52] update my custom preset, fix import --- .../multi/godforge/color/ForgeOfGodsStarColor.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java index 9593c1db95b..7904ea909b8 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -11,9 +11,9 @@ import org.jetbrains.annotations.Nullable; -import com.cleanroommc.modularui.utils.Color; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.shapes.Rectangle; +import com.gtnewhorizons.modularui.api.math.Color; import tectech.thing.gui.TecTechUITextures; @@ -48,10 +48,12 @@ public class ForgeOfGodsStarColor { .registerPreset(); public static final ForgeOfGodsStarColor MAYA_PICK = new ForgeOfGodsStarColor("Maya's Pick") - .addColor(91, 206, 250, 3.0f) - .addColor(245, 169, 184, 3.0f) + .addColor(0, 0, 0, 0.0f) + .addColor(109, 201, 225, 1.0f) .addColor(255, 255, 255, 3.0f) + .addColor(255, 172, 210, 1.0f) .setCycleSpeed(1) + .setCustomDrawable(new Rectangle().setColor(Color.rgb(255, 172, 210))) .registerPreset(); public static List getDefaultColors() { From 1f4dfc6faac2ff800eb9153c8dc2148d6eefd8b2 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:04:33 -0500 Subject: [PATCH 08/52] spotless, cleanup --- .../metaTileEntity/multi/godforge/MTEForgeOfGods.java | 9 ++++++--- .../multi/godforge/color/ForgeOfGodsStarColor.java | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index d06094ad903..ef7afd58241 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -133,6 +133,9 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int DEFAULT_FUEL_CONSUMPTION_FACTOR = 1; private static final int DEFAULT_MAX_BATTERY_CHARGE = 100; private static final int DEFAULT_RING_AMOUNT = 1; + private static final int DEFAULT_ROTATION_SPEED = 5; + private static final int DEFAULT_STAR_SIZE = 20; + private static final String DEFAULT_STAR_COLOR = ForgeOfGodsStarColor.DEFAULT.getName(); private static Textures.BlockIcons.CustomIcon ScreenON; @@ -171,9 +174,9 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, // Star cosmetics fields // actual star cosmetics private final StarColorStorage starColors = new StarColorStorage(); - private String selectedStarColor = ForgeOfGodsStarColor.DEFAULT.getName(); - private int rotationSpeed = 5; - private int starSize = 20; + private String selectedStarColor = DEFAULT_STAR_COLOR; + private int rotationSpeed = DEFAULT_ROTATION_SPEED; + private int starSize = DEFAULT_STAR_SIZE; // editing star color private ForgeOfGodsStarColor newStarColor = starColors.newTemplateColor(); private int starColorR, starColorG, starColorB; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java index 7904ea909b8..31bb441a05e 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -43,11 +43,11 @@ public class ForgeOfGodsStarColor { .setCustomDrawable(TecTechUITextures.PICTURE_RAINBOW_SQUARE) .registerPreset(); - public static final ForgeOfGodsStarColor CLOUD_PICK = new ForgeOfGodsStarColor("Cloud's Pick") + public static final ForgeOfGodsStarColor CLOUDS_PICK = new ForgeOfGodsStarColor("Cloud's Pick") .addColor(DEFAULT_RED, DEFAULT_GREEN, DEFAULT_BLUE, DEFAULT_GAMMA) // todo @cloud .registerPreset(); - public static final ForgeOfGodsStarColor MAYA_PICK = new ForgeOfGodsStarColor("Maya's Pick") + public static final ForgeOfGodsStarColor MAYAS_PICK = new ForgeOfGodsStarColor("Maya's Pick") .addColor(0, 0, 0, 0.0f) .addColor(109, 201, 225, 1.0f) .addColor(255, 255, 255, 3.0f) From eeb760d0afd441dbcd61f05fe1a7f3ab884fea4b Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:20:21 -0500 Subject: [PATCH 09/52] cleanup multi tooltip code --- .../multi/godforge/MTEForgeOfGods.java | 115 ++++-------------- .../godforge/color/ForgeOfGodsStarColor.java | 3 +- 2 files changed, 24 insertions(+), 94 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index ef7afd58241..1a2e01f5e86 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -3376,101 +3376,16 @@ public MultiblockTooltipBuilder createTooltip() { + "Clicking on the logo in the controller gui opens an extensive information window,") .addInfo("explaining everything there is to know about this multiblock.") .beginStructureBlock(127, 29, 186, false) + .addStructureInfo("Total blocks needed for the structure with " + getRingText("1", "2", "3") + "rings:") .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") + getRingText("3943", "7279", "11005") + "Transcendentally Amplified Magnetic Confinement Casing") + .addStructureInfo(getRingText("2819", "4831", "6567") + "Singularity Reinforced Stellar Shielding Casing") + .addStructureInfo(getRingText("272", "512", "824") + "Celestial Matter Guidance Casing") + .addStructureInfo(getRingText("130", "144", "158") + "Boundless Gravitationally Severed Structure Casing") + .addStructureInfo(getRingText("9", "54", "155") + "Spatially Transcendent Gravitational Lens Block") .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") + getRingText("345", "357", "397") + getRingText("Remote", "Medial", "Central") + + "Graviton Flow Modulator") .addStructureInfo( EnumChatFormatting.GOLD + "36" + EnumChatFormatting.GRAY + " Stellar Energy Siphon Casing") .addStructureInfoSeparator() @@ -3481,6 +3396,20 @@ public MultiblockTooltipBuilder createTooltip() { return tt; } + private static String getRingText(String oneRing, String twoRings, String threeRings) { + return EnumChatFormatting.DARK_PURPLE + oneRing + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.DARK_GREEN + + twoRings + + EnumChatFormatting.GRAY + + "/" + + EnumChatFormatting.AQUA + + threeRings + + EnumChatFormatting.GRAY + + " "; + } + @Override public boolean energyFlowOnRunningTick(ItemStack aStack, boolean allowProduction) { return true; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java index 31bb441a05e..dec00f0d3e6 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -29,6 +29,7 @@ public class ForgeOfGodsStarColor { public static final int DEFAULT_GREEN = 204; public static final int DEFAULT_BLUE = 255; public static final float DEFAULT_GAMMA = 3.0f; + public static final int DEFAULT_CYCLE_SPEED = 1; public static final ForgeOfGodsStarColor DEFAULT = new ForgeOfGodsStarColor("Default") .addColor(DEFAULT_RED, DEFAULT_GREEN, DEFAULT_BLUE, DEFAULT_GAMMA) @@ -70,7 +71,7 @@ public static List getDefaultColors() { // Star render settings private final List settings = new ArrayList<>(); - private int cycleSpeed = 1; + private int cycleSpeed = DEFAULT_CYCLE_SPEED; protected ForgeOfGodsStarColor(String name) { this(name, LATEST_VERSION); From 7148c95a4127fa5f0fd3064393e206017aadb107 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 21 Oct 2024 23:57:29 -0500 Subject: [PATCH 10/52] fix lang typo --- src/main/resources/assets/tectech/lang/en_US.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 6258577f5a6..1bb82478811 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1022,7 +1022,7 @@ fog.upgrade.text.30=Unlocks Magmatter production in the Heliofusion Exoticizer, fog.debug.resetbutton.text=Reset fog.debug.resetbutton.tooltip=Resets all upgrades to zero fog.debug.unlockall.text=Unlock all upgrades -fog.debug.gravitonshardsetter.tooltip=Set the amount of availabe graviton shards +fog.debug.gravitonshardsetter.tooltip=Set the amount of available graviton shards fog.button.fuelconfig.tooltip=Fuel Configuration Menu fog.button.upgradetree.tooltip=Path of Celestial Transcendence From de04ec5603fb5162d9e7e3f8ef3d2d25c56ed379 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Tue, 22 Oct 2024 23:28:47 +0200 Subject: [PATCH 11/52] fix rainbow icon size --- .../textures/gui/picture/rainbow_square.png | Bin 3493 -> 3665 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/tectech/textures/gui/picture/rainbow_square.png b/src/main/resources/assets/tectech/textures/gui/picture/rainbow_square.png index 545a44c4e5dfe980679f07ab47a0dec5aa012ee5..fe2b63b50e8bacee613a7d658042b312cf38596a 100644 GIT binary patch delta 3662 zcmV-U4zcm28_^sgiBL{Q4GJ0x0000DNk~Le0000g0000g2m$~A07{`=43Qxyf5HF& z4#EKyC`y0;01f6zL_t(oM?IM7Z(P@T#((GDSvkWQ?i`Y$D2d`COO~u?vn|`HEXi{0 zID(r6NSl60fTCaWAwYowDH>GiKM?eLKPGKbqfX;Gjx5{qu2{B|ShXdQ6nBag7jd}E z3}?T$&$*LybTFXqa^CHEpZ7UqfAF7yb(i%No9&c4@H;@O9ar;ag z>_85-VJlerTURQ<1A4Lt9)lAwyh->vd;}lEjb?Jk;7NGg=cI}GsSfhpcp1>rJ6c`A zk`rlIX~OQ(m}fu zM?6ML^lg*gBAO2XU?7H{qLyYS#d?HE_yguTy*D|w$Z20?EgoV%WjB)t)d0N8@mIEq zz5~C5w?fPwhx5jhM`JJ^ESaB4^WZ3T;o@|W!;5r|5!M}rvTWEklx1AzeOeU_HtUb# z50mR)%sL7x^lpjZAE{s-QGPY3bN8~@+nZm=dC7KSJb z5ziHQVuH-?ac;ov2y@+JGgQ=+%Dq6RPZ6VRtkV5};WdtXoWVcAMvDdaf3fdPo?GL2 zYEQD%!JHuZox^SOHS-h?Gh7< zgop?;_l52nTix!Zs^M-M+iJw`RQUD{hW~@mFQZ(2jFso9e_gqNXFQHp87VPPqQAnf zy6w^3#;%}ce~X>WM3~KzE4dkZyXZ1oIdao9mEBgN9e802S79(|h^l*4%UPe5R`*i2 zhsr7Vc7coU((`l7uQS{|NBtY{qB^t6{ta616J5ex#o59s;nWCuK`aifhBnjSNP%$S zA(etNK&F!f>uTI7TK!NbZkoDdX`sm`D)cJ)86}|Ef4$@>r+-=CrMKw(g)lM5imYB# z&>q99BqngC0wNK~ib+%WZPZ#QHBpREcJPh8EMzC_w+MLk0nwr}N_SEK*_+?lW|8tdJziv(X16?tdzVbz$>0e3E@6*w{?F#8qwY`m*UuRE zCFYGiY^c(*{Y0Lm`r{6k$VJ|IZ;-+Wx6{1us<{w(T?+uKei1*497@*BI`n&$Ux;+{sr-Eym^KS>QE=l7bI>mSQkl|W^3LkTQV<-yVvZ9CT|l+sW{%*fQK|cSEkj`!pP1B#JeyUN{$a8)#x;GF<}!(g#2(^koJbLge@!*4 zL$WQsA%fLaPye*k5+UlYy`tGC&l}(8FC$qs zbH-r=hI~Sr@UpGlbzjv>;&n6Qe}u<4R8e~UguSbFsY(jX6Thj6CC~)ysdrRaIpGQX zic%Y7No|QJw2R`+5--}0(5@=Ha;^+1PwSFO{f-qIopM{d+iO9B=KizzH<0~t|E+)v;QNdP!j-n#Pf|23-2t4fBtqy^EceKBM&>Q$w+ z;8Ijkl}jZ=1^e9anafx!eE()Q+cdJsCs_KYC zi-4xfvaQ{1xGk$CP~WZ9eq2bw0%M0G?7N0a-IV46~*dY@~gSrU{PC@q*7e zt4gn7K4JHY747m@p*1o#m7*%NA6v4}i)&xyTw50mMXjJj1*>J#e-xT*DQkZ^W$2d5 zJw8BI6Ix^;$Y!dv=B-R^onvT{bE|yE7eiG0Y)vlH{y776+nNeO1rt!mTviUisS=Of zAmrHmT6)01Q`;)|w5dFLx!$n$c6@74HQ z_-l6dam|ROqgUC#e`ZfD^1Q+GqQ%KQ_~O^6$LW0E-cgc+gc~Yh`|a1+k`TdJV(-xQ zUNe4+ML*td^^Kq<)C%&oCh{jZx}UyfVw*VfD`n3~W=s@)@(GM7&vF8UNMWG4Y z;>0@{N*WjEmO1z~&IfUo_n-cekfg43>V3(DD0OASvs~Rve|Utsh`_zCXhw;t>Ou0A z0Ks=f)4qx2F4p^5+s%DRqy!&3R>WT>@iBu7>=j1@fY;+Vc&gvGUY9quQ|=@jEr6XY$nVtXlfZcdS!RTIa%ky>f=h&+%hY9PIM$5{9)Vx1p9 zwr9z%+w9r0e?eP3Nw7#PJ9HM+t=KtZJiK#3i^SNfWllURL zBK5j@#k7+itY^d96QpxykhW%9ew9&6*;G&uF!MN*xD&+h(K<_JgD#zzg7Ggj3pkT; zW=E(zE897qyGr|i>YSs4fwaYWng7vGNh%sir%BB*e;H8VLWA1GSKXR=N%m~4o7_E; z)sQq~lTD0zRm~}_U%<@~+a@W2R3_=!oB9a8>ndi9x!r7@z}IBHxW?0$N&m|5<|v!8 zEmike&E@ZYN}Hgr*)fx3HEro#fb=WuXcJ77&VJ(Q2U~2+O5%ny^rh%DcEkkYMkh{@ zTUC^+f4&Kki;zvQ(!s-h730eNo#BA{1#@&HY}g{gn4m8m4lX z`bm5V=nGXYEOPu^n{Y>mmK$HC`YrgT&jB5Gf2A${X!xDanF7%(@S8Yq9$;B4tQ0Ew z0Y7GTtg?EM(%1NXkIqk-E1aI>8D9d$-$yY`Hq1lElBUL)kfGCGsz!U>POHS1xMH8{ z>Yh<@Lj8Fi94fRc)W*5)w&CZ#mGqr@>~+KI!`#}BFGAHv=$gk&(^Wt$r<2D8CI@-T ze|4_Xf0KiYJW?02TdmP%RlFUPa$z%&(c-rW;XTPzPy`#oX+6D0MAK1S*l2aN#LvWA zQnQ+(I{3aJEq&ac&n;UBU=5<2rZp?wY<~_pL+&VJZCp3}k*KI^k&Z0sBC$Z(=-gqe zpWib*!k%wy@br zxd&edVyjF4ybPy&o(RhNv`?23f1o*}qtvwn%%8%S2ijX6Xka#Wl{66B1(i#xRcBJ?yS))-OZqHWx6~NIFD$|e-g0w zM@`&(l&tOua(Y@dRcafvS(#`Mul^9Rs^|iIppdK!@>Sn@Uf@jz`BNV$BnE*=tHUFu giJ~KiB3R@90Qt;{;vdawp#T5?07*qoM6N<$g0HVGd01Y}xL_t(oM@^VnY+HAB#((!-QY1xcBdvX-BwMyD$+9imO~w=3SsYKC zq{+mS7L%E22GgQ_=v!a=i8Q`C9XLJZ2Gr1;b*48rX=g&)E*F3$|p@;TNQaM{B0{;~MP?+-@`+~L)1;sl%t_&e?APZ4uoqq z-}m4>1J9>9aE0)va89RqFY8^4u`-e^cp0baPVU&dJ&<#B~Iupe1;d}{K9B#&$=pwJ1@~Xun<`OF4coZyF z9cFBXEbET3(szeLDPF+sVJwK^IZfyaZId*3Cg)igvU#vihCN<=e@NGVt6m=e06ScI z7iqkYUr;;iFxbWH4?vjMoug@y$Rv(Xr+lvzVWUb5arNYySg7Yg1z*?|XL#x=uV-a` zxmt1aA^vm3M-1qK#rJMkvw9ScEpzx3K^eZh&h`sF-NHGGde?*!sQezxhuxGKBiaKH$Z@f}g@=UCgFz$48BnzR$T^d$`Td5ET$<1Id z7*yswG6F}N#a7311}+}PRje;e5PrwUf9~YMe$u-PO$}v}Fl=~b-5`3Kt&iC?Lw|xD zb96|t68P82I23}c=b6j0N~n~^Ei==8=O(>wc{OR{e{FUaUz)r{R<5<%Y;&fb9LT+? zSZ4_z_w&v^2A{(1Eh^Rq1HXYUslLsDB(E2|Hz*uq{V2KT-~dj4f%qEbD+cPz0Wvw3 zU8zPz3nfhpx2@)Bdk3XHiK07+w`BArr*gH3y-wk;2Y6j_AZ)$8m#YVgR+V0HPk~;> zx=7C~e{Xn&zhe4j275SL$7fZ1S;@U>gSOxf!dpB$lp$MS(Z_0DPFNADdRIq60pB&;Z*Xs0jF#Z5r@jNfS76Cw9@0iNe}bK?Hn~^Xm2|d{wz!WsZNhO&ixzqv z{`pOOZ`X73Ajv;c-HT9ChA+bxbg#(j%p3eR=KFW6`4pYQG%XQL5lInRz#bzzftRo- zEhk=wZ_za(BiIG7T5!8FSDoGw`f+`toH{~$ zsJ)7PDzI9nX>m4OYUR!j5LpE%(PIwom_E0U!jJj1rsO#Nx7a2d5+B{F;lUG39bx`i z7Iu=}gtbt7VbCTc71J@YAzUsK%6Kv3e`VSjlQ)W0hIQ#AzwL0NlNEIVkw-Vzi=)7O zqXh>U-OlgX{Qs~81mc%)=^JQs_lA?brCbg5iEb2gg zD+a1dR&|o>gzY+p@0t_rNva_|ZDE03mv4l~1#UQpT;fP&N&P=+OqGN7NLtc9$EF%mRC$}c@FpY&X{ z8jRh5E09G!0^*QokR`P0Y?dlTf2rDx8DsRuvgREXW3wiYEF}elo{fQNxoBIr4~yZ;*-C{XO%&To%v?M z%21-NSae6`^;f-dudY0S2gQ8p@fHeQ-14;!nHeHzype-?R1->#@`$tsx0<90>dJ$&QyX}^xG(NPnpfBf7@<|)pG;^#QvDIFRTWmug|rkXvrj#429ZJjF!DqJgr zKW}c98N&;dW%E&kHQ5$Rq%9^SO_F0_(}kr_{;#RLMC=QKpBQ;HHCJkOllu`D8w2n1 z+(R+45Mm?$%A#bVGsWgX>}!65PN}R3SDEx@4Ed{ZZG~33#8x7-1@}4m|PvD%0G4%@0{sDuMN)=)W%SB*Ql=n$bTWUD{ zsoTETeMEFoPT*J0HC-i#Ssm3D5hS6f>v-J2jT%0QSnt^F@AAr5{M?nsESDLqX~|GB zHQnz_(DN}R@B6v_Jp96Qb`O}5x<(9?_ewzz{pWY0iSRnvgHUy za3UnEloFn;Y@@1eYRW1M87eE)F{90bmfMM^S*0IuFNJ<`-K;h+9c0)tfD+|}$oM)v z4{7=XzV{qH`yrV>(>$LfdP3vA6CIGavBgJNm{+zle?~?sqIf0Jo5^7->os(EvAWSk zDt|D_t*Jkbx~ zy#QZ1!2zcUFK$zt#@Yy4V(buAXpWoU@r08h-s(2jjOMM$X_iw8$I2NV`fU7`X$k6T z0rh{Ee^{1=WtvB+y+-&X_J28??B>yHc)t?f9uqkZ@0K&z$GlS*sH`E=Xc710moQ0I z#kzIE0jjHT?CcT`C!IxFqIB0Ks(jz&dAwvs_zA2j>}mWn1gB6th&&*Co#1(VT0~Fy z`M8stFR&&ky|G63HT=J^d9R5Z{j5o6E!*4re!AXY? z@L%L$Mu1Hn;Z_sp9QzuZ9#A_)bcIOXNRU#Ta#)NoTg_aYoLaTE!@U_=hVg5MJ6*w* z%_PJiu~(Oc_jD^4j*@>B4lWVUj;W_L3ZSG@s3+Dr9qt)*Bh(jKSN$+K<(-u&xsyqpzS&pc{o&vQ^|l6nsW~{6fbvz8Nfyn{M&>Z))_U&P_x}bqsgn{CA7Y>m*56 z6K=i9aXL)8gtU)!+ki_>s?b4?QrGP5A&oMNSW+-KSezjL_nNYpE&CsDvk-O?UEoOo O0000 Date: Tue, 22 Oct 2024 23:32:30 +0200 Subject: [PATCH 12/52] add my preset --- .../multi/godforge/color/ForgeOfGodsStarColor.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java index dec00f0d3e6..a97190b74c0 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -45,7 +45,14 @@ public class ForgeOfGodsStarColor { .registerPreset(); public static final ForgeOfGodsStarColor CLOUDS_PICK = new ForgeOfGodsStarColor("Cloud's Pick") - .addColor(DEFAULT_RED, DEFAULT_GREEN, DEFAULT_BLUE, DEFAULT_GAMMA) // todo @cloud + .addColor(255, 255, 0, 0.8f) + .addColor(0, 0, 0, 0) + .addColor(0, 255, 255, 0.4f) + .addColor(0, 0, 0, 0) + .setCycleSpeed(1) + .setCustomDrawable( + new Rectangle() + .setColor(Color.rgb(255, 255, 0), Color.rgb(0, 0, 0), Color.rgb(0, 0, 0), Color.rgb(0, 255, 255))) .registerPreset(); public static final ForgeOfGodsStarColor MAYAS_PICK = new ForgeOfGodsStarColor("Maya's Pick") From cd65ce4be69e5c98d2ec722cc33fa373b3c26a88 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Tue, 22 Oct 2024 17:37:44 -0500 Subject: [PATCH 13/52] update my star color icon --- .../multi/godforge/color/ForgeOfGodsStarColor.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java index a97190b74c0..900ef76f636 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -61,7 +61,12 @@ public class ForgeOfGodsStarColor { .addColor(255, 255, 255, 3.0f) .addColor(255, 172, 210, 1.0f) .setCycleSpeed(1) - .setCustomDrawable(new Rectangle().setColor(Color.rgb(255, 172, 210))) + .setCustomDrawable( + new Rectangle().setColor( + Color.rgb(255, 172, 210), + Color.rgb(255, 255, 255), + Color.rgb(0, 0, 0), + Color.rgb(109, 201, 225))) .registerPreset(); public static List getDefaultColors() { From 17444f485310c670d600755c65f09ef866209a85 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 25 Oct 2024 00:34:02 +0200 Subject: [PATCH 14/52] add possible inputs window to exotic module --- .../multi/godforge/MTEExoticModule.java | 158 ++++++++++++++++++ .../resources/assets/tectech/lang/en_US.lang | 3 + 2 files changed, 161 insertions(+) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index d30f9402d91..f6b5ee6b38a 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -1,5 +1,6 @@ package tectech.thing.metaTileEntity.multi.godforge; +import static gregtech.api.enums.Mods.NewHorizonsCoreMod; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.util.GTRecipeBuilder.INGOTS; import static gregtech.api.util.GTRecipeBuilder.SECONDS; @@ -42,6 +43,8 @@ import com.gtnewhorizons.modularui.api.drawable.ItemDrawable; import com.gtnewhorizons.modularui.api.fluids.FluidTanksHandler; import com.gtnewhorizons.modularui.api.fluids.IFluidTanksHandler; +import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.math.Size; @@ -53,6 +56,7 @@ import com.gtnewhorizons.modularui.common.widget.DrawableWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.api.enums.MaterialsUEVplus; @@ -87,12 +91,14 @@ public class MTEExoticModule extends MTEBaseModule { private boolean recipeInProgress = false; private boolean recipeRegenerated = false; private boolean magmatterMode = false; + private boolean isCoremodPresent = NewHorizonsCoreMod.isModLoaded(); private FluidStack[] randomizedFluidInput = new FluidStack[] {}; private ItemStack[] randomizedItemInput = new ItemStack[] {}; private GTRecipe plasmaRecipe = null; private BigInteger powerForRecipe = BigInteger.ZERO; private static final int NUMBER_OF_INPUTS = 7; private static final int INPUT_LIST_WINDOW_ID = 11; + private static final int POSSIBLE_INPUTS_WINDOW_ID = 12; public MTEExoticModule(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); @@ -465,6 +471,7 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont .setTooltipShowUpDelay(TOOLTIP_DELAY)); super.addUIWidgets(builder, buildContext); buildContext.addSyncedWindow(INPUT_LIST_WINDOW_ID, this::createInputListWindow); + buildContext.addSyncedWindow(POSSIBLE_INPUTS_WINDOW_ID, this::createPossibleInputsWindow); builder.widget(createMagmatterSwitch(builder)); builder.widget(createExpectedInputsButton()); builder.widget( @@ -548,6 +555,10 @@ protected ModularWindow createInputListWindow(final EntityPlayer player) { builder, (widget, val) -> widget.notifyTooltipChange())); + if (isCoremodPresent) { + builder.widget(createPossibleInputsButton()); + } + return builder.build(); } @@ -563,6 +574,153 @@ private Widget createExpectedInputsButton() { .setPos(8, 69); } + protected ModularWindow createPossibleInputsWindow(final EntityPlayer player) { + final int WIDTH = 300; + final int HEIGHT = 143; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(284, 4)); + + int QGPItemMapSize = exoticModulePlasmaItemMap.size(); + int QGPFluidMapSize = exoticModulePlasmaFluidMap.size(); + + IItemHandlerModifiable QGPItemHandler = new ItemStackHandler(QGPItemMapSize); + IFluidTanksHandler QGPFluidHandler = new FluidTanksHandler(QGPFluidMapSize, 128000); + + List> itemEntryList = new ArrayList<>(exoticModulePlasmaItemMap.entrySet()); + List> fluidEntryList = new ArrayList<>(exoticModulePlasmaFluidMap.entrySet()); + + int slotYQGP = 0; + + for (int i = 0; i < QGPItemMapSize + QGPFluidMapSize; i++) { + + int slotXQGP = 6 + i % 16 * 18; + slotYQGP = 17 + i / 16 * 18; + + if (i < QGPItemMapSize) { + QGPItemHandler.setStackInSlot( + i, + itemEntryList.get(i) + .getKey() + .splitStack(1)); + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) + .setPos(slotXQGP, slotYQGP) + .setSize(18, 18)); + builder.widget( + new SlotWidget(QGPItemHandler, i).setAccess(false, false) + .setRenderStackSize(false) + .disableInteraction() + .setPos(slotXQGP, slotYQGP) + .setSize(18, 18)); + } else { + QGPFluidHandler.setFluidInTank( + i - QGPItemMapSize, + fluidEntryList.get(i - QGPItemMapSize) + .getKey() + .getFluid(), + 1); + builder.widget( + new DrawableWidget().setDrawable(ModularUITextures.FLUID_SLOT) + .setSize(18, 18) + .setPos(slotXQGP, slotYQGP)) + .widget( + new FluidSlotWidget(QGPFluidHandler, i - QGPItemMapSize).setInteraction(false, false) + .setSize(18, 18) + .setPos(slotXQGP, slotYQGP)); + } + } + + int magMatterItemMapSize = exoticModuleMagmatterItemMap.size(); + + IItemHandlerModifiable magMatterItemHandler = new ItemStackHandler(magMatterItemMapSize); + IFluidTanksHandler magMatterFluidHandler = new FluidTanksHandler(2, 128000); + magMatterFluidHandler.setFluidInTank( + 0, + MaterialsUEVplus.Space.getMolten(1) + .getFluid(), + 1); + magMatterFluidHandler.setFluidInTank( + 1, + MaterialsUEVplus.Time.getMolten(1) + .getFluid(), + 1); + + List> magMatteritemEntryList = new ArrayList<>( + exoticModuleMagmatterItemMap.entrySet()); + + int slotXMagmatter; + int slotYMagmatter; + + for (int i = 0; i < magMatterItemMapSize + 2; i++) { + slotXMagmatter = 6 + i % 16 * 18; + slotYMagmatter = slotYQGP + 30 + i / 16 * 18; + + if (i < magMatterItemMapSize) { + magMatterItemHandler.setStackInSlot( + i, + magMatteritemEntryList.get(i) + .getKey() + .splitStack(1)); + builder.widget( + new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) + .setPos(slotXMagmatter, slotYMagmatter) + .setSize(18, 18)); + builder.widget( + new SlotWidget(magMatterItemHandler, i).setAccess(false, false) + .setRenderStackSize(false) + .disableInteraction() + .setPos(slotXMagmatter, slotYMagmatter) + .setSize(18, 18)); + } else { + builder.widget( + new DrawableWidget().setDrawable(ModularUITextures.FLUID_SLOT) + .setSize(18, 18) + .setPos(slotXMagmatter, slotYMagmatter)) + .widget( + new FluidSlotWidget(magMatterFluidHandler, i - magMatterItemMapSize) + .setInteraction(false, false) + .setSize(18, 18) + .setPos(slotXMagmatter, slotYMagmatter)); + } + } + + builder.widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.possibleinputsqgp")) + .setDefaultColor(EnumChatFormatting.BLACK) + .setTextAlignment(Alignment.Center) + .setSize(300, 9) + .setPos(0, 6)); + + builder.widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.possibleinputsmagmatter")) + .setDefaultColor(EnumChatFormatting.BLACK) + .setTextAlignment(Alignment.Center) + .setSize(300, 9) + .setPos(0, slotYQGP + 21)); + + return builder.build(); + } + + private Widget createPossibleInputsButton() { + return new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(POSSIBLE_INPUTS_WINDOW_ID); + } + }) + .setPlayClickSound(true) + .setBackground(ModularUITextures.ICON_INFO) + .addTooltip(translateToLocal("fog.button.possibleexoticinputs.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(16, 16) + .setPos(79, 37); + } + protected ButtonWidget createMagmatterSwitch(IWidgetBuilder builder) { Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { if (isMagmatterCapable) { diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 1bb82478811..badcd207622 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1043,6 +1043,7 @@ fog.button.materialrequirements.tooltip.clickhere=Click to open material inserti fog.button.ejection.tooltip=Toggle Graviton Shard Ejection fog.button.formatting.tooltip=Toggle Number Formatting fog.button.exoticinputs.tooltip=Click to display expected inputs +fog.button.possibleexoticinputs.tooltip=Click to display all possible inputs fog.button.reciperefresh.tooltip=Click to reset recipe fog.button.refreshtimer.tooltip=Reset ready in fog.button.seconds=Seconds @@ -1090,6 +1091,8 @@ gt.blockmachines.multimachine.FOG.milestoneinfo=View Milestone Progress gt.blockmachines.multimachine.FOG.inversionactive=Inversion Active gt.blockmachines.multimachine.FOG.inversion=Inversion gt.blockmachines.multimachine.FOG.expectedinputs=Expected Inputs +gt.blockmachines.multimachine.FOG.possibleinputsqgp=Possible Input Materials for QGP +gt.blockmachines.multimachine.FOG.possibleinputsmagmatter=Possible Input Materials for Magmatter gt.blockmachines.multimachine.FOG.inversioninfotext=Once all milestones of the Forge reach tier 7, inversion activates. This uncaps the maximum tier of all milestones and allows to scale infinitely. The scaling of each milestone changes from exponential to linear, but the granted graviton shard amount keeps increasing. The amount of progress needed for each subsequent milestone is as much as needed for the 7th tier of each milestone. The Composition milestone is once again an exception, as that continues to scale by 1 each tier, with it's own formula for calculating progress. Each module type is given a value, ranging from 1 for the Helioflare Power Forge to 5 for the Heliofusion Exoticizer in magmatter mode, then the amount of each module present is substracted by 1 and multiplied by its value. These values are added up and divided by 5, this is the final milestone tier on top of the base 7. gt.blockmachines.multimachine.FOG.powermilestone=Charge gt.blockmachines.multimachine.FOG.recipemilestone=Conversion From 580a1aee57f0cc532b956546eb05bde2f6bb91a3 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 25 Oct 2024 02:57:20 +0200 Subject: [PATCH 15/52] fix display itemstacks changing stacksize --- .../multi/godforge/MTEExoticModule.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index f6b5ee6b38a..72c99f5949e 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -73,6 +73,7 @@ import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; import gregtech.api.util.GTStreamUtil; +import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; import tectech.TecTech; @@ -604,9 +605,10 @@ protected ModularWindow createPossibleInputsWindow(final EntityPlayer player) { if (i < QGPItemMapSize) { QGPItemHandler.setStackInSlot( i, - itemEntryList.get(i) - .getKey() - .splitStack(1)); + GTUtility.copyAmount( + 1, + itemEntryList.get(i) + .getKey())); builder.widget( new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) .setPos(slotXQGP, slotYQGP) @@ -663,9 +665,10 @@ protected ModularWindow createPossibleInputsWindow(final EntityPlayer player) { if (i < magMatterItemMapSize) { magMatterItemHandler.setStackInSlot( i, - magMatteritemEntryList.get(i) - .getKey() - .splitStack(1)); + GTUtility.copyAmount( + 1, + magMatteritemEntryList.get(i) + .getKey())); builder.widget( new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) .setPos(slotXMagmatter, slotYMagmatter) From 0372af195862d8c693f7d08c65137b4ebf0e5053 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 25 Oct 2024 02:57:45 +0200 Subject: [PATCH 16/52] enable exotic module batch mode --- .../thing/metaTileEntity/multi/godforge/MTEExoticModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index 72c99f5949e..0083396fcdf 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -376,7 +376,7 @@ public boolean supportsSingleRecipeLocking() { @Override public boolean supportsBatchMode() { - return false; + return true; } @Override From fcb5662f64f76f9de01ef908cf4637c80d24959b Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:16:39 -0500 Subject: [PATCH 17/52] fix screwdriver render disabling toggle --- .../multi/godforge/MTEForgeOfGods.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 1a2e01f5e86..8eeab125232 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -48,6 +48,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; @@ -167,6 +168,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private FormattingMode formattingMode = FormattingMode.NONE; private boolean isRenderActive; private boolean secretUpgrade; + private boolean isRendererDisabled; private final ItemStack[] storedUpgradeWindowItems = new ItemStack[16]; public ArrayList moduleHatches = new ArrayList<>(); protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); @@ -408,7 +410,7 @@ public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStac return false; } - if (internalBattery != 0 && !isRenderActive) { + if (internalBattery != 0 && !isRenderActive && !isRendererDisabled) { createRenderer(); } // Check there is 1 input bus @@ -539,7 +541,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (stellarFuelAmount >= neededStartupFuel) { stellarFuelAmount -= neededStartupFuel; increaseBattery(neededStartupFuel); - createRenderer(); + if (!isRendererDisabled) createRenderer(); } } } @@ -794,15 +796,15 @@ private void buildThirdRing() { @Override public final void onScrewdriverRightClick(ForgeDirection side, EntityPlayer aPlayer, float aX, float aY, float aZ) { - if (!ConfigHandler.debug.DEBUG_MODE) return; - if (isRenderActive) { - destroyRenderer(); - isRenderActive = false; + if (isRendererDisabled) { + isRendererDisabled = false; + // let the renderer automatically rebuild itself as needed through normal logic } else { - ringAmount = 3; - createRenderer(); - isRenderActive = true; + isRendererDisabled = true; + if (isRenderActive) destroyRenderer(); } + aPlayer.addChatMessage( + new ChatComponentText("Animations are now " + (isRendererDisabled ? "disabled" : "enabled") + ".")); } @Override @@ -3886,6 +3888,7 @@ public void saveNBTData(NBTTagCompound NBT) { NBT.setString("selectedStarColor", selectedStarColor); NBT.setInteger("ringAmount", ringAmount); NBT.setBoolean("isRenderActive", isRenderActive); + NBT.setBoolean("isRendererDisabled", isRendererDisabled); super.saveNBTData(NBT); } @@ -3992,6 +3995,7 @@ public void loadNBTData(NBTTagCompound NBT) { if (NBT.hasKey("selectedStarColor")) selectedStarColor = NBT.getString("selectedStarColor"); if (NBT.hasKey("ringAmount")) ringAmount = NBT.getInteger("ringAmount"); isRenderActive = NBT.getBoolean("isRenderActive"); + isRendererDisabled = NBT.getBoolean("isRendererDisabled"); starColors.rebuildFromNBT(NBT); From b1bf7cce78b338f27381dccc8077c45e638eec60 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Wed, 30 Oct 2024 22:50:08 -0500 Subject: [PATCH 18/52] improve nbt further, save formatting mode --- .../multi/godforge/MTEForgeOfGods.java | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 8eeab125232..3470713168b 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -137,6 +137,8 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int DEFAULT_ROTATION_SPEED = 5; private static final int DEFAULT_STAR_SIZE = 20; private static final String DEFAULT_STAR_COLOR = ForgeOfGodsStarColor.DEFAULT.getName(); + private static final FormattingMode DEFAULT_FORMATTING_MODE = FormattingMode.NONE; + private static final BigInteger DEFAULT_TOTAL_POWER = BigInteger.ZERO; private static Textures.BlockIcons.CustomIcon ScreenON; @@ -161,11 +163,11 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private float invertedRecipeMilestonePercentage; private float invertedFuelMilestonePercentage; private float invertedStructureMilestonePercentage; - private BigInteger totalPowerConsumed = BigInteger.ZERO; + private BigInteger totalPowerConsumed = DEFAULT_TOTAL_POWER; private boolean batteryCharging; private boolean inversion; private boolean gravitonShardEjection; - private FormattingMode formattingMode = FormattingMode.NONE; + private FormattingMode formattingMode = DEFAULT_FORMATTING_MODE; private boolean isRenderActive; private boolean secretUpgrade; private boolean isRendererDisabled; @@ -3899,8 +3901,6 @@ private void saveGeneralNBT(NBTTagCompound NBT, boolean force) { if (force || batteryCharging) NBT.setBoolean("batteryCharging", true); if (force || gravitonShardsAvailable != 0) NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); if (force || gravitonShardsSpent != 0) NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); - if (force || !BigInteger.ZERO.equals(totalPowerConsumed)) - NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); if (force || totalRecipesProcessed != 0) NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); if (force || totalFuelConsumed != 0) NBT.setLong("totalFuelConsumed", totalFuelConsumed); if (force || stellarFuelAmount != 0) NBT.setInteger("starFuelStored", stellarFuelAmount); @@ -3914,6 +3914,12 @@ private void saveGeneralNBT(NBTTagCompound NBT, boolean force) { if (force || maxBatteryCharge != DEFAULT_MAX_BATTERY_CHARGE) { NBT.setInteger("batterySize", maxBatteryCharge); } + if (force || !DEFAULT_TOTAL_POWER.equals(totalPowerConsumed)) { + NBT.setByteArray("totalPowerConsumed", totalPowerConsumed.toByteArray()); + } + if (force || formattingMode != DEFAULT_FORMATTING_MODE) { + NBT.setInteger("formattingMode", formattingMode.ordinal()); + } // Upgrades NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); @@ -3946,7 +3952,6 @@ public void loadNBTData(NBTTagCompound NBT) { batteryCharging = NBT.getBoolean("batteryCharging"); 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"); @@ -3960,6 +3965,13 @@ public void loadNBTData(NBTTagCompound NBT) { if (NBT.hasKey("batterySize")) { maxBatteryCharge = NBT.getInteger("batterySize"); } + if (NBT.hasKey("totalPowerConsumed")) { + totalPowerConsumed = new BigInteger(NBT.getByteArray("totalPowerConsumed")); + } + if (NBT.hasKey("formattingMode")) { + int index = MathHelper.clamp_int(NBT.getInteger("formattingMode"), 0, FormattingMode.VALUES.length); + formattingMode = FormattingMode.VALUES[index]; + } if (NBT.hasKey("upgrades")) { NBTTagCompound upgradesTag = NBT.getCompoundTag("upgrades"); From a87154bdc75bec0aeb51520a17685de1622f6c21 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Thu, 31 Oct 2024 05:37:30 +0100 Subject: [PATCH 19/52] replace power switch with cosmetic menu --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 3470713168b..b02aa626b07 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -898,7 +898,6 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont .setDefaultColor(EnumChatFormatting.WHITE) .setPos(6, 8) .setSize(74, 34)) - .widget(createPowerSwitchButton()) .widget(createBatteryButton(builder)) .widget(createEjectionSwitch(builder)) .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { @@ -967,7 +966,6 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont if (!widget.isClient()) widget.getContext() .openSyncedWindow(STAR_COSMETICS_WINDOW_ID); }) - .setSize(16, 16) .addTooltip(translateToLocal("fog.button.color.tooltip")) .setBackground(() -> { List button = new ArrayList<>(); @@ -975,7 +973,8 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont button.add(TecTechUITextures.OVERLAY_BUTTON_RAINBOW_SPIRAL); return button.toArray(new IDrawable[0]); }) - .setPos(152, 91) + .setPos(174, 148) + .setSize(16, 16) .setTooltipShowUpDelay(TOOLTIP_DELAY)); } From 171993cac3b5d9c6ef750778a069f49793982a00 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 12:40:38 -0500 Subject: [PATCH 20/52] change default formatting mode to commas --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index b02aa626b07..f24cc71ab12 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -137,7 +137,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int DEFAULT_ROTATION_SPEED = 5; private static final int DEFAULT_STAR_SIZE = 20; private static final String DEFAULT_STAR_COLOR = ForgeOfGodsStarColor.DEFAULT.getName(); - private static final FormattingMode DEFAULT_FORMATTING_MODE = FormattingMode.NONE; + private static final FormattingMode DEFAULT_FORMATTING_MODE = FormattingMode.COMMA; private static final BigInteger DEFAULT_TOTAL_POWER = BigInteger.ZERO; private static Textures.BlockIcons.CustomIcon ScreenON; From 3282d5628831620408bb019ccfd8e9466ba1e4fe Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 21:55:37 -0500 Subject: [PATCH 21/52] clean up exotic module modloaded checks --- .../thing/metaTileEntity/multi/godforge/MTEExoticModule.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index 0083396fcdf..bc93440066c 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -92,7 +92,6 @@ public class MTEExoticModule extends MTEBaseModule { private boolean recipeInProgress = false; private boolean recipeRegenerated = false; private boolean magmatterMode = false; - private boolean isCoremodPresent = NewHorizonsCoreMod.isModLoaded(); private FluidStack[] randomizedFluidInput = new FluidStack[] {}; private ItemStack[] randomizedItemInput = new ItemStack[] {}; private GTRecipe plasmaRecipe = null; @@ -556,7 +555,7 @@ protected ModularWindow createInputListWindow(final EntityPlayer player) { builder, (widget, val) -> widget.notifyTooltipChange())); - if (isCoremodPresent) { + if (NewHorizonsCoreMod.isModLoaded()) { builder.widget(createPossibleInputsButton()); } From ebe35abe26ffd032b3d9ede646134240c44368e2 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:15:41 -0500 Subject: [PATCH 22/52] fix star size/spin render updating --- .../multi/godforge/MTEForgeOfGods.java | 113 +++++++++++------- 1 file changed, 67 insertions(+), 46 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index f24cc71ab12..8bb9c1a6382 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -2680,8 +2680,6 @@ protected ModularWindow createStarCosmeticsWindow(final EntityPlayer player) { // Syncers builder.widget(new FakeSyncWidget.StringSyncer(() -> selectedStarColor, val -> selectedStarColor = val)); - builder.widget(new FakeSyncWidget.IntegerSyncer(() -> rotationSpeed, val -> rotationSpeed = val)); - builder.widget(new FakeSyncWidget.IntegerSyncer(() -> starSize, val -> starSize = val)); builder.widget(new FakeSyncWidget.IntegerSyncer(() -> editingStarIndex, val -> editingStarIndex = val)); builder.widget(starColors.getSyncer()); @@ -2751,50 +2749,73 @@ protected ModularWindow createStarCosmeticsWindow(final EntityPlayer player) { builder.widget(newPreset); - // Miscellaneous options not related to color settings - builder - .widget( - new TextWidget(EnumChatFormatting.UNDERLINE + translateToLocal("fog.cosmetics.misc")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(120, 25) - .setSize(80, 10)) - .widget( - TextWidget.localised("fog.cosmetics.spin") - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(120, 45) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> rotationSpeed = (int) val) - .setGetter(() -> rotationSpeed) - .setBounds(0, 100) - .setDefaultValue(5) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(155, 45) - .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)) - .widget( - TextWidget.localised("fog.cosmetics.size") - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(120, 65) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> starSize = (int) val) - .setGetter(() -> starSize) - .setBounds(1, 40) - .setDefaultValue(20) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(155, 65) - .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + // Misc Section + + // Header + builder.widget( + new TextWidget(EnumChatFormatting.UNDERLINE + translateToLocal("fog.cosmetics.misc")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(120, 25) + .setSize(80, 10)); + + // Spin Textbox + builder.widget( + TextWidget.localised("fog.cosmetics.spin") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(120, 45) + .setSize(60, 18)); + + NumericWidget rotationWidget = new NumericWidget(); + rotationWidget.setGetter(() -> rotationSpeed) + .setSetter(val -> { + if (rotationSpeed != (int) val) { + rotationSpeed = (int) val; + if (!rotationWidget.isClient()) { + updateRenderer(); + } + } + }) + .setBounds(0, 100) + .setDefaultValue(5) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(35, 18) + .setPos(155, 45) + .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + builder.widget(rotationWidget); + + // Size Textbox + builder.widget( + TextWidget.localised("fog.cosmetics.size") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(120, 65) + .setSize(60, 18)); + + NumericWidget spinWidget = new NumericWidget(); + spinWidget.setGetter(() -> starSize) + .setSetter(val -> { + if (starSize != (int) val) { + starSize = (int) val; + if (!spinWidget.isClient()) { + updateRenderer(); + } + } + }) + .setBounds(1, 40) + .setDefaultValue(20) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setSize(35, 18) + .setPos(155, 65) + .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + builder.widget(spinWidget); return builder.build(); } From bc0cc15e85f982c517123a1b3df13dc21c24a2cd Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:27:24 -0500 Subject: [PATCH 23/52] move GodforgeMath class to godforge package --- .../java/tectech/loader/recipe/Godforge.java | 2 +- .../multi/godforge}/GodforgeMath.java | 9 +------- .../multi/godforge/MTEExoticModule.java | 1 - .../multi/godforge/MTEForgeOfGods.java | 22 +++++++++---------- 4 files changed, 13 insertions(+), 21 deletions(-) rename src/main/java/tectech/{util => thing/metaTileEntity/multi/godforge}/GodforgeMath.java (95%) diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index 981f6b139a7..6a1ca170f7e 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -13,7 +13,7 @@ import static gregtech.api.util.GTRecipeConstants.FOG_PLASMA_TIER; import static tectech.recipe.TecTechRecipeMaps.godforgeExoticMatterRecipes; import static tectech.recipe.TecTechRecipeMaps.godforgePlasmaRecipes; -import static tectech.util.GodforgeMath.getRandomIntInRange; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.getRandomIntInRange; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/tectech/util/GodforgeMath.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java similarity index 95% rename from src/main/java/tectech/util/GodforgeMath.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java index d4d43f01cf2..2e09a62b7e5 100644 --- a/src/main/java/tectech/util/GodforgeMath.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java @@ -1,14 +1,7 @@ -package tectech.util; +package tectech.thing.metaTileEntity.multi.godforge; import java.math.BigInteger; -import tectech.thing.metaTileEntity.multi.godforge.MTEBaseModule; -import tectech.thing.metaTileEntity.multi.godforge.MTEExoticModule; -import tectech.thing.metaTileEntity.multi.godforge.MTEForgeOfGods; -import tectech.thing.metaTileEntity.multi.godforge.MTEMoltenModule; -import tectech.thing.metaTileEntity.multi.godforge.MTEPlasmaModule; -import tectech.thing.metaTileEntity.multi.godforge.MTESmeltingModule; - public class GodforgeMath { public static int getRandomIntInRange(int min, int max) { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index bc93440066c..ab3f8225f70 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -80,7 +80,6 @@ import tectech.recipe.TecTechRecipeMaps; import tectech.thing.CustomItemList; import tectech.thing.gui.TecTechUITextures; -import tectech.util.GodforgeMath; public class MTEExoticModule extends MTEBaseModule { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 8bb9c1a6382..f55e5feb5ae 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -14,17 +14,17 @@ 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.thing.metaTileEntity.multi.godforge.GodforgeMath.allowModuleConnection; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateEnergyDiscountForModules; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateFuelConsumption; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxFuelFactor; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxHeatForModules; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxParallelForModules; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateProcessingVoltageForModules; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateSpeedBonusForModules; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateStartupFuelConsumption; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.queryMilestoneStats; +import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.setMiscModuleParameters; import static tectech.util.TTUtility.toExponentForm; import java.awt.Desktop; From 0f390d2e6a30133baf97bda4d005477f4d5eb426 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:47:39 -0500 Subject: [PATCH 24/52] clean up upgrade tree ui window creation --- .../multi/godforge/MTEForgeOfGods.java | 487 +++--------------- 1 file changed, 59 insertions(+), 428 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index f55e5feb5ae..ffdca849cc7 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -1551,435 +1551,66 @@ protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, 28, 29)) .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, 29, 30)); + // spotless:off 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, - 4, - 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, - 4, - 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 MultiChildWidget().addChild( - new ButtonWidget().setOnClick(((clickData, widget) -> secretUpgrade = !secretUpgrade)) - .setSize(40, 15) - .setBackground(() -> { - if (secretUpgrade) { - return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_PRESSED_32x16 }; - } - return new IDrawable[0]; - }) - .addTooltip(translateToLocal("fog.upgrade.tt.secret")) - .setTooltipShowUpDelay(20)) - .addChild( - new TextWidget(translateToLocal("fog.upgrade.tt.short.secret")).setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.Center) - .setSize(34, 9) - .setPos(3, 4) - .setEnabled((widget -> secretUpgrade))) - .addChild( - new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE_OPAQUE) - .setEnabled(widget -> secretUpgrade) - .setPos(40, 4) - .setSize(20, 6)) - .setPos(new Pos2d(66, 56))) + .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, 4, 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, 4, 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)); + // spotless:on + + scrollable.widget( + new MultiChildWidget().addChild( + new ButtonWidget().setOnClick(((clickData, widget) -> secretUpgrade = !secretUpgrade)) + .setSize(40, 15) + .setBackground(() -> { + if (secretUpgrade) { + return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_PRESSED_32x16 }; + } + return new IDrawable[0]; + }) + .addTooltip(translateToLocal("fog.upgrade.tt.secret")) + .setTooltipShowUpDelay(20)) + .addChild( + new TextWidget(translateToLocal("fog.upgrade.tt.short.secret")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setSize(34, 9) + .setPos(3, 4) + .setEnabled((widget -> secretUpgrade))) + .addChild( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE_OPAQUE) + .setEnabled(widget -> secretUpgrade) + .setPos(40, 4) + .setSize(20, 6)) + .setPos(new Pos2d(66, 56))) .widget(new TextWidget("").setPos(0, 945)); builder.widget( From 97f2aeb4b724d21192bec30931dbd6ff2a7763ab Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Thu, 31 Oct 2024 22:57:18 -0500 Subject: [PATCH 25/52] clean up readability further --- .../multi/godforge/MTEForgeOfGods.java | 137 +++++++++--------- 1 file changed, 69 insertions(+), 68 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index ffdca849cc7..0e078d0b96f 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -1514,76 +1514,77 @@ protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { final int PARENT_HEIGHT = 300; ModularWindow.Builder builder = ModularWindow.builder(PARENT_WIDTH, PARENT_HEIGHT); - scrollable.widget(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, 0, 0, 1)) - .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, 0, 1, 2)) - .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, 0, 1, 3)) - .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, 0, 2, 4)) - .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, 0, 2, 5)) - .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, 0, 3, 5)) - .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, 0, 3, 6)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, 0, 5, 7)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, 0, 7, 9)) - .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, 4, 4, 8)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, 4, 7, 8)) - .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, 4, 6, 10)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, 4, 7, 10)) - .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, 0, 8, 11)) - .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, 0, 10, 11)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, 2, 11, 13)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, 2, 13, 18)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, 2, 18, 21)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, 2, 21, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, 1, 11, 12)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, 1, 12, 17)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, 1, 17, 20)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, 1, 20, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, 1, 17, 16)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, 3, 11, 14)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, 3, 14, 19)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, 3, 19, 22)) - .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, 3, 22, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, 3, 14, 15)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, 0, 23, 24)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, 0, 24, 25)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, 0, 25, 26)) - .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, 0, 26, 27)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, 0, 27, 28)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, 28, 29)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, 29, 30)); - // spotless:off 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, 4, 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, 4, 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(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, 0, 0, 1)) + .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, 0, 1, 2)) + .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, 0, 1, 3)) + .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, 0, 2, 4)) + .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, 0, 2, 5)) + .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, 0, 3, 5)) + .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, 0, 3, 6)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, 0, 5, 7)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, 0, 7, 9)) + .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, 4, 4, 8)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, 4, 7, 8)) + .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, 4, 6, 10)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, 4, 7, 10)) + .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, 0, 8, 11)) + .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, 0, 10, 11)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, 2, 11, 13)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, 2, 13, 18)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, 2, 18, 21)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, 2, 21, 23)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, 1, 11, 12)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, 1, 12, 17)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, 1, 17, 20)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, 1, 20, 23)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, 1, 17, 16)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, 3, 11, 14)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, 3, 14, 19)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, 3, 19, 22)) + .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, 3, 22, 23)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, 3, 14, 15)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, 0, 23, 24)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, 0, 24, 25)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, 0, 25, 26)) + .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, 0, 26, 27)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, 0, 27, 28)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, 28, 29)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, 29, 30)); + + 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, 4, 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, 4, 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)); // spotless:on scrollable.widget( From 7c07f9f8d0f9771cb3c0a09da0856983ee0e78bd Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 02:37:32 -0500 Subject: [PATCH 26/52] start on upgrade refactor --- .../godforge/upgrade/ForgeOfGodsUpgrade.java | 425 ++++++++++++++++++ 1 file changed, 425 insertions(+) create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java new file mode 100644 index 00000000000..4589f5d664b --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -0,0 +1,425 @@ +package tectech.thing.metaTileEntity.multi.godforge.upgrade; + +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGColor.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGIcon.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGWindowSize.*; + +import java.util.ArrayList; +import java.util.EnumMap; +import java.util.List; +import java.util.function.UnaryOperator; + +import net.minecraft.item.ItemStack; + +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Pos2d; + +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectList; +import it.unimi.dsi.fastutil.objects.ObjectLists; +import tectech.thing.gui.TecTechUITextures; + +// todo extra cost items +public enum ForgeOfGodsUpgrade { + + // spotless:off + + START(b -> b + .background(BLUE, COMPOSITION) + .windowSize(LARGE) + .treePos(126, 56)), + + IGCC(b -> b + .prereqs(START) + .cost(1) + .background(BLUE, CONVERSION) + .treePos(126, 116)), + + STEM(b -> b + .prereqs(IGCC) + .cost(1) + .background(BLUE, CATALYST) + .treePos(96, 176)), + + CFCE(b -> b + .prereqs(IGCC) + .cost(1) + .background(BLUE, CATALYST) + .treePos(156, 176)), + + GISS(b -> b + .prereqs(STEM) + .cost(1) + .background(BLUE, CHARGE) + .treePos(66, 236)), + + FDIM(b -> b + .prereqs(STEM, CFCE) + .cost(1) + .background(BLUE, COMPOSITION) + .treePos(126, 236)), + + SA(b -> b + .prereqs(CFCE) + .cost(1) + .background(BLUE, CONVERSION) + .treePos(186, 236)), + + GPCI(b -> b + .prereqs(FDIM) + .cost(2) + .background(BLUE, COMPOSITION) + .treePos(126, 296)), + + REC(b -> b + .prereqs(GISS, FDIM) + .requireAllPrereqs() + .cost(2) + .background(RED, CHARGE) + .treePos(56, 356)), + + GEM(b -> b + .prereqs(GPCI) + .cost(2) + .background(BLUE, CATALYST) + .treePos(126, 356)), + + CTCDD(b -> b + .prereqs(GPCI, SA) + .requireAllPrereqs() + .cost(2) + .background(RED, CONVERSION) + .treePos(196, 356)), + + QGIPU(b -> b + .prereqs(REC, CTCDD) + .cost(2) + .background(BLUE, CATALYST) + .treePos(126, 416)), + + SEFCP(b -> b + .prereqs(QGIPU) + .cost(3) + .background(PURPLE, CATALYST) + .treePos(66, 476)), + + TCT(b -> b + .prereqs(QGIPU) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 476)), + + GGEBE(b -> b + .prereqs(QGIPU) + .cost(3) + .background(GREEN, CHARGE) + .treePos(186, 476)), + + TPTP(b -> b + .prereqs(GGEBE) + .cost(4) + .background(GREEN, CONVERSION) + .treePos(246, 496)), + + DOP(b -> b + //.prereqs(CNTI) // todo + .cost(4) + .background(PURPLE, CONVERSION) + .treePos(6, 556)), + + CNTI(b -> b + .prereqs(SEFCP) + .cost(3) + .background(PURPLE, CHARGE) + .treePos(66, 536)), + + EPEC(b -> b + .prereqs(TCT) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 536)), + + IMKG(b -> b + .prereqs(GGEBE) + .cost(3) + .background(GREEN, CHARGE) + .treePos(186, 536)), + + NDPE(b -> b + .prereqs(CNTI) + .cost(3) + .background(PURPLE, CHARGE) + .treePos(66, 596)), + + POS(b -> b + .prereqs(EPEC) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 596)), + + DOR(b -> b + .prereqs(IMKG) + .cost(3) + .background(GREEN, CONVERSION) + .treePos(186, 596)), + + NGMS(b -> b + .prereqs(NDPE, POS, DOR) + .cost(4) + .background(BLUE, CHARGE) + .treePos(126, 656)), + + SEDS(b -> b + .prereqs(NGMS) + .cost(5) + .background(BLUE, CONVERSION) + .treePos(126, 718)), + + PA(b -> b + .prereqs(SEDS) + .cost(6) + .background(BLUE, CONVERSION) + .treePos(36, 758)), + + CD(b -> b + .prereqs(PA) + .cost(7) + .background(BLUE, COMPOSITION) + .treePos(36, 848)), + + TSE(b -> b + .prereqs(CD) + .cost(8) + .background(BLUE, CATALYST) + .treePos(126, 888)), + + TBF(b -> b + .prereqs(TSE) + .cost(9) + .background(BLUE, CHARGE) + .treePos(216, 848)), + + EE(b -> b + .prereqs(TBF) + .cost(10) + .background(BLUE, COMPOSITION) + .treePos(216, 758)), + + END(b -> b + .prereqs(EE) + .cost(12) + .background(BLUE, COMPOSITION) + .treePos(126, 798)), + + // spotless:on + + // SECRET(), // todo + + ; + + public static final ForgeOfGodsUpgrade[] VALUES = values(); + + static { + // build inverse dependents mapping + // todo make sure this is right + EnumMap> dependencies = new EnumMap<>(ForgeOfGodsUpgrade.class); + for (ForgeOfGodsUpgrade upgrade : VALUES) { + for (ForgeOfGodsUpgrade prerequisite : upgrade.prerequisites) { + dependencies.computeIfAbsent(prerequisite, $ -> new ArrayList<>()) + .add(upgrade); + } + } + for (var entry : dependencies.entrySet()) { + ForgeOfGodsUpgrade upgrade = entry.getKey(); + List deps = entry.getValue(); + if (deps == null) { + upgrade.dependents = new ForgeOfGodsUpgrade[0]; + } else { + upgrade.dependents = deps.toArray(new ForgeOfGodsUpgrade[0]); + } + } + + // scan for start of split upgrades + // todo make sure this is right + for (ForgeOfGodsUpgrade upgrade : VALUES) { + if (upgrade.dependents.length > 1) { + for (ForgeOfGodsUpgrade u : upgrade.dependents) { + u.startOfSplit = true; + } + } + } + } + + // Static tree linking + private final ForgeOfGodsUpgrade[] prerequisites; + private final boolean requireAllPrerequisites; + + // Cost + private final int shardCost; + private final List extraCost; + + // UI + private final BGColor color; + private final BGIcon icon; + private final BGWindowSize windowSize; + private final Pos2d treePos; + + // Pre-generated data + private ForgeOfGodsUpgrade[] dependents; + private boolean startOfSplit; + private final String name; + private final String nameShort; + private final String bodyText; + private final String loreText; + + ForgeOfGodsUpgrade(UnaryOperator u) { + Builder b = u.apply(new Builder()); + + this.prerequisites = b.prerequisites != null ? b.prerequisites.toArray(new ForgeOfGodsUpgrade[0]) + : new ForgeOfGodsUpgrade[0]; + this.requireAllPrerequisites = b.requireAllPrerequisites; + this.shardCost = b.shardCost; + this.extraCost = b.extraCost != null ? ObjectLists.unmodifiable(b.extraCost) : ObjectLists.emptyList(); + this.color = b.color; + this.icon = b.icon; + this.windowSize = b.windowSize; + this.treePos = b.treePos; + + this.name = "fog.upgrade.tt." + ordinal(); + this.nameShort = "fog.upgrade.tt.short." + ordinal(); + this.bodyText = "fog.upgrade.text." + ordinal(); + this.loreText = "fog.upgrade.lore." + ordinal(); + } + + public static class Builder { + + // Tree linking + private ObjectList prerequisites; + private boolean requireAllPrerequisites; + + // Cost + private int shardCost; + private ObjectList extraCost; + + // UI + private BGColor color = BLUE; + private BGIcon icon = CHARGE; + private BGWindowSize windowSize = STANDARD; + private Pos2d treePos = new Pos2d(0, 0); + + private Builder() {} + + public Builder prereqs(ForgeOfGodsUpgrade... prereqs) { + if (this.prerequisites != null) { + throw new IllegalArgumentException("Cannot repeat calls to ForgeOfGodsUpgrade$Builder#prereqs"); + } + this.prerequisites = new ObjectArrayList<>(prereqs); + return this; + } + + public Builder requireAllPrereqs() { + this.requireAllPrerequisites = true; + return this; + } + + // Cost + public Builder cost(int shards, ItemStack... extraCost) { + this.shardCost = shards; + if (extraCost != null) { + if (this.extraCost != null) { + throw new IllegalArgumentException("Cannot repeat calls to ForgeOfGodsUpgrade$Builder#cost"); + } + this.extraCost = new ObjectArrayList<>(extraCost); + } + return this; + } + + // UI + public Builder background(BGColor color, BGIcon icon) { + this.color = color; + this.icon = icon; + return this; + } + + public Builder windowSize(BGWindowSize windowSize) { + this.windowSize = windowSize; + return this; + } + + public Builder treePos(int x, int y) { + this.treePos = new Pos2d(x, y); + return this; + } + } + + public enum BGColor { + + BLUE(TecTechUITextures.BACKGROUND_GLOW_BLUE, TecTechUITextures.PICTURE_OVERLAY_BLUE), + PURPLE(TecTechUITextures.BACKGROUND_GLOW_PURPLE, TecTechUITextures.PICTURE_OVERLAY_PURPLE), + ORANGE(TecTechUITextures.BACKGROUND_GLOW_ORANGE, TecTechUITextures.PICTURE_OVERLAY_ORANGE), + GREEN(TecTechUITextures.BACKGROUND_GLOW_GREEN, TecTechUITextures.PICTURE_OVERLAY_GREEN), + RED(TecTechUITextures.BACKGROUND_GLOW_RED, TecTechUITextures.PICTURE_OVERLAY_RED), + + ; + + private final UITexture background; + private final UITexture overlay; + + BGColor(UITexture background, UITexture overlay) { + this.background = background; + this.overlay = overlay; + } + + public UITexture getBackground() { + return background; + } + + public UITexture getOverlay() { + return overlay; + } + } + + public enum BGIcon { + + CHARGE(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE, 0.8f), + CONVERSION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION, 0.72f), + CATALYST(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST, 1.0f), + COMPOSITION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION, 1.0f), + + ; + + private final UITexture symbol; + private final float widthRatio; + + BGIcon(UITexture symbol, float widthRatio) { + this.symbol = symbol; + this.widthRatio = widthRatio; + } + + public UITexture getSymbol() { + return symbol; + } + + public float getWidthRatio() { + return widthRatio; + } + } + + public enum BGWindowSize { + + STANDARD(250, 250, 110), + LARGE(300, 300, 85), + + ; + + private final int width; + private final int height; + private final int loreY; + + BGWindowSize(int width, int height, int loreY) { + this.width = width; + this.height = height; + this.loreY = loreY; + } + } +} From d55f27f243876a27f40376cf010ac07bdef628f9 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:18:37 -0500 Subject: [PATCH 27/52] cleanup, fix forward reference design issue --- .../godforge/upgrade/ForgeOfGodsUpgrade.java | 525 ++++++++---------- .../upgrade/ForgeOfGodsUpgradeData.java | 76 +++ 2 files changed, 320 insertions(+), 281 deletions(-) create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 4589f5d664b..5a85108b09e 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -1,8 +1,8 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGColor.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGIcon.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGWindowSize.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGColor.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGIcon.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGWindowSize.*; import java.util.ArrayList; import java.util.EnumMap; @@ -11,207 +11,46 @@ import net.minecraft.item.ItemStack; -import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.math.Pos2d; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; import it.unimi.dsi.fastutil.objects.ObjectLists; -import tectech.thing.gui.TecTechUITextures; // todo extra cost items public enum ForgeOfGodsUpgrade { - // spotless:off - - START(b -> b - .background(BLUE, COMPOSITION) - .windowSize(LARGE) - .treePos(126, 56)), - - IGCC(b -> b - .prereqs(START) - .cost(1) - .background(BLUE, CONVERSION) - .treePos(126, 116)), - - STEM(b -> b - .prereqs(IGCC) - .cost(1) - .background(BLUE, CATALYST) - .treePos(96, 176)), - - CFCE(b -> b - .prereqs(IGCC) - .cost(1) - .background(BLUE, CATALYST) - .treePos(156, 176)), - - GISS(b -> b - .prereqs(STEM) - .cost(1) - .background(BLUE, CHARGE) - .treePos(66, 236)), - - FDIM(b -> b - .prereqs(STEM, CFCE) - .cost(1) - .background(BLUE, COMPOSITION) - .treePos(126, 236)), - - SA(b -> b - .prereqs(CFCE) - .cost(1) - .background(BLUE, CONVERSION) - .treePos(186, 236)), - - GPCI(b -> b - .prereqs(FDIM) - .cost(2) - .background(BLUE, COMPOSITION) - .treePos(126, 296)), - - REC(b -> b - .prereqs(GISS, FDIM) - .requireAllPrereqs() - .cost(2) - .background(RED, CHARGE) - .treePos(56, 356)), - - GEM(b -> b - .prereqs(GPCI) - .cost(2) - .background(BLUE, CATALYST) - .treePos(126, 356)), - - CTCDD(b -> b - .prereqs(GPCI, SA) - .requireAllPrereqs() - .cost(2) - .background(RED, CONVERSION) - .treePos(196, 356)), - - QGIPU(b -> b - .prereqs(REC, CTCDD) - .cost(2) - .background(BLUE, CATALYST) - .treePos(126, 416)), - - SEFCP(b -> b - .prereqs(QGIPU) - .cost(3) - .background(PURPLE, CATALYST) - .treePos(66, 476)), - - TCT(b -> b - .prereqs(QGIPU) - .cost(3) - .background(ORANGE, CONVERSION) - .treePos(126, 476)), - - GGEBE(b -> b - .prereqs(QGIPU) - .cost(3) - .background(GREEN, CHARGE) - .treePos(186, 476)), - - TPTP(b -> b - .prereqs(GGEBE) - .cost(4) - .background(GREEN, CONVERSION) - .treePos(246, 496)), - - DOP(b -> b - //.prereqs(CNTI) // todo - .cost(4) - .background(PURPLE, CONVERSION) - .treePos(6, 556)), - - CNTI(b -> b - .prereqs(SEFCP) - .cost(3) - .background(PURPLE, CHARGE) - .treePos(66, 536)), - - EPEC(b -> b - .prereqs(TCT) - .cost(3) - .background(ORANGE, CONVERSION) - .treePos(126, 536)), - - IMKG(b -> b - .prereqs(GGEBE) - .cost(3) - .background(GREEN, CHARGE) - .treePos(186, 536)), - - NDPE(b -> b - .prereqs(CNTI) - .cost(3) - .background(PURPLE, CHARGE) - .treePos(66, 596)), - - POS(b -> b - .prereqs(EPEC) - .cost(3) - .background(ORANGE, CONVERSION) - .treePos(126, 596)), - - DOR(b -> b - .prereqs(IMKG) - .cost(3) - .background(GREEN, CONVERSION) - .treePos(186, 596)), - - NGMS(b -> b - .prereqs(NDPE, POS, DOR) - .cost(4) - .background(BLUE, CHARGE) - .treePos(126, 656)), - - SEDS(b -> b - .prereqs(NGMS) - .cost(5) - .background(BLUE, CONVERSION) - .treePos(126, 718)), - - PA(b -> b - .prereqs(SEDS) - .cost(6) - .background(BLUE, CONVERSION) - .treePos(36, 758)), - - CD(b -> b - .prereqs(PA) - .cost(7) - .background(BLUE, COMPOSITION) - .treePos(36, 848)), - - TSE(b -> b - .prereqs(CD) - .cost(8) - .background(BLUE, CATALYST) - .treePos(126, 888)), - - TBF(b -> b - .prereqs(TSE) - .cost(9) - .background(BLUE, CHARGE) - .treePos(216, 848)), - - EE(b -> b - .prereqs(TBF) - .cost(10) - .background(BLUE, COMPOSITION) - .treePos(216, 758)), - - END(b -> b - .prereqs(EE) - .cost(12) - .background(BLUE, COMPOSITION) - .treePos(126, 798)), - - // spotless:on + START, + IGCC, + STEM, + CFCE, + GISS, + FDIM, + SA, + GPCI, + REC, + GEM, + CTCDD, + QGIPU, + SEFCP, + TCT, + GGEBE, + TPTP, + DOP, + CNTI, + EPEC, + IMKG, + NDPE, + POS, + DOR, + NGMS, + SEDS, + PA, + CD, + TSE, + TBF, + EE, + END, // SECRET(), // todo @@ -220,7 +59,200 @@ public enum ForgeOfGodsUpgrade { public static final ForgeOfGodsUpgrade[] VALUES = values(); static { - // build inverse dependents mapping + // Build upgrade data. Done here due to potential forward references + + // spotless:off + + START.build(b -> b + .background(BLUE, COMPOSITION) + .windowSize(LARGE) + .treePos(126, 56)); + + IGCC.build(b -> b + .prereqs(START) + .cost(1) + .background(BLUE, CONVERSION) + .treePos(126, 116)); + + STEM.build(b -> b + .prereqs(IGCC) + .cost(1) + .background(BLUE, CATALYST) + .treePos(96, 176)); + + CFCE.build(b -> b + .prereqs(IGCC) + .cost(1) + .background(BLUE, CATALYST) + .treePos(156, 176)); + + GISS.build(b -> b + .prereqs(STEM) + .cost(1) + .background(BLUE, CHARGE) + .treePos(66, 236)); + + FDIM.build(b -> b + .prereqs(STEM, CFCE) + .cost(1) + .background(BLUE, COMPOSITION) + .treePos(126, 236)); + + SA.build(b -> b + .prereqs(CFCE) + .cost(1) + .background(BLUE, CONVERSION) + .treePos(186, 236)); + + GPCI.build(b -> b + .prereqs(FDIM) + .cost(2) + .background(BLUE, COMPOSITION) + .treePos(126, 296)); + + REC.build(b -> b + .prereqs(GISS, FDIM) + .requireAllPrereqs() + .cost(2) + .background(RED, CHARGE) + .treePos(56, 356)); + + GEM.build(b -> b + .prereqs(GPCI) + .cost(2) + .background(BLUE, CATALYST) + .treePos(126, 356)); + + CTCDD.build(b -> b + .prereqs(GPCI, SA) + .requireAllPrereqs() + .cost(2) + .background(RED, CONVERSION) + .treePos(196, 356)); + + QGIPU.build(b -> b + .prereqs(REC, CTCDD) + .cost(2) + .background(BLUE, CATALYST) + .treePos(126, 416)); + + SEFCP.build(b -> b + .prereqs(QGIPU) + .cost(3) + .background(PURPLE, CATALYST) + .treePos(66, 476)); + + TCT.build(b -> b + .prereqs(QGIPU) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 476)); + + GGEBE.build(b -> b + .prereqs(QGIPU) + .cost(3) + .background(GREEN, CHARGE) + .treePos(186, 476)); + + TPTP.build(b -> b + .prereqs(GGEBE) + .cost(4) + .background(GREEN, CONVERSION) + .treePos(246, 496)); + + DOP.build(b -> b + .prereqs(CNTI) + .cost(4) + .background(PURPLE, CONVERSION) + .treePos(6, 556)); + + CNTI.build(b -> b + .prereqs(SEFCP) + .cost(3) + .background(PURPLE, CHARGE) + .treePos(66, 536)); + + EPEC.build(b -> b + .prereqs(TCT) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 536)); + + IMKG.build(b -> b + .prereqs(GGEBE) + .cost(3) + .background(GREEN, CHARGE) + .treePos(186, 536)); + + NDPE.build(b -> b + .prereqs(CNTI) + .cost(3) + .background(PURPLE, CHARGE) + .treePos(66, 596)); + + POS.build(b -> b + .prereqs(EPEC) + .cost(3) + .background(ORANGE, CONVERSION) + .treePos(126, 596)); + + DOR.build(b -> b + .prereqs(IMKG) + .cost(3) + .background(GREEN, CONVERSION) + .treePos(186, 596)); + + NGMS.build(b -> b + .prereqs(NDPE, POS, DOR) + .cost(4) + .background(BLUE, CHARGE) + .treePos(126, 656)); + + SEDS.build(b -> b + .prereqs(NGMS) + .cost(5) + .background(BLUE, CONVERSION) + .treePos(126, 718)); + + PA.build(b -> b + .prereqs(SEDS) + .cost(6) + .background(BLUE, CONVERSION) + .treePos(36, 758)); + + CD.build(b -> b + .prereqs(PA) + .cost(7) + .background(BLUE, COMPOSITION) + .treePos(36, 848)); + + TSE.build(b -> b + .prereqs(CD) + .cost(8) + .background(BLUE, CATALYST) + .treePos(126, 888)); + + TBF.build(b -> b + .prereqs(TSE) + .cost(9) + .background(BLUE, CHARGE) + .treePos(216, 848)); + + EE.build(b -> b + .prereqs(TBF) + .cost(10) + .background(BLUE, COMPOSITION) + .treePos(216, 758)); + + END.build(b -> b + .prereqs(EE) + .cost(12) + .background(BLUE, COMPOSITION) + .treePos(126, 798)); + + // spotless:on + + // Build inverse dependents mapping // todo make sure this is right EnumMap> dependencies = new EnumMap<>(ForgeOfGodsUpgrade.class); for (ForgeOfGodsUpgrade upgrade : VALUES) { @@ -251,18 +283,18 @@ public enum ForgeOfGodsUpgrade { } // Static tree linking - private final ForgeOfGodsUpgrade[] prerequisites; - private final boolean requireAllPrerequisites; + private ForgeOfGodsUpgrade[] prerequisites; + private boolean requireAllPrerequisites; // Cost - private final int shardCost; - private final List extraCost; + private int shardCost; + private List extraCost; // UI - private final BGColor color; - private final BGIcon icon; - private final BGWindowSize windowSize; - private final Pos2d treePos; + private BGColor color; + private BGIcon icon; + private BGWindowSize windowSize; + private Pos2d treePos; // Pre-generated data private ForgeOfGodsUpgrade[] dependents; @@ -272,7 +304,14 @@ public enum ForgeOfGodsUpgrade { private final String bodyText; private final String loreText; - ForgeOfGodsUpgrade(UnaryOperator u) { + ForgeOfGodsUpgrade() { + this.name = "fog.upgrade.tt." + ordinal(); + this.nameShort = "fog.upgrade.tt.short." + ordinal(); + this.bodyText = "fog.upgrade.text." + ordinal(); + this.loreText = "fog.upgrade.lore." + ordinal(); + } + + private void build(UnaryOperator u) { Builder b = u.apply(new Builder()); this.prerequisites = b.prerequisites != null ? b.prerequisites.toArray(new ForgeOfGodsUpgrade[0]) @@ -284,11 +323,6 @@ public enum ForgeOfGodsUpgrade { this.icon = b.icon; this.windowSize = b.windowSize; this.treePos = b.treePos; - - this.name = "fog.upgrade.tt." + ordinal(); - this.nameShort = "fog.upgrade.tt.short." + ordinal(); - this.bodyText = "fog.upgrade.text." + ordinal(); - this.loreText = "fog.upgrade.lore." + ordinal(); } public static class Builder { @@ -351,75 +385,4 @@ public Builder treePos(int x, int y) { return this; } } - - public enum BGColor { - - BLUE(TecTechUITextures.BACKGROUND_GLOW_BLUE, TecTechUITextures.PICTURE_OVERLAY_BLUE), - PURPLE(TecTechUITextures.BACKGROUND_GLOW_PURPLE, TecTechUITextures.PICTURE_OVERLAY_PURPLE), - ORANGE(TecTechUITextures.BACKGROUND_GLOW_ORANGE, TecTechUITextures.PICTURE_OVERLAY_ORANGE), - GREEN(TecTechUITextures.BACKGROUND_GLOW_GREEN, TecTechUITextures.PICTURE_OVERLAY_GREEN), - RED(TecTechUITextures.BACKGROUND_GLOW_RED, TecTechUITextures.PICTURE_OVERLAY_RED), - - ; - - private final UITexture background; - private final UITexture overlay; - - BGColor(UITexture background, UITexture overlay) { - this.background = background; - this.overlay = overlay; - } - - public UITexture getBackground() { - return background; - } - - public UITexture getOverlay() { - return overlay; - } - } - - public enum BGIcon { - - CHARGE(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE, 0.8f), - CONVERSION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION, 0.72f), - CATALYST(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST, 1.0f), - COMPOSITION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION, 1.0f), - - ; - - private final UITexture symbol; - private final float widthRatio; - - BGIcon(UITexture symbol, float widthRatio) { - this.symbol = symbol; - this.widthRatio = widthRatio; - } - - public UITexture getSymbol() { - return symbol; - } - - public float getWidthRatio() { - return widthRatio; - } - } - - public enum BGWindowSize { - - STANDARD(250, 250, 110), - LARGE(300, 300, 85), - - ; - - private final int width; - private final int height; - private final int loreY; - - BGWindowSize(int width, int height, int loreY) { - this.width = width; - this.height = height; - this.loreY = loreY; - } - } } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java new file mode 100644 index 00000000000..7dc0f0a29c1 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java @@ -0,0 +1,76 @@ +package tectech.thing.metaTileEntity.multi.godforge.upgrade; + +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +import tectech.thing.gui.TecTechUITextures; + +enum BGColor { + + BLUE(TecTechUITextures.BACKGROUND_GLOW_BLUE, TecTechUITextures.PICTURE_OVERLAY_BLUE), + PURPLE(TecTechUITextures.BACKGROUND_GLOW_PURPLE, TecTechUITextures.PICTURE_OVERLAY_PURPLE), + ORANGE(TecTechUITextures.BACKGROUND_GLOW_ORANGE, TecTechUITextures.PICTURE_OVERLAY_ORANGE), + GREEN(TecTechUITextures.BACKGROUND_GLOW_GREEN, TecTechUITextures.PICTURE_OVERLAY_GREEN), + RED(TecTechUITextures.BACKGROUND_GLOW_RED, TecTechUITextures.PICTURE_OVERLAY_RED), + + ; + + private final UITexture background; + private final UITexture overlay; + + BGColor(UITexture background, UITexture overlay) { + this.background = background; + this.overlay = overlay; + } + + public UITexture getBackground() { + return background; + } + + public UITexture getOverlay() { + return overlay; + } +} + +enum BGIcon { + + CHARGE(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE, 0.8f), + CONVERSION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION, 0.72f), + CATALYST(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST, 1.0f), + COMPOSITION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION, 1.0f), + + ; + + private final UITexture symbol; + private final float widthRatio; + + BGIcon(UITexture symbol, float widthRatio) { + this.symbol = symbol; + this.widthRatio = widthRatio; + } + + public UITexture getSymbol() { + return symbol; + } + + public float getWidthRatio() { + return widthRatio; + } +} + +enum BGWindowSize { + + STANDARD(250, 250, 110), + LARGE(300, 300, 85), + + ; + + private final int width; + private final int height; + private final int loreY; + + BGWindowSize(int width, int height, int loreY) { + this.width = width; + this.height = height; + this.loreY = loreY; + } +} From 59be2bd18bac81aa7351a695039a1268d33e3972 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:19:40 -0500 Subject: [PATCH 28/52] fix missing window size call on END upgrade --- .../multi/godforge/upgrade/ForgeOfGodsUpgrade.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 5a85108b09e..3b2f42f7b09 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -248,6 +248,7 @@ public enum ForgeOfGodsUpgrade { .prereqs(EE) .cost(12) .background(BLUE, COMPOSITION) + .windowSize(LARGE) .treePos(126, 798)); // spotless:on From 9d19dc197fc04b9926d31ddb3ca66d08a46bb9aa Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 11:05:52 -0500 Subject: [PATCH 29/52] refactor graviton shard ejection button --- .../multi/godforge/MTEForgeOfGods.java | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 0e078d0b96f..42b56c43c31 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -993,35 +993,22 @@ protected ButtonWidget createPowerSwitchButton() { protected ButtonWidget createEjectionSwitch(IWidgetBuilder builder) { Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { - if (upgrades[30]) { - gravitonShardEjection = !gravitonShardEjection; - } + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + gravitonShardEjection = !gravitonShardEjection; }) - .setPlayClickSound(upgrades[30]) - .setBackground(() -> { - List 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]); - }) + .setBackground( + () -> new UITexture[] { TecTechUITextures.BUTTON_CELESTIAL_32x32, + gravitonShardEjection ? TecTechUITextures.OVERLAY_EJECTION_ON + : TecTechUITextures.OVERLAY_EJECTION_LOCKED }) + .addTooltip(translateToLocal("fog.button.ejection.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) .attachSyncer( new FakeSyncWidget.BooleanSyncer(() -> gravitonShardEjection, val -> gravitonShardEjection = val), builder) .setPos(26, 91) .setSize(16, 16) + .setEnabled($ -> upgrades[30]) .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; } From e770ca8cc7e3b7d2646d12edca1c49b029bb0e56 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 1 Nov 2024 19:21:10 +0100 Subject: [PATCH 30/52] remove power button remnants --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 42b56c43c31..a4d8f44bfe0 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -986,11 +986,6 @@ public void addGregTechLogo(ModularWindow.Builder builder) { .setPos(172, 67)); } - @Override - protected ButtonWidget createPowerSwitchButton() { - return ForgeOfGodsUI.createPowerSwitchButton(getBaseMetaTileEntity()); - } - protected ButtonWidget createEjectionSwitch(IWidgetBuilder builder) { Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); From 93b6950cc81eb9e2063bb70791bcb5ffa2df133e Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 16:04:50 -0500 Subject: [PATCH 31/52] finish upgrades refactor --- .../java/tectech/loader/recipe/Godforge.java | 148 ++-- .../multi/godforge/ForgeOfGodsUI.java | 156 ++++ .../multi/godforge/GodforgeMath.java | 68 +- .../multi/godforge/MTEForgeOfGods.java | 675 +++++------------- .../godforge/upgrade/ForgeOfGodsUpgrade.java | 124 +++- .../upgrade/ForgeOfGodsUpgradeData.java | 15 +- .../godforge/upgrade/UpgradeStorage.java | 203 ++++++ 7 files changed, 737 insertions(+), 652 deletions(-) create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index 6a1ca170f7e..2af284276b8 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -47,6 +47,7 @@ import it.unimi.dsi.fastutil.ints.IntList; import tectech.recipe.TecTechRecipeMaps; import tectech.thing.CustomItemList; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade; public class Godforge implements Runnable { @@ -55,7 +56,6 @@ public class Godforge implements Runnable { public static final HashMap exoticModulePlasmaItemMap = new HashMap<>(); public static final HashMap exoticModulePlasmaFluidMap = new HashMap<>(); public static final HashMap exoticModuleMagmatterItemMap = new HashMap<>(); - public static final HashMap godforgeUpgradeMats = new HashMap<>(); public static final List quarkGluonFluidItemsForNEI = new ArrayList<>(); public static final List quarkGluonItemsForNEI = new ArrayList<>(); public static final List magmatterTimeFluidItemsForNEI = new ArrayList<>(); @@ -688,83 +688,87 @@ public void run() { // Godforge upgrade materials if (EternalSingularity.isModLoaded() && GalaxySpace.isModLoaded()) { - godforgeUpgradeMats.put( - 0, - new ItemStack[] { GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUIVBase, 64), - ItemList.SuperconductorComposite.get(32), - GGMaterial.metastableOganesson.get(OrePrefixes.gearGt, 16), - getModItem(EternalSingularity.ID, "eternal_singularity", 8L), ItemList.Robot_Arm_UIV.get(64L), - ItemList.Field_Generator_UEV.get(64L) }); - - godforgeUpgradeMats.put( - 5, - new ItemStack[] { GregtechItemList.Mega_AlloyBlastSmelter.get(16L), - ItemList.Casing_Coil_Hypogen.get(64L), - CustomItemList.Godforge_HarmonicPhononTransmissionConduit.get(32L), - getModItem(EternalSingularity.ID, "eternal_singularity", 16L), - ItemRefer.Field_Restriction_Coil_T3.get(48), ItemList.Robot_Arm_UIV.get(64L), - ItemList.Field_Generator_UEV.get(64L) }); - - godforgeUpgradeMats.put( - 7, - new ItemStack[] { CustomItemList.Godforge_StellarEnergySiphonCasing.get(8), - GregtechItemList.FusionComputer_UV3.get(8), GregtechItemList.Casing_Fusion_Internal2.get(64), - getModItem(GalaxySpace.ID, "item.DysonSwarmParts", 64, 3), MaterialsAlloy.QUANTUM.getPlateDense(48), - MaterialsElements.STANDALONE.RHUGNOR.getGear(32), - getModItem(EternalSingularity.ID, "eternal_singularity", 16L), ItemList.Robot_Arm_UIV.get(64L), - ItemList.Field_Generator_UEV.get(64L) }); - - godforgeUpgradeMats.put( - 11, - new ItemStack[] { CustomItemList.Godforge_StellarEnergySiphonCasing.get(16), - ItemRefer.Compact_Fusion_MK5.get(2), ItemRefer.Compact_Fusion_Coil_T4.get(64), - CustomItemList.Godforge_HarmonicPhononTransmissionConduit.get(16), - ItemList.Machine_Multi_TranscendentPlasmaMixer.get(4), - MaterialsElements.STANDALONE.RHUGNOR.getGear(64), - GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Ichorium, 64), - getModItem(EternalSingularity.ID, "eternal_singularity", 32L), ItemList.Robot_Arm_UIV.get(64L), - ItemList.Field_Generator_UEV.get(64L) }); - - godforgeUpgradeMats.put( - 26, - new ItemStack[] { GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 64), - GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUMVBase, 64), - MaterialsElements.STANDALONE.HYPOGEN.getFrameBox(64), - MaterialsElements.STANDALONE.DRAGON_METAL.getFrameBox(64), - CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), - CustomItemList.EOH_Infinite_Energy_Casing.get(8), ItemList.ZPM6.get(2), - ItemList.Field_Generator_UMV.get(32) }); - - godforgeUpgradeMats.put( - 29, - new ItemStack[] { GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.WhiteDwarfMatter, 64), - GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.BlackDwarfMatter, 64), - GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.Eternity, 16), - GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.Universium, 2), - CustomItemList.EOH_Infinite_Energy_Casing.get(64), - CustomItemList.StabilisationFieldGeneratorTier5.get(16), ItemList.ZPM6.get(6), - ItemList.Field_Generator_UMV.get(64) }); - - godforgeUpgradeMats.put( - 30, - new ItemStack[] { CustomItemList.Machine_Multi_QuarkGluonPlasmaModule.get(32), - CustomItemList.Godforge_StellarEnergySiphonCasing.get(64), - CustomItemList.StabilisationFieldGeneratorTier6.get(48), - ItemList.Transdimensional_Alignment_Matrix.get(8), ItemList.ZPM6.get(16), - ItemList.Robot_Arm_UMV.get(64), ItemList.Conveyor_Module_UMV.get(64) }); + ForgeOfGodsUpgrade.START.addExtraCost( + GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUIVBase, 64), + ItemList.SuperconductorComposite.get(32), + GGMaterial.metastableOganesson.get(OrePrefixes.gearGt, 16), + getModItem(EternalSingularity.ID, "eternal_singularity", 8L), + ItemList.Robot_Arm_UIV.get(64L), + ItemList.Field_Generator_UEV.get(64L)); + + ForgeOfGodsUpgrade.FDIM.addExtraCost( + GregtechItemList.Mega_AlloyBlastSmelter.get(16L), + ItemList.Casing_Coil_Hypogen.get(64L), + CustomItemList.Godforge_HarmonicPhononTransmissionConduit.get(32L), + getModItem(EternalSingularity.ID, "eternal_singularity", 16L), + ItemRefer.Field_Restriction_Coil_T3.get(48), + ItemList.Robot_Arm_UIV.get(64L), + ItemList.Field_Generator_UEV.get(64L)); + + ForgeOfGodsUpgrade.GPCI.addExtraCost( + CustomItemList.Godforge_StellarEnergySiphonCasing.get(8), + GregtechItemList.FusionComputer_UV3.get(8), + GregtechItemList.Casing_Fusion_Internal2.get(64), + getModItem(GalaxySpace.ID, "item.DysonSwarmParts", 64, 3), + MaterialsAlloy.QUANTUM.getPlateDense(48), + MaterialsElements.STANDALONE.RHUGNOR.getGear(32), + getModItem(EternalSingularity.ID, "eternal_singularity", 16L), + ItemList.Robot_Arm_UIV.get(64L), + ItemList.Field_Generator_UEV.get(64L)); + + ForgeOfGodsUpgrade.QGPIU.addExtraCost( + CustomItemList.Godforge_StellarEnergySiphonCasing.get(16), + ItemRefer.Compact_Fusion_MK5.get(2), + ItemRefer.Compact_Fusion_Coil_T4.get(64), + CustomItemList.Godforge_HarmonicPhononTransmissionConduit.get(16), + ItemList.Machine_Multi_TranscendentPlasmaMixer.get(4), + MaterialsElements.STANDALONE.RHUGNOR.getGear(64), + GTOreDictUnificator.get(OrePrefixes.gearGt, Materials.Ichorium, 64), + getModItem(EternalSingularity.ID, "eternal_singularity", 32L), + ItemList.Robot_Arm_UIV.get(64L), + ItemList.Field_Generator_UEV.get(64L)); + + ForgeOfGodsUpgrade.CD.addExtraCost( + GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.SpaceTime, 64), + GTOreDictUnificator.get(OrePrefixes.frameGt, Materials.SuperconductorUMVBase, 64), + MaterialsElements.STANDALONE.HYPOGEN.getFrameBox(64), + MaterialsElements.STANDALONE.DRAGON_METAL.getFrameBox(64), + CustomItemList.EOH_Reinforced_Spatial_Casing.get(64), + CustomItemList.EOH_Infinite_Energy_Casing.get(8), + ItemList.ZPM6.get(2), + ItemList.Field_Generator_UMV.get(32)); + + ForgeOfGodsUpgrade.EE.addExtraCost( + GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.WhiteDwarfMatter, 64), + GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.BlackDwarfMatter, 64), + GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.Eternity, 16), + GTOreDictUnificator.get(OrePrefixes.frameGt, MaterialsUEVplus.Universium, 2), + CustomItemList.EOH_Infinite_Energy_Casing.get(64), + CustomItemList.StabilisationFieldGeneratorTier5.get(16), + ItemList.ZPM6.get(6), + ItemList.Field_Generator_UMV.get(64)); + + ForgeOfGodsUpgrade.END.addExtraCost( + CustomItemList.Machine_Multi_QuarkGluonPlasmaModule.get(32), + CustomItemList.Godforge_StellarEnergySiphonCasing.get(64), + CustomItemList.StabilisationFieldGeneratorTier6.get(48), + ItemList.Transdimensional_Alignment_Matrix.get(8), + ItemList.ZPM6.get(16), + ItemList.Robot_Arm_UMV.get(64), + ItemList.Conveyor_Module_UMV.get(64)); } } public static void runDevEnvironmentRecipes() { // put something in here to not crash the game in dev environment when opening the manual insertion window - godforgeUpgradeMats.put(0, new ItemStack[] { new ItemStack(Blocks.cobblestone, 4) }); - godforgeUpgradeMats.put(5, new ItemStack[] { new ItemStack(Blocks.cobblestone, 8) }); - godforgeUpgradeMats.put(7, new ItemStack[] { new ItemStack(Blocks.cobblestone, 12) }); - godforgeUpgradeMats.put(11, new ItemStack[] { new ItemStack(Blocks.cobblestone, 16) }); - godforgeUpgradeMats.put(26, new ItemStack[] { new ItemStack(Blocks.cobblestone, 32) }); - godforgeUpgradeMats.put(29, new ItemStack[] { new ItemStack(Blocks.cobblestone, 48) }); - godforgeUpgradeMats.put(30, new ItemStack[] { new ItemStack(Blocks.cobblestone, 64) }); + ForgeOfGodsUpgrade.START.addExtraCost(new ItemStack(Blocks.cobblestone, 4)); + ForgeOfGodsUpgrade.FDIM.addExtraCost(new ItemStack(Blocks.cobblestone, 8)); + ForgeOfGodsUpgrade.GPCI.addExtraCost(new ItemStack(Blocks.cobblestone, 12)); + ForgeOfGodsUpgrade.QGPIU.addExtraCost(new ItemStack(Blocks.cobblestone, 16)); + ForgeOfGodsUpgrade.CD.addExtraCost(new ItemStack(Blocks.cobblestone, 32)); + ForgeOfGodsUpgrade.EE.addExtraCost(new ItemStack(Blocks.cobblestone, 48)); + ForgeOfGodsUpgrade.END.addExtraCost(new ItemStack(Blocks.cobblestone, 64)); } public static void initMoltenModuleRecipes() { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java index a63ba81d7e3..e4299b25152 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java @@ -16,6 +16,7 @@ import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; +import com.google.common.collect.ImmutableList; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.drawable.UITexture; @@ -42,6 +43,7 @@ import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; import tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade; /** * Holds UI element builders and other conveniences shared between the primary Forge of the Gods and its modules. @@ -546,4 +548,158 @@ public static Widget createStarColorButton(Supplier text, Supplier shardGetter, + Runnable complete, Runnable respec, Supplier check) { + MultiChildWidget widget = new MultiChildWidget(); + widget.setSize(upgrade.getWindowSize()); + + Size windowSize = upgrade.getWindowSize(); + int w = windowSize.width; + int h = windowSize.height; + + // Close window button + widget.addChild( + ButtonWidget.closeWindowButton(true) + .setPos(w - 15, 3)); + + // Background symbol + widget.addChild( + new DrawableWidget().setDrawable(upgrade.getSymbol()) + .setPos((int) ((1 - upgrade.getSymbolWidthRatio() / 2) * w / 2), h / 4) + .setSize((int) (w / 2 * upgrade.getSymbolWidthRatio()), h / 2)); + + // Background overlay + widget.addChild( + new DrawableWidget().setDrawable(upgrade.getOverlay()) + .setPos(w / 4, h / 4) + .setSize(w / 2, h / 2)); + + // Upgrade name title + widget.addChild( + new TextWidget(upgrade.getNameText()).setTextAlignment(Alignment.Center) + .setDefaultColor(EnumChatFormatting.GOLD) + .setSize(w - 15, 30) + .setPos(9, 5)); + + // Upgrade body text + widget.addChild( + new TextWidget(upgrade.getBodyText()).setTextAlignment(Alignment.Center) + .setDefaultColor(EnumChatFormatting.WHITE) + .setSize(w - 15, upgrade.getLoreYPos() - 30) + .setPos(9, 30)); + + // Lore Text + widget.addChild( + new TextWidget(EnumChatFormatting.ITALIC + upgrade.getLoreText()).setTextAlignment(Alignment.Center) + .setDefaultColor(0xbbbdbd) + .setSize(w - 15, (int) (h * 0.9) - upgrade.getLoreYPos()) + .setPos(9, upgrade.getLoreYPos())); + + // Shard cost text + String costStr = " " + EnumChatFormatting.BLUE + upgrade.getShardCost(); + widget.addChild( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.shardcost") + costStr) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(70) + .setDefaultColor(0x9c9c9c) + .setPos(11, h - 25)); + + // Available shards text + widget.addChild( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.availableshards")) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(w - 87, h - 25)); + + // Available shards amount + widget.addChild( + TextWidget.dynamicText(() -> getAvailableShardsText(upgrade, shardGetter)) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(90) + .setDefaultColor(0x9c9c9c) + .setPos(w - 27, h - 18)); + + // Complete button group + MultiChildWidget completeGroup = new MultiChildWidget(); + completeGroup.setPos(w / 2 - 21, (int) (h * 0.9)); + + // Complete button + completeGroup.addChild(new ButtonWidget().setOnClick(($, $$) -> { + if (check.get()) { + respec.run(); + } else { + complete.run(); + } + }) + .setSize(40, 15) + .setBackground( + () -> new IDrawable[] { + check.get() ? GTUITextures.BUTTON_STANDARD_PRESSED : GTUITextures.BUTTON_STANDARD }) + .dynamicTooltip(() -> constructionStatusString(check)) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); + + // Complete text overlay + completeGroup.addChild( + TextWidget.dynamicText(() -> constructionStatusText(check)) + .setTextAlignment(Alignment.Center) + .setScale(0.7f) + .setMaxWidth(36) + .setPos(3, 5)); + + widget.addChild(completeGroup); + + return widget; + } + + public static Widget createMaterialInputButton(ForgeOfGodsUpgrade upgrade, Supplier check, + BiConsumer clickAction) { + Size windowSize = upgrade.getWindowSize(); + int w = windowSize.width; + int h = windowSize.height; + + return new ButtonWidget().setOnClick(clickAction) + .setPlayClickSound(true) + .setBackground( + () -> new IDrawable[] { check.get() ? TecTechUITextures.BUTTON_BOXED_CHECKMARK_18x18 + : TecTechUITextures.BUTTON_BOXED_EXCLAMATION_POINT_18x18 }) + .setPos(w / 2 - 40, (int) (h * 0.9)) + .setSize(15, 15) + .dynamicTooltip(() -> upgradeMaterialRequirements(check)) + .addTooltip( + EnumChatFormatting.GRAY + translateToLocal("fog.button.materialrequirements.tooltip.clickhere")); + } + + private static Text getAvailableShardsText(ForgeOfGodsUpgrade upgrade, Supplier shardGetter) { + EnumChatFormatting enoughShards = EnumChatFormatting.RED; + if (shardGetter.get() >= upgrade.getShardCost()) { + enoughShards = EnumChatFormatting.GREEN; + } + return new Text(enoughShards + Integer.toString(shardGetter.get())); + } + + private static List constructionStatusString(Supplier check) { + if (check.get()) { + return ImmutableList.of(translateToLocal("fog.upgrade.respec")); + } + return ImmutableList.of(translateToLocal("fog.upgrade.confirm")); + } + + public static Text constructionStatusText(Supplier check) { + if (check.get()) { + return new Text(translateToLocal("fog.upgrade.respec")); + } + return new Text(translateToLocal("fog.upgrade.confirm")); + } + + private static List upgradeMaterialRequirements(Supplier check) { + if (check.get()) { + return ImmutableList.of(translateToLocal("fog.button.materialrequirementsmet.tooltip")); + } + return ImmutableList.of(translateToLocal("fog.button.materialrequirements.tooltip")); + } } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java index 2e09a62b7e5..a311d7574d7 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/GodforgeMath.java @@ -1,5 +1,7 @@ package tectech.thing.metaTileEntity.multi.godforge; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.*; + import java.math.BigInteger; public class GodforgeMath { @@ -10,7 +12,7 @@ public static int getRandomIntInRange(int min, int max) { public static double calculateFuelConsumption(MTEForgeOfGods godforge) { double upgradeFactor = 1; - if (godforge.isUpgradeActive(2)) { + if (godforge.isUpgradeActive(STEM)) { upgradeFactor = 0.8; } if (godforge.getFuelType() == 0) { @@ -27,13 +29,13 @@ public static int calculateStartupFuelConsumption(MTEForgeOfGods godforge) { public static int calculateMaxFuelFactor(MTEForgeOfGods godforge) { int fuelCap = 5; - if (godforge.isUpgradeActive(27)) { + if (godforge.isUpgradeActive(TSE)) { fuelCap = Integer.MAX_VALUE; } else { - if (godforge.isUpgradeActive(9)) { + if (godforge.isUpgradeActive(GEM)) { fuelCap += godforge.getTotalActiveUpgrades(); } - if (godforge.isUpgradeActive(3)) { + if (godforge.isUpgradeActive(CFCE)) { fuelCap *= 1.2; } } @@ -52,7 +54,7 @@ public static int calculateEffectiveFuelFactor(MTEForgeOfGods godforge) { public static void calculateMaxHeatForModules(MTEBaseModule module, MTEForgeOfGods godforge) { double logBase = 1.5; int baseHeat = 12601; - if (godforge.isUpgradeActive(12)) { + if (godforge.isUpgradeActive(SEFCP)) { if (module instanceof MTESmeltingModule) { logBase = 1.12; } else { @@ -67,7 +69,7 @@ public static void calculateMaxHeatForModules(MTEBaseModule module, MTEForgeOfGo public static int calculateOverclockHeat(MTEBaseModule module, MTEForgeOfGods godforge, Integer recipeHeat) { int actualHeat; double exponent; - if (godforge.isUpgradeActive(20)) { + if (godforge.isUpgradeActive(NDPE)) { if (module instanceof MTESmeltingModule) { exponent = 0.85; } else { @@ -78,7 +80,7 @@ public static int calculateOverclockHeat(MTEBaseModule module, MTEForgeOfGods go } else { actualHeat = recipeHeat; } - } else if (godforge.isUpgradeActive(17)) { + } else if (godforge.isUpgradeActive(CNTI)) { actualHeat = Math.min(recipeHeat, 30000); } else { actualHeat = Math.min(recipeHeat, 15000); @@ -89,11 +91,11 @@ public static int calculateOverclockHeat(MTEBaseModule module, MTEForgeOfGods go public static void calculateSpeedBonusForModules(MTEBaseModule module, MTEForgeOfGods godforge) { double speedBonus = 1; - if (godforge.isUpgradeActive(1)) { + if (godforge.isUpgradeActive(IGCC)) { speedBonus = Math.pow(module.getHeat(), -0.01); } - if (godforge.isUpgradeActive(22)) { + if (godforge.isUpgradeActive(DOR)) { if (module instanceof MTEPlasmaModule) { speedBonus /= Math.pow(module.getMaxParallel(), 0.02); } else { @@ -102,7 +104,7 @@ public static void calculateSpeedBonusForModules(MTEBaseModule module, MTEForgeO } if (module instanceof MTEExoticModule) { - if (godforge.isUpgradeActive(25)) { + if (godforge.isUpgradeActive(PA)) { speedBonus = Math.sqrt(speedBonus); } else { speedBonus = 1; @@ -134,17 +136,17 @@ public static void calculateMaxParallelForModules(MTEBaseModule module, MTEForge } if (module instanceof MTEMoltenModule - || (module instanceof MTESmeltingModule && godforge.isUpgradeActive(16))) { + || (module instanceof MTESmeltingModule && godforge.isUpgradeActive(DOP))) { isMoltenOrSmeltingWithUpgrade = true; } - if (godforge.isUpgradeActive(10)) { + if (godforge.isUpgradeActive(CTCDD)) { node53 = 2; } - if (godforge.isUpgradeActive(6)) { + if (godforge.isUpgradeActive(SA)) { fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f; - if (godforge.isUpgradeActive(13)) { + if (godforge.isUpgradeActive(TCT)) { if (isMoltenOrSmeltingWithUpgrade) { fuelFactorMultiplier *= 3; } else { @@ -153,7 +155,7 @@ public static void calculateMaxParallelForModules(MTEBaseModule module, MTEForge } } - if (godforge.isUpgradeActive(18)) { + if (godforge.isUpgradeActive(EPEC)) { if (isMoltenOrSmeltingWithUpgrade) { heatMultiplier = 1 + module.getHeat() / 15000f; } else { @@ -161,7 +163,7 @@ public static void calculateMaxParallelForModules(MTEBaseModule module, MTEForge } } - if (godforge.isUpgradeActive(21)) { + if (godforge.isUpgradeActive(POS)) { if (isMoltenOrSmeltingWithUpgrade) { upgradeAmountMultiplier = 1 + godforge.getTotalActiveUpgrades() / 5f; } else { @@ -172,7 +174,7 @@ public static void calculateMaxParallelForModules(MTEBaseModule module, MTEForge float totalBonuses = node53 * fuelFactorMultiplier * heatMultiplier * upgradeAmountMultiplier; if (module instanceof MTEExoticModule) { - if (godforge.isUpgradeActive(25)) { + if (godforge.isUpgradeActive(PA)) { totalBonuses = (float) Math.sqrt(totalBonuses); } else { totalBonuses = 1; @@ -188,11 +190,11 @@ public static void calculateEnergyDiscountForModules(MTEBaseModule module, MTEFo double fillRatioDiscount = 1; double maxBatteryDiscount = 1; - if (godforge.isUpgradeActive(8)) { + if (godforge.isUpgradeActive(REC)) { maxBatteryDiscount = 1 - (1 - Math.pow(1.05, -0.05 * godforge.getMaxBatteryCharge())) / 20; } - if (godforge.isUpgradeActive(19)) { + if (godforge.isUpgradeActive(IMKG)) { double fillRatioMinusZeroPointFive = (double) godforge.getBatteryCharge() / godforge.getMaxBatteryCharge() - 0.5; if (module instanceof MTEPlasmaModule) { @@ -203,7 +205,7 @@ public static void calculateEnergyDiscountForModules(MTEBaseModule module, MTEFo } if (module instanceof MTEExoticModule) { - if (godforge.isUpgradeActive(25)) { + if (godforge.isUpgradeActive(PA)) { fillRatioDiscount = Math.sqrt(fillRatioDiscount); maxBatteryDiscount = Math.sqrt(maxBatteryDiscount); } else { @@ -218,11 +220,11 @@ public static void calculateEnergyDiscountForModules(MTEBaseModule module, MTEFo public static void calculateProcessingVoltageForModules(MTEBaseModule module, MTEForgeOfGods godforge) { long voltage = 2_000_000_000; - if (godforge.isUpgradeActive(4)) { + if (godforge.isUpgradeActive(GISS)) { voltage += calculateEffectiveFuelFactor(godforge) * 100_000_000L; } - if (godforge.isUpgradeActive(23)) { + if (godforge.isUpgradeActive(NGMS)) { voltage *= Math.pow(4, godforge.getRingAmount()); } @@ -233,20 +235,20 @@ public static void setMiscModuleParameters(MTEBaseModule module, MTEForgeOfGods int plasmaTier = 0; double overclockTimeFactor = 2; - if (godforge.isUpgradeActive(30)) { + if (godforge.isUpgradeActive(END)) { plasmaTier = 2; - } else if (godforge.isUpgradeActive(24)) { + } else if (godforge.isUpgradeActive(SEDS)) { plasmaTier = 1; } - if (godforge.isUpgradeActive(14)) { + if (godforge.isUpgradeActive(GGEBE)) { if (module instanceof MTEPlasmaModule) { overclockTimeFactor = 2.3; } else { overclockTimeFactor = 2.15; } if (module instanceof MTEExoticModule) { - if (godforge.isUpgradeActive(25)) { + if (godforge.isUpgradeActive(PA)) { overclockTimeFactor = 2 + Math.pow(overclockTimeFactor - 2, 2); } else { overclockTimeFactor = 2; @@ -254,25 +256,25 @@ public static void setMiscModuleParameters(MTEBaseModule module, MTEForgeOfGods } } - module.setUpgrade83(godforge.isUpgradeActive(19)); - module.setMultiStepPlasma(godforge.isUpgradeActive(15)); + module.setUpgrade83(godforge.isUpgradeActive(IMKG)); + module.setMultiStepPlasma(godforge.isUpgradeActive(TPTP)); module.setPlasmaTier(plasmaTier); - module.setMagmatterCapable(godforge.isUpgradeActive(30)); - module.setVoltageConfig(godforge.isUpgradeActive(28)); + module.setMagmatterCapable(godforge.isUpgradeActive(END)); + module.setVoltageConfig(godforge.isUpgradeActive(TBF)); module.setOverclockTimeFactor(overclockTimeFactor); } public static boolean allowModuleConnection(MTEBaseModule module, MTEForgeOfGods godforge) { - if (module instanceof MTEMoltenModule && godforge.isUpgradeActive(5)) { + if (module instanceof MTEMoltenModule && godforge.isUpgradeActive(FDIM)) { return true; } - if (module instanceof MTEPlasmaModule && godforge.isUpgradeActive(7)) { + if (module instanceof MTEPlasmaModule && godforge.isUpgradeActive(GPCI)) { return true; } - if (module instanceof MTEExoticModule && godforge.isUpgradeActive(11)) { + if (module instanceof MTEExoticModule && godforge.isUpgradeActive(QGPIU)) { return true; } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index a4d8f44bfe0..0f9dc09c2c9 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -11,7 +11,6 @@ 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.thing.metaTileEntity.multi.godforge.GodforgeMath.allowModuleConnection; @@ -25,6 +24,7 @@ import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateStartupFuelConsumption; import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.queryMilestoneStats; import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.setMiscModuleParameters; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.*; import static tectech.util.TTUtility.toExponentForm; import java.awt.Desktop; @@ -46,7 +46,6 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; @@ -56,7 +55,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.math.LongMath; -import com.google.common.primitives.Booleans; import com.gtnewhorizon.structurelib.alignment.constructable.IConstructable; import com.gtnewhorizon.structurelib.alignment.constructable.ISurvivalConstructable; import com.gtnewhorizon.structurelib.structure.IStructureDefinition; @@ -127,6 +125,8 @@ import tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor; import tectech.thing.metaTileEntity.multi.godforge.color.StarColorSetting; import tectech.thing.metaTileEntity.multi.godforge.color.StarColorStorage; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeStorage; public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { @@ -175,6 +175,9 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, public ArrayList moduleHatches = new ArrayList<>(); protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); + private final UpgradeStorage upgrades = new UpgradeStorage(); + private ForgeOfGodsUpgrade currentUpgradeWindow; + // Star cosmetics fields // actual star cosmetics private final StarColorStorage starColors = new StarColorStorage(); @@ -202,8 +205,6 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int STAR_CUSTOM_COLOR_WINDOW_ID = 19; private static final int STAR_CUSTOM_COLOR_IMPORT_WINDOW_ID = 20; 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; @@ -446,7 +447,7 @@ public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStac return false; } - if (isUpgradeActive(26)) { + if (isUpgradeActive(CD)) { if (checkPiece(STRUCTURE_PIECE_SECOND_RING, 55, 11, -67)) { ringAmount = 2; destroySecondRing(); @@ -466,7 +467,7 @@ public boolean checkMachine_EM(IGregTechTileEntity iGregTechTileEntity, ItemStac } } - if (isUpgradeActive(29)) { + if (isUpgradeActive(EE)) { if (checkPiece(STRUCTURE_PIECE_THIRD_RING, 47, 13, -76)) { ringAmount = 3; destroyThirdRing(); @@ -499,21 +500,19 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { startRecipeProcessing(); int maxModuleCount = 8; - if (upgrades[26]) { + if (isUpgradeActive(CD)) { maxModuleCount += 4; } - if (upgrades[29]) { + if (isUpgradeActive(EE)) { maxModuleCount += 4; } - boolean isFinalUpgradeUnlocked = upgrades[30]; - if (!mInputBusses.isEmpty()) { - if (internalBattery == 0 || isFinalUpgradeUnlocked) { + if (internalBattery == 0 || isUpgradeActive(END)) { MTEHatchInputBus inputBus = mInputBusses.get(0); ItemStack[] inputBusInventory = inputBus.getRealInventory(); ItemStack itemToAbsorb = STELLAR_FUEL; - if (isFinalUpgradeUnlocked && internalBattery != 0) { + if (isUpgradeActive(END) && internalBattery != 0) { itemToAbsorb = GTOreDictUnificator.get(OrePrefixes.gem, MaterialsUEVplus.GravitonShard, 1); } if (inputBusInventory != null) { @@ -559,7 +558,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { if (!ConfigHandler.debug.DEBUG_MODE) { determineGravitonShardAmount(); } - if (upgrades[30] && gravitonShardEjection) { + if (isUpgradeActive(END) && gravitonShardEjection) { ejectGravitonShards(); } @@ -574,7 +573,7 @@ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { calculateEnergyDiscountForModules(module, this); setMiscModuleParameters(module, this); queryMilestoneStats(module, this); - if (!upgrades[28]) { + if (!isUpgradeActive(TBF)) { calculateProcessingVoltageForModules(module, this); } } else { @@ -1002,8 +1001,8 @@ protected ButtonWidget createEjectionSwitch(IWidgetBuilder builder) { builder) .setPos(26, 91) .setSize(16, 16) - .setEnabled($ -> upgrades[30]) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(() -> upgrades[30], val -> upgrades[30] = val), builder); + .setEnabled($ -> isUpgradeActive(END)) + .attachSyncer(upgrades.getSingleSyncer(END), builder); return (ButtonWidget) button; } @@ -1012,7 +1011,7 @@ protected Widget createBatteryButton(IWidgetBuilder builder) { TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); if (clickData.mouseButton == 0) { batteryCharging = !batteryCharging; - } else if (clickData.mouseButton == 1 && !widget.isClient() && upgrades[8]) { + } else if (clickData.mouseButton == 1 && !widget.isClient() && isUpgradeActive(REC)) { widget.getContext() .openSyncedWindow(BATTERY_CONFIG_WINDOW_ID); } @@ -1101,12 +1100,9 @@ protected ModularWindow createFuelConfigWindow(final EntityPlayer player) { .setSize(70, 18) .setPos(4, 35) .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + // todo try to reduce .attachSyncer( - new FakeSyncWidget.ListSyncer<>( - () -> Booleans.asList(upgrades), - val -> upgrades = Booleans.toArray(val), - PacketBuffer::writeBoolean, - PacketBuffer::readBoolean), + upgrades.getFullSyncer(), builder, (widget, val) -> ((NumericWidget) widget).setMaxValue(calculateMaxFuelFactor(this)))) .widget( @@ -1478,96 +1474,51 @@ private Widget createMilestoneButton(int milestoneID, int width, int height, Pos .setTooltipShowUpDelay(TOOLTIP_DELAY); } - private int currentUpgradeID = 0; - private int currentColorCode = 0; - private int currentMilestoneBG = 0; - private int gravitonShardCost = 0; - private final int[][] prereqUpgrades = new int[31][]; - private int[] followupUpgrades = new int[] {}; - private boolean isUpradeSplitStart = false; - private boolean doesCurrentUpgradeRequireExtraMats = false; - private final boolean[] allPrereqRequired = new boolean[31]; - 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); + ModularWindow.Builder builder = ModularWindow.builder(300, 300); + Scrollable scrollable = new Scrollable().setVerticalScroll(); // spotless:off - scrollable - .widget(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, 0, 0, 1)) - .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, 0, 1, 2)) - .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, 0, 1, 3)) - .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, 0, 2, 4)) - .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, 0, 2, 5)) - .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, 0, 3, 5)) - .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, 0, 3, 6)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, 0, 5, 7)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, 0, 7, 9)) - .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, 4, 4, 8)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, 4, 7, 8)) - .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, 4, 6, 10)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, 4, 7, 10)) - .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, 0, 8, 11)) - .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, 0, 10, 11)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, 2, 11, 13)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, 2, 13, 18)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, 2, 18, 21)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, 2, 21, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, 1, 11, 12)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, 1, 12, 17)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, 1, 17, 20)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, 1, 20, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, 1, 17, 16)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, 3, 11, 14)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, 3, 14, 19)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, 3, 19, 22)) - .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, 3, 22, 23)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, 3, 14, 15)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, 0, 23, 24)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, 0, 24, 25)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, 0, 25, 26)) - .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, 0, 26, 27)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, 0, 27, 28)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, 28, 29)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, 29, 30)); - - 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, 4, 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, 4, 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)); - // spotless:on + scrollable.widget(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, 0, START, IGCC)) + .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, 0, IGCC, STEM)) + .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, 0, IGCC, CFCE)) + .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, 0, STEM, GISS)) + .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, 0, STEM, FDIM)) + .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, 0, CFCE, FDIM)) + .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, 0, CFCE, SA)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, 0, FDIM, GPCI)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, 0, GPCI, GEM)) + .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, 4, GISS, REC)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, 4, GPCI, REC)) + .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, 4, SA, CTCDD)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, 4, GPCI, CTCDD)) + .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, 0, REC, QGPIU)) + .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, 0, CTCDD, QGPIU)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, 2, QGPIU, TCT)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, 2, TCT, EPEC)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, 2, EPEC, POS)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, 2, POS, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, 1, QGPIU, SEFCP)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, 1, SEFCP, CNTI)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, 1, CNTI, NDPE)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, 1, NDPE, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, 1, CNTI, DOP)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, 3, QGPIU, GGEBE)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, 3, GGEBE, IMKG)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, 3, IMKG, DOR)) + .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, 3, DOR, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, 3, GGEBE, TPTP)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, 0, NGMS, SEDS)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, 0, SEDS, PA)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, 0, PA, CD)) + .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, 0, CD, TSE)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, 0, TSE, TBF)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, TBF, EE)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, EE, END)); + + for (ForgeOfGodsUpgrade upgrade : upgrades.getAllUpgrades()) { + scrollable.widget(createUpgradeBox(upgrade, scrollable)); + } scrollable.widget( new MultiChildWidget().addChild( @@ -1615,341 +1566,117 @@ protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { }) .setPos(282, 4)); if (ConfigHandler.debug.DEBUG_MODE) { - 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; - } - case 4 -> { - background = TecTechUITextures.BACKGROUND_GLOW_RED; - overlay = TecTechUITextures.PICTURE_OVERLAY_RED; - } - 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( + builder.widget( new MultiChildWidget() .addChild( - new TextWidget(translateToLocal("fog.upgrade.tt." + (currentUpgradeID))) - .setTextAlignment(Alignment.Center) - .setDefaultColor(EnumChatFormatting.GOLD) - .setSize(WIDTH - 15, 30) - .setPos(9, 5)) + new ButtonWidget().setOnClick((clickData, widget) -> upgrades.resetAll()) + .setSize(40, 15) + .setBackground(GTUITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.debug.resetbutton.tooltip")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .addChild( - new TextWidget(translateToLocal("fog.upgrade.text." + (currentUpgradeID))) + new TextWidget(translateToLocal("fog.debug.resetbutton.text")) .setTextAlignment(Alignment.Center) - .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)) + .setScale(0.57f) + .setMaxWidth(36) + .setPos(3, 3)) .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")) + new NumericWidget().setSetter(val -> gravitonShardsAvailable = (int) val) + .setGetter(() -> gravitonShardsAvailable) + .setBounds(0, 112) + .setDefaultValue(0) + .setScrollValues(1, 4, 64) .setTextAlignment(Alignment.Center) - .setScale(0.7f) - .setMaxWidth(90) - .setDefaultColor(0x9c9c9c) - .setPos(WIDTH - 87, HEIGHT - 25)) + .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( - 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) -> { - if (!upgrades[currentUpgradeID]) { - completeUpgrade(); - } else { - respecUpgrade(); - } - }) - .setSize(40, 15) - .setBackground(() -> { - if (upgrades[currentUpgradeID]) { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED }; - } else { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD }; - } - }) - .dynamicTooltip(this::constructionStatus) - .setTooltipShowUpDelay(TOOLTIP_DELAY)) - .addChild( - TextWidget.dynamicText(this::constructionStatusText) - .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)); + new ButtonWidget().setOnClick((clickData, widget) -> upgrades.unlockAll()) + .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(); } - private void completeUpgrade() { - int unlockedPrereqUpgrades = 0; - int unlockedSplitUpgrades = 0; - if (!upgrades[currentUpgradeID]) { - for (int prereqUpgrade : prereqUpgrades[currentUpgradeID]) { - if (upgrades[prereqUpgrade]) { - unlockedPrereqUpgrades++; - } - } - if (!doesCurrentUpgradeRequireExtraMats - || materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) - .indexOf(currentUpgradeID)]) { - if (allPrereqRequired[currentUpgradeID]) { - if (unlockedPrereqUpgrades == prereqUpgrades[currentUpgradeID].length - && gravitonShardsAvailable >= gravitonShardCost) { - gravitonShardsAvailable -= gravitonShardCost; - gravitonShardsSpent += gravitonShardCost; - upgrades[currentUpgradeID] = true; - } - } else if (unlockedPrereqUpgrades > 0 || prereqUpgrades[currentUpgradeID].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; - } - } - } - } - } + protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) { + ForgeOfGodsUpgrade upgrade = currentUpgradeWindow; - private void respecUpgrade() { - int unlockedFollowupUpgrades = 0; - int unlockedNeighboringUpgrades = 0; - boolean doesFollowupRequireAllPrereqs = false; - boolean canFollowupSpareAConnection = true; + ModularWindow.Builder builder = ModularWindow.builder(upgrade.getWindowSize()); + builder.setBackground(upgrade.getBackground()); - for (int followupUpgrade : followupUpgrades) { - if (upgrades[followupUpgrade]) { - unlockedFollowupUpgrades++; - if (allPrereqRequired[followupUpgrade]) { - doesFollowupRequireAllPrereqs = true; - } - int[] currentPrereqs = prereqUpgrades[followupUpgrade]; - for (int prereqUpgrade : currentPrereqs) { - if (upgrades[prereqUpgrade]) { - unlockedNeighboringUpgrades++; - } - } - if (unlockedNeighboringUpgrades <= 1) { - canFollowupSpareAConnection = false; - } - } + // Syncers + builder.widget( + new FakeSyncWidget.IntegerSyncer(() -> gravitonShardsAvailable, val -> gravitonShardsAvailable = val)); + builder.widget(upgrades.getSingleSyncer(upgrade)); - unlockedNeighboringUpgrades = 0; + builder.widget( + ForgeOfGodsUI.getIndividualUpgradeGroup( + upgrade, + () -> gravitonShardsAvailable, + () -> completeUpgrade(upgrade), + () -> respecUpgrade(upgrade), + () -> isUpgradeActive(upgrade))); + + if (upgrade.hasExtraCost()) { + builder.widget( + ForgeOfGodsUI + .createMaterialInputButton(upgrade, () -> upgrades.isCostPaid(upgrade), (clickData, widget) -> { + if (!widget.isClient()) { + ModularUIContext ctx = widget.getContext(); + ctx.openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); + ctx.closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + ctx.closeWindow(UPGRADE_TREE_WINDOW_ID); + } + })); } - if (!doesFollowupRequireAllPrereqs && followupUpgrades.length > 0 && canFollowupSpareAConnection) { - unlockedFollowupUpgrades = 0; - } + return builder.build(); + } - if (unlockedFollowupUpgrades == 0) { - gravitonShardsAvailable += gravitonShardCost; - gravitonShardsSpent -= gravitonShardCost; - upgrades[currentUpgradeID] = false; + private void completeUpgrade(ForgeOfGodsUpgrade upgrade) { + if (isUpgradeActive(upgrade)) return; + if (!upgrades.checkPrerequisites(upgrade)) return; + if (!upgrades.checkSplit(upgrade, ringAmount)) return; + if (!upgrades.checkCost(upgrade, gravitonShardsAvailable)) return; - if (currentUpgradeID == 30) { - gravitonShardEjection = false; - } - } + upgrades.unlockUpgrade(upgrade); + gravitonShardsAvailable -= upgrade.getShardCost(); + gravitonShardsSpent += upgrade.getShardCost(); } - private Widget createMaterialInputButton(int upgradeID, int xCoord, int yCoord, IWidgetBuilder builder) { - return new ButtonWidget().setOnClick((clickData, widget) -> { - if (!widget.isClient() && doesCurrentUpgradeRequireExtraMats) { - ModularUIContext ctx = widget.getContext(); - ctx.openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); - ctx.closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); - ctx.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); + private void respecUpgrade(ForgeOfGodsUpgrade upgrade) { + if (!isUpgradeActive(upgrade)) return; + if (!upgrades.checkDependents(upgrade)) return; + + upgrades.respecUpgrade(upgrade); + gravitonShardsAvailable += upgrade.getShardCost(); + gravitonShardsSpent -= upgrade.getShardCost(); + + if (upgrade == END) { + gravitonShardEjection = false; + } } - /** - * @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) { - prereqUpgrades[upgradeID] = prerequisiteUpgradeIDs; - allPrereqRequired[upgradeID] = requireAllPrerequisites; + private Widget createUpgradeBox(ForgeOfGodsUpgrade upgrade, IWidgetBuilder builder) { return new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { - currentUpgradeID = upgradeID; - currentColorCode = colorCode; - currentMilestoneBG = milestone; - gravitonShardCost = shardCost; - followupUpgrades = followingUpgradeIDs; - isUpradeSplitStart = isStartOfSplit; - doesCurrentUpgradeRequireExtraMats = requiresExtraMaterials; + currentUpgradeWindow = upgrade; if (clickData.mouseButton == 0) { if (clickData.shift) { - if (!doesCurrentUpgradeRequireExtraMats - || materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) - .indexOf(currentUpgradeID)]) { - completeUpgrade(); + if (!upgrade.hasExtraCost() || upgrades.isCostPaid(upgrade)) { + completeUpgrade(upgrade); } else if (!widget.isClient()) { ModularUIContext ctx = widget.getContext(); ctx.openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); @@ -1960,36 +1687,34 @@ private Widget createUpgradeBox(int upgradeID, int colorCode, int milestone, int ForgeOfGodsUI.reopenWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); } } else if (clickData.mouseButton == 1) { - respecUpgrade(); + respecUpgrade(upgrade); } }) .setSize(40, 15) .setBackground(() -> { - if (upgrades[upgradeID]) { + if (isUpgradeActive(upgrade)) { return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_PRESSED_32x16 }; } else { return new IDrawable[] { TecTechUITextures.BUTTON_SPACE_32x16 }; } }) - .addTooltip(translateToLocal("fog.upgrade.tt." + upgradeID)) + .addTooltip(upgrade.getNameText()) .setTooltipShowUpDelay(TOOLTIP_DELAY)) .addChild( - new TextWidget(translateToLocal("fog.upgrade.tt.short." + upgradeID)).setScale(0.8f) + new TextWidget(upgrade.getShortNameText()).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); + .setPos(upgrade.getTreePos()) + .attachSyncer(upgrades.getSingleSyncer(upgrade), builder); } private Widget createUpgradeConnectorLine(Pos2d pos, int length, float rotationAngle, int colorCode, - int startUpgradeID, int endUpgradeID) { + ForgeOfGodsUpgrade startUpgrade, ForgeOfGodsUpgrade endUpgrade) { return new DrawableWidget() .setDrawable( - () -> (upgrades[startUpgradeID] && upgrades[endUpgradeID]) + () -> (isUpgradeActive(startUpgrade) && isUpgradeActive(endUpgrade)) ? coloredLine(colorCode, true).withRotationDegree(rotationAngle) : coloredLine(colorCode, false).withRotationDegree(rotationAngle)) .setPos(pos) @@ -2024,7 +1749,8 @@ private IDrawable coloredLine(int colorCode, boolean opaque) { } protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { - ItemStack[] inputs = godforgeUpgradeMats.get(currentUpgradeID); + ForgeOfGodsUpgrade upgrade = currentUpgradeWindow; + ItemStack[] inputs = upgrade.getExtraCost(); final int WIDTH = 189; final int HEIGHT = 106; final int PARENT_WIDTH = getGUIWidth(); @@ -2092,8 +1818,7 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { for (int index : foundInputIndices) { inputSlotHandler.extractItem(index, inputSlotHandler.getStackInSlot(index).stackSize, false); } - materialPaidUpgrades[Arrays.asList(UPGRADE_MATERIAL_ID_CONVERSION) - .indexOf(currentUpgradeID)] = true; + upgrades.paidCost(upgrade); } } }) @@ -3072,8 +2797,8 @@ public int getFuelFactor() { return fuelConsumptionFactor; } - public boolean isUpgradeActive(int upgradeID) { - return upgrades[upgradeID]; + public boolean isUpgradeActive(ForgeOfGodsUpgrade upgrade) { + return upgrades.isUpgradeActive(upgrade); } public int getRingAmount() { @@ -3081,28 +2806,13 @@ public int getRingAmount() { } public int getTotalActiveUpgrades() { - int totalUpgrades = 0; - for (boolean upgrade : upgrades) { - if (upgrade) { - totalUpgrades++; - } - } - return totalUpgrades; + return upgrades.getTotalActiveUpgrades(); } 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( @@ -3431,26 +3141,6 @@ private Text milestoneProgressText(int milestoneID) { return new Text(progressText + ": " + EnumChatFormatting.GRAY + formattingMode.format(max) + " " + suffix); } - private Text constructionStatusText() { - return upgrades[currentUpgradeID] ? new Text(translateToLocal("fog.upgrade.respec")) - : new Text(translateToLocal("fog.upgrade.confirm")); - } - - private List constructionStatus() { - if (upgrades[currentUpgradeID]) { - return ImmutableList.of(translateToLocal("fog.upgrade.respec")); - } - return ImmutableList.of(translateToLocal("fog.upgrade.confirm")); - } - - private List 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; @@ -3555,27 +3245,7 @@ private void saveGeneralNBT(NBTTagCompound NBT, boolean force) { NBT.setInteger("formattingMode", formattingMode.ordinal()); } - // Upgrades - NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); - boolean hasSomeUpgrade = false; - for (int i = 0; i < upgrades.length; i++) { - boolean value = upgrades[i]; - upgradeBooleanArrayNBTTag.setBoolean("upgrade" + i, value); - if (value) hasSomeUpgrade = true; - } - if (force || hasSomeUpgrade) NBT.setTag("upgrades", upgradeBooleanArrayNBTTag); - - // Upgrade material costs paid - NBTTagCompound upgradeMaterialBooleanArrayNBTTag = new NBTTagCompound(); - boolean someCostPaid = false; - for (int i = 0; i < materialPaidUpgrades.length; i++) { - boolean value = materialPaidUpgrades[i]; - upgradeMaterialBooleanArrayNBTTag.setBoolean("upgradeMaterial" + i, value); - if (value) someCostPaid = true; - } - if (force || someCostPaid) NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); - - // Custom star colors + upgrades.serializeToNBT(NBT, force); starColors.serializeToNBT(NBT); } @@ -3607,29 +3277,11 @@ public void loadNBTData(NBTTagCompound NBT) { formattingMode = FormattingMode.VALUES[index]; } - if (NBT.hasKey("upgrades")) { - NBTTagCompound upgradesTag = NBT.getCompoundTag("upgrades"); - for (int i = 0; i < upgrades.length; i++) { - boolean upgrade = upgradesTag.getBoolean("upgrade" + i); - upgrades[i] = upgrade; - } - } - - if (NBT.hasKey("upgradeMaterials")) { - NBTTagCompound materialsTag = NBT.getCompoundTag("upgradeMaterials"); - for (int i = 0; i < materialPaidUpgrades.length; i++) { - boolean upgrade = materialsTag.getBoolean("upgradeMaterial" + i); - materialPaidUpgrades[i] = upgrade; - } - } - + // Stored items NBTTagCompound tempItemTag = NBT.getCompoundTag("upgradeWindowStorage"); - for (int index = 0; index < 16; index++) { - int stackSize = tempItemTag.getInteger(index + "stacksizeOfStoredUpgradeItems"); ItemStack itemStack = ItemStack.loadItemStackFromNBT(NBT.getCompoundTag(index + "storedUpgradeItem")); - if (itemStack != null) { storedUpgradeWindowItems[index] = itemStack.splitStack(stackSize); } @@ -3643,6 +3295,7 @@ public void loadNBTData(NBTTagCompound NBT) { isRenderActive = NBT.getBoolean("isRenderActive"); isRendererDisabled = NBT.getBoolean("isRendererDisabled"); + upgrades.rebuildFromNBT(NBT); starColors.rebuildFromNBT(NBT); super.loadNBTData(NBT); diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 3b2f42f7b09..4f04d8d460d 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -5,19 +5,23 @@ import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGWindowSize.*; import java.util.ArrayList; +import java.util.Arrays; import java.util.EnumMap; import java.util.List; +import java.util.Set; import java.util.function.UnaryOperator; import net.minecraft.item.ItemStack; +import net.minecraft.util.StatCollector; +import com.google.common.collect.ImmutableSet; +import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.math.Size; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; -import it.unimi.dsi.fastutil.objects.ObjectLists; -// todo extra cost items public enum ForgeOfGodsUpgrade { START, @@ -31,7 +35,7 @@ public enum ForgeOfGodsUpgrade { REC, GEM, CTCDD, - QGIPU, + QGPIU, SEFCP, TCT, GGEBE, @@ -58,6 +62,8 @@ public enum ForgeOfGodsUpgrade { public static final ForgeOfGodsUpgrade[] VALUES = values(); + static final Set SPLIT_UPGRADES; + static { // Build upgrade data. Done here due to potential forward references @@ -130,26 +136,26 @@ public enum ForgeOfGodsUpgrade { .background(RED, CONVERSION) .treePos(196, 356)); - QGIPU.build(b -> b + QGPIU.build(b -> b .prereqs(REC, CTCDD) .cost(2) .background(BLUE, CATALYST) .treePos(126, 416)); SEFCP.build(b -> b - .prereqs(QGIPU) + .prereqs(QGPIU) .cost(3) .background(PURPLE, CATALYST) .treePos(66, 476)); TCT.build(b -> b - .prereqs(QGIPU) + .prereqs(QGPIU) .cost(3) .background(ORANGE, CONVERSION) .treePos(126, 476)); GGEBE.build(b -> b - .prereqs(QGIPU) + .prereqs(QGPIU) .cost(3) .background(GREEN, CHARGE) .treePos(186, 476)); @@ -253,6 +259,9 @@ public enum ForgeOfGodsUpgrade { // spotless:on + // Build split upgrade set + SPLIT_UPGRADES = ImmutableSet.of(SEFCP, TCT, GGEBE); + // Build inverse dependents mapping // todo make sure this is right EnumMap> dependencies = new EnumMap<>(ForgeOfGodsUpgrade.class); @@ -265,22 +274,10 @@ public enum ForgeOfGodsUpgrade { for (var entry : dependencies.entrySet()) { ForgeOfGodsUpgrade upgrade = entry.getKey(); List deps = entry.getValue(); - if (deps == null) { - upgrade.dependents = new ForgeOfGodsUpgrade[0]; - } else { + if (deps != null) { upgrade.dependents = deps.toArray(new ForgeOfGodsUpgrade[0]); } } - - // scan for start of split upgrades - // todo make sure this is right - for (ForgeOfGodsUpgrade upgrade : VALUES) { - if (upgrade.dependents.length > 1) { - for (ForgeOfGodsUpgrade u : upgrade.dependents) { - u.startOfSplit = true; - } - } - } } // Static tree linking @@ -289,7 +286,7 @@ public enum ForgeOfGodsUpgrade { // Cost private int shardCost; - private List extraCost; + private final List extraCost = new ArrayList<>(); // UI private BGColor color; @@ -298,8 +295,7 @@ public enum ForgeOfGodsUpgrade { private Pos2d treePos; // Pre-generated data - private ForgeOfGodsUpgrade[] dependents; - private boolean startOfSplit; + private ForgeOfGodsUpgrade[] dependents = new ForgeOfGodsUpgrade[0]; private final String name; private final String nameShort; private final String bodyText; @@ -319,13 +315,84 @@ private void build(UnaryOperator u) { : new ForgeOfGodsUpgrade[0]; this.requireAllPrerequisites = b.requireAllPrerequisites; this.shardCost = b.shardCost; - this.extraCost = b.extraCost != null ? ObjectLists.unmodifiable(b.extraCost) : ObjectLists.emptyList(); this.color = b.color; this.icon = b.icon; this.windowSize = b.windowSize; this.treePos = b.treePos; } + public void addExtraCost(ItemStack... cost) { + extraCost.addAll(Arrays.asList(cost)); + } + + public ForgeOfGodsUpgrade[] getPrerequisites() { + return prerequisites; + } + + public boolean requiresAllPrerequisites() { + return requireAllPrerequisites; + } + + public ForgeOfGodsUpgrade[] getDependents() { + return dependents; + } + + public int getShardCost() { + return shardCost; + } + + public boolean hasExtraCost() { + return !extraCost.isEmpty(); + } + + public ItemStack[] getExtraCost() { + return extraCost.toArray(new ItemStack[0]); + } + + public UITexture getBackground() { + return color.getBackground(); + } + + public UITexture getOverlay() { + return color.getOverlay(); + } + + public UITexture getSymbol() { + return icon.getSymbol(); + } + + public float getSymbolWidthRatio() { + return icon.getWidthRatio(); + } + + public Size getWindowSize() { + return windowSize.getWindowSize(); + } + + public int getLoreYPos() { + return windowSize.getLoreY(); + } + + public Pos2d getTreePos() { + return treePos; + } + + public String getNameText() { + return StatCollector.translateToLocal(name); + } + + public String getShortNameText() { + return StatCollector.translateToLocal(nameShort); + } + + public String getBodyText() { + return StatCollector.translateToLocal(bodyText); + } + + public String getLoreText() { + return StatCollector.translateToLocal(loreText); + } + public static class Builder { // Tree linking @@ -334,7 +401,6 @@ public static class Builder { // Cost private int shardCost; - private ObjectList extraCost; // UI private BGColor color = BLUE; @@ -358,14 +424,8 @@ public Builder requireAllPrereqs() { } // Cost - public Builder cost(int shards, ItemStack... extraCost) { + public Builder cost(int shards) { this.shardCost = shards; - if (extraCost != null) { - if (this.extraCost != null) { - throw new IllegalArgumentException("Cannot repeat calls to ForgeOfGodsUpgrade$Builder#cost"); - } - this.extraCost = new ObjectArrayList<>(extraCost); - } return this; } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java index 7dc0f0a29c1..b3042879fb5 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java @@ -1,6 +1,7 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Size; import tectech.thing.gui.TecTechUITextures; @@ -64,13 +65,19 @@ enum BGWindowSize { ; - private final int width; - private final int height; + private final Size size; private final int loreY; BGWindowSize(int width, int height, int loreY) { - this.width = width; - this.height = height; + this.size = new Size(width, height); this.loreY = loreY; } + + public Size getWindowSize() { + return size; + } + + public int getLoreY() { + return loreY; + } } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java new file mode 100644 index 00000000000..2e9978686db --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java @@ -0,0 +1,203 @@ +package tectech.thing.metaTileEntity.multi.godforge.upgrade; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.EnumMap; +import java.util.stream.Stream; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; + +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +public class UpgradeStorage { + + private final EnumMap unlockedUpgrades = new EnumMap<>(ForgeOfGodsUpgrade.class); + + public UpgradeStorage() { + for (ForgeOfGodsUpgrade upgrade : ForgeOfGodsUpgrade.VALUES) { + unlockedUpgrades.put(upgrade, new UpgradeData()); + } + } + + /** Whether the passed upgrade is already unlocked (purchased). */ + public boolean isUpgradeActive(ForgeOfGodsUpgrade upgrade) { + return getData(upgrade).isActive(); + } + + public boolean isCostPaid(ForgeOfGodsUpgrade upgrade) { + return getData(upgrade).isCostPaid(); + } + + public void paidCost(ForgeOfGodsUpgrade upgrade) { + getData(upgrade).costPaid = true; + } + + public void unlockUpgrade(ForgeOfGodsUpgrade upgrade) { + getData(upgrade).active = true; + } + + public void respecUpgrade(ForgeOfGodsUpgrade upgrade) { + getData(upgrade).active = false; + } + + /** + * Whether the passed upgrade can be unlocked, checking that the prerequisites are satisfied. + */ + public boolean checkPrerequisites(ForgeOfGodsUpgrade upgrade) { + Stream prereqs = Arrays.stream(upgrade.getPrerequisites()) + .map(unlockedUpgrades::get); + + if (upgrade.requiresAllPrerequisites()) { + return prereqs.allMatch(UpgradeData::isActive); + } + return prereqs.anyMatch(UpgradeData::isActive); + } + + public boolean checkSplit(ForgeOfGodsUpgrade upgrade, int maxSplitUpgrades) { + if (ForgeOfGodsUpgrade.SPLIT_UPGRADES.contains(upgrade)) { + return ForgeOfGodsUpgrade.SPLIT_UPGRADES.stream() + .map(unlockedUpgrades::get) + .filter(UpgradeData::isActive) + .count() < maxSplitUpgrades; + } + return true; + } + + public boolean checkCost(ForgeOfGodsUpgrade upgrade, int availableShards) { + if (upgrade.getShardCost() > availableShards) return false; + return !upgrade.hasExtraCost() || isCostPaid(upgrade); + } + + /** @return true if any dependent upgrades are currently unlocked. */ + public boolean checkDependents(ForgeOfGodsUpgrade upgrade) { + for (ForgeOfGodsUpgrade dependent : upgrade.getDependents()) { + if (!isUpgradeActive(dependent)) continue; + + // Check failed, this dependent strictly requires the passed upgrade + if (dependent.requiresAllPrerequisites()) return false; + + // Check for some other prerequisite upgrade of the dependent to make sure that + // if the passed upgrade is removed, that upgrade is still valid + if (Arrays.stream(dependent.getPrerequisites()) + .map(unlockedUpgrades::get) + .filter(UpgradeData::isActive) + .count() <= 1) { + return false; + } + } + return true; + } + + private UpgradeData getData(ForgeOfGodsUpgrade upgrade) { + return unlockedUpgrades.computeIfAbsent(upgrade, $ -> new UpgradeData()); + } + + /** */ + public boolean hasAnyUpgrade() { + return isUpgradeActive(ForgeOfGodsUpgrade.START); + } + + public int getTotalActiveUpgrades() { + return (int) unlockedUpgrades.values() + .stream() + .map(UpgradeData::isActive) + .count(); + } + + public Collection getAllUpgrades() { + return unlockedUpgrades.keySet(); + } + + public void resetAll() { + for (UpgradeData data : unlockedUpgrades.values()) { + data.active = false; + data.costPaid = false; + } + } + + public void unlockAll() { + for (UpgradeData data : unlockedUpgrades.values()) { + data.active = true; + } + } + + public void serializeToNBT(NBTTagCompound NBT, boolean force) { + if (!force && !hasAnyUpgrade()) return; + + NBTTagCompound upgradeTag = new NBTTagCompound(); + for (ForgeOfGodsUpgrade upgrade : ForgeOfGodsUpgrade.VALUES) { + UpgradeData data = unlockedUpgrades.get(upgrade); + upgradeTag.setBoolean("upgrade" + upgrade.ordinal(), data.isActive()); + upgradeTag.setBoolean("upgrade" + upgrade.ordinal() + "cost", data.isCostPaid()); + } + NBT.setTag("upgrades", upgradeTag); + } + + public void rebuildFromNBT(NBTTagCompound NBT) { + if (!NBT.hasKey("upgrades")) return; + + NBTTagCompound upgradeTag = NBT.getCompoundTag("upgrades"); + for (int i = 0; i < ForgeOfGodsUpgrade.VALUES.length; i++) { + ForgeOfGodsUpgrade upgrade = ForgeOfGodsUpgrade.VALUES[i]; + UpgradeData data = unlockedUpgrades.get(upgrade); + data.active = upgradeTag.getBoolean("upgrade" + upgrade.ordinal()); + data.costPaid = upgradeTag.getBoolean("upgrade" + upgrade.ordinal() + "cost"); + } + } + + /** Sync widget to sync the full upgrade tree. */ + public FakeSyncWidget getFullSyncer() { + return new FakeSyncWidget.ListSyncer<>(() -> new ArrayList<>(unlockedUpgrades.values()), val -> { + for (int i = 0; i < val.size(); i++) { + unlockedUpgrades.put(ForgeOfGodsUpgrade.VALUES[i], val.get(i)); + } + }, UpgradeData::writeToBuffer, UpgradeData::readFromBuffer); + } + + /** Sync widget to sync a single upgrade. */ + public FakeSyncWidget getSingleSyncer(ForgeOfGodsUpgrade upgrade) { + return new FakeSyncWidget<>( + () -> unlockedUpgrades.get(upgrade), + val -> unlockedUpgrades.put(upgrade, val), + UpgradeData::writeToBuffer, + UpgradeData::readFromBuffer); + } + + private static class UpgradeData { + + private boolean active; + private boolean costPaid; + + public boolean isActive() { + return active; + } + + public boolean isCostPaid() { + return costPaid; + } + + private static void writeToBuffer(PacketBuffer buf, UpgradeData data) { + buf.writeBoolean(data.isActive()); + buf.writeBoolean(data.isCostPaid()); + } + + private static UpgradeData readFromBuffer(PacketBuffer buf) { + UpgradeData data = new UpgradeData(); + data.active = buf.readBoolean(); + data.costPaid = buf.readBoolean(); + return data; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + UpgradeData that = (UpgradeData) o; + + return active == that.active && costPaid == that.costPaid; + } + } +} From becc46050bf93941ca874cc36bc9c67acdb180cb Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Fri, 1 Nov 2024 20:45:33 -0500 Subject: [PATCH 32/52] more cleanup --- .../multi/godforge/MTEForgeOfGods.java | 253 ++++++++---------- .../godforge/upgrade/ForgeOfGodsUpgrade.java | 43 ++- .../upgrade/ForgeOfGodsUpgradeData.java | 83 ------ .../multi/godforge/upgrade/MilestoneIcon.java | 46 ++++ .../multi/godforge/upgrade/UpgradeColor.java | 72 +++++ 5 files changed, 258 insertions(+), 239 deletions(-) delete mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 0f9dc09c2c9..0807f20e308 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -126,6 +126,8 @@ import tectech.thing.metaTileEntity.multi.godforge.color.StarColorSetting; import tectech.thing.metaTileEntity.multi.godforge.color.StarColorStorage; import tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.MilestoneIcon; +import tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeColor; import tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeStorage; public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { @@ -1072,50 +1074,63 @@ protected ModularWindow createBatteryWindow(final EntityPlayer player) { } 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); + final int w = 78; + final int h = 130; + final int parentW = getGUIWidth(); + final int parentH = getGUIHeight(); + + ModularWindow.Builder builder = ModularWindow.builder(w, h); 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)) + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(parentW, parentH)) .add( - Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) - .add(WIDTH - 3, 0))); + Alignment.TopRight.getAlignedPos(new Size(parentW, parentH), new Size(w, h)) + .add(w - 3, 0))); + + // Window header 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) - // todo try to reduce - .attachSyncer( - upgrades.getFullSyncer(), - builder, - (widget, val) -> ((NumericWidget) widget).setMaxValue(calculateMaxFuelFactor(this)))) - .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)) + .setSize(74, 34)); + + // Fuel factor textbox + NumericWidget fuelFactor = new NumericWidget(); + fuelFactor.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); + builder.widget(fuelFactor); + + // Syncers for max fuel factor + builder.widget( + upgrades.getSingleSyncer(CFCE) + .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); + builder.widget( + upgrades.getSingleSyncer(GEM) + .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); + builder.widget( + upgrades.getSingleSyncer(TSE) + .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); + + builder.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) @@ -1193,8 +1208,7 @@ public void buildTooltip(List tooltip) { }) .setSize(18, 18)) .setPos(29, 82) - .setSize(18, 18) - .attachSyncer(new FakeSyncWidget.IntegerSyncer(this::getFuelType, this::setFuelType), builder)) + .setSize(18, 18)) .widget( new MultiChildWidget().addChild( new FluidNameHolderWidget( @@ -1352,52 +1366,24 @@ protected ModularWindow createMilestoneWindow(final EntityPlayer player) { } 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"; - } - } + final int w = 150; + final int h = 150; + final MilestoneIcon icon = MilestoneIcon.VALUES[currentMilestoneID]; + final Size iconSize = icon.getSize(); + ModularWindow.Builder builder = ModularWindow.builder(w, h); 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)) + new DrawableWidget().setDrawable(icon.getSymbol()) + .setSize(iconSize) + .setPos((w - iconSize.width) / 2, (h - iconSize.height) / 2)) .widget( - TextWidget.localised("gt.blockmachines.multimachine.FOG." + milestoneType + "milestone") - .setDefaultColor(EnumChatFormatting.GOLD) + new TextWidget(icon.getNameText()).setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(0, 8) .setSize(150, 15)) @@ -1479,42 +1465,44 @@ protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { Scrollable scrollable = new Scrollable().setVerticalScroll(); // spotless:off - scrollable.widget(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, 0, START, IGCC)) - .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, 0, IGCC, STEM)) - .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, 0, IGCC, CFCE)) - .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, 0, STEM, GISS)) - .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, 0, STEM, FDIM)) - .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, 0, CFCE, FDIM)) - .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, 0, CFCE, SA)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, 0, FDIM, GPCI)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, 0, GPCI, GEM)) - .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, 4, GISS, REC)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, 4, GPCI, REC)) - .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, 4, SA, CTCDD)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, 4, GPCI, CTCDD)) - .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, 0, REC, QGPIU)) - .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, 0, CTCDD, QGPIU)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, 2, QGPIU, TCT)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, 2, TCT, EPEC)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, 2, EPEC, POS)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, 2, POS, NGMS)) - .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, 1, QGPIU, SEFCP)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, 1, SEFCP, CNTI)) - .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, 1, CNTI, NDPE)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, 1, NDPE, NGMS)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, 1, CNTI, DOP)) - .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, 3, QGPIU, GGEBE)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, 3, GGEBE, IMKG)) - .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, 3, IMKG, DOR)) - .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, 3, DOR, NGMS)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, 3, GGEBE, TPTP)) - .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, 0, NGMS, SEDS)) - .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, 0, SEDS, PA)) - .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, 0, PA, CD)) - .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, 0, CD, TSE)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, 0, TSE, TBF)) - .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, 0, TBF, EE)) - .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, 0, EE, END)); + scrollable + .widget(createUpgradeConnectorLine(new Pos2d(143, 71), 45, 0, UpgradeColor.BLUE, START, IGCC)) + .widget(createUpgradeConnectorLine(new Pos2d(124, 124), 60, 27, UpgradeColor.BLUE, IGCC, STEM)) + .widget(createUpgradeConnectorLine(new Pos2d(162, 124), 60, 333, UpgradeColor.BLUE, IGCC, CFCE)) + .widget(createUpgradeConnectorLine(new Pos2d(94, 184), 60, 27, UpgradeColor.BLUE, STEM, GISS)) + .widget(createUpgradeConnectorLine(new Pos2d(130, 184), 60, 336, UpgradeColor.BLUE, STEM, FDIM)) + .widget(createUpgradeConnectorLine(new Pos2d(156, 184), 60, 24, UpgradeColor.BLUE, CFCE, FDIM)) + .widget(createUpgradeConnectorLine(new Pos2d(192, 184), 60, 333, UpgradeColor.BLUE, CFCE, SA)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 251), 45, 0, UpgradeColor.BLUE, FDIM, GPCI)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 311), 45, 0, UpgradeColor.BLUE, GPCI, GEM)) + .widget(createUpgradeConnectorLine(new Pos2d(78, 250), 110, 5, UpgradeColor.RED, GISS, REC)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 290), 80, 40, UpgradeColor.RED, GPCI, REC)) + .widget(createUpgradeConnectorLine(new Pos2d(208, 250), 110, 355, UpgradeColor.RED, SA, CTCDD)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 290), 80, 320, UpgradeColor.RED, GPCI, CTCDD)) + .widget(createUpgradeConnectorLine(new Pos2d(100, 355), 80, 313, UpgradeColor.BLUE, REC, QGPIU)) + .widget(createUpgradeConnectorLine(new Pos2d(186, 355), 80, 47, UpgradeColor.BLUE, CTCDD, QGPIU)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 430), 48, 0, UpgradeColor.ORANGE, QGPIU, TCT)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 490), 48, 0, UpgradeColor.ORANGE, TCT, EPEC)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 550), 48, 0, UpgradeColor.ORANGE, EPEC, POS)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 610), 48, 0, UpgradeColor.ORANGE, POS, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(110, 410), 80, 40, UpgradeColor.PURPLE, QGPIU, SEFCP)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 490), 48, 0, UpgradeColor.PURPLE, SEFCP, CNTI)) + .widget(createUpgradeConnectorLine(new Pos2d(83, 550), 48, 0, UpgradeColor.PURPLE, CNTI, NDPE)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 590), 80, 320, UpgradeColor.PURPLE, NDPE, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 536), 35, 45, UpgradeColor.PURPLE, CNTI, DOP)) + .widget(createUpgradeConnectorLine(new Pos2d(176, 410), 80, 320, UpgradeColor.GREEN, QGPIU, GGEBE)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 490), 48, 0, UpgradeColor.GREEN, GGEBE, IMKG)) + .widget(createUpgradeConnectorLine(new Pos2d(203, 550), 48, 0, UpgradeColor.GREEN, IMKG, DOR)) + .widget(createUpgradeConnectorLine(new Pos2d(185, 590), 80, 40, UpgradeColor.GREEN, DOR, NGMS)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 476), 35, 315, UpgradeColor.GREEN, GGEBE, TPTP)) + .widget(createUpgradeConnectorLine(new Pos2d(143, 670), 48, 0, UpgradeColor.BLUE, NGMS, SEDS)) + .widget(createUpgradeConnectorLine(new Pos2d(101, 707), 75, 62.3f, UpgradeColor.BLUE, SEDS, PA)) + .widget(createUpgradeConnectorLine(new Pos2d(53, 772), 78, 0, UpgradeColor.BLUE, PA, CD)) + .widget(createUpgradeConnectorLine(new Pos2d(95, 837), 75, 297.7f, UpgradeColor.BLUE, CD, TSE)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 837), 75, 62.3f, UpgradeColor.BLUE, TSE, TBF)) + .widget(createUpgradeConnectorLine(new Pos2d(233, 772), 78, 0, UpgradeColor.BLUE, TBF, EE)) + .widget(createUpgradeConnectorLine(new Pos2d(191, 747), 75, 62.3f, UpgradeColor.BLUE, EE, END)); + // spotless:on for (ForgeOfGodsUpgrade upgrade : upgrades.getAllUpgrades()) { scrollable.widget(createUpgradeBox(upgrade, scrollable)); @@ -1710,44 +1698,19 @@ private Widget createUpgradeBox(ForgeOfGodsUpgrade upgrade, IWidgetBuilder bu .attachSyncer(upgrades.getSingleSyncer(upgrade), builder); } - private Widget createUpgradeConnectorLine(Pos2d pos, int length, float rotationAngle, int colorCode, + private Widget createUpgradeConnectorLine(Pos2d pos, int length, float rotationAngle, UpgradeColor color, ForgeOfGodsUpgrade startUpgrade, ForgeOfGodsUpgrade endUpgrade) { - return new DrawableWidget() - .setDrawable( - () -> (isUpgradeActive(startUpgrade) && isUpgradeActive(endUpgrade)) - ? coloredLine(colorCode, true).withRotationDegree(rotationAngle) - : coloredLine(colorCode, false).withRotationDegree(rotationAngle)) + return new DrawableWidget().setDrawable(() -> { + UITexture texture = color.getConnector(); + if (isUpgradeActive(startUpgrade) && isUpgradeActive(endUpgrade)) { + texture = color.getOpaqueConnector(); + } + return texture.withRotationDegree(rotationAngle); + }) .setPos(pos) .setSize(6, length); } - private IDrawable coloredLine(int colorCode, boolean opaque) { - IDrawable line; - switch (colorCode) { - case 1 -> { - line = opaque ? TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_PURPLE_OPAQUE - : TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_PURPLE; - } - case 2 -> { - line = opaque ? TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_ORANGE_OPAQUE - : TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_ORANGE; - } - case 3 -> { - line = opaque ? TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_GREEN_OPAQUE - : TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_GREEN; - } - case 4 -> { - line = opaque ? TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_RED_OPAQUE - : TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_RED; - } - default -> { - line = opaque ? TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE_OPAQUE - : TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE; - } - } - return line; - } - protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { ForgeOfGodsUpgrade upgrade = currentUpgradeWindow; ItemStack[] inputs = upgrade.getExtraCost(); diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 4f04d8d460d..4ecf8f08bbc 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -1,8 +1,8 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGColor.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGIcon.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.BGWindowSize.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGWindowSize.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.MilestoneIcon.*; +import static tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeColor.*; import java.util.ArrayList; import java.util.Arrays; @@ -56,8 +56,6 @@ public enum ForgeOfGodsUpgrade { EE, END, - // SECRET(), // todo - ; public static final ForgeOfGodsUpgrade[] VALUES = values(); @@ -263,7 +261,6 @@ public enum ForgeOfGodsUpgrade { SPLIT_UPGRADES = ImmutableSet.of(SEFCP, TCT, GGEBE); // Build inverse dependents mapping - // todo make sure this is right EnumMap> dependencies = new EnumMap<>(ForgeOfGodsUpgrade.class); for (ForgeOfGodsUpgrade upgrade : VALUES) { for (ForgeOfGodsUpgrade prerequisite : upgrade.prerequisites) { @@ -289,8 +286,8 @@ public enum ForgeOfGodsUpgrade { private final List extraCost = new ArrayList<>(); // UI - private BGColor color; - private BGIcon icon; + private UpgradeColor color; + private MilestoneIcon icon; private BGWindowSize windowSize; private Pos2d treePos; @@ -403,8 +400,8 @@ public static class Builder { private int shardCost; // UI - private BGColor color = BLUE; - private BGIcon icon = CHARGE; + private UpgradeColor color = BLUE; + private MilestoneIcon icon = CHARGE; private BGWindowSize windowSize = STANDARD; private Pos2d treePos = new Pos2d(0, 0); @@ -430,7 +427,7 @@ public Builder cost(int shards) { } // UI - public Builder background(BGColor color, BGIcon icon) { + public Builder background(UpgradeColor color, MilestoneIcon icon) { this.color = color; this.icon = icon; return this; @@ -446,4 +443,28 @@ public Builder treePos(int x, int y) { return this; } } + + enum BGWindowSize { + + STANDARD(250, 250, 110), + LARGE(300, 300, 85), + + ; + + private final Size size; + private final int loreY; + + BGWindowSize(int width, int height, int loreY) { + this.size = new Size(width, height); + this.loreY = loreY; + } + + public Size getWindowSize() { + return size; + } + + public int getLoreY() { + return loreY; + } + } } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java deleted file mode 100644 index b3042879fb5..00000000000 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgradeData.java +++ /dev/null @@ -1,83 +0,0 @@ -package tectech.thing.metaTileEntity.multi.godforge.upgrade; - -import com.gtnewhorizons.modularui.api.drawable.UITexture; -import com.gtnewhorizons.modularui.api.math.Size; - -import tectech.thing.gui.TecTechUITextures; - -enum BGColor { - - BLUE(TecTechUITextures.BACKGROUND_GLOW_BLUE, TecTechUITextures.PICTURE_OVERLAY_BLUE), - PURPLE(TecTechUITextures.BACKGROUND_GLOW_PURPLE, TecTechUITextures.PICTURE_OVERLAY_PURPLE), - ORANGE(TecTechUITextures.BACKGROUND_GLOW_ORANGE, TecTechUITextures.PICTURE_OVERLAY_ORANGE), - GREEN(TecTechUITextures.BACKGROUND_GLOW_GREEN, TecTechUITextures.PICTURE_OVERLAY_GREEN), - RED(TecTechUITextures.BACKGROUND_GLOW_RED, TecTechUITextures.PICTURE_OVERLAY_RED), - - ; - - private final UITexture background; - private final UITexture overlay; - - BGColor(UITexture background, UITexture overlay) { - this.background = background; - this.overlay = overlay; - } - - public UITexture getBackground() { - return background; - } - - public UITexture getOverlay() { - return overlay; - } -} - -enum BGIcon { - - CHARGE(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE, 0.8f), - CONVERSION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION, 0.72f), - CATALYST(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST, 1.0f), - COMPOSITION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION, 1.0f), - - ; - - private final UITexture symbol; - private final float widthRatio; - - BGIcon(UITexture symbol, float widthRatio) { - this.symbol = symbol; - this.widthRatio = widthRatio; - } - - public UITexture getSymbol() { - return symbol; - } - - public float getWidthRatio() { - return widthRatio; - } -} - -enum BGWindowSize { - - STANDARD(250, 250, 110), - LARGE(300, 300, 85), - - ; - - private final Size size; - private final int loreY; - - BGWindowSize(int width, int height, int loreY) { - this.size = new Size(width, height); - this.loreY = loreY; - } - - public Size getWindowSize() { - return size; - } - - public int getLoreY() { - return loreY; - } -} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java new file mode 100644 index 00000000000..81c86167401 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java @@ -0,0 +1,46 @@ +package tectech.thing.metaTileEntity.multi.godforge.upgrade; + +import net.minecraft.util.StatCollector; + +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Size; + +import tectech.thing.gui.TecTechUITextures; + +public enum MilestoneIcon { + + CHARGE(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CHARGE, 60, 75, "power"), + CONVERSION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CONVERSION, 54, 75, "recipe"), + CATALYST(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_CATALYST, 75, 75, "fuel"), + COMPOSITION(TecTechUITextures.PICTURE_GODFORGE_MILESTONE_COMPOSITION, 75, 75, "purchasable"), + + ; + + public static final MilestoneIcon[] VALUES = values(); + + private final UITexture symbol; + private final Size size; + private final String name; + + MilestoneIcon(UITexture symbol, int width, int height, String shortName) { + this.symbol = symbol; + this.size = new Size(width, height); + this.name = "gt.blockmachines.multimachine.FOG." + shortName + "milestone"; + } + + public UITexture getSymbol() { + return symbol; + } + + public Size getSize() { + return size; + } + + public float getWidthRatio() { + return 1.0f * size.width / size.height; + } + + public String getNameText() { + return StatCollector.translateToLocal(name); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java new file mode 100644 index 00000000000..4d2613de565 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java @@ -0,0 +1,72 @@ +package tectech.thing.metaTileEntity.multi.godforge.upgrade; + +import com.gtnewhorizons.modularui.api.drawable.UITexture; + +import tectech.thing.gui.TecTechUITextures; + +public enum UpgradeColor { + + // spotless:off + + BLUE( + TecTechUITextures.BACKGROUND_GLOW_BLUE, + TecTechUITextures.PICTURE_OVERLAY_BLUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE_OPAQUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_BLUE), + + PURPLE( + TecTechUITextures.BACKGROUND_GLOW_PURPLE, + TecTechUITextures.PICTURE_OVERLAY_PURPLE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_PURPLE_OPAQUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_PURPLE), + + ORANGE( + TecTechUITextures.BACKGROUND_GLOW_ORANGE, + TecTechUITextures.PICTURE_OVERLAY_ORANGE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_ORANGE_OPAQUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_ORANGE), + + GREEN( + TecTechUITextures.BACKGROUND_GLOW_GREEN, + TecTechUITextures.PICTURE_OVERLAY_GREEN, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_GREEN_OPAQUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_GREEN), + + RED( + TecTechUITextures.BACKGROUND_GLOW_RED, + TecTechUITextures.PICTURE_OVERLAY_RED, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_RED_OPAQUE, + TecTechUITextures.PICTURE_UPGRADE_CONNECTOR_RED), + + ; + + // spotless:on + + private final UITexture background; + private final UITexture overlay; + private final UITexture opaqueConnector; + private final UITexture connector; + + UpgradeColor(UITexture background, UITexture overlay, UITexture opaqueConnector, UITexture connector) { + this.background = background; + this.overlay = overlay; + this.opaqueConnector = opaqueConnector; + this.connector = connector; + } + + public UITexture getBackground() { + return background; + } + + public UITexture getOverlay() { + return overlay; + } + + public UITexture getOpaqueConnector() { + return opaqueConnector; + } + + public UITexture getConnector() { + return connector; + } +} From f908638af72c36ab19d4437ad10f68085289b8c9 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sat, 2 Nov 2024 01:12:13 -0500 Subject: [PATCH 33/52] redo manual insertion window logic --- .../java/tectech/loader/recipe/Godforge.java | 6 +- .../tectech/thing/gui/TecTechUITextures.java | 1 + .../multi/godforge/ForgeOfGodsUI.java | 51 +++++++- .../multi/godforge/MTEForgeOfGods.java | 103 +++------------ .../godforge/upgrade/ForgeOfGodsUpgrade.java | 3 + .../godforge/upgrade/UpgradeStorage.java | 118 ++++++++++++++---- .../resources/assets/tectech/lang/en_US.lang | 2 +- .../textures/gui/picture/green_checkmark.png | Bin 0 -> 212 bytes 8 files changed, 172 insertions(+), 112 deletions(-) create mode 100644 src/main/resources/assets/tectech/textures/gui/picture/green_checkmark.png diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index 2af284276b8..d127f917928 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -762,7 +762,11 @@ public void run() { public static void runDevEnvironmentRecipes() { // put something in here to not crash the game in dev environment when opening the manual insertion window - ForgeOfGodsUpgrade.START.addExtraCost(new ItemStack(Blocks.cobblestone, 4)); + ForgeOfGodsUpgrade.START.addExtraCost( + new ItemStack(Blocks.cobblestone, 4), + new ItemStack(Blocks.dirt, 12), + new ItemStack(Blocks.diamond_block, 8), + new ItemStack(Blocks.gold_block, 32)); ForgeOfGodsUpgrade.FDIM.addExtraCost(new ItemStack(Blocks.cobblestone, 8)); ForgeOfGodsUpgrade.GPCI.addExtraCost(new ItemStack(Blocks.cobblestone, 12)); ForgeOfGodsUpgrade.QGPIU.addExtraCost(new ItemStack(Blocks.cobblestone, 16)); diff --git a/src/main/java/tectech/thing/gui/TecTechUITextures.java b/src/main/java/tectech/thing/gui/TecTechUITextures.java index 89fb7c5b110..ce335c1e40e 100644 --- a/src/main/java/tectech/thing/gui/TecTechUITextures.java +++ b/src/main/java/tectech/thing/gui/TecTechUITextures.java @@ -226,6 +226,7 @@ public class TecTechUITextures { .fullImage(MODID, "gui/picture/connector_red_opaque"); public static final UITexture SLOT_OUTLINE_GREEN = UITexture.fullImage(MODID, "gui/picture/green_selector"); public static final UITexture UNSELECTED_OPTION = UITexture.fullImage(MODID, "gui/picture/unselected_option"); + public static final UITexture GREEN_CHECKMARK_11x9 = UITexture.fullImage(MODID, "gui/picture/green_checkmark"); public static final UITexture PICTURE_GODFORGE_MILESTONE_CHARGE = UITexture .fullImage(MODID, "gui/picture/milestone_charge"); public static final UITexture PICTURE_GODFORGE_MILESTONE_CONVERSION = UITexture diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java index e4299b25152..92f13da01c0 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java @@ -13,6 +13,7 @@ import java.util.function.DoubleSupplier; import java.util.function.Supplier; +import net.minecraft.item.ItemStack; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.StatCollector; @@ -20,6 +21,7 @@ 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.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Size; import com.gtnewhorizons.modularui.api.screen.ModularUIContext; @@ -33,6 +35,7 @@ import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; import com.gtnewhorizons.modularui.common.widget.Scrollable; import com.gtnewhorizons.modularui.common.widget.SliderWidget; +import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; @@ -689,7 +692,7 @@ private static List constructionStatusString(Supplier check) { return ImmutableList.of(translateToLocal("fog.upgrade.confirm")); } - public static Text constructionStatusText(Supplier check) { + private static Text constructionStatusText(Supplier check) { if (check.get()) { return new Text(translateToLocal("fog.upgrade.respec")); } @@ -702,4 +705,50 @@ private static List upgradeMaterialRequirements(Supplier check) } return ImmutableList.of(translateToLocal("fog.button.materialrequirements.tooltip")); } + + public static Widget createExtraCostWidget(final ItemStack costStack, Supplier paidAmount) { + MultiChildWidget widget = new MultiChildWidget(); + widget.setSize(36, 18); + + if (costStack == null) { + // Nothing to pay, so just create a simple disabled slot drawable + widget.addChild( + new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_DISABLED) + .setSize(18, 18)); + return widget; + } + + // Item slot + ItemStackHandler handler = new ItemStackHandler(1); + ItemStack handlerStack = costStack.copy(); + handlerStack.stackSize = Math.max(1, handlerStack.stackSize - paidAmount.get()); + handler.setStackInSlot(0, handlerStack); + widget.addChild( + new SlotWidget(handler, 0).setAccess(false, false) + .setRenderStackSize(false) + .disableInteraction() + .setBackground(GTUITextures.BUTTON_STANDARD_PRESSED)); + + // Progress text + widget.addChild(new DynamicTextWidget(() -> { + short paid = paidAmount.get(); + EnumChatFormatting color = EnumChatFormatting.YELLOW; + if (paid == 0) color = EnumChatFormatting.RED; + else if (paid == costStack.stackSize) color = EnumChatFormatting.GREEN; + return new Text(color + "x" + (costStack.stackSize - paid)); + }).setTextAlignment(Alignment.Center) + .setScale(0.8f) + .setPos(18, 5) + .setSize(18, 9) + .setEnabled(w -> paidAmount.get() < costStack.stackSize)); + + // Completed checkmark + widget.addChild( + new DrawableWidget().setDrawable(TecTechUITextures.GREEN_CHECKMARK_11x9) + .setPos(21, 5) + .setSize(11, 9) + .setEnabled(w -> paidAmount.get() >= costStack.stackSize)); + + return widget; + } } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 0807f20e308..f9fe6c5b1c1 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -36,7 +36,6 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.function.Function; import javax.annotation.Nullable; @@ -64,7 +63,6 @@ import com.gtnewhorizons.modularui.api.drawable.Text; import com.gtnewhorizons.modularui.api.drawable.UITexture; import com.gtnewhorizons.modularui.api.drawable.shapes.Rectangle; -import com.gtnewhorizons.modularui.api.forge.IItemHandlerModifiable; import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Color; @@ -78,7 +76,6 @@ 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.DynamicPositionedRow; import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; @@ -87,7 +84,6 @@ 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.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; import com.gtnewhorizons.modularui.common.widget.textfield.TextFieldWidget; @@ -1004,7 +1000,7 @@ protected ButtonWidget createEjectionSwitch(IWidgetBuilder builder) { .setPos(26, 91) .setSize(16, 16) .setEnabled($ -> isUpgradeActive(END)) - .attachSyncer(upgrades.getSingleSyncer(END), builder); + .attachSyncer(upgrades.getSyncer(END), builder); return (ButtonWidget) button; } @@ -1111,13 +1107,13 @@ protected ModularWindow createFuelConfigWindow(final EntityPlayer player) { // Syncers for max fuel factor builder.widget( - upgrades.getSingleSyncer(CFCE) + upgrades.getSyncer(CFCE) .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); builder.widget( - upgrades.getSingleSyncer(GEM) + upgrades.getSyncer(GEM) .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); builder.widget( - upgrades.getSingleSyncer(TSE) + upgrades.getSyncer(TSE) .setOnClientUpdate($ -> fuelFactor.setMaxValue(calculateMaxFuelFactor(this)))); builder.widget( @@ -1608,7 +1604,7 @@ protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) // Syncers builder.widget( new FakeSyncWidget.IntegerSyncer(() -> gravitonShardsAvailable, val -> gravitonShardsAvailable = val)); - builder.widget(upgrades.getSingleSyncer(upgrade)); + builder.widget(upgrades.getSyncer(upgrade)); builder.widget( ForgeOfGodsUI.getIndividualUpgradeGroup( @@ -1634,6 +1630,7 @@ protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) return builder.build(); } + // todo ringAmount is not client synced, causing a UI desync when unlocking split upgrades private void completeUpgrade(ForgeOfGodsUpgrade upgrade) { if (isUpgradeActive(upgrade)) return; if (!upgrades.checkPrerequisites(upgrade)) return; @@ -1695,7 +1692,7 @@ private Widget createUpgradeBox(ForgeOfGodsUpgrade upgrade, IWidgetBuilder bu .setSize(34, 9) .setPos(3, 4)) .setPos(upgrade.getTreePos()) - .attachSyncer(upgrades.getSingleSyncer(upgrade), builder); + .attachSyncer(upgrades.getSyncer(upgrade), builder); } private Widget createUpgradeConnectorLine(Pos2d pos, int length, float rotationAngle, UpgradeColor color, @@ -1718,20 +1715,12 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { 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(); for (int i = 0; i < 16; i++) { inputSlotHandler.insertItem(i, storedUpgradeWindowItems[i], false); storedUpgradeWindowItems[i] = null; } - List 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()); @@ -1741,6 +1730,7 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { .add(Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT))) .subtract(5, 0) .add(0, 4)); + builder.widget(upgrades.getSyncer(upgrade)); builder.widget( SlotGroup.ofItemHandler(inputSlotHandler, 4) .startFromSlot(0) @@ -1764,25 +1754,8 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { .setSize(10, 10)); builder.widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { if (!widget.isClient()) { - ArrayList 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); - } - upgrades.paidCost(upgrade); - } + upgrades.payCost(upgrade, inputSlotHandler); + ForgeOfGodsUI.reopenWindow(widget, MANUAL_INSERTION_WINDOW_ID); } }) .setPlayClickSound(true) @@ -1797,59 +1770,17 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { .setPos(5, 82) .setSize(179, 16)); - IItemHandlerModifiable upgradeMatsHandler = new ItemStackHandler(12); - int uniqueItems = inputs.length; for (int i = 0; i < 12; i++) { - int cleanDiv4 = i / 4; - if (i < uniqueItems) { - ItemStack stack = inputs[i]; - if (stack != null) { - upgradeMatsHandler.setStackInSlot(i, stack.copy()); - } - builder.widget( - new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) - .setPos(5 + cleanDiv4 * 36, 6 + i % 4 * 18) - .setSize(18, 18)); - columnList.get(cleanDiv4) - .addChild( - new SlotWidget(upgradeMatsHandler, i).setAccess(false, false) - .setRenderStackSize(false) - .disableInteraction()); - 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 + i % 4 * 18) - .setSize(18, 18)); - } - } - - int counter = 0; - for (DynamicPositionedColumn column : columnList) { - int spacing = 0; - int xCord = counter * 36; - int yCord = 0; - if (counter > 2) { - spacing = 10; - xCord = 19 + (counter - 3) * 36; - yCord = 5; + final int ii = i; + ItemStack stack = null; + if (i < inputs.length) { + stack = inputs[i]; } - columns.addChild( - column.setSpace(spacing) - .setAlignment(MainAxisAlignment.SPACE_BETWEEN) - .setSize(16, 72) - .setPos(xCord, yCord)); - counter++; + Widget costWidget = ForgeOfGodsUI.createExtraCostWidget(stack, () -> upgrades.getPaidCosts(upgrade)[ii]); + costWidget.setPos(5 + (36 * (i / 4)), 6 + (18 * (i % 4))); + builder.widget(costWidget); } - builder.widget( - columns.setSize(108, 72) - .setPos(5, 6)); - return builder.build(); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 4ecf8f08bbc..371b452f7bf 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -319,6 +319,9 @@ private void build(UnaryOperator u) { } public void addExtraCost(ItemStack... cost) { + if (extraCost.size() + cost.length > 12) { + throw new IllegalArgumentException("Too many inputs for Godforge upgrade cost, cannot be more than 12!"); + } extraCost.addAll(Arrays.asList(cost)); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java index 2e9978686db..b7b0a3b7732 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java @@ -1,16 +1,19 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; -import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; import java.util.stream.Stream; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.PacketBuffer; +import com.gtnewhorizons.modularui.api.forge.ItemStackHandler; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +import gregtech.api.util.GTUtility; + public class UpgradeStorage { private final EnumMap unlockedUpgrades = new EnumMap<>(ForgeOfGodsUpgrade.class); @@ -30,8 +33,48 @@ public boolean isCostPaid(ForgeOfGodsUpgrade upgrade) { return getData(upgrade).isCostPaid(); } - public void paidCost(ForgeOfGodsUpgrade upgrade) { - getData(upgrade).costPaid = true; + public short[] getPaidCosts(ForgeOfGodsUpgrade upgrade) { + return getData(upgrade).amountsPaid; + } + + /** Handles consuming items and updating state if successful. Does NOT handle graviton shards! */ + public void payCost(ForgeOfGodsUpgrade upgrade, ItemStackHandler handler) { + UpgradeData data = getData(upgrade); + + if (!upgrade.hasExtraCost()) { + data.costPaid = true; + return; + } + + ItemStack[] extraCost = upgrade.getExtraCost(); + for (int i = 0; i < handler.getSlots(); i++) { + ItemStack inputStack = handler.getStackInSlot(i); + if (inputStack == null) continue; + + for (int j = 0; j < extraCost.length; j++) { + ItemStack costStack = extraCost[j]; + int alreadyPaid = data.amountsPaid[j]; + if (alreadyPaid >= costStack.stackSize) continue; + + if (GTUtility.areStacksEqual(inputStack, costStack)) { + int maxExtract = costStack.stackSize - alreadyPaid; + ItemStack extractedStack = handler.extractItem(i, maxExtract, false); + if (extractedStack != null) { + data.amountsPaid[j] += extractedStack.stackSize; + } + } + } + } + + // Check if all costs are paid + for (int i = 0; i < extraCost.length; i++) { + ItemStack costStack = extraCost[i]; + if (costStack == null) continue; + if (data.amountsPaid[i] < costStack.stackSize) { + return; + } + } + data.costPaid = true; } public void unlockUpgrade(ForgeOfGodsUpgrade upgrade) { @@ -46,13 +89,16 @@ public void respecUpgrade(ForgeOfGodsUpgrade upgrade) { * Whether the passed upgrade can be unlocked, checking that the prerequisites are satisfied. */ public boolean checkPrerequisites(ForgeOfGodsUpgrade upgrade) { - Stream prereqs = Arrays.stream(upgrade.getPrerequisites()) + ForgeOfGodsUpgrade[] prereqs = upgrade.getPrerequisites(); + if (prereqs.length == 0) return true; + + Stream prereqStream = Arrays.stream(upgrade.getPrerequisites()) .map(unlockedUpgrades::get); if (upgrade.requiresAllPrerequisites()) { - return prereqs.allMatch(UpgradeData::isActive); + return prereqStream.allMatch(UpgradeData::isActive); } - return prereqs.anyMatch(UpgradeData::isActive); + return prereqStream.anyMatch(UpgradeData::isActive); } public boolean checkSplit(ForgeOfGodsUpgrade upgrade, int maxSplitUpgrades) { @@ -94,9 +140,22 @@ private UpgradeData getData(ForgeOfGodsUpgrade upgrade) { return unlockedUpgrades.computeIfAbsent(upgrade, $ -> new UpgradeData()); } - /** */ - public boolean hasAnyUpgrade() { - return isUpgradeActive(ForgeOfGodsUpgrade.START); + private boolean hasAnyProgress() { + if (isUpgradeActive(ForgeOfGodsUpgrade.START)) return true; + + // Check if any costs have been paid in any upgrades + for (var entry : unlockedUpgrades.entrySet()) { + ForgeOfGodsUpgrade upgrade = entry.getKey(); + if (upgrade.hasExtraCost()) { + UpgradeData data = entry.getValue(); + if (data.isCostPaid()) return true; + for (int i = 0; i < data.amountsPaid.length; i++) { + if (data.amountsPaid[i] != 0) return true; + } + } + } + + return false; } public int getTotalActiveUpgrades() { @@ -124,13 +183,20 @@ public void unlockAll() { } public void serializeToNBT(NBTTagCompound NBT, boolean force) { - if (!force && !hasAnyUpgrade()) return; + if (!force && !hasAnyProgress()) return; NBTTagCompound upgradeTag = new NBTTagCompound(); for (ForgeOfGodsUpgrade upgrade : ForgeOfGodsUpgrade.VALUES) { UpgradeData data = unlockedUpgrades.get(upgrade); upgradeTag.setBoolean("upgrade" + upgrade.ordinal(), data.isActive()); - upgradeTag.setBoolean("upgrade" + upgrade.ordinal() + "cost", data.isCostPaid()); + if (upgrade.hasExtraCost()) { + NBTTagCompound costTag = new NBTTagCompound(); + costTag.setBoolean("paid", data.isCostPaid()); + for (int i = 0; i < data.amountsPaid.length; i++) { + costTag.setShort("costPaid" + i, data.amountsPaid[i]); + } + upgradeTag.setTag("extraCost" + upgrade.ordinal(), costTag); + } } NBT.setTag("upgrades", upgradeTag); } @@ -143,21 +209,18 @@ public void rebuildFromNBT(NBTTagCompound NBT) { ForgeOfGodsUpgrade upgrade = ForgeOfGodsUpgrade.VALUES[i]; UpgradeData data = unlockedUpgrades.get(upgrade); data.active = upgradeTag.getBoolean("upgrade" + upgrade.ordinal()); - data.costPaid = upgradeTag.getBoolean("upgrade" + upgrade.ordinal() + "cost"); - } - } - - /** Sync widget to sync the full upgrade tree. */ - public FakeSyncWidget getFullSyncer() { - return new FakeSyncWidget.ListSyncer<>(() -> new ArrayList<>(unlockedUpgrades.values()), val -> { - for (int i = 0; i < val.size(); i++) { - unlockedUpgrades.put(ForgeOfGodsUpgrade.VALUES[i], val.get(i)); + if (upgrade.hasExtraCost() && upgradeTag.hasKey("extraCost" + upgrade.ordinal())) { + NBTTagCompound costTag = upgradeTag.getCompoundTag("extraCost" + upgrade.ordinal()); + data.costPaid = costTag.getBoolean("paid"); + for (int j = 0; j < data.amountsPaid.length; j++) { + data.amountsPaid[j] = costTag.getShort("costPaid" + j); + } } - }, UpgradeData::writeToBuffer, UpgradeData::readFromBuffer); + } } /** Sync widget to sync a single upgrade. */ - public FakeSyncWidget getSingleSyncer(ForgeOfGodsUpgrade upgrade) { + public FakeSyncWidget getSyncer(ForgeOfGodsUpgrade upgrade) { return new FakeSyncWidget<>( () -> unlockedUpgrades.get(upgrade), val -> unlockedUpgrades.put(upgrade, val), @@ -169,6 +232,7 @@ private static class UpgradeData { private boolean active; private boolean costPaid; + private final short[] amountsPaid = new short[12]; public boolean isActive() { return active; @@ -181,12 +245,18 @@ public boolean isCostPaid() { private static void writeToBuffer(PacketBuffer buf, UpgradeData data) { buf.writeBoolean(data.isActive()); buf.writeBoolean(data.isCostPaid()); + for (int i = 0; i < data.amountsPaid.length; i++) { + buf.writeShort(data.amountsPaid[i]); + } } private static UpgradeData readFromBuffer(PacketBuffer buf) { UpgradeData data = new UpgradeData(); data.active = buf.readBoolean(); data.costPaid = buf.readBoolean(); + for (int i = 0; i < data.amountsPaid.length; i++) { + data.amountsPaid[i] = buf.readShort(); + } return data; } @@ -197,7 +267,9 @@ public boolean equals(Object o) { UpgradeData that = (UpgradeData) o; - return active == that.active && costPaid == that.costPaid; + if (active != that.active) return false; + if (costPaid != that.costPaid) return false; + return Arrays.equals(amountsPaid, that.amountsPaid); } } } diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index badcd207622..d4262a25952 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1103,7 +1103,7 @@ gt.blockmachines.multimachine.FOG.recipes=Recipes Processed gt.blockmachines.multimachine.FOG.fuelconsumed=Fuel Units Consumed gt.blockmachines.multimachine.FOG.extensions=Extensions Built gt.blockmachines.multimachine.FOG.shardgain=Graviton Shards gained -gt.blockmachines.multimachine.FOG.consumeUpgradeMats=Click to consume upgrade materials, supply §4exact§r stacksizes +gt.blockmachines.multimachine.FOG.consumeUpgradeMats=Click to consume upgrade materials gt.blockmachines.multimachine.FOG.clickhere=Confused? Click here for some general info gt.blockmachines.multimachine.FOG.introduction=§NIntroduction gt.blockmachines.multimachine.FOG.introductioninfotext=There's a lot going on in the Forge of the Gods, which can be quite confusing at first. This menu aims to explain everything that is happening and all the capabilities/mechanics of the forge. diff --git a/src/main/resources/assets/tectech/textures/gui/picture/green_checkmark.png b/src/main/resources/assets/tectech/textures/gui/picture/green_checkmark.png new file mode 100644 index 0000000000000000000000000000000000000000..3816be66b25ce16b84fb0b48f2ae1f76ffd1041d GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^+(699!3-oX?^2ToQjEnx?oJHr&dIz4a#+$GeH|GX zHuiJ>Nn{1`MFV_7T-7_(^%uxHKjQTH&!F0jD6^ulj15S!mjw9*{|5sGDQ{*s zpb%$)M`SSr1K(i~W;~w1A_XXD>gnPbA`xzShLelIfrH6m_n-fhw{PWYa?~kcZ!@-8 wGuQdO%+=qXDXp_TQWdvtH@J2*a=wRMAUETL{|x+zKm!;&UHx3vIVCg!0EAFJlmGw# literal 0 HcmV?d00001 From 1fafc5e29c3478dcef9fec58a09a36f48f8a1b31 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sat, 2 Nov 2024 01:24:00 -0500 Subject: [PATCH 34/52] tiny cleanup --- .../metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java index b7b0a3b7732..5c6d0aa9758 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java @@ -92,7 +92,7 @@ public boolean checkPrerequisites(ForgeOfGodsUpgrade upgrade) { ForgeOfGodsUpgrade[] prereqs = upgrade.getPrerequisites(); if (prereqs.length == 0) return true; - Stream prereqStream = Arrays.stream(upgrade.getPrerequisites()) + Stream prereqStream = Arrays.stream(prereqs) .map(unlockedUpgrades::get); if (upgrade.requiresAllPrerequisites()) { From 1dac7e091d9cab4e57edb7f431b416358c280d19 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:24:05 -0500 Subject: [PATCH 35/52] reformat file layout slightly --- .../java/tectech/loader/recipe/Godforge.java | 2 +- .../thing/block/RenderForgeOfGods.java | 4 +- .../multi/godforge/MTEBaseModule.java | 1 + .../multi/godforge/MTEExoticModule.java | 2 + .../multi/godforge/MTEForgeOfGods.java | 283 +++--------------- .../ForgeOfGodsRingsStructureString.java | 2 +- .../ForgeOfGodsStructureString.java | 2 +- .../godforge/upgrade/ForgeOfGodsUpgrade.java | 6 +- .../godforge/{ => util}/ForgeOfGodsUI.java | 134 ++++++++- .../godforge/{ => util}/GodforgeMath.java | 9 +- .../godforge/util/MilestoneFormatter.java | 47 +++ .../{upgrade => util}/MilestoneIcon.java | 2 +- .../{upgrade => util}/UpgradeColor.java | 2 +- 13 files changed, 250 insertions(+), 246 deletions(-) rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{ => structure}/ForgeOfGodsRingsStructureString.java (99%) rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{ => structure}/ForgeOfGodsStructureString.java (99%) rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{ => util}/ForgeOfGodsUI.java (83%) rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{ => util}/GodforgeMath.java (95%) create mode 100644 src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/MilestoneFormatter.java rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{upgrade => util}/MilestoneIcon.java (95%) rename src/main/java/tectech/thing/metaTileEntity/multi/godforge/{upgrade => util}/UpgradeColor.java (97%) diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index d127f917928..b40c0d81c29 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -13,7 +13,7 @@ import static gregtech.api.util.GTRecipeConstants.FOG_PLASMA_TIER; import static tectech.recipe.TecTechRecipeMaps.godforgeExoticMatterRecipes; import static tectech.recipe.TecTechRecipeMaps.godforgePlasmaRecipes; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.getRandomIntInRange; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.getRandomIntInRange; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/tectech/thing/block/RenderForgeOfGods.java b/src/main/java/tectech/thing/block/RenderForgeOfGods.java index 90914344900..af67c97d44b 100644 --- a/src/main/java/tectech/thing/block/RenderForgeOfGods.java +++ b/src/main/java/tectech/thing/block/RenderForgeOfGods.java @@ -28,8 +28,8 @@ import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; import tectech.Reference; -import tectech.thing.metaTileEntity.multi.godforge.ForgeOfGodsRingsStructureString; -import tectech.thing.metaTileEntity.multi.godforge.ForgeOfGodsStructureString; +import tectech.thing.metaTileEntity.multi.godforge.structure.ForgeOfGodsRingsStructureString; +import tectech.thing.metaTileEntity.multi.godforge.structure.ForgeOfGodsStructureString; import tectech.util.StructureVBO; import tectech.util.TextureUpdateRequester; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java index 8b432d2ce86..85cc5b11b59 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java @@ -57,6 +57,7 @@ import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; +import tectech.thing.metaTileEntity.multi.godforge.util.ForgeOfGodsUI; public class MTEBaseModule extends TTMultiblockBase { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index ab3f8225f70..c9515579f38 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -80,6 +80,8 @@ import tectech.recipe.TecTechRecipeMaps; import tectech.thing.CustomItemList; import tectech.thing.gui.TecTechUITextures; +import tectech.thing.metaTileEntity.multi.godforge.util.ForgeOfGodsUI; +import tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath; public class MTEExoticModule extends MTEBaseModule { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index f9fe6c5b1c1..3d5ba3dbe74 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -6,26 +6,24 @@ import static gregtech.api.util.GTModHandler.getModItem; import static gregtech.api.util.GTRecipeBuilder.SECONDS; import static gregtech.api.util.GTUtility.filterValidMTEs; -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.thing.casing.TTCasingsContainer.GodforgeCasings; import static tectech.thing.casing.TTCasingsContainer.forgeOfGodsRenderBlock; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.allowModuleConnection; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateEnergyDiscountForModules; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateFuelConsumption; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxFuelFactor; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxHeatForModules; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateMaxParallelForModules; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateProcessingVoltageForModules; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateSpeedBonusForModules; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.calculateStartupFuelConsumption; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.queryMilestoneStats; -import static tectech.thing.metaTileEntity.multi.godforge.GodforgeMath.setMiscModuleParameters; import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.*; -import static tectech.util.TTUtility.toExponentForm; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.allowModuleConnection; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateEnergyDiscountForModules; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateFuelConsumption; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateMaxFuelFactor; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateMaxHeatForModules; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateMaxParallelForModules; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateProcessingVoltageForModules; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateSpeedBonusForModules; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.calculateStartupFuelConsumption; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.queryMilestoneStats; +import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.setMiscModuleParameters; import java.awt.Desktop; import java.awt.Toolkit; @@ -47,6 +45,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; +import net.minecraft.util.ChunkCoordinates; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; @@ -66,7 +65,6 @@ 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.ModularUIContext; @@ -76,7 +74,6 @@ 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.DynamicPositionedRow; import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.FluidNameHolderWidget; @@ -117,14 +114,18 @@ import tectech.thing.block.TileEntityForgeOfGods; import tectech.thing.gui.TecTechUITextures; import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; -import tectech.thing.metaTileEntity.multi.godforge.ForgeOfGodsUI.StarColorRGBM; import tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor; import tectech.thing.metaTileEntity.multi.godforge.color.StarColorSetting; import tectech.thing.metaTileEntity.multi.godforge.color.StarColorStorage; +import tectech.thing.metaTileEntity.multi.godforge.structure.ForgeOfGodsRingsStructureString; +import tectech.thing.metaTileEntity.multi.godforge.structure.ForgeOfGodsStructureString; import tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade; -import tectech.thing.metaTileEntity.multi.godforge.upgrade.MilestoneIcon; -import tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeColor; import tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeStorage; +import tectech.thing.metaTileEntity.multi.godforge.util.ForgeOfGodsUI; +import tectech.thing.metaTileEntity.multi.godforge.util.ForgeOfGodsUI.StarColorRGBM; +import tectech.thing.metaTileEntity.multi.godforge.util.MilestoneFormatter; +import tectech.thing.metaTileEntity.multi.godforge.util.MilestoneIcon; +import tectech.thing.metaTileEntity.multi.godforge.util.UpgradeColor; public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { @@ -135,7 +136,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int DEFAULT_ROTATION_SPEED = 5; private static final int DEFAULT_STAR_SIZE = 20; private static final String DEFAULT_STAR_COLOR = ForgeOfGodsStarColor.DEFAULT.getName(); - private static final FormattingMode DEFAULT_FORMATTING_MODE = FormattingMode.COMMA; + private static final MilestoneFormatter DEFAULT_FORMATTING_MODE = MilestoneFormatter.COMMA; private static final BigInteger DEFAULT_TOTAL_POWER = BigInteger.ZERO; private static Textures.BlockIcons.CustomIcon ScreenON; @@ -165,7 +166,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private boolean batteryCharging; private boolean inversion; private boolean gravitonShardEjection; - private FormattingMode formattingMode = DEFAULT_FORMATTING_MODE; + private MilestoneFormatter formattingMode = DEFAULT_FORMATTING_MODE; private boolean isRenderActive; private boolean secretUpgrade; private boolean isRendererDisabled; @@ -660,19 +661,10 @@ public IGTHatchAdder adder() { } private TileEntityForgeOfGods getRenderer() { - 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; - + ChunkCoordinates renderPos = getRenderPos(); TileEntity tile = this.getBaseMetaTileEntity() .getWorld() - .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + .getTileEntity(renderPos.posX, renderPos.posY, renderPos.posZ); if (tile instanceof TileEntityForgeOfGods forgeTile) { return forgeTile; @@ -693,26 +685,17 @@ private void updateRenderer() { } 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; + ChunkCoordinates renderPos = getRenderPos(); this.getBaseMetaTileEntity() .getWorld() - .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + .setBlock(renderPos.posX, renderPos.posY, renderPos.posZ, Blocks.air); this.getBaseMetaTileEntity() .getWorld() - .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), forgeOfGodsRenderBlock); + .setBlock(renderPos.posX, renderPos.posY, renderPos.posZ, forgeOfGodsRenderBlock); TileEntityForgeOfGods rendererTileEntity = (TileEntityForgeOfGods) this.getBaseMetaTileEntity() .getWorld() - .getTileEntity((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + .getTileEntity(renderPos.posX, renderPos.posY, renderPos.posZ); switch (ringAmount) { case 2 -> { @@ -724,9 +707,7 @@ private void createRenderer() { destroySecondRing(); destroyThirdRing(); } - default -> { - destroyFirstRing(); - } + default -> destroyFirstRing(); } rendererTileEntity.setRenderRotation(getRotation(), getDirection()); @@ -736,20 +717,10 @@ private void createRenderer() { } 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; - + ChunkCoordinates renderPos = getRenderPos(); this.getBaseMetaTileEntity() .getWorld() - .setBlock((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset), Blocks.air); + .setBlock(renderPos.posX, renderPos.posY, renderPos.posZ, Blocks.air); switch (ringAmount) { case 2 -> { @@ -761,14 +732,23 @@ private void destroyRenderer() { buildSecondRing(); buildThirdRing(); } - default -> { - buildFirstRing(); - } + default -> buildFirstRing(); } isRenderActive = false; } + private ChunkCoordinates getRenderPos() { + IGregTechTileEntity gregTechTileEntity = this.getBaseMetaTileEntity(); + int x = gregTechTileEntity.getXCoord(); + int y = gregTechTileEntity.getYCoord(); + int z = gregTechTileEntity.getZCoord(); + double xOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetX; + double yOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetY; + double zOffset = 122 * getExtendedFacing().getRelativeBackInWorld().offsetZ; + return new ChunkCoordinates((int) (x + xOffset), (int) (y + yOffset), (int) (z + zOffset)); + } + private void destroyFirstRing() { buildPiece(STRUCTURE_PIECE_FIRST_RING_AIR, null, false, 63, 14, -59); } @@ -1430,8 +1410,8 @@ protected ModularWindow createIndividualMilestoneWindow(final EntityPlayer playe .attachSyncer( new FakeSyncWidget.ByteSyncer( () -> (byte) formattingMode.ordinal(), - val -> formattingMode = FormattingMode.VALUES[MathHelper - .clamp_int(val, 0, FormattingMode.VALUES.length - 1)]), + val -> formattingMode = MilestoneFormatter.VALUES[MathHelper + .clamp_int(val, 0, MilestoneFormatter.VALUES.length - 1)]), builder)); return builder.build(); @@ -1789,119 +1769,7 @@ protected ModularWindow createGeneralInfoWindow(final EntityPlayer player) { } protected ModularWindow createSpecialThanksWindow(final EntityPlayer player) { - final int WIDTH = 200; - final int HEIGHT = 200; - ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); - - builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_RAINBOW); - builder.setDraggable(true); - builder.widget( - ButtonWidget.closeWindowButton(true) - .setPos(184, 4)) - .widget( - new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_THANKS) - .setPos(50, 50) - .setSize(100, 100)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.contributors")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.Center) - .setScale(1f) - .setPos(0, 5) - .setSize(200, 15)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.lead")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 30) - .setSize(60, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.cloud")).setScale(0.8f) - .setDefaultColor(EnumChatFormatting.AQUA) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 40) - .setSize(60, 10)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.programming")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 55) - .setSize(60, 10)) - .widget( - new TextWidget( - translateToLocal("gt.blockmachines.multimachine.FOG.serenibyss") + " " - + EnumChatFormatting.DARK_AQUA - + translateToLocal("gt.blockmachines.multimachine.FOG.teg")).setScale(0.8f) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 67) - .setSize(60, 10)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.textures")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 85) - .setSize(100, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.ant")).setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GREEN) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 95) - .setSize(60, 10)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.rendering")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 110) - .setSize(100, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.bucket")).setScale(0.8f) - .setDefaultColor(EnumChatFormatting.WHITE) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 120) - .setSize(60, 10)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.lore")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 135) - .setSize(100, 10)) - .widget( - delenoName().setSpace(-1) - .setAlignment(MainAxisAlignment.SPACE_BETWEEN) - .setPos(7, 145) - .setSize(60, 10)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.playtesting")) - .setScale(0.8f) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 160) - .setSize(100, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.misi")).setScale(0.8f) - .setDefaultColor(0xffc26f) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 170) - .setSize(60, 10)) - .widget( - new TextWidget(EnumChatFormatting.ITALIC + translateToLocal("gt.blockmachines.multimachine.FOG.thanks")) - .setScale(0.8f) - .setDefaultColor(0xbbbdbd) - .setTextAlignment(Alignment.Center) - .setPos(90, 140) - .setSize(100, 60)); - return builder.build(); + return ForgeOfGodsUI.createSpecialThanksWindow(); } protected ModularWindow createStarCosmeticsWindow(final EntityPlayer player) { @@ -2580,20 +2448,6 @@ private void openCustomStarColorWindowFresh(Widget widget, @Nullable ForgeOfGods } } - private DynamicPositionedRow delenoName() { - DynamicPositionedRow nameRow = new DynamicPositionedRow(); - String deleno = translateToLocal("gt.blockmachines.multimachine.FOG.deleno"); - int[] colors = new int[] { 0xffffff, 0xf6fff5, 0xecffec, 0xe3ffe2, 0xd9ffd9, 0xd0ffcf }; - - for (int i = 0; i < 6; i++) { - nameRow.addChild( - new TextWidget(Character.toString(deleno.charAt(i))).setDefaultColor(colors[i]) - .setScale(0.8f) - .setTextAlignment(Alignment.CenterLeft)); - } - return nameRow; - } - @Override public MultiblockTooltipBuilder createTooltip() { final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); @@ -2909,47 +2763,6 @@ private Text gravitonShardAmountText(int milestoneID) { translateToLocal("gt.blockmachines.multimachine.FOG.shardgain") + ": " + EnumChatFormatting.GRAY + sum); } - private enum FormattingMode { - - NONE, - COMMA, - EXPONENT; - - static final FormattingMode[] VALUES = values(); - - FormattingMode cycle() { - return switch (this) { - case NONE -> COMMA; - case COMMA -> EXPONENT; - case EXPONENT -> NONE; - }; - } - - String format(Number number) { - return switch (this) { - case NONE -> number.toString(); - case COMMA -> { - if (number instanceof BigInteger bi) yield formatNumbers(bi); - else yield formatNumbers(number.longValue()); - } - case EXPONENT -> { - if (number instanceof BigInteger bi) { - if (bi.compareTo(BigInteger.valueOf(1_000L)) > 0) { - yield toExponentForm(bi); - } - yield bi.toString(); - } else { - long value = number.longValue(); - if (value > 1_000L) { - yield toExponentForm(value); - } - yield Long.toString(value); - } - } - }; - } - } - private Text totalMilestoneProgress(int milestoneID) { Number progress; String suffix; @@ -2994,7 +2807,7 @@ private Text milestoneProgressText(int milestoneID) { String progressText = translateToLocal("gt.blockmachines.multimachine.FOG.progress"); Text done = new Text( translateToLocal("gt.blockmachines.multimachine.FOG.milestonecomplete") - + (formattingMode != FormattingMode.NONE ? EnumChatFormatting.DARK_RED + "?" : "")); + + (formattingMode != DEFAULT_FORMATTING_MODE ? EnumChatFormatting.DARK_RED + "?" : "")); if (milestoneProgress[milestoneID] >= 7 && !inversion) { return done; @@ -3167,8 +2980,8 @@ public void loadNBTData(NBTTagCompound NBT) { totalPowerConsumed = new BigInteger(NBT.getByteArray("totalPowerConsumed")); } if (NBT.hasKey("formattingMode")) { - int index = MathHelper.clamp_int(NBT.getInteger("formattingMode"), 0, FormattingMode.VALUES.length); - formattingMode = FormattingMode.VALUES[index]; + int index = MathHelper.clamp_int(NBT.getInteger("formattingMode"), 0, MilestoneFormatter.VALUES.length); + formattingMode = MilestoneFormatter.VALUES[index]; } // Stored items diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsRingsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsRingsStructureString.java similarity index 99% rename from src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsRingsStructureString.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsRingsStructureString.java index fcff5c7026f..116dc7b5ba5 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsRingsStructureString.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsRingsStructureString.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge; +package tectech.thing.metaTileEntity.multi.godforge.structure; import static tectech.util.TTUtility.replaceLetters; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsStructureString.java similarity index 99% rename from src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsStructureString.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsStructureString.java index 1780be0079b..277db1d1e13 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsStructureString.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/structure/ForgeOfGodsStructureString.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge; +package tectech.thing.metaTileEntity.multi.godforge.structure; import static tectech.util.TTUtility.appendStringArrays; import static tectech.util.TTUtility.replaceLetters; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java index 371b452f7bf..05b5f491d74 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/ForgeOfGodsUpgrade.java @@ -1,8 +1,8 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; import static tectech.thing.metaTileEntity.multi.godforge.upgrade.ForgeOfGodsUpgrade.BGWindowSize.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.MilestoneIcon.*; -import static tectech.thing.metaTileEntity.multi.godforge.upgrade.UpgradeColor.*; +import static tectech.thing.metaTileEntity.multi.godforge.util.MilestoneIcon.*; +import static tectech.thing.metaTileEntity.multi.godforge.util.UpgradeColor.*; import java.util.ArrayList; import java.util.Arrays; @@ -21,6 +21,8 @@ import it.unimi.dsi.fastutil.objects.ObjectArrayList; import it.unimi.dsi.fastutil.objects.ObjectList; +import tectech.thing.metaTileEntity.multi.godforge.util.MilestoneIcon; +import tectech.thing.metaTileEntity.multi.godforge.util.UpgradeColor; public enum ForgeOfGodsUpgrade { diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java similarity index 83% rename from src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java index 92f13da01c0..ac5618e7bce 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge; +package tectech.thing.metaTileEntity.multi.godforge.util; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static net.minecraft.util.StatCollector.translateToLocal; @@ -23,6 +23,7 @@ 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.MainAxisAlignment; import com.gtnewhorizons.modularui.api.math.Size; import com.gtnewhorizons.modularui.api.screen.ModularUIContext; import com.gtnewhorizons.modularui.api.screen.ModularWindow; @@ -30,6 +31,7 @@ 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.DynamicPositionedRow; import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; @@ -751,4 +753,134 @@ public static Widget createExtraCostWidget(final ItemStack costStack, Supplier COMMA; + case COMMA -> EXPONENT; + case EXPONENT -> NONE; + }; + } + + public String format(Number number) { + return switch (this) { + case NONE -> number.toString(); + case COMMA -> { + if (number instanceof BigInteger bi) yield formatNumbers(bi); + else yield formatNumbers(number.longValue()); + } + case EXPONENT -> { + if (number instanceof BigInteger bi) { + if (bi.compareTo(BigInteger.valueOf(1_000L)) > 0) { + yield toExponentForm(bi); + } + yield bi.toString(); + } else { + long value = number.longValue(); + if (value > 1_000L) { + yield toExponentForm(value); + } + yield Long.toString(value); + } + } + }; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/MilestoneIcon.java similarity index 95% rename from src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/MilestoneIcon.java index 81c86167401..41af5b0e187 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/MilestoneIcon.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/MilestoneIcon.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge.upgrade; +package tectech.thing.metaTileEntity.multi.godforge.util; import net.minecraft.util.StatCollector; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/UpgradeColor.java similarity index 97% rename from src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java rename to src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/UpgradeColor.java index 4d2613de565..7bcab73f267 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeColor.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/UpgradeColor.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge.upgrade; +package tectech.thing.metaTileEntity.multi.godforge.util; import com.gtnewhorizons.modularui.api.drawable.UITexture; From ad3822c02140c9aec5a49cab0738f38c673d0d24 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sat, 2 Nov 2024 14:32:11 -0500 Subject: [PATCH 36/52] clean up annotations --- .../multi/godforge/MTEExoticModule.java | 10 ++++------ .../multi/godforge/MTEMoltenModule.java | 10 ++++------ .../multi/godforge/MTEPlasmaModule.java | 10 ++++------ .../multi/godforge/MTESmeltingModule.java | 12 +++++------- 4 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index c9515579f38..f07e32937f8 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -23,8 +23,6 @@ import java.util.Map; import java.util.stream.Stream; -import javax.annotation.Nonnull; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -133,7 +131,7 @@ protected Stream findRecipeMatches(@Nullable RecipeMap map) { @NotNull @Override - protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { if (!recipeInProgress || recipeRegenerated) { powerForRecipe = BigInteger.valueOf(getProcessingVoltage()) .multiply(BigInteger.valueOf(recipe.mDuration * actualParallel)); @@ -171,7 +169,7 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { @NotNull @Override - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { EUt = calculatedEut; powerForRecipe = BigInteger.valueOf(EUt) .multiply(BigInteger.valueOf(duration * actualParallel)); @@ -188,9 +186,9 @@ protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { return CheckRecipeResultRegistry.SUCCESSFUL; } - @Nonnull + @NotNull @Override - protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) .setDurationDecreasePerOC(getOverclockTimeFactor()); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java index 51bfe51ac00..eace01bb6a7 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java @@ -11,8 +11,6 @@ import java.math.BigInteger; import java.util.ArrayList; -import javax.annotation.Nonnull; - import net.minecraft.util.EnumChatFormatting; import org.jetbrains.annotations.NotNull; @@ -54,7 +52,7 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override - protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { if (recipe.mSpecialValue > getHeat()) { return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); } @@ -70,9 +68,9 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { return CheckRecipeResultRegistry.SUCCESSFUL; } - @Nonnull + @NotNull @Override - protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) .setRecipeHeat(recipe.mSpecialValue) .setHeatOC(true) @@ -85,7 +83,7 @@ protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe @NotNull @Override - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java index 29675ae5cef..05ae43e341b 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java @@ -14,8 +14,6 @@ import java.math.BigInteger; import java.util.ArrayList; -import javax.annotation.Nonnull; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumChatFormatting; @@ -77,7 +75,7 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override - protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { wirelessEUt = (long) recipe.mEUt * getMaxParallel(); if (getUserEU(userUUID).compareTo(BigInteger.valueOf(wirelessEUt * recipe.mDuration)) < 0) { return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); @@ -91,7 +89,7 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { @NotNull @Override - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { wirelessEUt = (long) recipe.mEUt * maxParallel; if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { return CheckRecipeResultRegistry.insufficientPower(wirelessEUt * recipe.mDuration); @@ -106,9 +104,9 @@ protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { return CheckRecipeResultRegistry.SUCCESSFUL; } - @Nonnull + @NotNull @Override - protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) .setDurationDecreasePerOC(getOverclockTimeFactor()); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java index ba8e5f26661..1e499b3507a 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java @@ -17,8 +17,6 @@ import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; - import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; @@ -70,7 +68,7 @@ public RecipeMap getRecipeMap() { return furnaceMode ? RecipeMaps.furnaceRecipes : RecipeMaps.blastFurnaceRecipes; } - @Nonnull + @NotNull @Override public Collection> getAvailableRecipeMaps() { return Arrays.asList(RecipeMaps.blastFurnaceRecipes, RecipeMaps.furnaceRecipes); @@ -89,7 +87,7 @@ protected ProcessingLogic createProcessingLogic() { @NotNull @Override - protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { if (recipe.mSpecialValue > getHeat()) { return CheckRecipeResultRegistry.insufficientHeat(recipe.mSpecialValue); @@ -108,7 +106,7 @@ protected CheckRecipeResult validateRecipe(@Nonnull GTRecipe recipe) { @NotNull @Override - protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { + protected CheckRecipeResult onRecipeStart(@NotNull GTRecipe recipe) { if (!addEUToGlobalEnergyMap(userUUID, -calculatedEut * duration)) { return CheckRecipeResultRegistry.insufficientPower(calculatedEut * duration); } @@ -124,9 +122,9 @@ protected CheckRecipeResult onRecipeStart(@Nonnull GTRecipe recipe) { return CheckRecipeResultRegistry.SUCCESSFUL; } - @Nonnull + @NotNull @Override - protected OverclockCalculator createOverclockCalculator(@Nonnull GTRecipe recipe) { + protected OverclockCalculator createOverclockCalculator(@NotNull GTRecipe recipe) { return super.createOverclockCalculator(recipe).setEUt(getProcessingVoltage()) .setRecipeHeat(recipe.mSpecialValue) .setHeatOC(true) From fd866c489b6a1d41a597de3f875375192ae03385 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Wed, 6 Nov 2024 23:15:50 +0100 Subject: [PATCH 37/52] add full upgrade tree syncer --- .../multi/godforge/upgrade/UpgradeStorage.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java index 5c6d0aa9758..a473cc15ed0 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/upgrade/UpgradeStorage.java @@ -1,5 +1,6 @@ package tectech.thing.metaTileEntity.multi.godforge.upgrade; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.EnumMap; @@ -228,6 +229,15 @@ public FakeSyncWidget getSyncer(ForgeOfGodsUpgrade upgrade) { UpgradeData::readFromBuffer); } + /** Sync widget to sync the full upgrade tree. */ + public FakeSyncWidget getFullSyncer() { + return new FakeSyncWidget.ListSyncer<>(() -> new ArrayList<>(unlockedUpgrades.values()), val -> { + for (int i = 0; i < val.size(); i++) { + unlockedUpgrades.put(ForgeOfGodsUpgrade.VALUES[i], val.get(i)); + } + }, UpgradeData::writeToBuffer, UpgradeData::readFromBuffer); + } + private static class UpgradeData { private boolean active; From 899241a2ebff66ee0a7b7808ff005c0b39ed32a9 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Wed, 6 Nov 2024 23:16:29 +0100 Subject: [PATCH 38/52] add base statistics window --- .../tectech/thing/gui/TecTechUITextures.java | 2 + .../multi/godforge/MTEForgeOfGods.java | 244 +++++++++++++++++- .../resources/assets/tectech/lang/en_US.lang | 12 + .../gui/overlay_button/statistics.png | Bin 0 -> 445 bytes 4 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/assets/tectech/textures/gui/overlay_button/statistics.png diff --git a/src/main/java/tectech/thing/gui/TecTechUITextures.java b/src/main/java/tectech/thing/gui/TecTechUITextures.java index ce335c1e40e..f8e6bbe59b5 100644 --- a/src/main/java/tectech/thing/gui/TecTechUITextures.java +++ b/src/main/java/tectech/thing/gui/TecTechUITextures.java @@ -123,6 +123,8 @@ public class TecTechUITextures { .fullImage(MODID, "gui/overlay_button/furnace_mode_on"); public static final UITexture OVERLAY_BUTTON_FURNACE_MODE_OFF = UITexture .fullImage(MODID, "gui/overlay_button/furnace_mode_off"); + public static final UITexture OVERLAY_BUTTON_STATISTICS = UITexture + .fullImage(MODID, "gui/overlay_button/statistics"); 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"); diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 3d5ba3dbe74..2a290367a21 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -6,6 +6,7 @@ import static gregtech.api.util.GTModHandler.getModItem; import static gregtech.api.util.GTRecipeBuilder.SECONDS; import static gregtech.api.util.GTUtility.filterValidMTEs; +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; @@ -203,6 +204,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int STAR_COSMETICS_WINDOW_ID = 18; private static final int STAR_CUSTOM_COLOR_WINDOW_ID = 19; private static final int STAR_CUSTOM_COLOR_IMPORT_WINDOW_ID = 20; + private static final int STATISTICS_WINDOW_ID = 21; private static final int TEXTURE_INDEX = 960; private static final long POWER_MILESTONE_CONSTANT = LongMath.pow(10, 15); private static final long RECIPE_MILESTONE_CONSTANT = LongMath.pow(10, 7); @@ -829,6 +831,7 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont buildContext.addSyncedWindow(STAR_COSMETICS_WINDOW_ID, this::createStarCosmeticsWindow); buildContext.addSyncedWindow(STAR_CUSTOM_COLOR_WINDOW_ID, this::createStarCustomColorWindow); buildContext.addSyncedWindow(STAR_CUSTOM_COLOR_IMPORT_WINDOW_ID, this::createStarColorImportWindow); + buildContext.addSyncedWindow(STATISTICS_WINDOW_ID, this::createStatisticsWindow); builder.widget( new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) @@ -952,7 +955,23 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont }) .setPos(174, 148) .setSize(16, 16) - .setTooltipShowUpDelay(TOOLTIP_DELAY)); + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (!widget.isClient()) { + widget.getContext() + .openSyncedWindow(STATISTICS_WINDOW_ID); + } + }) + .addTooltip(translateToLocal("fog.button.statistics.tooltip")) + .setBackground(() -> { + List button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_STATISTICS); + return button.toArray(new IDrawable[0]); + }) + .setPos(26, 91) + .setSize(16, 16) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); } @Override @@ -977,7 +996,7 @@ protected ButtonWidget createEjectionSwitch(IWidgetBuilder builder) { .attachSyncer( new FakeSyncWidget.BooleanSyncer(() -> gravitonShardEjection, val -> gravitonShardEjection = val), builder) - .setPos(26, 91) + .setPos(44, 91) .setSize(16, 16) .setEnabled($ -> isUpgradeActive(END)) .attachSyncer(upgrades.getSyncer(END), builder); @@ -2448,6 +2467,227 @@ private void openCustomStarColorWindowFresh(Widget widget, @Nullable ForgeOfGods } } + protected ModularWindow createStatisticsWindow(final EntityPlayer player) { + final int WIDTH = 300; + final int HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE); + builder.setDraggable(true); + + builder + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.modulestats")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setScale(1f) + .setPos(0, 8) + .setSize(300, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.heat")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 56) + .setSize(69, 30)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.effectiveheat")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 86) + .setSize(69, 30)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.parallel")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 116) + .setSize(69, 30)) + + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.speedbonus")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 146) + .setSize(69, 30)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.energydiscount")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 176) + .setSize(69, 30)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.ocdivisor")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(12, 206) + .setSize(69, 30)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.powerforge")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(88, 40) + .setSize(40, 10)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.meltingcore")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(141, 40) + .setSize(40, 10)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.plasmafab")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(193, 40) + .setSize(44, 10)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.exoticizer")).setScale(0.8f) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setPos(246, 43) + .setSize(40, 10)); + + builder.widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) + .setSize(1, 197) + .setPos(81, 38)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) + .setSize(1, 197) + .setPos(134, 38)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) + .setSize(1, 197) + .setPos(187, 38)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) + .setSize(1, 197) + .setPos(240, 38)); + + builder.widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 55)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 85)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 115)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 145)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 175)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 205)) + .widget( + new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) + .setSize(276, 1) + .setPos(12, 235)); + + MTESmeltingModule smelting = new MTESmeltingModule("smelting"); + MTEMoltenModule molten = new MTEMoltenModule("molten"); + MTEPlasmaModule plasma = new MTEPlasmaModule("plasma"); + MTEExoticModule exotic = new MTEExoticModule("exotic"); + + builder.widget( + new FakeSyncWidget.ByteSyncer( + () -> (byte) formattingMode.ordinal(), + val -> formattingMode = MilestoneFormatter.VALUES[MathHelper + .clamp_int(val, 0, MilestoneFormatter.VALUES.length - 1)])); + builder + .widget(new FakeSyncWidget.IntegerSyncer(() -> fuelConsumptionFactor, val -> fuelConsumptionFactor = val)); + builder.widget(upgrades.getFullSyncer()); + + for (int i = 0; i < 24; i++) { + MTEBaseModule module; + switch (i % 4) { + case 1 -> { + module = molten; + } + case 2 -> { + module = plasma; + } + case 3 -> { + module = exotic; + } + default -> { + module = smelting; + } + } + + int cleanDiv4 = i / 4; + String relevantInfo; + switch (cleanDiv4) { + case 1 -> { + calculateMaxHeatForModules(module, this); + relevantInfo = String.valueOf(formattingMode.format(module.getHeatForOC())); + } + case 2 -> { + calculateMaxParallelForModules(module, this); + relevantInfo = String.valueOf(formattingMode.format(module.getMaxParallel())); + } + case 3 -> { + calculateSpeedBonusForModules(module, this); + relevantInfo = String.valueOf(formatNumbers(module.getSpeedBonus())); + } + case 4 -> { + calculateEnergyDiscountForModules(module, this); + relevantInfo = String.valueOf(formatNumbers(module.getEnergyDiscount())); + } + case 5 -> { + setMiscModuleParameters(module, this); + relevantInfo = String.valueOf(formatNumbers(module.getOverclockTimeFactor())); + } + default -> { + calculateMaxHeatForModules(module, this); + relevantInfo = String.valueOf(formattingMode.format(module.getHeat())); + } + } + + builder.widget( + new MultiChildWidget() + .addChild( + new ButtonWidget() + .setOnClick( + (clickData, widget) -> { + if (clickData.mouseButton == 0) {} else if (clickData.mouseButton == 1) {} + }) + .setSize(53, 30) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.clickstat")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .addChild( + new DynamicTextWidget(() -> new Text(relevantInfo)).setScale(1f) + .setDefaultColor(EnumChatFormatting.GREEN) + .setTextAlignment(Alignment.Center) + .setSize(53, 30)) + .setPos(81 + (i % 4) * 53, 55 + (i / 4 * 30))); + } + + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(284, 4)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + if (clickData.mouseButton == 0) { + formattingMode = formattingMode.cycle(); + ForgeOfGodsUI.reopenWindow(widget, STATISTICS_WINDOW_ID); + } + }) + .setSize(20, 20) + .addTooltip(translateToLocal("fog.button.formatting.tooltip")) + .setBackground(TecTechUITextures.OVERLAY_CYCLIC_BLUE) + .setPos(8, 272) + .setTooltipShowUpDelay(TOOLTIP_DELAY)); + + return builder.build(); + } + @Override public MultiblockTooltipBuilder createTooltip() { final MultiblockTooltipBuilder tt = new MultiblockTooltipBuilder(); diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index d4262a25952..5828a396df6 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1049,6 +1049,7 @@ fog.button.refreshtimer.tooltip=Reset ready in fog.button.seconds=Seconds fog.button.thanks.tooltip=List of Contributors fog.button.color.tooltip=Cosmetics Menu +fog.button.statistics.tooltip=Stats Overview achievement.gt.blockmachines.multimachine.em.forge_of_gods=Forge of the Gods @@ -1131,6 +1132,17 @@ gt.blockmachines.multimachine.FOG.bucket=BucketBrigade gt.blockmachines.multimachine.FOG.playtesting=Playtesting gt.blockmachines.multimachine.FOG.misi=Misi gt.blockmachines.multimachine.FOG.thanks=A huge thank you to these incredible people for helping to make this a reality! -Cloud +gt.blockmachines.multimachine.FOG.modulestats=Module Statistics +gt.blockmachines.multimachine.FOG.powerforge=Power Forge +gt.blockmachines.multimachine.FOG.meltingcore=Melting Core +gt.blockmachines.multimachine.FOG.plasmafab=Plasma Fabricator +gt.blockmachines.multimachine.FOG.exoticizer=Exoticizer +gt.blockmachines.multimachine.FOG.heat=Heat +gt.blockmachines.multimachine.FOG.effectiveheat=Effective Heat +gt.blockmachines.multimachine.FOG.speedbonus=Speed Bonus +gt.blockmachines.multimachine.FOG.energydiscount=Energy Discount +gt.blockmachines.multimachine.FOG.ocdivisor=OC Divisor +gt.blockmachines.multimachine.FOG.clickstat=Click to view value breakdown gt.blockmachines.multimachine.FOG.hint.0=1 - Classic Hatches or Transcendentally Amplified Magnetic Confinement Casing gt.blockmachines.multimachine.FOG.hint.1=2 - Module Controllers or Singularity Reinforced Stellar Shielding Casing diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/statistics.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/statistics.png new file mode 100644 index 0000000000000000000000000000000000000000..bee81de488a50398b6eb991067776a6df4224577 GIT binary patch literal 445 zcmV;u0Yd(XP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0a8gsK~y+T#Zo;_ z!!QtiVX9z3(9Tqdg_W%f3oMNM0Dc7v3ll;@?EHle{DDeUlomRaud-E&2&iFcK`aPJ znmDP$*>YODQeo_i&hJ_AUEZC8xx-Q{v3DM3S;j#N!~;$%X%fVOIJlL;IWCR!i~>6+ zADO*d0!FmSgHxmv-oEwGIxUa$78FY)Q3ymNVik-+>@`lJA&ChL2bDvYoGQE2iWJ0L zvTB7}c(~Y_;UEt2)ULt1sY&hK)#2USNLYxMjziG|Bdueqg+M9Qj)JaJ?TmoY!sbC; zcvUxG-iEX<-cn1?m;19@=yx3qx(zVWZ|*hT-4^Kp{Z18w$Ex8{z$lQ?!5sRuQ!18& z#pW#-1;kgEiW^ugu9KSph1D_&D{Ds5NSlYi)DVaG>e=}2Ir#A#2>d33*DF~p2V;Ny n2g{W+F|B{`**-Gz<_X{z2M^J5tdjHu00000NkvXXu0mjfxb3?J literal 0 HcmV?d00001 From 08dc0e7695cd8bf47a76ca846c4f6e4129641caf Mon Sep 17 00:00:00 2001 From: GDCloud Date: Thu, 7 Nov 2024 02:13:45 +0100 Subject: [PATCH 39/52] fix nbt saving issue --- .../thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 2a290367a21..7b1ec91b0d6 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -3169,14 +3169,14 @@ public void saveNBTData(NBTTagCompound NBT) { private void saveGeneralNBT(NBTTagCompound NBT, boolean force) { if (force || selectedFuelType != 0) NBT.setInteger("selectedFuelType", selectedFuelType); if (force || internalBattery != 0) NBT.setInteger("internalBattery", internalBattery); - if (force || batteryCharging) NBT.setBoolean("batteryCharging", true); + if (force || batteryCharging) NBT.setBoolean("batteryCharging", batteryCharging); if (force || gravitonShardsAvailable != 0) NBT.setInteger("gravitonShardsAvailable", gravitonShardsAvailable); if (force || gravitonShardsSpent != 0) NBT.setInteger("gravitonShardsSpent", gravitonShardsSpent); if (force || totalRecipesProcessed != 0) NBT.setLong("totalRecipesProcessed", totalRecipesProcessed); if (force || totalFuelConsumed != 0) NBT.setLong("totalFuelConsumed", totalFuelConsumed); if (force || stellarFuelAmount != 0) NBT.setInteger("starFuelStored", stellarFuelAmount); - if (force || gravitonShardEjection) NBT.setBoolean("gravitonShardEjection", true); - if (force || secretUpgrade) NBT.setBoolean("secretUpgrade", true); + if (force || gravitonShardEjection) NBT.setBoolean("gravitonShardEjection", gravitonShardEjection); + if (force || secretUpgrade) NBT.setBoolean("secretUpgrade", secretUpgrade); // Fields with non-zero defaults if (force || fuelConsumptionFactor != DEFAULT_FUEL_CONSUMPTION_FACTOR) { From 5e3dc4e31ecfa5208d25defc89318b67c108be8f Mon Sep 17 00:00:00 2001 From: GDCloud Date: Thu, 7 Nov 2024 02:58:50 +0100 Subject: [PATCH 40/52] improve stored fuel text positioning --- .../multi/godforge/MTEForgeOfGods.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 7b1ec91b0d6..ce10ca65e0d 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -874,10 +874,15 @@ public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildCont .setPos(174, 110) .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( - TextWidget.dynamicText(this::storedFuel) + TextWidget.dynamicText(this::storedFuelHeaderText) .setDefaultColor(EnumChatFormatting.WHITE) .setPos(6, 8) - .setSize(74, 34)) + .setSize(185, 10)) + .widget( + TextWidget.dynamicText(this::storedFuel) + .setDefaultColor(EnumChatFormatting.WHITE) + .setPos(6, 20) + .setSize(185, 10)) .widget(createBatteryButton(builder)) .widget(createEjectionSwitch(builder)) .widget(new FakeSyncWidget.BooleanSyncer(() -> getBaseMetaTileEntity().isAllowedToWork(), val -> { @@ -2803,17 +2808,16 @@ private Text fuelUsage() { private Text storedFuel() { if (internalBattery == 0) { - return new Text( - translateToLocal("gt.blockmachines.multimachine.FOG.storedstartupfuel") + " " - + stellarFuelAmount - + "/" - + neededStartupFuel); + return new Text(stellarFuelAmount + "/" + neededStartupFuel); } - return new Text( - translateToLocal("gt.blockmachines.multimachine.FOG.storedfuel") + " " - + internalBattery - + "/" - + maxBatteryCharge); + return new Text(internalBattery + "/" + maxBatteryCharge); + } + + private Text storedFuelHeaderText() { + if (internalBattery == 0) { + return new Text(translateToLocal("gt.blockmachines.multimachine.FOG.storedstartupfuel")); + } + return new Text(translateToLocal("gt.blockmachines.multimachine.FOG.storedfuel")); } private void checkInversionStatus() { From 0addce2ba252aeaf937d39ccaa33174a64513e9e Mon Sep 17 00:00:00 2001 From: GDCloud Date: Thu, 7 Nov 2024 03:05:36 +0100 Subject: [PATCH 41/52] simplify grid line code --- .../multi/godforge/MTEForgeOfGods.java | 50 ++++--------------- 1 file changed, 10 insertions(+), 40 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index ce10ca65e0d..48c09a1a1a1 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -2549,51 +2549,21 @@ protected ModularWindow createStatisticsWindow(final EntityPlayer player) { .setPos(246, 43) .setSize(40, 10)); - builder.widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) - .setSize(1, 197) - .setPos(81, 38)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) - .setSize(1, 197) - .setPos(134, 38)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) - .setSize(1, 197) - .setPos(187, 38)) - .widget( + // Vertical grid lines + for (int i = 0; i < 4; i++) { + builder.widget( new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(190, 200, 0))) .setSize(1, 197) - .setPos(240, 38)); + .setPos(81 + 53 * i, 38)); + } - builder.widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 55)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 85)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 115)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 145)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 175)) - .widget( - new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) - .setSize(276, 1) - .setPos(12, 205)) - .widget( + // Horizontal grid lines + for (int i = 0; i < 7; i++) { + builder.widget( new DrawableWidget().setDrawable(new Rectangle().setColor(Color.rgb(0, 170, 170))) .setSize(276, 1) - .setPos(12, 235)); + .setPos(12, 55 + 30 * i)); + } MTESmeltingModule smelting = new MTESmeltingModule("smelting"); MTEMoltenModule molten = new MTEMoltenModule("molten"); From c7ee29777597ad65406b586afdcf7d673e0343f5 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 8 Nov 2024 02:40:55 +0100 Subject: [PATCH 42/52] add parameter descriptions --- .../multi/godforge/MTEForgeOfGods.java | 25 +++++++++++++------ .../resources/assets/tectech/lang/en_US.lang | 6 +++++ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 48c09a1a1a1..6ef59062f2f 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -2492,38 +2492,49 @@ protected ModularWindow createStatisticsWindow(final EntityPlayer player) { .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 56) - .setSize(69, 30)) + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.heat")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.effectiveheat")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 86) - .setSize(69, 30)) + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.effectiveheat")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.parallel")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 116) - .setSize(69, 30)) - + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.parallel")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.speedbonus")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 146) - .setSize(69, 30)) + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.speedbonus")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.energydiscount")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 176) - .setSize(69, 30)) + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.energydiscount")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.ocdivisor")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setPos(12, 206) - .setSize(69, 30)) + .setSize(69, 30) + .addTooltip(translateToLocal("fog.text.tooltip.ocdivisor")) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.powerforge")).setScale(0.8f) .setDefaultColor(EnumChatFormatting.GOLD) diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 5828a396df6..735dab0520e 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1050,6 +1050,12 @@ fog.button.seconds=Seconds fog.button.thanks.tooltip=List of Contributors fog.button.color.tooltip=Cosmetics Menu fog.button.statistics.tooltip=Stats Overview +fog.text.tooltip.heat=Heat value used for checking if a recipe can run +fog.text.tooltip.effectiveheat=Heat value used for calculating bonuses +fog.text.tooltip.parallel=Maximum parallel amount +fog.text.tooltip.speedbonus=Multiplier for base recipe time, making it shorter +fog.text.tooltip.energydiscount=Multiplier for base energy usage, reducing it +fog.text.tooltip.ocdivisor=Divisor for recipe time reduction per overclock (does not affect perfect OCs) achievement.gt.blockmachines.multimachine.em.forge_of_gods=Forge of the Gods From f71d6fb270db69c4e4556cac2245c565a847345b Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sat, 9 Nov 2024 03:04:50 +0100 Subject: [PATCH 43/52] fix exoticizer ignoring input fluid amounts --- .../thing/metaTileEntity/multi/godforge/MTEExoticModule.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index f07e32937f8..e14a40f8631 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -160,7 +160,8 @@ protected CheckRecipeResult validateRecipe(@NotNull GTRecipe recipe) { } for (FluidStack stack : recipe.mFluidInputs) { - if (!ArrayUtils.contains(inputFluids, stack)) { + if (!ArrayUtils.contains(inputFluids, stack) + || inputFluids[ArrayUtils.indexOf(inputFluids, stack)].amount != stack.amount) { return SimpleCheckRecipeResult.ofFailure("waiting_for_inputs"); } } From 94dc032cb29dc3f092fb387e5b8e7ceee522bb73 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Sun, 17 Nov 2024 16:26:42 +0100 Subject: [PATCH 44/52] minor upgrade description change --- src/main/resources/assets/tectech/lang/en_US.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 735dab0520e..577cb7c3ddb 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -991,7 +991,7 @@ fog.upgrade.text.0=Unlocks the base functionality of the Forge of the Gods, mean fog.upgrade.text.1=Unlocks a recipe time reduction multiplier based on the current heat the multi is running at. This bonus is calculated via following formula: Multiplier = 1 / (Heat^0.01) fog.upgrade.text.2=Increases fuel efficiency by multiplying the actual fuel consumption by 0.8 fog.upgrade.text.3=Multiplies the maximum fuel consumption by 1.2 -fog.upgrade.text.4=Increases the base processing voltage of the multi by: Stellar Fuel Units/sec * 10^8 EU/t +fog.upgrade.text.4=Increases the base processing voltage of all modules by: Stellar Fuel Units/sec * 10^8 EU/t fog.upgrade.text.5=Unlocks the Helioflux Melting Core module. fog.upgrade.text.6=Unlocks a multiplier to maximum parallel based on fuel consumption rate. This bonus is calculated via this formula: Multiplier = 1 + (Stellar Fuel Units/sec) / 15 fog.upgrade.text.7=Unlocks the Heliothermal Plasma Fabricator module and basic element -> plasma processing (1 step plasmas, T3 fusion maximum). From b667983d64e52fde9b080580541773936f84474b Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:58:09 -0600 Subject: [PATCH 45/52] Fix IMKG formula description --- src/main/resources/assets/tectech/lang/en_US.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 577cb7c3ddb..b11dc0041b8 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1006,7 +1006,7 @@ fog.upgrade.text.15=Allows the Heliothermal Plasma Fabricator to process multi s fog.upgrade.text.16=Allows the Helioflare Power Forge to receive the full benefits of the Helioflux Melting Core upgrade path. fog.upgrade.text.17=Increases the cap of EBF heat bonuses to 30,000K. fog.upgrade.text.18=Unlocks a multiplier to maximum parallel based on current heat. This bonus is calculated via this formula: Multiplier = 1 + Heat / 15000 -fog.upgrade.text.19=Improves the EBF energy reduction heat bonus from 5% to 8% and adds an energy discount based on the fill level of the internal battery. This bonus is calculated via this formula: Discount = (Current fill level / Max Capacity - 0.5)^2 * (-0.6) + 0.15 +fog.upgrade.text.19=Improves the EBF energy reduction heat bonus from 5% to 8% and adds an energy discount based on the fill level of the internal battery. This bonus is calculated via this formula (* 2/3 for modules other than the Plasma Fabricator): Discount = (Current fill level / Max Capacity - 0.5)^2 * (-0.6) + 0.15 fog.upgrade.text.20=EBF heat bonuses are granted above 30,000K, but the heat value used in heat bonus calculations is determined by this formula: Actual Heat = 30000 + (Current Heat - 30000)^0.85 fog.upgrade.text.21=Unlocks a multiplier to maximum parallel based on total amount of purchased upgrades. This bonus is calculated via this formula: Multiplier = 1 + Upgrade Amount / 5 fog.upgrade.text.22=Improves IGCC based on current maximum parallel. Improved Formula: Multiplier = (1 / Heat^0.01) / (Parallel^0.02) From 04c0aaead207d49aa831e1b6baf2b07698c69aad Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:05:21 -0600 Subject: [PATCH 46/52] reword IMKG description, fix SEFCP description --- src/main/resources/assets/tectech/lang/en_US.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index b11dc0041b8..4b7f5ec8c42 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -999,14 +999,14 @@ fog.upgrade.text.8=Unlocks a configuration window for maximum battery size and i fog.upgrade.text.9=Increases maximum fuel consumption by 1 Stellar Fuel Unit/sec for every purchased upgrade. fog.upgrade.text.10=Adds a x2 multiplier to maximum parallel. fog.upgrade.text.11=Unlocks the Heliofusion Exoticizer module and quark gluon plasma creation. At this point this module is not affected by any other multipliers or bonuses from other upgrades. -fog.upgrade.text.12=Improves the fuel consumption -> heat conversion formula. Improved formula: Heat = log1.12(Stellar Fuel Units/sec) * 1000 + 12601 +fog.upgrade.text.12=Improves the fuel consumption -> heat conversion formula. Improved formula: Power Forge Heat = log1.12(Stellar Fuel Units/sec) * 1000 + 12601, Melting Core Heat = log1.18(Stellar Fuel Units/sec) * 1000 + 12601 fog.upgrade.text.13=Improves the formula of SA to: Multiplier = 1 + (Stellar Fuel Units/sec) / 5 fog.upgrade.text.14=Improves the OC formula from 4/2 OCs to 4/2.3 OCs. fog.upgrade.text.15=Allows the Heliothermal Plasma Fabricator to process multi step plasmas. Tier restriction still applies. fog.upgrade.text.16=Allows the Helioflare Power Forge to receive the full benefits of the Helioflux Melting Core upgrade path. fog.upgrade.text.17=Increases the cap of EBF heat bonuses to 30,000K. fog.upgrade.text.18=Unlocks a multiplier to maximum parallel based on current heat. This bonus is calculated via this formula: Multiplier = 1 + Heat / 15000 -fog.upgrade.text.19=Improves the EBF energy reduction heat bonus from 5% to 8% and adds an energy discount based on the fill level of the internal battery. This bonus is calculated via this formula (* 2/3 for modules other than the Plasma Fabricator): Discount = (Current fill level / Max Capacity - 0.5)^2 * (-0.6) + 0.15 +fog.upgrade.text.19=Improves the EBF energy reduction heat bonus from 5% to 8% and adds an energy discount based on the fill level of the internal battery. This bonus is calculated via the formula: Discount = (Current fill level / Max Capacity - 0.5)^2 * (-0.6) + 0.15, multiplied by 2/3 for modules other than the Plasma Fabricator fog.upgrade.text.20=EBF heat bonuses are granted above 30,000K, but the heat value used in heat bonus calculations is determined by this formula: Actual Heat = 30000 + (Current Heat - 30000)^0.85 fog.upgrade.text.21=Unlocks a multiplier to maximum parallel based on total amount of purchased upgrades. This bonus is calculated via this formula: Multiplier = 1 + Upgrade Amount / 5 fog.upgrade.text.22=Improves IGCC based on current maximum parallel. Improved Formula: Multiplier = (1 / Heat^0.01) / (Parallel^0.02) From bb908e59c218af4c4c8549c5ae53dc9da2b6d462 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Mon, 18 Nov 2024 00:29:17 -0600 Subject: [PATCH 47/52] move away from classicHatches() for multi parts --- .../metaTileEntity/multi/godforge/MTEForgeOfGods.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 6ef59062f2f..c3740255500 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -1,6 +1,9 @@ package tectech.thing.metaTileEntity.multi.godforge; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +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.Mods.Avaritia; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.util.GTModHandler.getModItem; @@ -321,7 +324,13 @@ public IStructureDefinition getStructure_EM() { .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( + 'A', + HatchElementBuilder.builder() + .atLeast(InputBus, InputHatch, OutputBus) + .casingIndex(TEXTURE_INDEX + 3) + .dot(1) + .buildAndChain(GodforgeCasings, 3)) .addElement('B', ofBlock(GodforgeCasings, 0)) .addElement('C', ofBlock(GodforgeCasings, 1)) .addElement('D', ofBlock(GodforgeCasings, 2)) From 8e6a1ded998281824f0c307e6caccb3ce8040d31 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Wed, 20 Nov 2024 21:03:41 -0600 Subject: [PATCH 48/52] improve window handling --- .../multi/godforge/MTEForgeOfGods.java | 31 +++++++------------ .../multi/godforge/util/ForgeOfGodsUI.java | 9 ++++++ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index c3740255500..2b7e86374b2 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -71,7 +71,6 @@ import com.gtnewhorizons.modularui.api.math.Color; import com.gtnewhorizons.modularui.api.math.Pos2d; import com.gtnewhorizons.modularui.api.math.Size; -import com.gtnewhorizons.modularui.api.screen.ModularUIContext; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; @@ -1366,8 +1365,7 @@ protected ModularWindow createMilestoneWindow(final EntityPlayer player) { if (!widget.isClient()) { widget.getWindow() .closeWindow(); - widget.getContext() - .closeWindow(INDIVIDUAL_MILESTONE_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, INDIVIDUAL_MILESTONE_WINDOW_ID); } }) .setPos(382, 6)); @@ -1557,8 +1555,7 @@ protected ModularWindow createUpgradeTreeWindow(final EntityPlayer player) { if (!widget.isClient()) { widget.getWindow() .closeWindow(); - widget.getContext() - .closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); } }) .setPos(282, 4)); @@ -1631,12 +1628,9 @@ protected ModularWindow createIndividualUpgradeWindow(final EntityPlayer player) builder.widget( ForgeOfGodsUI .createMaterialInputButton(upgrade, () -> upgrades.isCostPaid(upgrade), (clickData, widget) -> { - if (!widget.isClient()) { - ModularUIContext ctx = widget.getContext(); - ctx.openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); - ctx.closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); - ctx.closeWindow(UPGRADE_TREE_WINDOW_ID); - } + ForgeOfGodsUI.reopenWindow(widget, MANUAL_INSERTION_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, UPGRADE_TREE_WINDOW_ID); })); } @@ -1675,11 +1669,10 @@ private Widget createUpgradeBox(ForgeOfGodsUpgrade upgrade, IWidgetBuilder bu if (clickData.shift) { if (!upgrade.hasExtraCost() || upgrades.isCostPaid(upgrade)) { completeUpgrade(upgrade); - } else if (!widget.isClient()) { - ModularUIContext ctx = widget.getContext(); - ctx.openSyncedWindow(MANUAL_INSERTION_WINDOW_ID); - ctx.closeWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); - ctx.closeWindow(UPGRADE_TREE_WINDOW_ID); + } else { + ForgeOfGodsUI.reopenWindow(widget, MANUAL_INSERTION_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); + ForgeOfGodsUI.closeWindow(widget, UPGRADE_TREE_WINDOW_ID); } } else { ForgeOfGodsUI.reopenWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); @@ -1756,10 +1749,8 @@ protected ModularWindow createManualInsertionWindow(final EntityPlayer player) { if (!widget.isClient()) { widget.getWindow() .closeWindow(); - widget.getContext() - .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); - widget.getContext() - .openSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID); + ForgeOfGodsUI.reopenWindow(widget, UPGRADE_TREE_WINDOW_ID); + ForgeOfGodsUI.reopenWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); } }) .setBackground(ModularUITextures.VANILLA_BACKGROUND, new Text("x")) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java index ac5618e7bce..5bdcf6ed2ef 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java @@ -426,6 +426,15 @@ public static void reopenWindow(Widget widget, int windowId) { } } + public static void closeWindow(Widget widget, int windowId) { + if (!widget.isClient()) { + ModularUIContext ctx = widget.getContext(); + if (ctx.isWindowOpen(windowId)) { + ctx.closeWindow(windowId); + } + } + } + public enum StarColorRGBM { RED(EnumChatFormatting.RED, RED_ARGB, 0, 255, ForgeOfGodsStarColor.DEFAULT_RED), From b3479a05bc3c4b5ff5f3d4e811ea8e8ad6283f97 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Fri, 22 Nov 2024 02:47:23 +0100 Subject: [PATCH 49/52] add nei window for upgrade costs --- .../api/gui/modularui/GTUITextures.java | 1 + .../gregtech/api/util/GTRecipeConstants.java | 6 ++ .../loader/recipe/BaseRecipeLoader.java | 1 + .../java/tectech/loader/recipe/Godforge.java | 66 ++++++++++++++++ .../recipe/GodforgeUpgradeCostFrontend.java | 71 ++++++++++++++++++ .../tectech/recipe/TecTechRecipeMaps.java | 12 +++ .../multi/godforge/MTEForgeOfGods.java | 7 ++ .../textures/gui/picture/arrow_gray.png | Bin 0 -> 195 bytes .../resources/assets/tectech/lang/en_US.lang | 1 + 9 files changed, 165 insertions(+) create mode 100644 src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java create mode 100644 src/main/resources/assets/gregtech/textures/gui/picture/arrow_gray.png diff --git a/src/main/java/gregtech/api/gui/modularui/GTUITextures.java b/src/main/java/gregtech/api/gui/modularui/GTUITextures.java index 2e0fc114d9e..499f043af18 100644 --- a/src/main/java/gregtech/api/gui/modularui/GTUITextures.java +++ b/src/main/java/gregtech/api/gui/modularui/GTUITextures.java @@ -537,6 +537,7 @@ public static FallbackableUITexture fallbackableProgressbar(String name, UITextu public static final UITexture PICTURE_SLOTS_HOLO_3BY3 = UITexture .fullImage(GregTech.ID, "gui/picture/slots_holo_3by3"); public static final UITexture PICTURE_ARROW_DOUBLE = UITexture.fullImage(GregTech.ID, "gui/picture/arrow_double"); + public static final UITexture PICTURE_ARROW_GRAY = UITexture.fullImage(GregTech.ID, "gui/picture/arrow_gray"); public static final UITexture PICTURE_SUPER_BUFFER = UITexture.fullImage(GregTech.ID, "gui/picture/super_buffer"); public static final UITexture PICTURE_SQUARE_LIGHT_GRAY = UITexture .fullImage(GregTech.ID, "gui/picture/square_light_gray"); diff --git a/src/main/java/gregtech/api/util/GTRecipeConstants.java b/src/main/java/gregtech/api/util/GTRecipeConstants.java index 883f1060ac7..f0e4cacd650 100644 --- a/src/main/java/gregtech/api/util/GTRecipeConstants.java +++ b/src/main/java/gregtech/api/util/GTRecipeConstants.java @@ -129,6 +129,12 @@ public class GTRecipeConstants { public static final RecipeMetadataKey FOG_PLASMA_MULTISTEP = SimpleRecipeMetadataKey .create(Boolean.class, "fog_plasma_multistep"); + /** + * FOG Shortened upgrade name. + */ + public static final RecipeMetadataKey FOG_UPGRADE_NAME_SHORT = SimpleRecipeMetadataKey + .create(String.class, "fog_plasma_upgrade_name_short"); + /** * DEFC Casing tier. */ diff --git a/src/main/java/tectech/loader/recipe/BaseRecipeLoader.java b/src/main/java/tectech/loader/recipe/BaseRecipeLoader.java index 180e8514f4a..445dd9c0690 100644 --- a/src/main/java/tectech/loader/recipe/BaseRecipeLoader.java +++ b/src/main/java/tectech/loader/recipe/BaseRecipeLoader.java @@ -46,5 +46,6 @@ public void run() { } else { Godforge.runDevEnvironmentRecipes(); } + Godforge.addFakeUpgradeCostRecipes(); } } diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index b40c0d81c29..51be5b9e7fc 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -11,6 +11,7 @@ import static gregtech.api.util.GTRecipeConstants.FOG_EXOTIC_TIER; import static gregtech.api.util.GTRecipeConstants.FOG_PLASMA_MULTISTEP; import static gregtech.api.util.GTRecipeConstants.FOG_PLASMA_TIER; +import static gregtech.api.util.GTRecipeConstants.FOG_UPGRADE_NAME_SHORT; import static tectech.recipe.TecTechRecipeMaps.godforgeExoticMatterRecipes; import static tectech.recipe.TecTechRecipeMaps.godforgePlasmaRecipes; import static tectech.thing.metaTileEntity.multi.godforge.util.GodforgeMath.getRandomIntInRange; @@ -26,6 +27,8 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.ArrayUtils; + import goodgenerator.items.GGMaterial; import goodgenerator.util.ItemRefer; import gregtech.api.enums.GTValues; @@ -775,6 +778,69 @@ public static void runDevEnvironmentRecipes() { ForgeOfGodsUpgrade.END.addExtraCost(new ItemStack(Blocks.cobblestone, 64)); } + public static void addFakeUpgradeCostRecipes() { + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.START.getExtraCost())) + .itemOutputs( + CustomItemList.Godforge_GravitonFlowModulatorTier1.get(1), + CustomItemList.Machine_Multi_SmeltingModule.get(1)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.START.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.FDIM.getExtraCost())) + .itemOutputs(CustomItemList.Machine_Multi_MoltenModule.get(1)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.FDIM.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.GPCI.getExtraCost())) + .itemOutputs(CustomItemList.Machine_Multi_PlasmaModule.get(1)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.GPCI.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.QGPIU.getExtraCost())) + .itemOutputs(CustomItemList.Machine_Multi_QuarkGluonPlasmaModule.get(1)) + .fluidOutputs(MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.QGPIU.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.CD.getExtraCost())) + .itemOutputs(CustomItemList.Godforge_GravitonFlowModulatorTier2.get(1)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.CD.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.EE.getExtraCost())) + .itemOutputs(CustomItemList.Godforge_GravitonFlowModulatorTier3.get(1)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.EE.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + GTValues.RA.stdBuilder() + .itemInputs(ArrayUtils.addAll(ForgeOfGodsUpgrade.END.getExtraCost())) + .itemOutputs(MaterialsUEVplus.GravitonShard.getGems(1)) + .fluidOutputs(MaterialsUEVplus.MagMatter.getMolten(576), Materials.Neutronium.getPlasma(1000)) + .duration(1) + .eut(1) + .metadata(FOG_UPGRADE_NAME_SHORT, ForgeOfGodsUpgrade.END.getShortNameText()) + .fake() + .addTo(TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes); + } + public static void initMoltenModuleRecipes() { for (GTRecipe recipe : RecipeMaps.blastFurnaceRecipes.getAllRecipes()) { List itemOutputs = new ArrayList<>(1); diff --git a/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java b/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java new file mode 100644 index 00000000000..439473fc189 --- /dev/null +++ b/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java @@ -0,0 +1,71 @@ +package tectech.recipe; + +import static gregtech.api.util.GTRecipeConstants.FOG_UPGRADE_NAME_SHORT; + +import java.util.List; + +import javax.annotation.ParametersAreNonnullByDefault; + +import net.minecraft.util.EnumChatFormatting; + +import com.gtnewhorizons.modularui.api.math.Pos2d; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; + +import gregtech.api.recipe.BasicUIPropertiesBuilder; +import gregtech.api.recipe.NEIRecipePropertiesBuilder; +import gregtech.api.recipe.RecipeMapFrontend; +import gregtech.api.util.MethodsReturnNonnullByDefault; +import gregtech.common.gui.modularui.UIHelper; +import gregtech.nei.RecipeDisplayInfo; +import tectech.thing.gui.TecTechUITextures; + +@ParametersAreNonnullByDefault +@MethodsReturnNonnullByDefault +public class GodforgeUpgradeCostFrontend extends RecipeMapFrontend { + + public GodforgeUpgradeCostFrontend(BasicUIPropertiesBuilder uiPropertiesBuilder, + NEIRecipePropertiesBuilder neiPropertiesBuilder) { + super(uiPropertiesBuilder, neiPropertiesBuilder); + } + + @Override + public void addGregTechLogo(ModularWindow.Builder builder, Pos2d windowOffset) { + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_GODFORGE_LOGO) + .setSize(18, 18) + .setPos(new Pos2d(151, 63).add(windowOffset))); + } + + @Override + public List getItemInputPositions(int itemInputCount) { + return UIHelper.getGridPositions(itemInputCount, 8, 17, 4); + } + + @Override + public List getItemOutputPositions(int itemOutputCount) { + return UIHelper.getGridPositions(itemOutputCount, 116, 26, 1); + } + + @Override + public List getFluidOutputPositions(int fluidOutputCount) { + return UIHelper.getGridPositions(fluidOutputCount, 134, 26, 1); + } + + @Override + protected void drawDurationInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {} + + @Override + protected void drawSpecialInfo(RecipeDisplayInfo recipeInfo) { + String upgradeName = recipeInfo.recipe.getMetadataOrDefault(FOG_UPGRADE_NAME_SHORT, ""); + recipeInfo.drawText(" ", 83, -76); + recipeInfo.drawText( + "" + EnumChatFormatting.BLUE + EnumChatFormatting.UNDERLINE + EnumChatFormatting.BOLD + upgradeName, + 112, + 0); + } + +} diff --git a/src/main/java/tectech/recipe/TecTechRecipeMaps.java b/src/main/java/tectech/recipe/TecTechRecipeMaps.java index d4908df5b7f..de98a2c2749 100644 --- a/src/main/java/tectech/recipe/TecTechRecipeMaps.java +++ b/src/main/java/tectech/recipe/TecTechRecipeMaps.java @@ -85,4 +85,16 @@ public static void init() {} .logoPos(151, 63) .build(); + public static final RecipeMap godforgeFakeUpgradeCostRecipes = RecipeMapBuilder + .of("gt.recipe.upgrade_costs") + .maxIO(12, 2, 0, 2) + .addSpecialTexture(83, 38, 30, 13, GTUITextures.PICTURE_ARROW_GRAY) + .dontUseProgressBar() + .neiTransferRect(83, 38, 30, 13) + .frontend(GodforgeUpgradeCostFrontend::new) + .neiHandlerInfo( + builder -> builder.setDisplayStack(CustomItemList.Machine_Multi_ForgeOfGods.get(1)) + .setHeight(100)) + .build(); + } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 2b7e86374b2..782a82d3a5f 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -104,6 +104,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEHatchInput; import gregtech.api.metatileentity.implementations.MTEHatchInputBus; +import gregtech.api.recipe.RecipeMap; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.HatchElementBuilder; @@ -113,6 +114,7 @@ import gregtech.common.tileentities.machines.MTEHatchOutputBusME; import tectech.TecTech; import tectech.loader.ConfigHandler; +import tectech.recipe.TecTechRecipeMaps; import tectech.thing.block.BlockGodforgeGlass; import tectech.thing.block.TileEntityForgeOfGods; import tectech.thing.gui.TecTechUITextures; @@ -3117,6 +3119,11 @@ public void addTotalRecipesProcessed(long amount) { @Override protected void setHatchRecipeMap(MTEHatchInput hatch) {} + @Override + public RecipeMap getRecipeMap() { + return TecTechRecipeMaps.godforgeFakeUpgradeCostRecipes; + } + @Override public void setItemNBT(NBTTagCompound NBT) { saveGeneralNBT(NBT, false); diff --git a/src/main/resources/assets/gregtech/textures/gui/picture/arrow_gray.png b/src/main/resources/assets/gregtech/textures/gui/picture/arrow_gray.png new file mode 100644 index 0000000000000000000000000000000000000000..392add3320603f231858925b2b3ab82a1aa26729 GIT binary patch literal 195 zcmeAS@N?(olHy`uVBq!ia0vp^av(MbGmz|Dqqh`DF%}28J29*~C-V}>VM%xNb!1@J z*w6hZkrl{i3-AeX?e6XdGIi_T<^n0Ek|4j}{|ryJ8+ZYEoCO|{#S9F5hd`K7RKu$Q zC}`p7;uxY4oSblkZ^0vrrHVp3mL4>!SmGG;V@YFC0++gif-i%>7U@&2>;jRW{_-w7 gprXdmZEVEEaAPZ@V2t};VW1fdp00i_>zopr0QspkN&o-= literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index 44b853d2673..c5b2227f820 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -1339,6 +1339,7 @@ gt.recipe.researchStation=Research Station gt.recipe.fog_plasma=Heliothermal Plasma Fabricator gt.recipe.fog_exotic=Heliofusion Exoticizer gt.recipe.fog_molten=Helioflux Melting Core +gt.recipe.upgrade_costs=Godforge Upgrades # NEI From bcf92b3bb438fffbf716585931c738adb2a61017 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Sat, 23 Nov 2024 11:57:09 -0600 Subject: [PATCH 50/52] improve upgrade nei page text centering --- .../java/tectech/recipe/GodforgeUpgradeCostFrontend.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java b/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java index 439473fc189..aa818561717 100644 --- a/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java +++ b/src/main/java/tectech/recipe/GodforgeUpgradeCostFrontend.java @@ -6,6 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault; +import net.minecraft.client.Minecraft; import net.minecraft.util.EnumChatFormatting; import com.gtnewhorizons.modularui.api.math.Pos2d; @@ -61,11 +62,13 @@ protected void drawEnergyInfo(RecipeDisplayInfo recipeInfo) {} @Override protected void drawSpecialInfo(RecipeDisplayInfo recipeInfo) { String upgradeName = recipeInfo.recipe.getMetadataOrDefault(FOG_UPGRADE_NAME_SHORT, ""); + int width = Minecraft.getMinecraft().fontRenderer.getStringWidth(upgradeName); + if (width % 2 == 1) width -= 1; + int xOffset = 18 - width / 2 - 1; recipeInfo.drawText(" ", 83, -76); recipeInfo.drawText( - "" + EnumChatFormatting.BLUE + EnumChatFormatting.UNDERLINE + EnumChatFormatting.BOLD + upgradeName, - 112, + EnumChatFormatting.BLUE.toString() + EnumChatFormatting.UNDERLINE + EnumChatFormatting.BOLD + upgradeName, + 110 + xOffset, 0); } - } From af909f8da64b175b02ec191d624ecbbfdc2d7cf4 Mon Sep 17 00:00:00 2001 From: Maya <10861407+serenibyss@users.noreply.github.com> Date: Tue, 26 Nov 2024 17:01:04 -0600 Subject: [PATCH 51/52] allow manual insertion slots to open NEI on click --- .../multi/godforge/util/ForgeOfGodsUI.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java index 5bdcf6ed2ef..d6f9be66333 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/util/ForgeOfGodsUI.java @@ -41,6 +41,8 @@ import com.gtnewhorizons.modularui.common.widget.TextWidget; import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; import gregtech.api.enums.VoidingMode; import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.modularui.IControllerWithOptionalFeatures; @@ -738,7 +740,18 @@ public static Widget createExtraCostWidget(final ItemStack costStack, Supplier { + if (widget.isClient()) { + if (clickData.mouseButton == 0) { + GuiCraftingRecipe.openRecipeGui("item", handlerStack.copy()); + } else if (clickData.mouseButton == 1) { + GuiUsageRecipe.openRecipeGui("item", handlerStack.copy()); + } + } + }) + .setSize(16, 16) + .setPos(1, 1)); // Progress text widget.addChild(new DynamicTextWidget(() -> { From 5bc3d23bb53c7fed9f4b32fc487460e242004569 Mon Sep 17 00:00:00 2001 From: GDCloud Date: Wed, 27 Nov 2024 02:35:37 +0100 Subject: [PATCH 52/52] remove breakdown tooltip (put on ice for now) --- .../multi/godforge/MTEForgeOfGods.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 782a82d3a5f..a5f833d830a 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -2639,16 +2639,9 @@ protected ModularWindow createStatisticsWindow(final EntityPlayer player) { } builder.widget( - new MultiChildWidget() - .addChild( - new ButtonWidget() - .setOnClick( - (clickData, widget) -> { - if (clickData.mouseButton == 0) {} else if (clickData.mouseButton == 1) {} - }) - .setSize(53, 30) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.clickstat")) - .setTooltipShowUpDelay(TOOLTIP_DELAY)) + new MultiChildWidget().addChild( + new ButtonWidget().setOnClick((clickData, widget) -> {}) + .setSize(53, 30)) .addChild( new DynamicTextWidget(() -> new Text(relevantInfo)).setScale(1f) .setDefaultColor(EnumChatFormatting.GREEN)