diff options
44 files changed, 2411 insertions, 844 deletions
diff --git a/src/main/java/tectech/loader/recipe/Godforge.java b/src/main/java/tectech/loader/recipe/Godforge.java index 30e3a37f2c..981f6b139a 100644 --- a/src/main/java/tectech/loader/recipe/Godforge.java +++ b/src/main/java/tectech/loader/recipe/Godforge.java @@ -758,13 +758,13 @@ public class Godforge implements Runnable { 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) }); - godforgeUpgradeMats.put(5, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); - godforgeUpgradeMats.put(7, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); - godforgeUpgradeMats.put(11, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); - godforgeUpgradeMats.put(26, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); - godforgeUpgradeMats.put(29, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); - godforgeUpgradeMats.put(30, new ItemStack[] { new ItemStack(Blocks.cobblestone) }); + 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) }); } public static void initMoltenModuleRecipes() { diff --git a/src/main/java/tectech/loader/thing/MachineLoader.java b/src/main/java/tectech/loader/thing/MachineLoader.java index 36b8b03c12..bf8f2e740a 100644 --- a/src/main/java/tectech/loader/thing/MachineLoader.java +++ b/src/main/java/tectech/loader/thing/MachineLoader.java @@ -641,16 +641,16 @@ import tectech.thing.metaTileEntity.multi.MTEActiveTransformer; import tectech.thing.metaTileEntity.multi.MTEDataBank; import tectech.thing.metaTileEntity.multi.MTEEnergyInfuser; import tectech.thing.metaTileEntity.multi.MTEEyeOfHarmony; -import tectech.thing.metaTileEntity.multi.MTEForgeOfGods; import tectech.thing.metaTileEntity.multi.MTEMicrowave; import tectech.thing.metaTileEntity.multi.MTENetworkSwitch; import tectech.thing.metaTileEntity.multi.MTEQuantumComputer; import tectech.thing.metaTileEntity.multi.MTEResearchStation; import tectech.thing.metaTileEntity.multi.MTETeslaTower; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEExoticModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEMoltenModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEPlasmaModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTESmeltingModule; +import tectech.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; import tectech.thing.metaTileEntity.pipe.MTEPipeBlockData; import tectech.thing.metaTileEntity.pipe.MTEPipeBlockEnergy; import tectech.thing.metaTileEntity.pipe.MTEPipeData; diff --git a/src/main/java/tectech/loader/thing/ThingsLoader.java b/src/main/java/tectech/loader/thing/ThingsLoader.java index 7844a6865e..219bed8852 100644 --- a/src/main/java/tectech/loader/thing/ThingsLoader.java +++ b/src/main/java/tectech/loader/thing/ThingsLoader.java @@ -17,6 +17,7 @@ import tectech.thing.casing.SpacetimeCompressionFieldCasing; import tectech.thing.casing.StabilisationFieldCasing; import tectech.thing.casing.TTCasingsContainer; import tectech.thing.casing.TimeAccelerationFieldCasing; +import tectech.thing.item.FakeItemQGP; import tectech.thing.item.ItemAstralArrayFabricator; import tectech.thing.item.ItemEnderFluidLinkCover; import tectech.thing.item.ItemEuMeterGT; @@ -84,6 +85,7 @@ public class ThingsLoader implements Runnable { ItemTeslaCoilComponent.run(); ItemAstralArrayFabricator.run(); + FakeItemQGP.run(); TecTech.LOGGER.info("Crafting Components registered"); TecTech.LOGGER.info("Debug Items registered"); diff --git a/src/main/java/tectech/thing/CustomItemList.java b/src/main/java/tectech/thing/CustomItemList.java index 2c4b4c895b..5788b82259 100644 --- a/src/main/java/tectech/thing/CustomItemList.java +++ b/src/main/java/tectech/thing/CustomItemList.java @@ -461,6 +461,7 @@ public enum CustomItemList implements IItemContainer { Godforge_GravitonFlowModulatorTier2, Godforge_GravitonFlowModulatorTier3, Godforge_HarmonicPhononTransmissionConduit, + Godforge_FakeItemQGP, astralArrayFabricator; diff --git a/src/main/java/tectech/thing/block/RenderForgeOfGods.java b/src/main/java/tectech/thing/block/RenderForgeOfGods.java index 498db3b9ed..9091434490 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.shader.ShaderProgram; import com.gtnewhorizon.gtnhlib.client.renderer.vbo.VertexBuffer; import tectech.Reference; -import tectech.thing.metaTileEntity.multi.ForgeOfGodsRingsStructureString; -import tectech.thing.metaTileEntity.multi.ForgeOfGodsStructureString; +import tectech.thing.metaTileEntity.multi.godforge.ForgeOfGodsRingsStructureString; +import tectech.thing.metaTileEntity.multi.godforge.ForgeOfGodsStructureString; import tectech.util.StructureVBO; import tectech.util.TextureUpdateRequester; @@ -429,9 +429,7 @@ public class RenderForgeOfGods extends TileEntitySpecialRenderer { long millis = System.currentTimeMillis() % (1000 * 36000); float timer = millis / (50f); // to ticks - if (forgeTile.getRainbowMode()) { - forgeTile.incrementRainbowColors(); - } + forgeTile.incrementColors(); RenderEntireStar(forgeTile, x, y, z, timer); RenderRings(forgeTile, x, y, z, timer); diff --git a/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java index 49ab89de2b..a8a8992a63 100644 --- a/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java +++ b/src/main/java/tectech/thing/block/TileEntityForgeOfGods.java @@ -1,5 +1,10 @@ package tectech.thing.block; +import static tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor.DEFAULT_BLUE; +import static tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor.DEFAULT_GAMMA; +import static tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor.DEFAULT_GREEN; +import static tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor.DEFAULT_RED; + import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; @@ -9,33 +14,41 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; import com.gtnewhorizon.structurelib.alignment.enumerable.Rotation; +import com.gtnewhorizons.modularui.api.math.Color; + +import tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor; +import tectech.thing.metaTileEntity.multi.godforge.color.StarColorSetting; public class TileEntityForgeOfGods extends TileEntity { private float radius = 32; private float rotationSpeed = 10; private int ringCount = 1; - private float colorR = .7f, colorG = .8f, colorB = 1f, gamma = 3f; private float rotAngle = 0, rotAxisX = 1, rotAxisY = 0, rotAxisZ = 0; - private int rainbowR = 255, rainbowG = 0, rainbowB = 0; - private int rainbowState = 0; - private boolean rainbowMode = false; - private int rainbowCycleSpeed = 1; + + private ForgeOfGodsStarColor starColor = ForgeOfGodsStarColor.DEFAULT; + + // current color data + private int currentColor = Color.rgb(DEFAULT_RED, DEFAULT_GREEN, DEFAULT_BLUE); + private float gamma = DEFAULT_GAMMA; + + // interpolation color data + private int cycleStep; + private int interpIndex; + private int interpA; + private int interpB; + private float interpGammaA; + private float interpGammaB; private static final String NBT_TAG = "FOG:"; private static final String ROTATION_SPEED_NBT_TAG = NBT_TAG + "ROTATION"; private static final String SIZE_NBT_TAG = NBT_TAG + "RADIUS"; private static final String RINGS_NBT_TAG = NBT_TAG + "RINGS"; - private static final String COLOR_RED_NBT_TAG = NBT_TAG + "COLOR_RED"; - private static final String COLOR_GREEN_NBT_TAG = NBT_TAG + "COLOR_GREEN"; - private static final String COLOR_BLUE_NBT_TAG = NBT_TAG + "COLOR_BLUE"; - private static final String COLOR_GAMMA_NBT_TAG = NBT_TAG + "COLOR_GAMMA"; private static final String ROT_ANGLE_NBT_TAG = NBT_TAG + "ROT_ANGLE"; private static final String ROT_AXIS_X_NBT_TAG = NBT_TAG + "ROT_AXIS_X"; private static final String ROT_AXIS_Y_NBT_TAG = NBT_TAG + "ROT_AXIS_Y"; private static final String ROT_AXIS_Z_NBT_TAG = NBT_TAG + "ROT_AXIS_Z"; - private static final String RAINBOW_MODE_NBT_TAG = NBT_TAG + "RAINBOW_MODE"; - private static final String RAINBOW_MODE_CYCLE_SPEED_NBT_TAG = NBT_TAG + "RAINBOW_MODE_CYCLE_SPEED"; + private static final String STAR_COLOR_TAG = NBT_TAG + "STAR_COLOR"; public static final float BACK_PLATE_DISTANCE = -121.5f, BACK_PLATE_RADIUS = 13f; @@ -66,39 +79,39 @@ public class TileEntityForgeOfGods extends TileEntity { } public float getColorR() { - return rainbowMode ? rainbowR / 255f : colorR; + return Color.getRedF(currentColor); } public float getColorG() { - return rainbowMode ? rainbowG / 255f : colorG; + return Color.getGreenF(currentColor); } public float getColorB() { - return rainbowMode ? rainbowB / 255f : colorB; + return Color.getBlueF(currentColor); } public float getGamma() { return gamma; } - public void setColor(float r, float g, float b) { - setColor(r, g, b, 1); - } - - public void setColor(float r, float g, float b, float gamma) { - colorR = r; - colorG = g; - colorB = b; - this.gamma = gamma; - } - - public void setRainbowMode(boolean state, int cycleSpeed) { - this.rainbowMode = state; - this.rainbowCycleSpeed = cycleSpeed; - } + public void setColor(ForgeOfGodsStarColor color) { + this.starColor = color; + if (this.starColor == null) { + this.starColor = ForgeOfGodsStarColor.DEFAULT; + } - public boolean getRainbowMode() { - return rainbowMode; + StarColorSetting colorSetting = starColor.getColor(0); + currentColor = Color.rgb(colorSetting.getColorR(), colorSetting.getColorG(), colorSetting.getColorB()); + gamma = colorSetting.getGamma(); + + if (starColor.numColors() > 1) { + cycleStep = 0; + interpA = currentColor; + interpGammaA = gamma; + colorSetting = starColor.getColor(1); + interpB = Color.rgb(colorSetting.getColorR(), colorSetting.getColorG(), colorSetting.getColorB()); + interpGammaB = colorSetting.getGamma(); + } } public int getRingCount() { @@ -172,49 +185,46 @@ public class TileEntityForgeOfGods extends TileEntity { return y0 + ((x - x0) * (y1 - y0)) / (x1 - x0); } - public void incrementRainbowColors() { - if (rainbowState == 0) { - rainbowG += rainbowCycleSpeed; - if (rainbowG >= 255) { - rainbowG = 255; - rainbowState = 1; + public void incrementColors() { + if (starColor.numColors() > 1) { + cycleStep += starColor.getCycleSpeed(); + + if (cycleStep < 255) { + // interpolate like normal between these two colors + interpolateColors(); + } else if (cycleStep == 255) { + // interpolate like normal, but then update interp values to the next set and reset cycleStep + cycleStarColors(); + currentColor = interpA; + gamma = interpGammaA; + cycleStep = 0; + } else { + // update interp values to the next set, reset cycleStep then interpolate + cycleStep = -255; + cycleStarColors(); + interpolateColors(); } } - if (rainbowState == 1) { - rainbowR -= rainbowCycleSpeed; - if (rainbowR <= 0) { - rainbowR = 0; - rainbowState = 2; - } - } - if (rainbowState == 2) { - rainbowB += rainbowCycleSpeed; - if (rainbowB >= 255) { - rainbowB = 255; - rainbowState = 3; - } - } - if (rainbowState == 3) { - rainbowG -= rainbowCycleSpeed; - if (rainbowG <= 0) { - rainbowG = 0; - rainbowState = 4; - } - } - if (rainbowState == 4) { - rainbowR += rainbowCycleSpeed; - if (rainbowR >= 255) { - rainbowR = 255; - rainbowState = 5; - } - } - if (rainbowState == 5) { - rainbowB -= rainbowCycleSpeed; - if (rainbowB <= 0) { - rainbowB = 0; - rainbowState = 0; - } + } + + private void interpolateColors() { + float position = cycleStep / 255.0f; + currentColor = Color.interpolate(interpA, interpB, position); + gamma = interpGammaA + (interpGammaB - interpGammaA) * position; + } + + private void cycleStarColors() { + interpA = interpB; + interpGammaA = interpGammaB; + + interpIndex++; + if (interpIndex >= starColor.numColors()) { + interpIndex = 0; } + StarColorSetting nextColor = starColor.getColor(interpIndex); + + interpB = Color.rgb(nextColor.getColorR(), nextColor.getColorG(), nextColor.getColorB()); + interpGammaB = nextColor.getGamma(); } @Override @@ -223,16 +233,11 @@ public class TileEntityForgeOfGods extends TileEntity { compound.setFloat(ROTATION_SPEED_NBT_TAG, rotationSpeed); compound.setFloat(SIZE_NBT_TAG, radius); compound.setInteger(RINGS_NBT_TAG, ringCount); - compound.setFloat(COLOR_RED_NBT_TAG, colorR); - compound.setFloat(COLOR_GREEN_NBT_TAG, colorG); - compound.setFloat(COLOR_BLUE_NBT_TAG, colorB); - compound.setFloat(COLOR_GAMMA_NBT_TAG, gamma); compound.setFloat(ROT_ANGLE_NBT_TAG, rotAngle); compound.setFloat(ROT_AXIS_X_NBT_TAG, rotAxisX); compound.setFloat(ROT_AXIS_Y_NBT_TAG, rotAxisY); compound.setFloat(ROT_AXIS_Z_NBT_TAG, rotAxisZ); - compound.setBoolean(RAINBOW_MODE_NBT_TAG, rainbowMode); - compound.setInteger(RAINBOW_MODE_CYCLE_SPEED_NBT_TAG, rainbowCycleSpeed); + compound.setTag(STAR_COLOR_TAG, starColor.serializeToNBT()); } @Override @@ -244,16 +249,14 @@ public class TileEntityForgeOfGods extends TileEntity { ringCount = compound.getInteger(RINGS_NBT_TAG); if (ringCount < 1) ringCount = 1; - colorR = compound.getFloat(COLOR_RED_NBT_TAG); - colorG = compound.getFloat(COLOR_GREEN_NBT_TAG); - colorB = compound.getFloat(COLOR_BLUE_NBT_TAG); - gamma = compound.getFloat(COLOR_GAMMA_NBT_TAG); rotAngle = compound.getFloat(ROT_ANGLE_NBT_TAG); rotAxisX = compound.getFloat(ROT_AXIS_X_NBT_TAG); rotAxisY = compound.getFloat(ROT_AXIS_Y_NBT_TAG); rotAxisZ = compound.getFloat(ROT_AXIS_Z_NBT_TAG); - rainbowMode = compound.getBoolean(RAINBOW_MODE_NBT_TAG); - rainbowCycleSpeed = compound.getInteger(RAINBOW_MODE_CYCLE_SPEED_NBT_TAG); + + if (compound.hasKey(STAR_COLOR_TAG)) { + setColor(ForgeOfGodsStarColor.deserialize(compound.getCompoundTag(STAR_COLOR_TAG))); + } } @Override diff --git a/src/main/java/tectech/thing/gui/TecTechUITextures.java b/src/main/java/tectech/thing/gui/TecTechUITextures.java index 298d528e21..89fb7c5b11 100644 --- a/src/main/java/tectech/thing/gui/TecTechUITextures.java +++ b/src/main/java/tectech/thing/gui/TecTechUITextures.java @@ -24,6 +24,8 @@ public class TecTechUITextures { public static final UITexture BACKGROUND_GLOW_GREEN = UITexture.fullImage(MODID, "gui/background/green_glow"); public static final UITexture BACKGROUND_GLOW_RED = UITexture.fullImage(MODID, "gui/background/red_glow"); public static final UITexture BACKGROUND_GLOW_WHITE = UITexture.fullImage(MODID, "gui/background/white_glow"); + public static final UITexture BACKGROUND_GLOW_WHITE_HALF = UITexture + .fullImage(MODID, "gui/background/white_glow_half"); public static final UITexture BACKGROUND_GLOW_RAINBOW = UITexture.fullImage(MODID, "gui/background/rainbow_glow"); public static final UITexture BACKGROUND_SPACE = UITexture.fullImage(MODID, "gui/background/space"); @@ -89,6 +91,38 @@ public class TecTechUITextures { .fullImage(MODID, "gui/overlay_button/rainbow_spiral"); public static final UITexture OVERLAY_BUTTON_RAINBOW_SPIRAL_OFF = UITexture .fullImage(MODID, "gui/overlay_button/rainbow_spiral_off"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_on"); + public static final UITexture OVERLAY_BUTTON_INPUT_SEPARATION_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/input_separation_off"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_on"); + public static final UITexture OVERLAY_BUTTON_BATCH_MODE_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/batch_mode_off"); + public static final UITexture OVERLAY_BUTTON_LOAF_MODE = UITexture + .fullImage(MODID, "gui/overlay_button/loaf_mode_on"); + public static final UITexture OVERLAY_BUTTON_LOAF_MODE_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/loaf_mode_off"); + public static final UITexture OVERLAY_BUTTON_RECIPE_LOCKED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_locked"); + public static final UITexture OVERLAY_BUTTON_RECIPE_UNLOCKED = UITexture + .fullImage(MODID, "gui/overlay_button/recipe_unlocked"); + public static final UITexture OVERLAY_BUTTON_VOIDING_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/voiding_disabled"); + public static final UITexture OVERLAY_BUTTON_VOIDING_ITEMS = UITexture + .fullImage(MODID, "gui/overlay_button/voiding_items"); + public static final UITexture OVERLAY_BUTTON_VOIDING_FLUIDS = UITexture + .fullImage(MODID, "gui/overlay_button/voiding_fluids"); + public static final UITexture OVERLAY_BUTTON_VOIDING_BOTH = UITexture + .fullImage(MODID, "gui/overlay_button/voiding_both"); + public static final UITexture OVERLAY_BUTTON_STRUCTURE_CHECK = UITexture + .fullImage(MODID, "gui/overlay_button/structure_check_on"); + public static final UITexture OVERLAY_BUTTON_STRUCTURE_CHECK_OFF = UITexture + .fullImage(MODID, "gui/overlay_button/structure_check_off"); + public static final UITexture OVERLAY_BUTTON_FURNACE_MODE = UITexture + .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_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"); @@ -145,6 +179,7 @@ public class TecTechUITextures { .collect(Collectors.toList()) .toArray(new UITexture[0]); public static final UITexture PICTURE_HEAT_SINK_SMALL = UITexture.fullImage(MODID, "gui/picture/heat_sink_small"); + public static final UITexture PICTURE_HEAT_SINK_16x8 = UITexture.fullImage(MODID, "gui/picture/heat_sink_16x8"); public static final UITexture PICTURE_PARAMETER_BLANK = UITexture.fullImage(MODID, "gui/picture/parameter_blank"); public static final UITexture[] PICTURE_PARAMETER_BLUE = IntStream.range(0, 20) .mapToObj(i -> UITexture.partly(MODID, "gui/picture/parameter_blue", 158, 4, i * 8, 0, i * 8 + 6, 4)) @@ -190,6 +225,7 @@ public class TecTechUITextures { public static final UITexture PICTURE_UPGRADE_CONNECTOR_RED_OPAQUE = UITexture .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 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/item/FakeItemQGP.java b/src/main/java/tectech/thing/item/FakeItemQGP.java new file mode 100644 index 0000000000..a3d6929e0f --- /dev/null +++ b/src/main/java/tectech/thing/item/FakeItemQGP.java @@ -0,0 +1,34 @@ +package tectech.thing.item; + +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.item.Item; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import tectech.Reference; +import tectech.thing.CustomItemList; + +public class FakeItemQGP extends Item { + + public static FakeItemQGP INSTANCE; + + private FakeItemQGP() { + setHasSubtypes(false); + setUnlocalizedName("tm.fakeItemQGP"); + setTextureName(Reference.MODID + ":fakeItemQGP"); + } + + public static void run() { + INSTANCE = new FakeItemQGP(); + GameRegistry.registerItem(INSTANCE, INSTANCE.getUnlocalizedName()); + CustomItemList.Godforge_FakeItemQGP.set(INSTANCE) + .hidden(); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister iconRegister) { + itemIcon = iconRegister.registerIcon(getIconString()); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsRingsStructureString.java index 56aabb28ec..fcff5c7026 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsRingsStructureString.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsRingsStructureString.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi; +package tectech.thing.metaTileEntity.multi.godforge; import static tectech.util.TTUtility.replaceLetters; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsStructureString.java index 776689eee5..1780be0079 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/ForgeOfGodsStructureString.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsStructureString.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi; +package tectech.thing.metaTileEntity.multi.godforge; import static tectech.util.TTUtility.appendStringArrays; import static tectech.util.TTUtility.replaceLetters; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java new file mode 100644 index 0000000000..a63ba81d7e --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/ForgeOfGodsUI.java @@ -0,0 +1,549 @@ +package tectech.thing.metaTileEntity.multi.godforge; + +import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; +import static net.minecraft.util.StatCollector.translateToLocal; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.DoubleConsumer; +import java.util.function.DoubleSupplier; +import java.util.function.Supplier; + +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; + +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.drawable.Text; +import com.gtnewhorizons.modularui.api.drawable.UITexture; +import com.gtnewhorizons.modularui.api.math.Alignment; +import com.gtnewhorizons.modularui.api.math.Size; +import com.gtnewhorizons.modularui.api.screen.ModularUIContext; +import com.gtnewhorizons.modularui.api.screen.ModularWindow; +import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; +import com.gtnewhorizons.modularui.api.widget.Widget; +import com.gtnewhorizons.modularui.common.widget.ButtonWidget; +import com.gtnewhorizons.modularui.common.widget.DrawableWidget; +import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; +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.TextWidget; +import com.gtnewhorizons.modularui.common.widget.textfield.NumericWidget; + +import gregtech.api.enums.VoidingMode; +import gregtech.api.gui.modularui.GTUITextures; +import gregtech.api.interfaces.modularui.IControllerWithOptionalFeatures; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import tectech.TecTech; +import tectech.thing.gui.TecTechUITextures; +import tectech.thing.metaTileEntity.multi.godforge.color.ForgeOfGodsStarColor; + +/** + * Holds UI element builders and other conveniences shared between the primary Forge of the Gods and its modules. + */ +public class ForgeOfGodsUI { + + // ARGB representations of the 4 colors used in the color selector (red, green, blue, gold) + public static final int RED_ARGB = 0xFFFF5555; + public static final int GREEN_ARGB = 0xFF55FF55; + public static final int BLUE_ARGB = 0xFF0000AA; + public static final int GOLD_ARGB = 0xFFFFAA00; + + public static ButtonWidget createPowerSwitchButton(final IGregTechTileEntity tileEntity) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + if (tileEntity.isAllowedToWork()) { + tileEntity.disableWorking(); + } else { + tileEntity.enableWorking(); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (tileEntity.isAllowedToWork()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); + } + return ret.toArray(new IDrawable[0]); + }) + .setPos(174, 148) + .setSize(16, 16); + button.addTooltip("Power Switch") + .setTooltipShowUpDelay(TOOLTIP_DELAY); + return (ButtonWidget) button; + } + + public static ButtonWidget createInputSeparationButton(final IGregTechTileEntity tileEntity, + final IControllerWithOptionalFeatures mte, IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + mte.setInputSeparation(!mte.isInputSeparationEnabled()); + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (mte.isInputSeparationEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_INPUT_SEPARATION); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_INPUT_SEPARATION_OFF); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.BooleanSyncer(mte::isInputSeparationEnabled, mte::setInputSeparation), + builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.input_separation")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(mte.getInputSeparationButtonPos()) + .setSize(16, 16); + return (ButtonWidget) button; + } + + public static ButtonWidget createBatchModeButton(final IGregTechTileEntity tileEntity, + final IControllerWithOptionalFeatures mte, IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + mte.setBatchMode(!mte.isBatchModeEnabled()); + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (mte.isBatchModeEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATCH_MODE); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_BATCH_MODE_OFF); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(mte::isBatchModeEnabled, mte::setBatchMode), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.batch_mode")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(mte.getBatchModeButtonPos()) + .setSize(16, 16); + return (ButtonWidget) button; + } + + public static ButtonWidget createLockToSingleRecipeButton(final IGregTechTileEntity tileEntity, + final IControllerWithOptionalFeatures mte, IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + mte.setRecipeLocking(!mte.isRecipeLockingEnabled()); + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (mte.isRecipeLockingEnabled()) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_RECIPE_LOCKED); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_RECIPE_UNLOCKED); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(mte::isRecipeLockingEnabled, mte::setRecipeLocking), builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.lock_recipe")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(mte.getRecipeLockingButtonPos()) + .setSize(16, 16); + return (ButtonWidget) button; + } + + public static ButtonWidget createStructureUpdateButton(final IGregTechTileEntity tileEntity, + final IControllerWithOptionalFeatures mte, IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + if (mte.getStructureUpdateTime() <= -20) { + mte.setStructureUpdateTime(1); + } + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + if (mte.getStructureUpdateTime() > -20) { + ret.add(TecTechUITextures.OVERLAY_BUTTON_STRUCTURE_CHECK); + } else { + ret.add(TecTechUITextures.OVERLAY_BUTTON_STRUCTURE_CHECK_OFF); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer(mte::getStructureUpdateTime, mte::setStructureUpdateTime), + builder) + .addTooltip(StatCollector.translateToLocal("GT5U.gui.button.structure_update")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(mte.getStructureUpdateButtonPos()) + .setSize(16, 16); + return (ButtonWidget) button; + } + + public static ButtonWidget createVoidExcessButton(final IGregTechTileEntity tileEntity, + final IControllerWithOptionalFeatures mte, IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(tileEntity, "fx_click"); + Set<VoidingMode> allowed = mte.getAllowedVoidingModes(); + switch (clickData.mouseButton) { + case 0 -> mte.setVoidingMode( + mte.getVoidingMode() + .nextInCollection(allowed)); + case 1 -> mte.setVoidingMode( + mte.getVoidingMode() + .previousInCollection(allowed)); + } + widget.notifyTooltipChange(); + }) + .setPlayClickSound(false) + .setBackground(() -> { + List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + switch (mte.getVoidingMode()) { + case VOID_NONE -> ret.add(TecTechUITextures.OVERLAY_BUTTON_VOIDING_OFF); + case VOID_ITEM -> ret.add(TecTechUITextures.OVERLAY_BUTTON_VOIDING_ITEMS); + case VOID_FLUID -> ret.add(TecTechUITextures.OVERLAY_BUTTON_VOIDING_FLUIDS); + case VOID_ALL -> ret.add(TecTechUITextures.OVERLAY_BUTTON_VOIDING_BOTH); + } + return ret.toArray(new IDrawable[0]); + }) + .attachSyncer( + new FakeSyncWidget.IntegerSyncer( + () -> mte.getVoidingMode() + .ordinal(), + val -> mte.setVoidingMode(VoidingMode.fromOrdinal(val))), + builder) + .dynamicTooltip( + () -> Arrays.asList( + StatCollector.translateToLocal("GT5U.gui.button.voiding_mode"), + StatCollector.translateToLocal( + mte.getVoidingMode() + .getTransKey()))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(mte.getVoidingModeButtonPos()) + .setSize(16, 16); + return (ButtonWidget) button; + } + + public static ModularWindow createGeneralInfoWindow(Supplier<Boolean> inversionGetter, + Consumer<Boolean> inversionSetter) { + final Scrollable scrollable = new Scrollable().setVerticalScroll(); + final int WIDTH = 300; + final int HEIGHT = 300; + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + + builder.setDraggable(true); + scrollable.widget( + new TextWidget(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.introduction")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 13) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.introductioninfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 30) + .setSize(280, 50)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.tableofcontents")) + .setDefaultColor(EnumChatFormatting.AQUA) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 80) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(150)) + .setBackground( + new Text(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 95) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(434)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 110) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1088)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 125) + .setSize(150, 15)) + .widget( + new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1412)) + .setBackground( + new Text( + EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) + .alignment(Alignment.CenterLeft) + .color(0x55ffff)) + .setPos(7, 140) + .setSize(150, 15)) + .widget( + TextWidget.dynamicText(() -> inversionInfoText(inversionGetter.get())) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 155) + .setSize(150, 15)) + .widget(new ButtonWidget().setOnClick((clickData, widget) -> { + if (inversionGetter.get()) { + scrollable.setVerticalScrollOffset(1766); + } + }) + .setPlayClickSound(inversionGetter.get()) + .setPos(7, 155) + .setSize(150, 15) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(inversionGetter, inversionSetter), scrollable)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(127, 160) + .setSize(40, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 177) + .setSize(280, 250)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 440) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.moduleinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 461) + .setSize(280, 620)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1098) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.upgradeinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1115) + .setSize(280, 290)) + .widget( + new TextWidget( + EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) + .setDefaultColor(EnumChatFormatting.DARK_PURPLE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1422) + .setSize(280, 15)) + .widget( + new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.milestoneinfotext")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1439) + .setSize(280, 320)) + .widget( + TextWidget.dynamicText(() -> inversionHeaderText(inversionGetter.get())) + .setDefaultColor(EnumChatFormatting.WHITE) + .setTextAlignment(Alignment.TopCenter) + .setPos(7, 1776) + .setSize(280, 15)) + .widget( + TextWidget.dynamicText(() -> inversionInfoText(inversionGetter.get())) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(7, 1793) + .setSize(280, 160)) + .widget( + new TextWidget("").setPos(7, 1965) + .setSize(10, 10)); + + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_GLOW_WHITE) + .setPos(0, 0) + .setSize(300, 300)) + .widget( + scrollable.setSize(292, 292) + .setPos(4, 4)) + .widget( + ButtonWidget.closeWindowButton(true) + .setPos(284, 4)); + + return builder.build(); + } + + private static Text inversionHeaderText(boolean inversion) { + return inversion + ? new Text( + EnumChatFormatting.BOLD + "§k2" + + EnumChatFormatting.RESET + + EnumChatFormatting.WHITE + + EnumChatFormatting.BOLD + + translateToLocal("gt.blockmachines.multimachine.FOG.inversion") + + EnumChatFormatting.BOLD + + "§k2") + : new Text(""); + } + + private static Text inversionInfoText(boolean inversion) { + return inversion ? new Text(translateToLocal("gt.blockmachines.multimachine.FOG.inversioninfotext")) + : new Text(""); + } + + public static void reopenWindow(Widget widget, int windowId) { + if (!widget.isClient()) { + ModularUIContext ctx = widget.getContext(); + if (ctx.isWindowOpen(windowId)) { + ctx.closeWindow(windowId); + } + ctx.openSyncedWindow(windowId); + } + } + + public enum StarColorRGBM { + + RED(EnumChatFormatting.RED, RED_ARGB, 0, 255, ForgeOfGodsStarColor.DEFAULT_RED), + GREEN(EnumChatFormatting.GREEN, GREEN_ARGB, 0, 255, ForgeOfGodsStarColor.DEFAULT_GREEN), + BLUE(EnumChatFormatting.DARK_BLUE, BLUE_ARGB, 0, 255, ForgeOfGodsStarColor.DEFAULT_BLUE), + GAMMA(EnumChatFormatting.GOLD, GOLD_ARGB, 0, 100, ForgeOfGodsStarColor.DEFAULT_GAMMA); + + private final String title; + private final EnumChatFormatting mcColor; + private final int muiColor; + private final float lowerBound, upperBound; + private final float defaultValue; + + StarColorRGBM(EnumChatFormatting mcColor, int muiColor, float lower, float upper, float defaultVal) { + this.title = "fog.cosmetics.color." + name().toLowerCase(); + this.mcColor = mcColor; + this.muiColor = muiColor; + this.lowerBound = lower; + this.upperBound = upper; + this.defaultValue = defaultVal; + } + + public String tooltip(float value) { + if (this == GAMMA) { + return String.format("%s%s: %.1f", mcColor, translateToLocal(title), value); + } + return String.format("%s%s: %d", mcColor, translateToLocal(title), (int) value); + } + } + + public static Widget createStarColorRGBMGroup(StarColorRGBM color, DoubleConsumer setter, DoubleSupplier getter) { + MultiChildWidget widget = new MultiChildWidget(); + widget.setSize(184, 16); + + // Title + widget.addChild( + new TextWidget(translateToLocal(color.title)).setDefaultColor(color.mcColor) + .setTextAlignment(Alignment.CenterLeft) + .setPos(0, 0) + .setSize(32, 16)); + + // Color slider + widget.addChild(new SliderWidget().setSetter(val -> { + int aux = (int) (val * 10); + setter.accept(aux / 10d); + }) + .setGetter(() -> (float) getter.getAsDouble()) + .setBounds(color.lowerBound, color.upperBound) + .setHandleSize(new Size(4, 0)) + .dynamicTooltip(() -> { + List<String> ret = new ArrayList<>(); + ret.add(color.tooltip((float) getter.getAsDouble())); + return ret; + }) + .setUpdateTooltipEveryTick(true) + .setSize(118, 8) + .setPos(32, 4)); + + // Color manual text box + Widget numberEntry = new NumericWidget().setSetter(setter) + .setGetter(getter) + .setBounds(color.lowerBound, color.upperBound) + .setDefaultValue(color.defaultValue) + .setTextAlignment(Alignment.Center) + .setTextColor(color.muiColor) + .setSize(32, 16) + .setPos(152, 0) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + + if (color == StarColorRGBM.GAMMA) { + numberEntry.addTooltip(translateToLocal("fog.cosmetics.onlydecimals")); + ((NumericWidget) numberEntry).setIntegerOnly(false); + } else { + numberEntry.addTooltip(translateToLocal("fog.cosmetics.onlyintegers")); + } + + return widget.addChild(numberEntry); + } + + public static Widget createStarColorButton(String text, String tooltip, + BiConsumer<Widget.ClickData, Widget> onClick) { + MultiChildWidget widget = new MultiChildWidget(); + widget.setSize(35, 15); + + widget.addChild( + new ButtonWidget().setOnClick(onClick) + .setSize(35, 15) + .setBackground(GTUITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal(tooltip)) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(0, 0)); + + widget.addChild( + TextWidget.localised(text) + .setTextAlignment(Alignment.Center) + .setPos(0, 0) + .setSize(35, 15)); + + return widget; + } + + public static Widget createStarColorButton(Supplier<String> text, Supplier<String> tooltip, + BiConsumer<Widget.ClickData, Widget> onClick) { + MultiChildWidget widget = new MultiChildWidget(); + widget.setSize(35, 15); + + widget.addChild( + new ButtonWidget().setOnClick(onClick) + .setSize(35, 15) + .setBackground(GTUITextures.BUTTON_STANDARD) + .dynamicTooltip(() -> { + List<String> ret = new ArrayList<>(); + ret.add(translateToLocal(tooltip.get())); + return ret; + }) + .setUpdateTooltipEveryTick(true) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(0, 0)); + + widget.addChild( + new DynamicTextWidget(() -> new Text(translateToLocal(text.get()))).setTextAlignment(Alignment.Center) + .setPos(0, 0) + .setSize(35, 15)); + + return widget; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEBaseModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java index eb89e8bf6c..8b432d2ce8 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEBaseModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEBaseModule.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge_modules; +package tectech.thing.metaTileEntity.multi.godforge; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; @@ -54,8 +54,8 @@ import gregtech.api.recipe.RecipeMap; import gregtech.api.recipe.RecipeMaps; import gregtech.api.render.TextureFactory; import gregtech.api.util.GTStructureUtility; +import tectech.TecTech; import tectech.thing.gui.TecTechUITextures; -import tectech.thing.metaTileEntity.multi.MTEForgeOfGods; import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; public class MTEBaseModule extends TTMultiblockBase { @@ -295,66 +295,73 @@ public class MTEBaseModule extends TTMultiblockBase { @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - builder.widget( - new DrawableWidget().setDrawable(GTUITextures.PICTURE_SCREEN_BLACK) - .setPos(4, 4) - .setSize(190, 85)); - final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); - builder.widget( - inventorySlot.setPos(173, 167) - .setBackground(GTUITextures.SLOT_DARK_GRAY)); - final DynamicPositionedColumn screenElements = new DynamicPositionedColumn(); + final SlotWidget inventorySlot = new SlotWidget(inventoryHandler, 1); drawTexts(screenElements, inventorySlot); - builder.widget( - new Scrollable().setVerticalScroll() - .widget(screenElements.setPos(10, 0)) - .setPos(0, 7) - .setSize(190, 79)); buildContext.addSyncedWindow(VOLTAGE_WINDOW_ID, this::createVoltageWindow); + buildContext.addSyncedWindow(GENERAL_INFO_WINDOW_ID, this::createGeneralInfoWindow); builder.widget( - TextWidget.dynamicText(this::connectionStatus) - .setDefaultColor(EnumChatFormatting.BLACK) - .setPos(75, 94) - .setSize(100, 10)); - - builder.widget( - new ButtonWidget().setOnClick( - (data, widget) -> { - if (!widget.isClient()) widget.getContext() - .openSyncedWindow(GENERAL_INFO_WINDOW_ID); - }) - .setSize(18, 18) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.clickhere")) + new DrawableWidget().setSize(18, 18) .setPos(172, 67) + .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.clickhere")) .setTooltipShowUpDelay(TOOLTIP_DELAY)); - buildContext.addSyncedWindow(GENERAL_INFO_WINDOW_ID, this::createGeneralInfoWindow); - - builder.widget(createPowerSwitchButton(builder)) - .widget(createVoidExcessButton(builder)) - .widget(createInputSeparationButton(builder)) - .widget(createBatchModeButton(builder)) - .widget(createLockToSingleRecipeButton(builder)) + builder.widget( + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 85)) + .widget( + inventorySlot.setPos(173, 167) + .setBackground(getGUITextureSet().getItemSlot(), TecTechUITextures.OVERLAY_SLOT_MESH)) + .widget( + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + .setPos(173, 185) + .setSize(18, 6)) + .widget( + new Scrollable().setVerticalScroll() + .widget(screenElements.setPos(10, 0)) + .setPos(0, 7) + .setSize(190, 79)) + .widget( + TextWidget.dynamicText(this::connectionStatus) + .setDefaultColor(EnumChatFormatting.BLACK) + .setPos(75, 94) + .setSize(100, 10)) + .widget( + new ButtonWidget().setOnClick( + (data, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(GENERAL_INFO_WINDOW_ID); + }) + .setSize(18, 18) + .setPos(172, 67) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) + .widget(createPowerSwitchButton(builder)) .widget(createVoltageButton(builder)) .widget(createStructureUpdateButton(builder)); + + if (supportsVoidProtection()) builder.widget(createVoidExcessButton(builder)); + if (supportsInputSeparation()) builder.widget(createInputSeparationButton(builder)); + if (supportsBatchMode()) builder.widget(createBatchModeButton(builder)); + if (supportsSingleRecipeLocking()) builder.widget(createLockToSingleRecipeButton(builder)); } protected Widget createVoltageButton(IWidgetBuilder<?> builder) { Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { if (isVoltageConfigUnlocked) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); if (!widget.isClient()) { widget.getContext() .openSyncedWindow(VOLTAGE_WINDOW_ID); } } }) - .setPlayClickSound(isVoltageConfigUnlocked) + .setPlayClickSound(false) .setBackground(() -> { List<UITexture> ret = new ArrayList<>(); - ret.add(GTUITextures.BUTTON_STANDARD); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); if (isVoltageConfigUnlocked) { ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_PASS_ON); } else { @@ -412,7 +419,37 @@ public class MTEBaseModule extends TTMultiblockBase { } protected ModularWindow createGeneralInfoWindow(final EntityPlayer player) { - return MTEForgeOfGods.createGeneralInfoWindow(() -> isInversionUnlocked, val -> isInversionUnlocked = val); + return ForgeOfGodsUI.createGeneralInfoWindow(() -> isInversionUnlocked, val -> isInversionUnlocked = val); + } + + @Override + public ButtonWidget createPowerSwitchButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createPowerSwitchButton(getBaseMetaTileEntity()); + } + + @Override + public ButtonWidget createInputSeparationButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createInputSeparationButton(getBaseMetaTileEntity(), this, builder); + } + + @Override + public ButtonWidget createBatchModeButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createBatchModeButton(getBaseMetaTileEntity(), this, builder); + } + + @Override + public ButtonWidget createLockToSingleRecipeButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createLockToSingleRecipeButton(getBaseMetaTileEntity(), this, builder); + } + + @Override + public ButtonWidget createStructureUpdateButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createStructureUpdateButton(getBaseMetaTileEntity(), this, builder); + } + + @Override + public ButtonWidget createVoidExcessButton(IWidgetBuilder<?> builder) { + return ForgeOfGodsUI.createVoidExcessButton(getBaseMetaTileEntity(), this, builder); } @Override diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEExoticModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java index dcf4389e2e..d30f9402d9 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEExoticModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEExoticModule.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge_modules; +package tectech.thing.metaTileEntity.multi.godforge; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.util.GTRecipeBuilder.INGOTS; @@ -17,9 +17,7 @@ import static tectech.loader.recipe.Godforge.exoticModulePlasmaItemMap; import java.math.BigInteger; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.stream.Stream; @@ -34,13 +32,14 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; +import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import com.google.common.collect.ImmutableList; import com.gtnewhorizons.modularui.api.ModularUITextures; import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.drawable.UITexture; +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.math.Alignment; @@ -57,21 +56,24 @@ import com.gtnewhorizons.modularui.common.widget.FluidSlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TierEU; import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; import gregtech.api.recipe.RecipeMap; -import gregtech.api.recipe.RecipeMapBackend; -import gregtech.api.recipe.RecipeMapBuilder; import gregtech.api.recipe.check.CheckRecipeResult; import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.recipe.check.SimpleCheckRecipeResult; +import gregtech.api.util.GTOreDictUnificator; import gregtech.api.util.GTRecipe; +import gregtech.api.util.GTStreamUtil; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; +import tectech.TecTech; import tectech.recipe.TecTechRecipeMaps; +import tectech.thing.CustomItemList; import tectech.thing.gui.TecTechUITextures; import tectech.util.GodforgeMath; @@ -87,13 +89,8 @@ public class MTEExoticModule extends MTEBaseModule { private boolean magmatterMode = false; private FluidStack[] randomizedFluidInput = new FluidStack[] {}; private ItemStack[] randomizedItemInput = new ItemStack[] {}; - List<FluidStack> inputPlasmas = new ArrayList<>(); private GTRecipe plasmaRecipe = null; private BigInteger powerForRecipe = BigInteger.ZERO; - private static final RecipeMap<RecipeMapBackend> tempRecipeMap = RecipeMapBuilder.of("godforgeExoticTempRecipeMap") - .maxIO(0, 0, 7, 2) - .disableRegisterNEI() - .build(); private static final int NUMBER_OF_INPUTS = 7; private static final int INPUT_LIST_WINDOW_ID = 11; @@ -118,17 +115,13 @@ public class MTEExoticModule extends MTEBaseModule { @Override protected Stream<GTRecipe> findRecipeMatches(@Nullable RecipeMap<?> map) { if (!recipeInProgress) { - if (magmatterMode) { plasmaRecipe = generateMagmatterRecipe(); } else { plasmaRecipe = generateQuarkGluonRecipe(); } - - tempRecipeMap.add(plasmaRecipe); } - return tempRecipeMap.getAllRecipes() - .parallelStream(); + return GTStreamUtil.ofNullable(plasmaRecipe); } @NotNull @@ -138,8 +131,7 @@ public class MTEExoticModule extends MTEBaseModule { powerForRecipe = BigInteger.valueOf(getProcessingVoltage()) .multiply(BigInteger.valueOf(recipe.mDuration * actualParallel)); if (getUserEU(userUUID).compareTo(powerForRecipe) < 0) { - tempRecipeMap.getBackend() - .clearRecipes(); + plasmaRecipe = null; return CheckRecipeResultRegistry.insufficientStartupPower(powerForRecipe); } @@ -161,10 +153,13 @@ public class MTEExoticModule extends MTEBaseModule { recipeInProgress = true; recipeRegenerated = false; } - if (new HashSet<>(Arrays.asList(inputFluids)).containsAll(inputPlasmas)) { - return CheckRecipeResultRegistry.SUCCESSFUL; + + for (FluidStack stack : recipe.mFluidInputs) { + if (!ArrayUtils.contains(inputFluids, stack)) { + return SimpleCheckRecipeResult.ofFailure("waiting_for_inputs"); + } } - return SimpleCheckRecipeResult.ofFailure("waiting_for_inputs"); + return CheckRecipeResultRegistry.SUCCESSFUL; } @NotNull @@ -181,8 +176,7 @@ public class MTEExoticModule extends MTEBaseModule { addToPowerTally(powerForRecipe); addToRecipeTally(calculatedParallels); setCalculatedEut(0); - tempRecipeMap.getBackend() - .clearRecipes(); + plasmaRecipe = null; recipeInProgress = false; return CheckRecipeResultRegistry.SUCCESSFUL; } @@ -213,8 +207,6 @@ public class MTEExoticModule extends MTEBaseModule { private GTRecipe generateQuarkGluonRecipe() { actualParallel = getMaxParallel(); - tempRecipeMap.getBackend() - .clearRecipes(); numberOfFluids = GodforgeMath.getRandomIntInRange(0, NUMBER_OF_INPUTS); numberOfItems = NUMBER_OF_INPUTS - numberOfFluids; randomizedFluidInput = getRandomFluidInputs(exoticModulePlasmaFluidMap, numberOfFluids); @@ -232,16 +224,14 @@ public class MTEExoticModule extends MTEBaseModule { } } - inputPlasmas = new ArrayList<>(Arrays.asList(convertItemToPlasma(randomizedItemInput, 1))); - inputPlasmas.addAll(Arrays.asList(convertFluidToPlasma(randomizedFluidInput, 1))); - return new GTRecipe( false, null, null, null, null, - inputPlasmas.toArray(new FluidStack[0]), + ArrayUtils + .addAll(convertItemToPlasma(randomizedItemInput, 1), convertFluidToPlasma(randomizedFluidInput, 1)), new FluidStack[] { MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000 * actualParallel) }, 10 * SECONDS, (int) TierEU.RECIPE_MAX, @@ -250,8 +240,6 @@ public class MTEExoticModule extends MTEBaseModule { private GTRecipe generateMagmatterRecipe() { actualParallel = getMaxParallel(); - tempRecipeMap.getBackend() - .clearRecipes(); randomizedItemInput = getRandomItemInputs(exoticModuleMagmatterItemMap, 1); numberOfItems = 1; numberOfFluids = 2; @@ -259,10 +247,6 @@ public class MTEExoticModule extends MTEBaseModule { int spaceAmount = GodforgeMath.getRandomIntInRange(51, 100); randomizedFluidInput = new FluidStack[] { MaterialsUEVplus.Time.getMolten(timeAmount * 1000L), MaterialsUEVplus.Space.getMolten(spaceAmount * 1000L) }; - inputPlasmas = new ArrayList<>( - Arrays.asList(convertItemToPlasma(randomizedItemInput, spaceAmount - timeAmount))); - inputPlasmas.add(MaterialsUEVplus.Time.getMolten(timeAmount)); - inputPlasmas.add(MaterialsUEVplus.Space.getMolten(spaceAmount)); return new GTRecipe( false, @@ -270,7 +254,10 @@ public class MTEExoticModule extends MTEBaseModule { null, null, null, - inputPlasmas.toArray(new FluidStack[0]), + ArrayUtils.addAll( + convertItemToPlasma(randomizedItemInput, spaceAmount - timeAmount), + MaterialsUEVplus.Time.getMolten(timeAmount), + MaterialsUEVplus.Space.getMolten(spaceAmount)), new FluidStack[] { MaterialsUEVplus.MagMatter.getMolten(576 * actualParallel) }, 10 * SECONDS, (int) TierEU.RECIPE_MAX, @@ -394,17 +381,22 @@ public class MTEExoticModule extends MTEBaseModule { // Store damage values/stack sizes of input plasmas NBTTagCompound fluidStackListNBTTag = new NBTTagCompound(); - fluidStackListNBTTag.setLong("numberOfPlasmas", inputPlasmas.size()); - int indexFluids = 0; - for (FluidStack fluidStack : inputPlasmas) { - // Save fluid amount to NBT - fluidStackListNBTTag.setLong(indexFluids + "fluidAmount", fluidStack.amount); + if (plasmaRecipe != null) { + fluidStackListNBTTag.setLong("numberOfPlasmas", plasmaRecipe.mFluidInputs.length); - // Save FluidStack to NBT - NBT.setTag(indexFluids + "fluidStack", fluidStack.writeToNBT(new NBTTagCompound())); + int index = 0; + for (FluidStack stack : plasmaRecipe.mFluidInputs) { + // Save fluid amount to NBT + fluidStackListNBTTag.setLong(index + "fluidAmount", stack.amount); - indexFluids++; + // Save FluidStack to NBT + NBT.setTag(index + "fluidStack", stack.writeToNBT(new NBTTagCompound())); + + index++; + } + } else { + fluidStackListNBTTag.setLong("numberOfPlasmas", 0); } NBT.setTag("inputPlasmas", fluidStackListNBTTag); @@ -421,35 +413,39 @@ public class MTEExoticModule extends MTEBaseModule { // Load damage values/fluid amounts of input plasmas and convert back to fluids NBTTagCompound tempFluidTag = NBT.getCompoundTag("inputPlasmas"); - // Iterate over all stored fluids - for (int indexFluids = 0; indexFluids < tempFluidTag.getLong("numberOfPlasmas"); indexFluids++) { + long numberOfPlasmas = tempFluidTag.getLong("numberOfPlasmas"); + if (numberOfPlasmas > 0) { - // Load fluid amount from NBT - int fluidAmount = tempFluidTag.getInteger(indexFluids + "fluidAmount"); + FluidStack[] stacks = new FluidStack[(int) numberOfPlasmas]; + for (int i = 0; i < numberOfPlasmas; i++) { + // Load fluid amount from NBT + int amount = tempFluidTag.getInteger(i + "fluidAmount"); - // Load FluidStack from NBT - FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(NBT.getCompoundTag(indexFluids + "fluidStack")); + // Load FluidStack from NBT + FluidStack stack = FluidStack.loadFluidStackFromNBT(NBT.getCompoundTag(i + "fluidStack")); - inputPlasmas.add(new FluidStack(fluidStack, fluidAmount)); - } - FluidStack outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000L * actualParallel); + stacks[i] = new FluidStack(stack, amount); + } - if (magmatterMode) { - outputFluid = MaterialsUEVplus.MagMatter.getMolten(576L * actualParallel); - } + FluidStack outputFluid; + if (magmatterMode) { + outputFluid = MaterialsUEVplus.MagMatter.getMolten(576L * actualParallel); + } else { + outputFluid = MaterialsUEVplus.QuarkGluonPlasma.getFluid(1000L * actualParallel); + } - tempRecipeMap.add( - new GTRecipe( + plasmaRecipe = new GTRecipe( false, null, null, null, null, - inputPlasmas.toArray(new FluidStack[0]), + stacks, new FluidStack[] { outputFluid }, 10 * SECONDS, (int) TierEU.RECIPE_MAX, - 0)); + 0); + } super.loadNBTData(NBT); } @@ -469,7 +465,7 @@ public class MTEExoticModule extends MTEBaseModule { .setTooltipShowUpDelay(TOOLTIP_DELAY)); super.addUIWidgets(builder, buildContext); buildContext.addSyncedWindow(INPUT_LIST_WINDOW_ID, this::createInputListWindow); - builder.widget(magmatterSwitch(builder)); + builder.widget(createMagmatterSwitch(builder)); builder.widget(createExpectedInputsButton()); builder.widget( new DrawableWidget().setDrawable(ModularUITextures.ICON_INFO) @@ -496,8 +492,8 @@ public class MTEExoticModule extends MTEBaseModule { IFluidTanksHandler tanksHandler = new FluidTanksHandler(7, 128000); for (int i = 0; i < 7; i++) { - if (i < inputPlasmas.size()) { - FluidStack plasma = inputPlasmas.get(i); + if (plasmaRecipe != null && i < plasmaRecipe.mFluidInputs.length) { + FluidStack plasma = plasmaRecipe.mFluidInputs[i]; tanksHandler.setFluidInTank(i, plasma.getFluid(), plasma.amount); } builder.widget( @@ -530,19 +526,15 @@ public class MTEExoticModule extends MTEBaseModule { plasmaRecipe = generateQuarkGluonRecipe(); } recipeRegenerated = true; - tempRecipeMap.add(plasmaRecipe); for (int i = 0; i < 7; i++) { - if (i < inputPlasmas.size()) { - FluidStack plasma = inputPlasmas.get(i); + if (i < plasmaRecipe.mFluidInputs.length) { + FluidStack plasma = plasmaRecipe.mFluidInputs[i]; tanksHandler.setFluidInTank(i, plasma.getFluid(), plasma.amount); } } ticker = 0; - widget.getContext() - .closeWindow(INPUT_LIST_WINDOW_ID); - widget.getContext() - .openSyncedWindow(INPUT_LIST_WINDOW_ID); + ForgeOfGodsUI.reopenWindow(widget, INPUT_LIST_WINDOW_ID); } }) .setPlayClickSound(true) @@ -571,46 +563,43 @@ public class MTEExoticModule extends MTEBaseModule { .setPos(8, 69); } - protected ButtonWidget magmatterSwitch(IWidgetBuilder<?> builder) { + protected ButtonWidget createMagmatterSwitch(IWidgetBuilder<?> builder) { Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { if (isMagmatterCapable) { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); magmatterMode = !magmatterMode; + widget.notifyTooltipChange(); } }) - .setPlayClickSound(isMagmatterCapable) - .setBackground(() -> { - List<UITexture> ret = new ArrayList<>(); - if (isMagmatterModeOn()) { - ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); - if (isMagmatterCapable) { - ret.add(GTUITextures.OVERLAY_BUTTON_CHECKMARK); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); - } - } else { - ret.add(GTUITextures.BUTTON_STANDARD); - if (isMagmatterCapable) { - ret.add(GTUITextures.OVERLAY_BUTTON_CROSS); - } else { - ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); - } + .setPlayClickSound(false) + .setBackground( + () -> new IDrawable[] { TecTechUITextures.BUTTON_CELESTIAL_32x32, + new ItemDrawable( + isMagmatterCapable && isMagmatterModeOn() + ? GTOreDictUnificator.get(OrePrefixes.dust, MaterialsUEVplus.MagMatter, 1) + : CustomItemList.Godforge_FakeItemQGP.get(1)) + + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isMagmatterModeOn, this::setMagmatterMode), builder) + .dynamicTooltip(() -> { + List<String> ret = new ArrayList<>(); + if (!isMagmatterModeOn()) { + ret.add(translateToLocal("fog.button.magmattermode.tooltip.01")); + } + if (isMagmatterCapable && isMagmatterModeOn()) { + ret.add(translateToLocal("fog.button.magmattermode.tooltip.02")); } if (!isMagmatterCapable) { - ret.add(GTUITextures.OVERLAY_BUTTON_DISABLE); + ret.add(EnumChatFormatting.GRAY + translateToLocal("fog.button.magmattermode.tooltip.03")); } - return ret.toArray(new IDrawable[0]); + return ret; }) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isMagmatterModeOn, this::setMagmatterMode), builder) - .addTooltip(translateToLocal("fog.button.magmattermode.tooltip.01")) .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(174, 91) .setSize(16, 16) + .setPos(174, 91) .attachSyncer( new FakeSyncWidget.BooleanSyncer(() -> isMagmatterCapable, this::setMagmatterCapable), builder); - if (!isMagmatterCapable) { - button.addTooltip(EnumChatFormatting.GRAY + translateToLocal("fog.button.magmattermode.tooltip.02")); - } return (ButtonWidget) button; } @@ -635,6 +624,15 @@ public class MTEExoticModule extends MTEBaseModule { } @Override + public void setMagmatterCapable(boolean isCapable) { + if (!isCapable && isMagmatterCapable) { + // only set when it previously was capable + setMagmatterMode(false); + } + super.setMagmatterCapable(isCapable); + } + + @Override protected boolean filtersFluid() { return false; } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/MTEForgeOfGods.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java index 5824b99bed..c7d52215c9 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/MTEForgeOfGods.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEForgeOfGods.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi; +package tectech.thing.metaTileEntity.multi.godforge; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static gregtech.api.enums.Mods.Avaritia; @@ -27,14 +27,19 @@ import static tectech.util.GodforgeMath.queryMilestoneStats; import static tectech.util.GodforgeMath.setMiscModuleParameters; import static tectech.util.TTUtility.toExponentForm; +import java.awt.Desktop; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.StringSelection; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.function.Consumer; -import java.util.function.Supplier; +import java.util.function.Function; + +import javax.annotation.Nullable; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; @@ -76,6 +81,7 @@ 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; import com.gtnewhorizons.modularui.common.widget.FluidNameHolderWidget; import com.gtnewhorizons.modularui.common.widget.MultiChildWidget; @@ -85,11 +91,14 @@ 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; +import blockrenderer6343.client.world.ClientFakePlayer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import gregtech.api.enums.Materials; import gregtech.api.enums.MaterialsUEVplus; +import gregtech.api.enums.Mods; import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.SoundResource; import gregtech.api.enums.Textures; @@ -113,11 +122,10 @@ import tectech.thing.block.BlockGodforgeGlass; import tectech.thing.block.TileEntityForgeOfGods; import tectech.thing.gui.TecTechUITextures; import tectech.thing.metaTileEntity.multi.base.TTMultiblockBase; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEBaseModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEExoticModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEMoltenModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEPlasmaModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTESmeltingModule; +import tectech.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; public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ISurvivalConstructable { @@ -132,12 +140,6 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private int ringAmount = 1; private int stellarFuelAmount = 0; private int neededStartupFuel = 0; - private int rendererColorRed = 179; - private int rendererColorGreen = 204; - private int rendererColorBlue = 255; - private int rotationSpeed = 5; - private int starSize = 20; - private int rainbowCycleSpeed = 1; private long fuelConsumption = 0; private long totalRecipesProcessed = 0; private long totalFuelConsumed = 0; @@ -150,7 +152,6 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private float invertedRecipeMilestonePercentage = 0; private float invertedFuelMilestonePercentage = 0; private float invertedStructureMilestonePercentage = 0; - private float rendererGamma = 3f; private BigInteger totalPowerConsumed = BigInteger.ZERO; private boolean batteryCharging = false; private boolean inversion = false; @@ -158,11 +159,24 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private FormattingMode formattingMode = FormattingMode.NONE; private boolean isRenderActive = false; private boolean secretUpgrade = false; - private boolean rainbowMode = false; private final ItemStack[] storedUpgradeWindowItems = new ItemStack[16]; public ArrayList<MTEBaseModule> moduleHatches = new ArrayList<>(); protected ItemStackHandler inputSlotHandler = new ItemStackHandler(16); + // 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; + // editing star color + private ForgeOfGodsStarColor newStarColor = starColors.newTemplateColor(); + private int starColorR, starColorG, starColorB; + private float starGamma; + private int editingStarIndex; // editing a full color preset + private int editingColorIndex; // editing a single color in a preset + private ForgeOfGodsStarColor importedStarColor; + private static final int FUEL_CONFIG_WINDOW_ID = 9; private static final int UPGRADE_TREE_WINDOW_ID = 10; private static final int INDIVIDUAL_UPGRADE_WINDOW_ID = 11; @@ -172,7 +186,9 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final int MANUAL_INSERTION_WINDOW_ID = 15; private static final int GENERAL_INFO_WINDOW_ID = 16; private static final int SPECIAL_THANKS_WINDOW_ID = 17; - private static final int STAR_COLOR_CONFIG_WINDOW_ID = 18; + 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 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 }; @@ -197,15 +213,44 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private static final String SCANNER_INFO_BAR = EnumChatFormatting.BLUE.toString() + EnumChatFormatting.STRIKETHROUGH + "--------------------------------------------"; private static final ItemStack STELLAR_FUEL = Avaritia.isModLoaded() ? getModItem(Avaritia.ID, "Resource", 1, 8) - : GTOreDictUnificator.get(OrePrefixes.block, Materials.CosmicNeutronium, 1); + : GTOreDictUnificator.get(OrePrefixes.block, Materials.Neutronium, 1); public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) { // 1000 blocks max per placement. int realBudget = elementBudget >= 1000 ? elementBudget : Math.min(1000, elementBudget * 5); + int built = 0; + + if (Mods.BlockRenderer6343.isModLoaded() && env.getActor() instanceof ClientFakePlayer) { + built = survivialBuildPiece(STRUCTURE_PIECE_MAIN, stackSize, 63, 14, 1, elementBudget, env, false, true); + if (stackSize.stackSize > 1) { + built += survivialBuildPiece( + STRUCTURE_PIECE_SECOND_RING, + stackSize, + 55, + 11, + -67, + realBudget, + env, + false, + true); + } + if (stackSize.stackSize > 2) { + built += survivialBuildPiece( + STRUCTURE_PIECE_THIRD_RING, + stackSize, + 47, + 13, + -76, + realBudget, + env, + false, + true); + } + return built; + } survivialBuildPiece(STRUCTURE_PIECE_SHAFT, stackSize, 63, 14, 1, realBudget, env, false, true); - int built = 0; if (stackSize.stackSize > 0 && ringAmount < 1) { built += survivialBuildPiece( STRUCTURE_PIECE_FIRST_RING, @@ -393,7 +438,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, if (checkPiece(STRUCTURE_PIECE_SECOND_RING, 55, 11, -67)) { ringAmount = 2; destroySecondRing(); - UpdateRenderer(); + updateRenderer(); } if (isRenderActive && ringAmount >= 2 && !checkPiece(STRUCTURE_PIECE_SECOND_RING_AIR, 55, 11, -67)) { destroyRenderer(); @@ -404,7 +449,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } if (ringAmount >= 2) { ringAmount = 1; - UpdateRenderer(); + updateRenderer(); buildSecondRing(); } } @@ -413,7 +458,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, if (checkPiece(STRUCTURE_PIECE_THIRD_RING, 47, 13, -76)) { ringAmount = 3; destroyThirdRing(); - UpdateRenderer(); + updateRenderer(); } if (isRenderActive && ringAmount == 3 && !checkPiece(STRUCTURE_PIECE_THIRD_RING_AIR, 47, 13, -76)) { destroyRenderer(); @@ -421,7 +466,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } else { if (ringAmount == 3) { ringAmount = 2; - UpdateRenderer(); + updateRenderer(); buildThirdRing(); } } @@ -448,14 +493,21 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, if (upgrades[29]) { maxModuleCount += 4; } + + boolean isFinalUpgradeUnlocked = upgrades[30]; + if (!mInputBusses.isEmpty()) { - if (internalBattery == 0) { + if (internalBattery == 0 || isFinalUpgradeUnlocked) { MTEHatchInputBus inputBus = mInputBusses.get(0); ItemStack[] inputBusInventory = inputBus.getRealInventory(); + ItemStack itemToAbsorb = STELLAR_FUEL; + if (isFinalUpgradeUnlocked && internalBattery != 0) { + itemToAbsorb = GTOreDictUnificator.get(OrePrefixes.gem, MaterialsUEVplus.GravitonShard, 1); + } if (inputBusInventory != null) { for (int i = 0; i < inputBusInventory.length; i++) { ItemStack itemStack = inputBusInventory[i]; - if (itemStack != null && itemStack.isItemEqual(STELLAR_FUEL)) { + if (itemStack != null && itemStack.isItemEqual(itemToAbsorb)) { int stacksize = itemStack.stackSize; if (inputBus instanceof MTEHatchInputBusME meBus) { ItemStack realItem = meBus.getRealInventory()[i + 16]; @@ -465,22 +517,30 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, stacksize = realItem.stackSize; } inputBus.decrStackSize(i, stacksize); - stellarFuelAmount += stacksize; + if (internalBattery == 0) { + stellarFuelAmount += stacksize; + } else { + gravitonShardsAvailable += stacksize; + } inputBus.updateSlots(); } } } - neededStartupFuel = calculateStartupFuelConsumption(this); - if (stellarFuelAmount >= neededStartupFuel) { - stellarFuelAmount -= neededStartupFuel; - increaseBattery(neededStartupFuel); - createRenderer(); + if (internalBattery == 0) { + neededStartupFuel = calculateStartupFuelConsumption(this); + if (stellarFuelAmount >= neededStartupFuel) { + stellarFuelAmount -= neededStartupFuel; + increaseBattery(neededStartupFuel); + createRenderer(); + } } - } else { - drainFuel(); } } + if (internalBattery != 0) { + drainFuel(); + } + determineCompositionMilestoneLevel(); checkInversionStatus(); determineMilestoneProgress(); @@ -611,15 +671,14 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, return null; } - private void UpdateRenderer() { + private void updateRenderer() { TileEntityForgeOfGods tile = getRenderer(); if (tile == null) return; tile.setRingCount(ringAmount); tile.setStarRadius(starSize); tile.setRotationSpeed(rotationSpeed); - tile.setColor(rendererColorRed / 255f, rendererColorGreen / 255f, rendererColorBlue / 255f, rendererGamma); - tile.setRainbowMode(rainbowMode, rainbowCycleSpeed); + tile.setColor(starColors.getByName(selectedStarColor)); tile.updateToClient(); } @@ -662,7 +721,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } rendererTileEntity.setRenderRotation(getRotation(), getDirection()); - UpdateRenderer(); + updateRenderer(); isRenderActive = true; } @@ -769,17 +828,6 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { - if (doesBindPlayerInventory()) { - builder.widget( - new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) - .setPos(4, 4) - .setSize(190, 85)); - } else { - builder.widget( - new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE_NO_INVENTORY) - .setPos(4, 4) - .setSize(190, 171)); - } buildContext.addSyncedWindow(UPGRADE_TREE_WINDOW_ID, this::createUpgradeTreeWindow); buildContext.addSyncedWindow(INDIVIDUAL_UPGRADE_WINDOW_ID, this::createIndividualUpgradeWindow); buildContext.addSyncedWindow(FUEL_CONFIG_WINDOW_ID, this::createFuelConfigWindow); @@ -789,27 +837,34 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, buildContext.addSyncedWindow(MANUAL_INSERTION_WINDOW_ID, this::createManualInsertionWindow); buildContext.addSyncedWindow(GENERAL_INFO_WINDOW_ID, this::createGeneralInfoWindow); buildContext.addSyncedWindow(SPECIAL_THANKS_WINDOW_ID, this::createSpecialThanksWindow); - buildContext.addSyncedWindow(STAR_COLOR_CONFIG_WINDOW_ID, this::createStarColorConfigWindow); + 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); + builder.widget( - new ButtonWidget().setOnClick( - (clickData, widget) -> { - if (!widget.isClient()) widget.getContext() - .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); - }) - .setSize(16, 16) - .setBackground(() -> { - List<UITexture> button = new ArrayList<>(); - button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); - button.add(TecTechUITextures.OVERLAY_BUTTON_ARROW_BLUE_UP); - return button.toArray(new IDrawable[0]); - }) - .addTooltip("Path of Celestial Transcendence") - .setPos(174, 167) - .setTooltipShowUpDelay(TOOLTIP_DELAY)) + new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_SCREEN_BLUE) + .setPos(4, 4) + .setSize(190, 85)) + .widget( + new ButtonWidget().setOnClick( + (clickData, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(UPGRADE_TREE_WINDOW_ID); + }) + .setSize(16, 16) + .setBackground(() -> { + List<UITexture> button = new ArrayList<>(); + button.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); + button.add(TecTechUITextures.OVERLAY_BUTTON_ARROW_BLUE_UP); + return button.toArray(new IDrawable[0]); + }) + .addTooltip("Path of Celestial Transcendence") + .setPos(174, 167) + .setTooltipShowUpDelay(TOOLTIP_DELAY)) .widget( - new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_SMALL) + new DrawableWidget().setDrawable(TecTechUITextures.PICTURE_HEAT_SINK_16x8) .setPos(174, 183) - .setSize(16, 6)) + .setSize(16, 8)) .widget(new ButtonWidget().setOnClick((clickData, widget) -> { if (!widget.isClient()) { widget.getContext() @@ -898,7 +953,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, new ButtonWidget().setOnClick( (clickData, widget) -> { if (!widget.isClient()) widget.getContext() - .openSyncedWindow(STAR_COLOR_CONFIG_WINDOW_ID); + .openSyncedWindow(STAR_COSMETICS_WINDOW_ID); }) .setSize(16, 16) .addTooltip(translateToLocal("fog.button.color.tooltip")) @@ -922,30 +977,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, @Override protected ButtonWidget createPowerSwitchButton() { - Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { - TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); - if (getBaseMetaTileEntity().isAllowedToWork()) { - getBaseMetaTileEntity().disableWorking(); - } else { - getBaseMetaTileEntity().enableWorking(); - } - }) - .setPlayClickSound(false) - .setBackground(() -> { - List<UITexture> ret = new ArrayList<>(); - ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); - if (getBaseMetaTileEntity().isAllowedToWork()) { - ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON); - } else { - ret.add(TecTechUITextures.OVERLAY_BUTTON_POWER_SWITCH_DISABLED); - } - return ret.toArray(new IDrawable[0]); - }) - .setPos(174, doesBindPlayerInventory() ? 148 : 172) - .setSize(16, 16); - button.addTooltip("Power Switch") - .setTooltipShowUpDelay(TOOLTIP_DELAY); - return (ButtonWidget) button; + return ForgeOfGodsUI.createPowerSwitchButton(getBaseMetaTileEntity()); } protected ButtonWidget createEjectionSwitch(IWidgetBuilder<?> builder) { @@ -1395,7 +1427,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, .setPos(5, 30) .setSize(140, 30)) .widget( - TextWidget.dynamicText(() -> currentMilestone(currentMilestoneID)) + TextWidget.dynamicText(() -> currentMilestoneLevel(currentMilestoneID)) .setScale(0.7f) .setDefaultColor(EnumChatFormatting.WHITE) .setTextAlignment(Alignment.Center) @@ -1439,7 +1471,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, private Widget createMilestoneButton(int milestoneID, int width, int height, Pos2d pos) { return new ButtonWidget().setOnClick((clickData, widget) -> { currentMilestoneID = milestoneID; - reopenWindow(widget, INDIVIDUAL_MILESTONE_WINDOW_ID); + ForgeOfGodsUI.reopenWindow(widget, INDIVIDUAL_MILESTONE_WINDOW_ID); }) .setSize(width, height) .setBackground(() -> switch (milestoneID) { @@ -2217,6 +2249,10 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, gravitonShardsAvailable += gravitonShardCost; gravitonShardsSpent -= gravitonShardCost; upgrades[currentUpgradeID] = false; + + if (currentUpgradeID == 30) { + gravitonShardEjection = false; + } } } @@ -2296,7 +2332,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, ctx.closeWindow(UPGRADE_TREE_WINDOW_ID); } } else { - reopenWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); + ForgeOfGodsUI.reopenWindow(widget, INDIVIDUAL_UPGRADE_WINDOW_ID); } } else if (clickData.mouseButton == 1) { respecUpgrade(); @@ -2455,9 +2491,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, if (i < uniqueItems) { ItemStack stack = inputs[i]; if (stack != null) { - stack = stack.copy(); - stack.stackSize = 1; - upgradeMatsHandler.setStackInSlot(i, stack); + upgradeMatsHandler.setStackInSlot(i, stack.copy()); } builder.widget( new DrawableWidget().setDrawable(GTUITextures.BUTTON_STANDARD_PRESSED) @@ -2466,6 +2500,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, columnList.get(cleanDiv4) .addChild( new SlotWidget(upgradeMatsHandler, i).setAccess(false, false) + .setRenderStackSize(false) .disableInteraction()); columnList.get(cleanDiv4 + 3) .addChild( @@ -2506,168 +2541,7 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } protected ModularWindow createGeneralInfoWindow(final EntityPlayer player) { - return createGeneralInfoWindow(() -> inversion, val -> inversion = val); - } - - // because modularui1 creates its synced windows following a specific interface spec, so we have to create a - // second method in order to pass a parameter :( - public static ModularWindow createGeneralInfoWindow(Supplier<Boolean> inversionGetter, - Consumer<Boolean> inversionSetter) { - final Scrollable scrollable = new Scrollable().setVerticalScroll(); - final int WIDTH = 300; - final int HEIGHT = 300; - ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); - - builder.setDraggable(true); - scrollable.widget( - new TextWidget(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.introduction")) - .setDefaultColor(EnumChatFormatting.DARK_PURPLE) - .setTextAlignment(Alignment.TopCenter) - .setPos(7, 13) - .setSize(280, 15)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.introductioninfotext")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 30) - .setSize(280, 50)) - .widget( - new TextWidget( - EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.tableofcontents")) - .setDefaultColor(EnumChatFormatting.AQUA) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 80) - .setSize(150, 15)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(150)) - .setBackground( - new Text(EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) - .alignment(Alignment.CenterLeft) - .color(0x55ffff)) - .setPos(7, 95) - .setSize(150, 15)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(434)) - .setBackground( - new Text( - EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) - .alignment(Alignment.CenterLeft) - .color(0x55ffff)) - .setPos(7, 110) - .setSize(150, 15)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1088)) - .setBackground( - new Text( - EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) - .alignment(Alignment.CenterLeft) - .color(0x55ffff)) - .setPos(7, 125) - .setSize(150, 15)) - .widget( - new ButtonWidget().setOnClick((clickData, widget) -> scrollable.setVerticalScrollOffset(1412)) - .setBackground( - new Text( - EnumChatFormatting.BOLD + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) - .alignment(Alignment.CenterLeft) - .color(0x55ffff)) - .setPos(7, 140) - .setSize(150, 15)) - .widget( - TextWidget.dynamicText(() -> inversionInfoText(inversionGetter.get())) - .setDefaultColor(EnumChatFormatting.WHITE) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 155) - .setSize(150, 15)) - .widget(new ButtonWidget().setOnClick((clickData, widget) -> { - if (inversionGetter.get()) { - scrollable.setVerticalScrollOffset(1766); - } - }) - .setPlayClickSound(inversionGetter.get()) - .setPos(7, 155) - .setSize(150, 15) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(inversionGetter, inversionSetter), scrollable)) - .widget( - new TextWidget( - EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.fuel")) - .setDefaultColor(EnumChatFormatting.DARK_PURPLE) - .setTextAlignment(Alignment.TopCenter) - .setPos(127, 160) - .setSize(40, 15)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.fuelinfotext")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 177) - .setSize(280, 250)) - .widget( - new TextWidget( - EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.modules")) - .setDefaultColor(EnumChatFormatting.DARK_PURPLE) - .setTextAlignment(Alignment.TopCenter) - .setPos(7, 440) - .setSize(280, 15)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.moduleinfotext")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 461) - .setSize(280, 620)) - .widget( - new TextWidget( - EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.upgrades")) - .setDefaultColor(EnumChatFormatting.DARK_PURPLE) - .setTextAlignment(Alignment.TopCenter) - .setPos(7, 1098) - .setSize(280, 15)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.upgradeinfotext")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 1115) - .setSize(280, 290)) - .widget( - new TextWidget( - EnumChatFormatting.BOLD + "§N" + translateToLocal("gt.blockmachines.multimachine.FOG.milestones")) - .setDefaultColor(EnumChatFormatting.DARK_PURPLE) - .setTextAlignment(Alignment.TopCenter) - .setPos(7, 1422) - .setSize(280, 15)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.milestoneinfotext")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 1439) - .setSize(280, 320)) - .widget( - TextWidget.dynamicText(() -> inversionHeaderText(inversionGetter.get())) - .setDefaultColor(EnumChatFormatting.WHITE) - .setTextAlignment(Alignment.TopCenter) - .setPos(7, 1776) - .setSize(280, 15)) - .widget( - TextWidget.dynamicText(() -> inversionInfoText(inversionGetter.get())) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(7, 1793) - .setSize(280, 160)) - .widget( - new TextWidget("").setPos(7, 1965) - .setSize(10, 10)); - - builder.widget( - new DrawableWidget().setDrawable(TecTechUITextures.BACKGROUND_GLOW_WHITE) - .setPos(0, 0) - .setSize(300, 300)) - .widget( - scrollable.setSize(292, 292) - .setPos(4, 4)) - .widget( - ButtonWidget.closeWindowButton(true) - .setPos(284, 4)); - - return builder.build(); + return ForgeOfGodsUI.createGeneralInfoWindow(() -> inversion, val -> inversion = val); } protected ModularWindow createSpecialThanksWindow(final EntityPlayer player) { @@ -2786,176 +2660,99 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, return builder.build(); } - protected ModularWindow createStarColorConfigWindow(final EntityPlayer player) { + protected ModularWindow createStarCosmeticsWindow(final EntityPlayer player) { final int WIDTH = 200; final int HEIGHT = 200; ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE); builder.setDraggable(true); + + // 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()); + + // Exit button and header builder.widget( ButtonWidget.closeWindowButton(true) .setPos(184, 4)) .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.cosmetics")) - .setDefaultColor(EnumChatFormatting.GOLD) + new TextWidget(translateToLocal("fog.cosmetics.header")).setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.Center) .setScale(1f) .setPos(0, 5) - .setSize(200, 15)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.color")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 25) - .setSize(60, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.red")) - .setDefaultColor(EnumChatFormatting.RED) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 45) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> rendererColorRed = (int) val) - .setGetter(() -> rendererColorRed) - .setBounds(0, 255) - .setDefaultValue(179) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(40, 45) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> rendererColorRed, val -> rendererColorRed = val), - builder)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.green")) - .setDefaultColor(EnumChatFormatting.GREEN) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 65) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> rendererColorGreen = (int) val) - .setGetter(() -> rendererColorGreen) - .setBounds(0, 255) - .setDefaultValue(204) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(40, 65) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> rendererColorGreen, val -> rendererColorGreen = val), - builder)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.blue")) - .setDefaultColor(EnumChatFormatting.DARK_BLUE) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 85) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> rendererColorBlue = (int) val) - .setGetter(() -> rendererColorBlue) - .setBounds(0, 255) - .setDefaultValue(255) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(40, 85) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> rendererColorBlue, val -> rendererColorBlue = val), - builder)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.gamma")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 105) - .setSize(60, 18)) - .widget( - new NumericWidget().setSetter(val -> rendererGamma = (float) val) - .setGetter(() -> rendererGamma) - .setBounds(0, 100) - .setDefaultValue(3) - .setIntegerOnly(false) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(35, 18) - .setPos(40, 105) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.decimals")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.FloatSyncer(() -> rendererGamma, val -> rendererGamma = val), - builder)) - .widget( - new DrawableWidget().setDrawable( - () -> new Rectangle().setColor(Color.rgb(rendererColorRed, rendererColorGreen, rendererColorBlue))) - .setSize(80, 80) - .setPos(100, 45)) - .widget( - new DrawableWidget().setDrawable(() -> rainbowMode ? TecTechUITextures.PICTURE_RAINBOW_SQUARE : null) - .setSize(80, 80) - .setPos(100, 45)) - .widget(new ButtonWidget().setOnClick((clickData, widget) -> { - if (!widget.isClient()) { - rainbowMode = !rainbowMode; - } - }) - .setPlayClickSound(true) - .setBackground(() -> { - if (rainbowMode) { - return new IDrawable[] { TecTechUITextures.BUTTON_CELESTIAL_32x32, - TecTechUITextures.OVERLAY_BUTTON_RAINBOW_SPIRAL }; - } else { - return new IDrawable[] { TecTechUITextures.BUTTON_CELESTIAL_32x32, - TecTechUITextures.OVERLAY_BUTTON_RAINBOW_SPIRAL_OFF }; - } - }) - .addTooltip(translateToLocal("fog.button.rainbowmode.tooltip")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(100, 130) + .setSize(200, 15)); + + // Color options + // Header + builder.widget( + new TextWidget(EnumChatFormatting.UNDERLINE + translateToLocal("fog.cosmetics.color")) + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setPos(9, 25) + .setSize(60, 10)); + + // Current presets + for (int i = 0; i < 7; i++) { + MultiChildWidget widget = createColorGroup(i); + widget.setPos(8, 45 + i * 20); + builder.widget(widget); + } + + // Option to add a new preset, only shown if there is room available + MultiChildWidget newPreset = new MultiChildWidget(); + Function<Widget, Boolean> newPresetEnabled = $ -> !starColors.isFull(); + newPreset.setSize(18, 80); + newPreset.setPosProvider(($, $$, $$$) -> new Pos2d(8, 45 + starColors.size() * 20)); + newPreset.setEnabled(newPresetEnabled); + + // New preset button + newPreset.addChild(new ButtonWidget().setOnClick((data, widget) -> { + if (!widget.isClient()) { + editingStarIndex = -1; + openCustomStarColorWindowFresh(widget, null); + } + }) + .setPlayClickSound(true) + .setBackground(GTUITextures.BUTTON_STANDARD) + .addTooltip(translateToLocal("fog.cosmetics.starcolor")) + .setSize(16, 16) + .setPos(0, 0) + .setEnabled(newPresetEnabled)); + + // Text overlaid on the above button + newPreset.addChild( + new TextWidget("+").setDefaultColor(EnumChatFormatting.DARK_GRAY) + .setTextAlignment(Alignment.Center) .setSize(16, 16) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(() -> rainbowMode, (val) -> rainbowMode = val), builder)) + .setPos(0, 0) + .setEnabled(newPresetEnabled)); + + // Text for what this button does + newPreset.addChild( + new TextWidget(translateToLocal("fog.cosmetics.customstarcolor")).setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.CenterLeft) + .setSize(60, 18) + .setPos(20, 0) + .setEnabled(newPresetEnabled)); + + builder.widget(newPreset); + + // Miscellaneous options not related to color settings + builder .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.speed")) + new TextWidget(EnumChatFormatting.UNDERLINE + translateToLocal("fog.cosmetics.misc")) .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.CenterLeft) - .setPos(120, 129) - .setSize(60, 18)) + .setPos(120, 25) + .setSize(80, 10)) .widget( - new NumericWidget().setSetter(val -> rainbowCycleSpeed = (int) val) - .setGetter(() -> rainbowCycleSpeed) - .setBounds(0, 100) - .setDefaultValue(1) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setSize(28, 18) - .setPos(152, 129) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> rainbowCycleSpeed, val -> rainbowCycleSpeed = val), - builder)) - .widget( - new TextWidget( - EnumChatFormatting.UNDERLINE + translateToLocal("gt.blockmachines.multimachine.FOG.misc")) - .setDefaultColor(EnumChatFormatting.GOLD) - .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 130) - .setSize(80, 10)) - .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.spin")) + TextWidget.localised("fog.cosmetics.spin") .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 150) + .setPos(120, 45) .setSize(60, 18)) .widget( new NumericWidget().setSetter(val -> rotationSpeed = (int) val) @@ -2965,18 +2762,15 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, .setTextAlignment(Alignment.Center) .setTextColor(Color.WHITE.normal) .setSize(35, 18) - .setPos(40, 150) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) + .setPos(155, 45) + .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer( - new FakeSyncWidget.IntegerSyncer(() -> rotationSpeed, val -> rotationSpeed = val), - builder)) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)) .widget( - new TextWidget(translateToLocal("gt.blockmachines.multimachine.FOG.size")) + TextWidget.localised("fog.cosmetics.size") .setDefaultColor(EnumChatFormatting.GOLD) .setTextAlignment(Alignment.CenterLeft) - .setPos(8, 170) + .setPos(120, 65) .setSize(60, 18)) .widget( new NumericWidget().setSetter(val -> starSize = (int) val) @@ -2986,63 +2780,538 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, .setTextAlignment(Alignment.Center) .setTextColor(Color.WHITE.normal) .setSize(35, 18) - .setPos(40, 170) - .addTooltip(translateToLocal("gt.blockmachines.multimachine.FOG.integers")) + .setPos(155, 65) + .addTooltip(translateToLocal("fog.cosmetics.onlyintegers")) .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) - .attachSyncer(new FakeSyncWidget.IntegerSyncer(() -> starSize, val -> starSize = val), builder)) - .widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + + return builder.build(); + } + + private MultiChildWidget createColorGroup(final int index) { + final int textWidth = 60; // for convenient changing, if we need to make this wider + + MultiChildWidget parent = new MultiChildWidget(); + parent.setSize(18, 20 + textWidth); + Function<Widget, Boolean> enabledCheck = $ -> index < starColors.size(); + + // Button to enable this star color + parent.addChild(new ButtonWidget().setOnClick((data, widget) -> { + if (!widget.isClient()) { + if (index < starColors.size()) { + ForgeOfGodsStarColor color = starColors.getByIndex(index); + if (data.shift && !color.isPresetColor()) { + // if shift is held, open color editor for this preset, if not a default preset + editingStarIndex = index; + openCustomStarColorWindowFresh(widget, color); + } else { + // otherwise select this color + selectedStarColor = color.getName(); + updateRenderer(); + } + } + } + }) + .setPlayClickSound(true) + .setBackground(() -> { + IDrawable bg = GTUITextures.BUTTON_STANDARD; + if (index < starColors.size()) { + ForgeOfGodsStarColor color = starColors.getByIndex(index); + if (color.getName() + .equals(selectedStarColor)) { + bg = GTUITextures.BUTTON_STANDARD_PRESSED; + } + } + return new IDrawable[] { bg }; + }) + .addTooltips( + ImmutableList.of( + translateToLocal("fog.cosmetics.selectcolor.tooltip.1"), + translateToLocal("fog.cosmetics.selectcolor.tooltip.2"))) + .setSize(16, 16) + .setPos(0, 0) + .setEnabled(enabledCheck)); + + // Drawable representation of this star color, overlaid on the above button + parent.addChild(new DrawableWidget().setDrawable(() -> { + if (index < starColors.size()) { + return starColors.getByIndex(index) + .getDrawable(); + } + return IDrawable.EMPTY; + }) + .setPos(1, 1) + .setSize(14, 14) + .setEnabled(enabledCheck)); + + // Name of this star color + parent.addChild(new DynamicTextWidget(() -> { + if (index < starColors.size()) { + ForgeOfGodsStarColor color = starColors.getByIndex(index); + return new Text(color.getName()); + } + return Text.EMPTY; + }).setDefaultColor(ForgeOfGodsUI.GOLD_ARGB) + .setTextAlignment(Alignment.CenterLeft) + .setSize(textWidth, 18) + .setPos(20, 0) + .setEnabled(enabledCheck)); + + return parent; + } + + protected ModularWindow createStarCustomColorWindow(final EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(200, 200); + builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE); + builder.setDraggable(true); + + // Syncers + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> starColorR, val -> starColorR = val)); + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> starColorG, val -> starColorG = val)); + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> starColorB, val -> starColorB = val)); + builder.widget(new FakeSyncWidget.FloatSyncer(() -> starGamma, val -> starGamma = val)); + builder.widget(new FakeSyncWidget.IntegerSyncer(() -> editingColorIndex, val -> editingColorIndex = val)); + + builder.widget( + new FakeSyncWidget<>( + () -> newStarColor, + val -> newStarColor = val, + ForgeOfGodsStarColor::writeToBuffer, + ForgeOfGodsStarColor::readFromBuffer)); + + // Exit button and header + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(184, 4)) + .widget( + TextWidget.localised("fog.cosmetics.starcolor") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setScale(1f) + .setPos(0, 5) + .setSize(200, 15)); + + // *********** + // Color Entry + // *********** + + // RGB + Gamma text fields + Widget redField = ForgeOfGodsUI + .createStarColorRGBMGroup(StarColorRGBM.RED, val -> starColorR = (int) val, () -> starColorR); + builder.widget(redField.setPos(8, 21)); + + Widget greenField = ForgeOfGodsUI + .createStarColorRGBMGroup(StarColorRGBM.GREEN, val -> starColorG = (int) val, () -> starColorG); + builder.widget(greenField.setPos(8, 40)); + + Widget blueField = ForgeOfGodsUI + .createStarColorRGBMGroup(StarColorRGBM.BLUE, val -> starColorB = (int) val, () -> starColorB); + builder.widget(blueField.setPos(8, 59)); + + Widget gammaField = ForgeOfGodsUI + .createStarColorRGBMGroup(StarColorRGBM.GAMMA, val -> starGamma = (float) val, () -> starGamma); + builder.widget(gammaField.setPos(8, 78)); + + // Color preview box + Widget colorPreviewBox = new DrawableWidget() + .setDrawable(() -> new Rectangle().setColor(Color.rgb(starColorR, starColorG, starColorB))) + .setSize(168, 15) + .setPos(16, 99); + builder.widget(colorPreviewBox); + + // Apply color button + Widget colorApplyButton = ForgeOfGodsUI.createStarColorButton(() -> { + if (editingColorIndex >= 0) { + return "fog.cosmetics.applycolor"; + } + return "fog.cosmetics.addcolor"; + }, () -> { + if (editingColorIndex >= 0) { + return "fog.cosmetics.applycolor.tooltip"; + } + return "fog.cosmetics.addcolor.tooltip"; + }, (clickData, widget) -> { + if (!widget.isClient()) { + StarColorSetting color = new StarColorSetting(starColorR, starColorG, starColorB, starGamma); + if (editingColorIndex >= 0 && editingColorIndex < newStarColor.numColors()) { + // insert into the list, as we are editing an existing color + newStarColor.setColor(editingColorIndex, color); + } else { + // add a new color at the end of the list + newStarColor.addColor(color); + } + ForgeOfGodsUI.reopenWindow(widget, STAR_CUSTOM_COLOR_WINDOW_ID); + } + }); + builder.widget(colorApplyButton.setPos(63, 118)); + + // Reset color button + Widget colorResetButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.resetcolor", + "fog.cosmetics.resetcolor.tooltip", + (clickData, widget) -> { if (!widget.isClient()) { - UpdateRenderer(); - reopenWindow(widget, STAR_COLOR_CONFIG_WINDOW_ID); + starColorR = ForgeOfGodsStarColor.DEFAULT_RED; + starColorG = ForgeOfGodsStarColor.DEFAULT_GREEN; + starColorB = ForgeOfGodsStarColor.DEFAULT_BLUE; + starGamma = ForgeOfGodsStarColor.DEFAULT_GAMMA; + } + }); + builder.widget(colorResetButton.setPos(102, 118)); + + // ********** + // Color List + // ********** + + // Color list + for (int i = 0; i < 9; i++) { + final int ii = i; + + MultiChildWidget colorListEntry = new MultiChildWidget(); + colorListEntry.setSize(18, 18); + colorListEntry.setPos(8 + i * 18, 136); + + // List entry button + selector outline + colorListEntry.addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + if (widget.isClient()) return; + + if (clickData.mouseButton == 0) { // left click + // deselect this if its already selected + if (editingColorIndex == ii) { + editingColorIndex = -1; + return; + } + + // otherwise select this if it's valid to select + if (ii < newStarColor.numColors()) { + editingColorIndex = ii; + StarColorSetting color = newStarColor.getColor(ii); + starColorR = color.getColorR(); + starColorG = color.getColorG(); + starColorB = color.getColorB(); + starGamma = color.getGamma(); + } + } else if (clickData.mouseButton == 1) { // right click + // if this is valid, remove it and shift other values down + if (ii < newStarColor.numColors()) { + newStarColor.removeColor(ii); + + if (editingColorIndex == ii) { + // deselect if this index was selected + editingColorIndex = -1; + } else if (editingColorIndex > ii) { + // shift down the editing index if it was after this entry + editingColorIndex -= 1; + } + ForgeOfGodsUI.reopenWindow(widget, STAR_CUSTOM_COLOR_WINDOW_ID); + } } }) - .setSize(35, 15) - .setBackground(GTUITextures.BUTTON_STANDARD) - .addTooltip(translateToLocal("fog.button.updaterenderer.tooltip")) + .setPlayClickSound(false) + .setBackground(() -> { + if (editingColorIndex == ii) { + return new IDrawable[] { TecTechUITextures.UNSELECTED_OPTION, + TecTechUITextures.SLOT_OUTLINE_GREEN }; + } + return new IDrawable[] { TecTechUITextures.UNSELECTED_OPTION }; + }) + .dynamicTooltip(() -> { + List<String> ret = new ArrayList<>(); + ret.add(translateToLocal("fog.cosmetics.colorlist.tooltip.1")); + ret.add(translateToLocal("fog.cosmetics.colorlist.tooltip.2")); + + if (ii < newStarColor.numColors()) { + ret.add(""); + StarColorSetting color = newStarColor.getColor(ii); + ret.add(StarColorRGBM.RED.tooltip(color.getColorR())); + ret.add(StarColorRGBM.GREEN.tooltip(color.getColorG())); + ret.add(StarColorRGBM.BLUE.tooltip(color.getColorB())); + ret.add(StarColorRGBM.GAMMA.tooltip(color.getGamma())); + } + return ret; + }) + .setUpdateTooltipEveryTick(true) .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(0, 0)) - .addChild( - TextWidget.localised("gt.blockmachines.multimachine.FOG.apply") - .setTextAlignment(Alignment.Center) - .setPos(0, 0) - .setSize(35, 15)) - .setSize(35, 15) - .setPos(157, 177)) - .widget(new MultiChildWidget().addChild(new ButtonWidget().setOnClick((clickData, widget) -> { + .setSize(18, 18) + .setPos(0, 0)); + + // List entry color + colorListEntry.addChild(new DrawableWidget().setDrawable(() -> { + if (ii < newStarColor.numColors()) { + StarColorSetting color = newStarColor.getColor(ii); + return new Rectangle().setColor(Color.rgb(color.getColorR(), color.getColorG(), color.getColorB())); + } + return IDrawable.EMPTY; + }) + .setSize(16, 16) + .setPos(1, 1)); + + builder.widget(colorListEntry); + } + + // Cycle rate text field + Widget cycleRateField = new NumericWidget().setSetter(val -> newStarColor.setCycleSpeed((int) val)) + .setGetter(() -> newStarColor.getCycleSpeed()) + .setBounds(1, 100) + .setDefaultValue(1) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .addTooltip(translateToLocal("fog.cosmetics.cyclespeed")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .setSize(21, 16) + .setPos(171, 137); + builder.widget(cycleRateField); + + // Name text field + Widget nameEntryField = new TextFieldWidget().setSetter(val -> newStarColor.setName(val)) + .setGetter(() -> newStarColor.getName()) + .setMaxLength(15) + .setTextAlignment(Alignment.CenterLeft) + .setTextColor(ForgeOfGodsUI.GOLD_ARGB) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .addTooltips( + ImmutableList.of( + translateToLocal("fog.cosmetics.starcolorname.tooltip.1"), + translateToLocal("fog.cosmetics.starcolorname.tooltip.2"))) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(101, 158) + .setSize(91, 16); + builder.widget(nameEntryField); + + // Name label + Widget nameLabel = TextWidget.localised("fog.cosmetics.starcolorname") + .setTextAlignment(Alignment.CenterLeft) + .setDefaultColor(EnumChatFormatting.GOLD) + .setPos(8, 158) + .setSize(100, 16); + builder.widget(nameLabel); + + // ************** + // Preset Buttons + // ************** + + // Save preset button + Widget savePresetButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.savecolors", + "fog.cosmetics.savecolors.tooltip", + (clickData, widget) -> { + if (!widget.isClient()) { + if (newStarColor.numColors() == 0) return; + if (editingStarIndex >= 0) { + starColors.insert(newStarColor, editingStarIndex); + selectedStarColor = newStarColor.getName(); + updateRenderer(); + } else { + starColors.store(newStarColor); + } + widget.getWindow() + .closeWindow(); + ForgeOfGodsUI.reopenWindow(widget, STAR_COSMETICS_WINDOW_ID); + } + }); + builder.widget(savePresetButton.setPos(138, 177)); + + // Delete preset button + Widget deletePresetButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.deletecolors", + "fog.cosmetics.deletecolors.tooltip", + (clickData, widget) -> { + if (!widget.isClient()) { + starColors.drop(newStarColor); + if (selectedStarColor.equals(newStarColor.getName())) { + // set to default if the deleted color was selected + selectedStarColor = ForgeOfGodsStarColor.DEFAULT.getName(); + updateRenderer(); + } + widget.getWindow() + .closeWindow(); + ForgeOfGodsUI.reopenWindow(widget, STAR_COSMETICS_WINDOW_ID); + } + }); + builder.widget(deletePresetButton.setPos(101, 177)); + + // Import preset button + Widget importPresetButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.importcolors", + "fog.cosmetics.importcolors.tooltip", + (clickData, widget) -> { if (!widget.isClient()) { - rendererColorRed = 179; - rendererColorGreen = 204; - rendererColorBlue = 255; - rendererGamma = 3f; - rotationSpeed = 5; - starSize = 20; - rainbowMode = false; - rainbowCycleSpeed = 1; + // reset state from before if it exists + importedStarColor = null; + widget.getContext() + .openSyncedWindow(STAR_CUSTOM_COLOR_IMPORT_WINDOW_ID); + } + }); + builder.widget(importPresetButton.setPos(64, 177)); + + // Export preset button + Widget exportPresetButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.exportcolors", + "fog.cosmetics.exportcolors.tooltip", + (clickData, widget) -> { + if (widget.isClient()) { + if (newStarColor.numColors() == 0) return; + if (Desktop.isDesktopSupported()) { + String output = newStarColor.serializeToString(); + Clipboard clipboard = Toolkit.getDefaultToolkit() + .getSystemClipboard(); + clipboard.setContents(new StringSelection(output), null); + } + } + }); + builder.widget(exportPresetButton.setPos(27, 177)); + + return builder.build(); + } + + protected ModularWindow createStarColorImportWindow(final EntityPlayer player) { + ModularWindow.Builder builder = ModularWindow.builder(200, 100); + builder.setBackground(TecTechUITextures.BACKGROUND_GLOW_WHITE_HALF); + builder.setDraggable(true); + + // Syncers + builder.widget( + new FakeSyncWidget<>( + () -> importedStarColor, + val -> importedStarColor = val, + ForgeOfGodsStarColor::writeToBuffer, + ForgeOfGodsStarColor::readFromBuffer)); + + // Exit button and header + builder.widget( + ButtonWidget.closeWindowButton(true) + .setPos(184, 4)) + .widget( + TextWidget.localised("fog.cosmetics.importer.import") + .setDefaultColor(EnumChatFormatting.GOLD) + .setTextAlignment(Alignment.Center) + .setScale(1f) + .setPos(0, 5) + .setSize(200, 15)); + + // Serialized star color input + TextFieldWidget textField = new TextFieldWidget(); + textField.setSynced(false, true) + .setSetter(val -> { + if (!textField.isClient()) { + if (val == null || val.isEmpty()) { + importedStarColor = null; + return; + } + importedStarColor = ForgeOfGodsStarColor.deserialize(val); } }) - .setSize(35, 15) - .setBackground(GTUITextures.BUTTON_STANDARD) - .addTooltip(translateToLocal("fog.button.resetcosmetics.tooltip")) - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(0, 0)) - .addChild( - TextWidget.localised("fog.debug.resetbutton.text") - .setTextAlignment(Alignment.Center) - .setPos(0, 0) - .setSize(35, 15)) - .setSize(35, 15) - .setPos(120, 177)); + .setMaxLength(32767) + .setScrollBar() + .setTextAlignment(Alignment.CenterLeft) + .setTextColor(Color.WHITE.normal) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .setSize(184, 18) + .setPos(8, 20); + builder.widget(textField); + + // Color preview for a valid star color string + for (int i = 0; i < 9; i++) { + int ii = i; + Widget colorEntry = new DrawableWidget().setDrawable(() -> { + if (importedStarColor != null && ii < importedStarColor.numColors()) { + StarColorSetting color = importedStarColor.getColor(ii); + return new Rectangle().setColor(Color.rgb(color.getColorR(), color.getColorG(), color.getColorB())) + .withOffset(1, 1, -2, -2); + } + return IDrawable.EMPTY; + }) + .setBackground(TecTechUITextures.UNSELECTED_OPTION) + .dynamicTooltip(() -> { + if (importedStarColor != null && ii < importedStarColor.numColors()) { + StarColorSetting color = importedStarColor.getColor(ii); + List<String> ret = new ArrayList<>(); + ret.add(StarColorRGBM.RED.tooltip(color.getColorR())); + ret.add(StarColorRGBM.GREEN.tooltip(color.getColorG())); + ret.add(StarColorRGBM.BLUE.tooltip(color.getColorB())); + ret.add(StarColorRGBM.GAMMA.tooltip(color.getGamma())); + return ret; + } + return Collections.emptyList(); + }) + .setSize(18, 18) + .setPos(8 + i * 18, 42); + builder.widget(colorEntry); + } + + // Cycle rate + Widget cycleRateText = new DynamicTextWidget(() -> { + if (importedStarColor != null) { + return new Text(Integer.toString(importedStarColor.getCycleSpeed())); + } + return Text.EMPTY; + }).setTextAlignment(Alignment.Center) + .setDefaultColor(Color.WHITE.normal) + .addTooltip(translateToLocal("fog.cosmetics.cyclespeed")) + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD) + .setSize(21, 16) + .setPos(171, 43); + builder.widget(cycleRateText); + + // Validator string + Widget validatorText = new DynamicTextWidget(() -> { + if (importedStarColor == null) { + return new Text(EnumChatFormatting.RED + translateToLocal("fog.cosmetics.importer.error")); + } + return new Text(EnumChatFormatting.GREEN + translateToLocal("fog.cosmetics.importer.valid")); + }).setTextAlignment(Alignment.Center) + .setPos(0, 62) + .setSize(200, 16); + builder.widget(validatorText); + + // Confirm button + Widget confirmImportButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.importer.apply", + "fog.cosmetics.importer.apply.tooltip", + (clickData, widget) -> { + if (!widget.isClient()) { + // no action if a valid star color isn't provided + if (importedStarColor != null) { + widget.getWindow() + .closeWindow(); + openCustomStarColorWindowFresh(widget, importedStarColor); + } + } + }); + builder.widget(confirmImportButton.setPos(101, 77)); + + // Reset button + Widget resetImportButton = ForgeOfGodsUI.createStarColorButton( + "fog.cosmetics.importer.reset", + "fog.cosmetics.importer.reset.tooltip", + (clickData, widget) -> { + if (!widget.isClient()) { + importedStarColor = null; + } + }); + builder.widget(resetImportButton.setPos(64, 77)); + return builder.build(); } - private void reopenWindow(Widget widget, int windowId) { + // Opens the custom color window while also resetting the editing values. + // Can optionally pass a star color to set as the editing color + private void openCustomStarColorWindowFresh(Widget widget, @Nullable ForgeOfGodsStarColor importedColor) { if (!widget.isClient()) { - ModularUIContext ctx = widget.getContext(); - if (ctx.isWindowOpen(windowId)) { - ctx.closeWindow(windowId); + // Reset star color state + if (importedColor == null) { + importedColor = starColors.newTemplateColor(); } - ctx.openSyncedWindow(windowId); + newStarColor = importedColor; + editingColorIndex = -1; + starColorR = ForgeOfGodsStarColor.DEFAULT_RED; + starColorG = ForgeOfGodsStarColor.DEFAULT_GREEN; + starColorB = ForgeOfGodsStarColor.DEFAULT_BLUE; + starGamma = ForgeOfGodsStarColor.DEFAULT_GAMMA; + + ForgeOfGodsUI.reopenWindow(widget, STAR_CUSTOM_COLOR_WINDOW_ID); } } @@ -3532,11 +3801,12 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, + suffix); } - private Text currentMilestone(int milestoneID) { + private Text currentMilestoneLevel(int milestoneID) { + int milestoneLevel = inversion ? milestoneProgress[milestoneID] : Math.min(milestoneProgress[milestoneID], 7); return new Text( translateToLocal("gt.blockmachines.multimachine.FOG.milestoneprogress") + ": " + EnumChatFormatting.GRAY - + milestoneProgress[milestoneID]); + + milestoneLevel); } private Text milestoneProgressText(int milestoneID) { @@ -3586,24 +3856,6 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, return new Text(progressText + ": " + EnumChatFormatting.GRAY + formattingMode.format(max) + " " + suffix); } - private static Text inversionHeaderText(boolean inversion) { - return inversion - ? new Text( - EnumChatFormatting.BOLD + "§k2" - + EnumChatFormatting.RESET - + EnumChatFormatting.WHITE - + EnumChatFormatting.BOLD - + translateToLocal("gt.blockmachines.multimachine.FOG.inversion") - + EnumChatFormatting.BOLD - + "§k2") - : new Text(""); - } - - private static Text inversionInfoText(boolean inversion) { - return inversion ? new Text(translateToLocal("gt.blockmachines.multimachine.FOG.inversioninfotext")) - : new Text(""); - } - private Text constructionStatusText() { return upgrades[currentUpgradeID] ? new Text(translateToLocal("fog.upgrade.respec")) : new Text(translateToLocal("fog.upgrade.confirm")); @@ -3704,6 +3956,9 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } NBT.setTag("upgradeMaterials", upgradeMaterialBooleanArrayNBTTag); + + starColors.serializeToNBT(NBT); + super.saveNBTData(NBT); } @@ -3721,18 +3976,8 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, NBT.setLong("totalFuelConsumed", totalFuelConsumed); NBT.setInteger("starFuelStored", stellarFuelAmount); NBT.setBoolean("gravitonShardEjection", gravitonShardEjection); - NBT.setBoolean("isRenderActive", isRenderActive); NBT.setInteger("ringAmount", ringAmount); NBT.setBoolean("secretUpgrade", secretUpgrade); - NBT.setInteger("rendererColorRed", rendererColorRed); - NBT.setInteger("rendererColorGreen", rendererColorGreen); - NBT.setInteger("rendererColorBlue", rendererColorBlue); - NBT.setFloat("rendererGamma", rendererGamma); - NBT.setInteger("rotationSpeed", rotationSpeed); - NBT.setInteger("starSize", starSize); - NBT.setBoolean("rainbowMode", rainbowMode); - NBT.setInteger("rainbowCycleSpeed", rainbowCycleSpeed); - NBT.setBoolean("isRenderActive", isRenderActive); // Store booleanArray of all upgrades NBTTagCompound upgradeBooleanArrayNBTTag = new NBTTagCompound(); @@ -3768,6 +4013,15 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } NBT.setTag("upgradeWindowStorage", upgradeWindowStorageNBTTag); + + // Renderer information + NBT.setInteger("rotationSpeed", rotationSpeed); + NBT.setInteger("starSize", starSize); + NBT.setString("selectedStarColor", selectedStarColor); + NBT.setBoolean("isRenderActive", isRenderActive); + + starColors.serializeToNBT(NBT); + super.saveNBTData(NBT); } @@ -3785,18 +4039,8 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, totalFuelConsumed = NBT.getLong("totalFuelConsumed"); stellarFuelAmount = NBT.getInteger("starFuelStored"); gravitonShardEjection = NBT.getBoolean("gravitonShardEjection"); - isRenderActive = NBT.getBoolean("isRenderActive"); ringAmount = NBT.getInteger("ringAmount"); secretUpgrade = NBT.getBoolean("secretUpgrade"); - rendererColorRed = NBT.getInteger("rendererColorRed"); - rendererColorGreen = NBT.getInteger("rendererColorGreen"); - rendererColorBlue = NBT.getInteger("rendererColorBlue"); - rendererGamma = NBT.getFloat("rendererGamma"); - rotationSpeed = NBT.getInteger("rotationSpeed"); - starSize = NBT.getInteger("starSize"); - rainbowMode = NBT.getBoolean("rainbowMode"); - rainbowCycleSpeed = NBT.getInteger("rainbowCycleSpeed"); - isRenderActive = NBT.getBoolean("isRenderActive"); NBTTagCompound tempBooleanTag = NBT.getCompoundTag("upgrades"); @@ -3824,6 +4068,14 @@ public class MTEForgeOfGods extends TTMultiblockBase implements IConstructable, } } + // Renderer information + rotationSpeed = NBT.getInteger("rotationSpeed"); + starSize = NBT.getInteger("starSize"); + selectedStarColor = NBT.getString("selectedStarColor"); + isRenderActive = NBT.getBoolean("isRenderActive"); + + starColors.rebuildFromNBT(NBT); + super.loadNBTData(NBT); } diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEMoltenModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java index 63f8879805..51bfe51ac0 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEMoltenModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEMoltenModule.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge_modules; +package tectech.thing.metaTileEntity.multi.godforge; import static gregtech.api.util.GTUtility.formatNumbers; import static gregtech.common.misc.WirelessNetworkManager.addEUToGlobalEnergyMap; diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEPlasmaModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java index faebecff47..29675ae5ce 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTEPlasmaModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTEPlasmaModule.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge_modules; +package tectech.thing.metaTileEntity.multi.godforge; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.util.GTRecipeConstants.FOG_PLASMA_MULTISTEP; @@ -16,6 +16,7 @@ import java.util.ArrayList; import javax.annotation.Nonnull; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.EnumChatFormatting; import org.jetbrains.annotations.NotNull; @@ -23,9 +24,9 @@ import org.jetbrains.annotations.NotNull; import com.gtnewhorizons.modularui.api.drawable.IDrawable; import com.gtnewhorizons.modularui.api.math.Alignment; import com.gtnewhorizons.modularui.api.math.Color; +import com.gtnewhorizons.modularui.api.math.Size; import com.gtnewhorizons.modularui.api.screen.ModularWindow; import com.gtnewhorizons.modularui.api.screen.UIBuildContext; -import com.gtnewhorizons.modularui.api.widget.IWidgetBuilder; import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; @@ -45,6 +46,7 @@ import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; import tectech.loader.ConfigHandler; import tectech.recipe.TecTechRecipeMaps; +import tectech.thing.gui.TecTechUITextures; public class MTEPlasmaModule extends MTEBaseModule { @@ -52,6 +54,8 @@ public class MTEPlasmaModule extends MTEBaseModule { private int currentParallel = 0; private int inputMaxParallel = 0; + private static final int DEBUG_WINDOW_ID = 11; + public MTEPlasmaModule(int aID, String aName, String aNameRegional) { super(aID, aName, aNameRegional); } @@ -124,64 +128,95 @@ public class MTEPlasmaModule extends MTEBaseModule { @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { super.addUIWidgets(builder, buildContext); + buildContext.addSyncedWindow(DEBUG_WINDOW_ID, this::createDebugWindow); if (ConfigHandler.debug.DEBUG_MODE) { - builder.widget(createTestButton(builder)) - .widget(createTestButton2()) - .widget(createTestButton3()); + builder.widget(createDebugWindowButton()); } } - protected Widget createTestButton(IWidgetBuilder<?> builder) { - return new ButtonWidget() - .setOnClick((clickData, widget) -> isMultiStepPlasmaCapable = !isMultiStepPlasmaCapable) - .setPlayClickSoundResource( - () -> isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation - : SoundResource.GUI_BUTTON_DOWN.resourceLocation) - .setBackground(() -> { - if (isMultiStepPlasmaCapable) { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED, - GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; - } else { - return new IDrawable[] { GTUITextures.BUTTON_STANDARD, - GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; - } + protected ButtonWidget createDebugWindowButton() { + Widget button = new ButtonWidget().setOnClick( + (data, widget) -> { + if (!widget.isClient()) widget.getContext() + .openSyncedWindow(DEBUG_WINDOW_ID); }) - .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isAllowedToWork, val -> { - if (val) enableWorking(); - else disableWorking(); - }), builder) - .addTooltip("multi-step") + .setPlayClickSound(false) + .setBackground(TecTechUITextures.BUTTON_CELESTIAL_32x32, TecTechUITextures.OVERLAY_BUTTON_LOAF_MODE) + .addTooltip("Debug Window") .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setPos(174, 100) + .setPos(174, 91) .setSize(16, 16); + return (ButtonWidget) button; } - protected Widget createTestButton2() { - return new TextFieldWidget().setSetterInt(this::setPlasmaTier) - .setGetterInt(this::getPlasmaTier) - .setNumbers(0, 2) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setPos(3, 18) - .addTooltip("fusion tier") - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setSize(16, 16) - .setPos(174, 80) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); - } + protected ModularWindow createDebugWindow(final EntityPlayer player) { + final int WIDTH = 78; + final int HEIGHT = 60; + final int PARENT_WIDTH = getGUIWidth(); + final int PARENT_HEIGHT = getGUIHeight(); + ModularWindow.Builder builder = ModularWindow.builder(WIDTH, HEIGHT); + builder.setBackground(GTUITextures.BACKGROUND_SINGLEBLOCK_DEFAULT); + builder.setGuiTint(getGUIColorization()); + builder.setDraggable(true); + builder.setPos( + (size, window) -> Alignment.Center.getAlignedPos(size, new Size(PARENT_WIDTH, PARENT_HEIGHT)) + .add( + Alignment.TopRight.getAlignedPos(new Size(PARENT_WIDTH, PARENT_HEIGHT), new Size(WIDTH, HEIGHT)) + .add(WIDTH - 3, 0))); - protected Widget createTestButton3() { - return new TextFieldWidget().setSetterInt(val -> inputMaxParallel = val) - .setGetterInt(() -> inputMaxParallel) - .setNumbers(0, Integer.MAX_VALUE) - .setTextAlignment(Alignment.Center) - .setTextColor(Color.WHITE.normal) - .setPos(3, 18) - .addTooltip("parallel") - .setTooltipShowUpDelay(TOOLTIP_DELAY) - .setSize(70, 16) - .setPos(174, 60) - .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD); + // Debug enable/disable multi-step + builder.widget( + new ButtonWidget().setOnClick((clickData, widget) -> isMultiStepPlasmaCapable = !isMultiStepPlasmaCapable) + .setPlayClickSoundResource( + () -> isAllowedToWork() ? SoundResource.GUI_BUTTON_UP.resourceLocation + : SoundResource.GUI_BUTTON_DOWN.resourceLocation) + .setBackground(() -> { + if (isMultiStepPlasmaCapable) { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD_PRESSED, + GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_ON }; + } else { + return new IDrawable[] { GTUITextures.BUTTON_STANDARD, + GTUITextures.OVERLAY_BUTTON_POWER_SWITCH_OFF }; + } + }) + .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isAllowedToWork, val -> { + if (val) enableWorking(); + else disableWorking(); + }), builder) + .addTooltip("multi-step") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setPos(4, 40) + .setSize(16, 16)); + + // Debug set plasma tier + builder.widget( + new TextFieldWidget().setSetterInt(this::setPlasmaTier) + .setGetterInt(this::getPlasmaTier) + .setNumbers(0, 2) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("fusion tier") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(16, 16) + .setPos(4, 20) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + + // Debug set max parallel + builder.widget( + new TextFieldWidget().setSetterInt(val -> inputMaxParallel = val) + .setGetterInt(() -> inputMaxParallel) + .setNumbers(0, Integer.MAX_VALUE) + .setTextAlignment(Alignment.Center) + .setTextColor(Color.WHITE.normal) + .setPos(3, 18) + .addTooltip("parallel") + .setTooltipShowUpDelay(TOOLTIP_DELAY) + .setSize(70, 16) + .setPos(4, 4) + .setBackground(GTUITextures.BACKGROUND_TEXT_FIELD)); + + return builder.build(); } @Override diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTESmeltingModule.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java index 779280b1fe..ba8e5f2666 100644 --- a/src/main/java/tectech/thing/metaTileEntity/multi/godforge_modules/MTESmeltingModule.java +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/MTESmeltingModule.java @@ -1,4 +1,4 @@ -package tectech.thing.metaTileEntity.multi.godforge_modules; +package tectech.thing.metaTileEntity.multi.godforge; import static gregtech.api.metatileentity.BaseTileEntity.TOOLTIP_DELAY; import static gregtech.api.util.GTUtility.formatNumbers; @@ -14,6 +14,7 @@ import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import javax.annotation.Nonnull; @@ -32,7 +33,6 @@ import com.gtnewhorizons.modularui.api.widget.Widget; import com.gtnewhorizons.modularui.common.widget.ButtonWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; -import gregtech.api.gui.modularui.GTUITextures; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.logic.ProcessingLogic; @@ -43,6 +43,8 @@ import gregtech.api.recipe.check.CheckRecipeResultRegistry; import gregtech.api.util.GTRecipe; import gregtech.api.util.MultiblockTooltipBuilder; import gregtech.api.util.OverclockCalculator; +import tectech.TecTech; +import tectech.thing.gui.TecTechUITextures; public class MTESmeltingModule extends MTEBaseModule { @@ -149,27 +151,31 @@ public class MTESmeltingModule extends MTEBaseModule { @Override public void addUIWidgets(ModularWindow.Builder builder, UIBuildContext buildContext) { super.addUIWidgets(builder, buildContext); - builder.widget(furnaceSwitch(builder)); - + builder.widget(createFurnaceModeButton(builder)); } - protected ButtonWidget furnaceSwitch(IWidgetBuilder<?> builder) { - Widget button = new ButtonWidget().setOnClick((clickData, widget) -> furnaceMode = !furnaceMode) - .setPlayClickSound(true) + protected ButtonWidget createFurnaceModeButton(IWidgetBuilder<?> builder) { + Widget button = new ButtonWidget().setOnClick((clickData, widget) -> { + TecTech.proxy.playSound(getBaseMetaTileEntity(), "fx_click"); + furnaceMode = !furnaceMode; + widget.notifyTooltipChange(); + }) + .setPlayClickSound(false) .setBackground(() -> { List<UITexture> ret = new ArrayList<>(); + ret.add(TecTechUITextures.BUTTON_CELESTIAL_32x32); if (isFurnaceModeOn()) { - ret.add(GTUITextures.BUTTON_STANDARD_PRESSED); - ret.add(GTUITextures.OVERLAY_BUTTON_CHECKMARK); + ret.add(TecTechUITextures.OVERLAY_BUTTON_FURNACE_MODE); } else { - ret.add(GTUITextures.BUTTON_STANDARD); - ret.add(GTUITextures.OVERLAY_BUTTON_CROSS); - + ret.add(TecTechUITextures.OVERLAY_BUTTON_FURNACE_MODE_OFF); } return ret.toArray(new IDrawable[0]); }) .attachSyncer(new FakeSyncWidget.BooleanSyncer(this::isFurnaceModeOn, this::setFurnaceMode), builder) - .addTooltip(translateToLocal("fog.button.furnacemode.tooltip")) + .dynamicTooltip( + () -> Collections.singletonList( + translateToLocal( + furnaceMode ? "fog.button.furnacemode.tooltip.02" : "fog.button.furnacemode.tooltip.01"))) .setTooltipShowUpDelay(TOOLTIP_DELAY) .setPos(174, 91) .setSize(16, 16); 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 new file mode 100644 index 0000000000..9593c1db95 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColor.java @@ -0,0 +1,346 @@ +package tectech.thing.metaTileEntity.multi.godforge.color; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; + +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 tectech.thing.gui.TecTechUITextures; + +@SuppressWarnings("unused") // for the preset color fields +public class ForgeOfGodsStarColor { + + private static final int LATEST_VERSION = 1; + + // Preset colors + private static final Map<String, ForgeOfGodsStarColor> PRESETS = new LinkedHashMap<>(4); + + public static final int DEFAULT_RED = 179; + 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 ForgeOfGodsStarColor DEFAULT = new ForgeOfGodsStarColor("Default") + .addColor(DEFAULT_RED, DEFAULT_GREEN, DEFAULT_BLUE, DEFAULT_GAMMA) + .registerPreset(); + + public static final ForgeOfGodsStarColor RAINBOW = new ForgeOfGodsStarColor("Rainbow").addColor(255, 0, 0, 3.0f) + .addColor(255, 255, 0, 3.0f) + .addColor(0, 255, 0, 3.0f) + .addColor(0, 255, 255, 3.0f) + .addColor(255, 0, 255, 3.0f) + .setCycleSpeed(1) + .setCustomDrawable(TecTechUITextures.PICTURE_RAINBOW_SQUARE) + .registerPreset(); + + public static final ForgeOfGodsStarColor CLOUD_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") + .addColor(91, 206, 250, 3.0f) + .addColor(245, 169, 184, 3.0f) + .addColor(255, 255, 255, 3.0f) + .setCycleSpeed(1) + .registerPreset(); + + public static List<ForgeOfGodsStarColor> getDefaultColors() { + return new ArrayList<>(PRESETS.values()); + } + + // "Metadata" about this star color, not related to star rendering + private String name; + // version currently unused, but can be used to retain compatibility with old serialized star colors + // if the structure of the data changes significantly. + private final int version; + private boolean isPreset; + private IDrawable drawable; + + // Star render settings + private final List<StarColorSetting> settings = new ArrayList<>(); + private int cycleSpeed = 1; + + protected ForgeOfGodsStarColor(String name) { + this(name, LATEST_VERSION); + } + + private ForgeOfGodsStarColor(String name, int version) { + this.name = name; + this.version = version; + } + + private ForgeOfGodsStarColor registerPreset() { + this.isPreset = true; + PRESETS.put(getName(), this); + return this; + } + + public boolean isPresetColor() { + return isPreset; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ForgeOfGodsStarColor setCycleSpeed(int speed) { + this.cycleSpeed = speed; + return this; + } + + public int getCycleSpeed() { + return cycleSpeed; + } + + public ForgeOfGodsStarColor addColor(int r, int g, int b, float gamma) { + settings.add(new StarColorSetting(r, g, b, gamma)); + return this; + } + + public ForgeOfGodsStarColor addColor(StarColorSetting color) { + settings.add(color); + return this; + } + + private ForgeOfGodsStarColor addColors(List<StarColorSetting> colors) { + settings.addAll(colors); + return this; + } + + public int numColors() { + return settings.size(); + } + + public StarColorSetting getColor(int index) { + return settings.get(index); + } + + public void setColor(int index, StarColorSetting color) { + settings.set(index, color); + } + + public void removeColor(int index) { + settings.remove(index); + } + + public ForgeOfGodsStarColor setCustomDrawable(IDrawable drawable) { + this.drawable = drawable; + return this; + } + + /** @return a picture representation of this star color. */ + public IDrawable getDrawable() { + if (drawable == null) { + StarColorSetting setting = settings.get(0); + drawable = new Rectangle() + .setColor(Color.rgb(setting.getColorR(), setting.getColorG(), setting.getColorB())); + } + return drawable; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + ForgeOfGodsStarColor that = (ForgeOfGodsStarColor) o; + + if (cycleSpeed != that.cycleSpeed) return false; + if (!name.equals(that.name)) return false; + if (settings.size() != that.settings.size()) return false; + for (int i = 0; i < settings.size(); i++) { + StarColorSetting thisSetting = settings.get(i); + StarColorSetting thatSetting = that.settings.get(i); + if (!thisSetting.equals(thatSetting)) return false; + } + return true; + } + + @Override + public String toString() { + return serializeToString(); + } + + public NBTTagCompound serializeToNBT() { + NBTTagCompound NBT = new NBTTagCompound(); + + if (isPresetColor()) { + // Known color, we can just do this with a simple key + NBT.setString("Preset", getName()); + return NBT; + } + + NBT.setString("Name", getName()); + NBT.setInteger("CycleSpeed", cycleSpeed); + NBT.setInteger("Version", version); + + if (!settings.isEmpty()) { + NBTTagCompound settingsNBT = new NBTTagCompound(); + settingsNBT.setInteger("Size", settings.size()); + + for (int i = 0; i < settings.size(); i++) { + StarColorSetting setting = settings.get(i); + settingsNBT.setTag(Integer.toString(i), setting.serialize()); + } + + NBT.setTag("Settings", settingsNBT); + } + + return NBT; + } + + public static ForgeOfGodsStarColor deserialize(NBTTagCompound NBT) { + if (NBT.hasKey("Preset")) { + return PRESETS.get(NBT.getString("Preset")); + } + + ForgeOfGodsStarColor color = new ForgeOfGodsStarColor(NBT.getString("Name")); + color.setCycleSpeed(NBT.getInteger("CycleSpeed")); + + if (NBT.hasKey("Settings")) { + NBTTagCompound settingsNBT = NBT.getCompoundTag("Settings"); + int size = settingsNBT.getInteger("Size"); + for (int i = 0; i < size; i++) { + NBTTagCompound colorNBT = settingsNBT.getCompoundTag(Integer.toString(i)); + StarColorSetting setting = StarColorSetting.deserialize(colorNBT); + color.settings.add(setting); + } + } + + return color; + } + + public String serializeToString() { + StringBuilder sb = new StringBuilder(); + sb.append("StarColorV1:{"); + sb.append("Name:"); + sb.append(getName()); + sb.append(",Cycle:"); + sb.append(getCycleSpeed()); + + for (StarColorSetting setting : settings) { + sb.append("|"); + sb.append("r:"); + sb.append(setting.getColorR()); + sb.append(",g:"); + sb.append(setting.getColorG()); + sb.append(",b:"); + sb.append(setting.getColorB()); + sb.append(",m:"); + sb.append(setting.getGamma()); + } + + sb.append("}"); + return sb.toString(); + } + + @Nullable + public static ForgeOfGodsStarColor deserialize(String raw) { + if (raw == null) return null; + if (!raw.startsWith("StarColorV1:{") || !raw.endsWith("}")) return null; + + // Wrap in try-catch for easy format "checking" + try { + String[] data = raw.substring(13, raw.length() - 1) + .split("\\|"); + + // Parse the header (name and cycle rate) + String header = data[0]; + String[] headerData = header.split(","); + + // Name + String name = null; + if (headerData[0].startsWith("Name:")) { + name = headerData[0].substring(5); + } + + // Cycle Rate + Integer cycleRate = null; + if (headerData[1].startsWith("Cycle:")) { + cycleRate = Integer.valueOf(headerData[1].substring(6)); + } + + List<StarColorSetting> colorSettings = new ArrayList<>(); + for (int i = 1; i < data.length; i++) { + String[] colorData = data[i].split(","); + int r = -1, g = -1, b = -1; + float m = -1; + for (String color : colorData) { + String[] singleData = color.split(":"); + switch (singleData[0]) { + case "r" -> r = Integer.parseInt(singleData[1]); + case "g" -> g = Integer.parseInt(singleData[1]); + case "b" -> b = Integer.parseInt(singleData[1]); + case "m" -> m = Float.parseFloat(singleData[1]); + } + } + if (r != -1 && g != -1 && b != -1 && m != -1) { + colorSettings.add(new StarColorSetting(r, g, b, m)); + } + } + + if (name != null && cycleRate != null && !colorSettings.isEmpty()) { + return new ForgeOfGodsStarColor(name).setCycleSpeed(cycleRate) + .addColors(colorSettings); + } + return null; + } catch (Throwable ignored) { + return null; + } + } + + public static void writeToBuffer(PacketBuffer buf, ForgeOfGodsStarColor color) { + buf.writeBoolean(color == null); + if (color != null) { + buf.writeBoolean(color.isPresetColor()); + try { + buf.writeStringToBuffer(color.name); + } catch (IOException ignored) {} + + if (!color.isPresetColor()) { + buf.writeInt(color.cycleSpeed); + buf.writeInt(color.settings.size()); + for (StarColorSetting setting : color.settings) { + StarColorSetting.writeToBuffer(buf, setting); + } + } + } + } + + public static ForgeOfGodsStarColor readFromBuffer(PacketBuffer buf) { + if (buf.readBoolean()) return null; + boolean isPresetColor = buf.readBoolean(); + String name; + try { + name = buf.readStringFromBuffer(32767); + } catch (IOException ignored) { + return null; + } + + if (isPresetColor) { + return PRESETS.get(name); + } + + ForgeOfGodsStarColor color = new ForgeOfGodsStarColor(name); + color.setCycleSpeed(buf.readInt()); + int size = buf.readInt(); + for (int i = 0; i < size; i++) { + color.addColor(StarColorSetting.readFromBuffer(buf)); + } + return color; + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorSetting.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorSetting.java new file mode 100644 index 0000000000..b096d80fbd --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorSetting.java @@ -0,0 +1,89 @@ +package tectech.thing.metaTileEntity.multi.godforge.color; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class StarColorSetting { + + private final int r, g, b; + private final float gamma; + + public StarColorSetting(int r, int g, int b, float gamma) { + this.r = r; + this.g = g; + this.b = b; + this.gamma = gamma; + } + + public int getColorR() { + return r; + } + + public int getColorG() { + return g; + } + + public int getColorB() { + return b; + } + + public float getGamma() { + return gamma; + } + + protected NBTTagCompound serialize() { + NBTTagCompound NBT = new NBTTagCompound(); + NBT.setInteger("R", r); + NBT.setInteger("G", g); + NBT.setInteger("B", b); + NBT.setFloat("Gamma", gamma); + return NBT; + } + + protected static StarColorSetting deserialize(NBTTagCompound NBT) { + int r = NBT.getInteger("R"); + int g = NBT.getInteger("G"); + int b = NBT.getInteger("B"); + float gamma = NBT.getFloat("Gamma"); + return new StarColorSetting(r, g, b, gamma); + } + + public static void writeToBuffer(PacketBuffer buf, StarColorSetting color) { + buf.writeInt(color.r); + buf.writeInt(color.g); + buf.writeInt(color.b); + buf.writeFloat(color.gamma); + } + + public static StarColorSetting readFromBuffer(PacketBuffer buf) { + int r = buf.readInt(); + int g = buf.readInt(); + int b = buf.readInt(); + float gamma = buf.readFloat(); + return new StarColorSetting(r, g, b, gamma); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + StarColorSetting that = (StarColorSetting) o; + + if (r != that.r) return false; + if (g != that.g) return false; + if (b != that.b) return false; + return gamma == that.gamma; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("r", r) + .append("g", g) + .append("b", b) + .append("gamma", gamma) + .build(); + } +} diff --git a/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorStorage.java b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorStorage.java new file mode 100644 index 0000000000..a7a4e25298 --- /dev/null +++ b/src/main/java/tectech/thing/metaTileEntity/multi/godforge/color/StarColorStorage.java @@ -0,0 +1,130 @@ +package tectech.thing.metaTileEntity.multi.godforge.color; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; + +import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; + +public class StarColorStorage { + + public static final int MAX_STAR_COLORS = 7; + private static final String NBT_LIST_KEY = "customStarColors"; + + private final Map<String, ForgeOfGodsStarColor> nameMapping = new HashMap<>(MAX_STAR_COLORS); + private List<ForgeOfGodsStarColor> indexMapping = new ArrayList<>(MAX_STAR_COLORS); + + public StarColorStorage() { + initPresets(); + } + + private void initPresets() { + List<ForgeOfGodsStarColor> presets = ForgeOfGodsStarColor.getDefaultColors(); + for (ForgeOfGodsStarColor preset : presets) { + nameMapping.put(preset.getName(), preset); + indexMapping.add(preset); + } + } + + public ForgeOfGodsStarColor newTemplateColor() { + String name = "New Star Color"; + for (int i = 0; i < MAX_STAR_COLORS; i++) { + if (nameMapping.containsKey(name)) { + name = "New Star Color " + (i + 1); + } else break; + } + return new ForgeOfGodsStarColor(name); + } + + /** Store a unique star color. Will append numbers to the name to guarantee a unique name. */ + public void store(ForgeOfGodsStarColor color) { + indexMapping.add(color); + if (!nameMapping.containsKey(color.getName())) { + nameMapping.put(color.getName(), color); + return; + } + for (int i = 0; i < MAX_STAR_COLORS; i++) { + String newName = color.getName() + " " + (i + 1); + if (!nameMapping.containsKey(newName)) { + nameMapping.put(newName, color); + color.setName(newName); + return; + } + } + } + + /** Insert a star color at a given position. */ + public void insert(ForgeOfGodsStarColor color, int pos) { + ForgeOfGodsStarColor existing = indexMapping.set(pos, color); + if (existing != null) { + nameMapping.remove(existing.getName()); + nameMapping.put(color.getName(), color); + } + } + + public void drop(ForgeOfGodsStarColor color) { + ForgeOfGodsStarColor existing = nameMapping.remove(color.getName()); + if (existing != null) { + indexMapping.remove(existing); + } + } + + public ForgeOfGodsStarColor getByName(String name) { + return nameMapping.get(name); + } + + public ForgeOfGodsStarColor getByIndex(int index) { + return indexMapping.get(index); + } + + public boolean isFull() { + return indexMapping.size() >= MAX_STAR_COLORS; + } + + public int size() { + return indexMapping.size(); + } + + public void serializeToNBT(NBTTagCompound NBT) { + NBTTagList tagList = new NBTTagList(); + for (ForgeOfGodsStarColor color : indexMapping) { + if (color.isPresetColor()) continue; + tagList.appendTag(color.serializeToNBT()); + } + if (tagList.tagCount() > 0) { + NBT.setTag(NBT_LIST_KEY, tagList); + } + } + + public void rebuildFromNBT(NBTTagCompound NBT) { + nameMapping.clear(); + indexMapping.clear(); + initPresets(); + + if (NBT.hasKey(NBT_LIST_KEY)) { + NBTTagList tagList = NBT.getTagList(NBT_LIST_KEY, Constants.NBT.TAG_COMPOUND); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound colorNBT = tagList.getCompoundTagAt(i); + ForgeOfGodsStarColor color = ForgeOfGodsStarColor.deserialize(colorNBT); + if (!color.isPresetColor()) { + store(color); + } + } + } + } + + public FakeSyncWidget<?> getSyncer() { + return new FakeSyncWidget.ListSyncer<>(() -> indexMapping, val -> { + indexMapping = val; + nameMapping.clear(); + for (ForgeOfGodsStarColor color : indexMapping) { + nameMapping.put(color.getName(), color); + } + }, ForgeOfGodsStarColor::writeToBuffer, ForgeOfGodsStarColor::readFromBuffer); + } +} diff --git a/src/main/java/tectech/util/GodforgeMath.java b/src/main/java/tectech/util/GodforgeMath.java index 1a0fa96805..d4d43f01cf 100644 --- a/src/main/java/tectech/util/GodforgeMath.java +++ b/src/main/java/tectech/util/GodforgeMath.java @@ -2,12 +2,12 @@ package tectech.util; import java.math.BigInteger; -import tectech.thing.metaTileEntity.multi.MTEForgeOfGods; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEBaseModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEExoticModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEMoltenModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTEPlasmaModule; -import tectech.thing.metaTileEntity.multi.godforge_modules.MTESmeltingModule; +import tectech.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 { @@ -150,14 +150,13 @@ public class GodforgeMath { } if (godforge.isUpgradeActive(6)) { + fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f; if (godforge.isUpgradeActive(13)) { if (isMoltenOrSmeltingWithUpgrade) { - fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f * 3; + fuelFactorMultiplier *= 3; } else { - fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f * 2; + fuelFactorMultiplier *= 2; } - } else { - fuelFactorMultiplier = 1 + calculateEffectiveFuelFactor(godforge) / 15f; } } @@ -197,7 +196,7 @@ public class GodforgeMath { double maxBatteryDiscount = 1; if (godforge.isUpgradeActive(8)) { - maxBatteryDiscount = 1 - (1 - Math.pow(1.001, -0.01 * godforge.getMaxBatteryCharge())) / 20; + maxBatteryDiscount = 1 - (1 - Math.pow(1.05, -0.05 * godforge.getMaxBatteryCharge())) / 20; } if (godforge.isUpgradeActive(19)) { @@ -211,12 +210,12 @@ public class GodforgeMath { } if (module instanceof MTEExoticModule) { - if (!godforge.isUpgradeActive(25)) { - fillRatioDiscount = 1; - maxBatteryDiscount = 1; - } else { + if (godforge.isUpgradeActive(25)) { fillRatioDiscount = Math.sqrt(fillRatioDiscount); maxBatteryDiscount = Math.sqrt(maxBatteryDiscount); + } else { + fillRatioDiscount = 1; + maxBatteryDiscount = 1; } } @@ -224,7 +223,7 @@ public class GodforgeMath { } public static void calculateProcessingVoltageForModules(MTEBaseModule module, MTEForgeOfGods godforge) { - long voltage = Integer.MAX_VALUE; + long voltage = 2_000_000_000; if (godforge.isUpgradeActive(4)) { voltage += calculateEffectiveFuelFactor(godforge) * 100_000_000L; diff --git a/src/main/resources/assets/tectech/lang/en_US.lang b/src/main/resources/assets/tectech/lang/en_US.lang index eceda5a5c1..adadc268b9 100644 --- a/src/main/resources/assets/tectech/lang/en_US.lang +++ b/src/main/resources/assets/tectech/lang/en_US.lang @@ -987,7 +987,7 @@ fog.upgrade.lore.28=The usage of graviton shards in electrical systems to create fog.upgrade.lore.29=The final external structural upgrade to the Forge requires the most advanced understanding of graviton shards and their applications in extreme environments. With this, the last 4 module slots of the Forge of the Gods are available to construct, ascending your operation to unseen heights of technological mastery. fog.upgrade.lore.30=With total mastery of the Forge of the Gods achieved, it is possible to begin a new universe-spanning initiative. It is now possible to quantize and extract graviton shards for use outside the Forge in powerful new technological endeavours; produce the most exotic plasmas beyond merely periodic elements; and most importantly, begin to understand the immense power of magmatter, a form of matter made entirely of magnetic monopoles with density and stability billions of times that of conventional bosonic matter. It is with this development you realise that the completion of the Forge was not the end goal, but merely a stepping stone to universal transcendence. -fog.upgrade.text.0=Unlocks the base functionality of the Forge of the Gods, meaning 8 module slots, 1 ring and the Helioflare Power Forge module. +fog.upgrade.text.0=Unlocks the base functionality of the Forge of the Gods, meaning 8 module slots, 1 ring, the Helioflare Power Forge module, 2 billion EU/t processing voltage and 15,000K heat bonus cap. 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 @@ -999,7 +999,7 @@ 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.2(Stellar Fuel Units/sec) * 1000 + 12601 +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.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. @@ -1010,14 +1010,14 @@ fog.upgrade.text.19=Improves the EBF energy reduction heat bonus from 5% to 8% a 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) -fog.upgrade.text.23=Increases maximum processing voltage by 1 tier per active ring. +fog.upgrade.text.23=Multiplies maximum processing voltage by 4 per active ring, applies after other bonuses. fog.upgrade.text.24=Allows the Heliothermal Plasma Fabricator to process up to T5 plasmas. fog.upgrade.text.25=Allows the Heliofusion Exoticizer to be affected by other upgrade benefits, but those benefits are square rooted first. The overclock bonus is adjusted via the following formula: OC Factor = 2 + (Base OC Factor - 2)^2 fog.upgrade.text.26=Allows construction of the second ring and adds 4 module slots. -fog.upgrade.text.27=Uncaps maximum fuel consumption, but fuel consumption used in bonus calculations scales according to this formula: Actual FC = Current Max FC + (Current FC - Current Max FC)^0.75, where FC refers to fuel consumption and max FC refers to the max fuel consumption without this upgrade. +fog.upgrade.text.27=Uncaps maximum fuel consumption, but fuel consumption used in bonus calculations scales according to this formula: Actual FC = Current Max FC + (Current FC - Current Max FC)^0.4, where FC refers to fuel consumption and max FC refers to the max fuel consumption without this upgrade. fog.upgrade.text.28=Uncaps maximum processing voltage. Voltage can be set in each module's GUI. fog.upgrade.text.29=Allows construction of the third ring and adds 4 module slots. -fog.upgrade.text.30=Unlocks Magmatter production in the Heliofusion Exoticizer, creation of exotic plasmas in the Heliothermal Plasma Fabricator and Graviton Shard ejection. +fog.upgrade.text.30=Unlocks Magmatter production in the Heliofusion Exoticizer, creation of exotic plasmas in the Heliothermal Plasma Fabricator and Graviton Shard ejection & injection. fog.debug.resetbutton.text=Reset fog.debug.resetbutton.tooltip=Resets all upgrades to zero @@ -1025,9 +1025,11 @@ 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.furnacemode.tooltip=Toggle Furnace Mode -fog.button.magmattermode.tooltip.01=Toggle Magmatter Mode -fog.button.magmattermode.tooltip.02=Magmatter Mode locked, missing upgrade +fog.button.furnacemode.tooltip.01=Blast Mode +fog.button.furnacemode.tooltip.02=Furnace Mode +fog.button.magmattermode.tooltip.01=Quark-Gluon Plasma Mode +fog.button.magmattermode.tooltip.02=Magmatter Mode +fog.button.magmattermode.tooltip.03=Magmatter Mode locked, missing upgrade fog.button.battery.tooltip.01=Toggle Battery Charging fog.button.battery.tooltip.02=Right click to open configuration menu (if unlocked) fog.button.voltageconfig.tooltip.01=Open voltage config @@ -1045,9 +1047,6 @@ 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.updaterenderer.tooltip=Apply Changes -fog.button.resetcosmetics.tooltip=Reset Values -fog.button.rainbowmode.tooltip=Toggle Rainbow Mode achievement.gt.blockmachines.multimachine.em.forge_of_gods=Forge of the Gods @@ -1110,7 +1109,7 @@ gt.blockmachines.multimachine.FOG.modules=Modules gt.blockmachines.multimachine.FOG.upgrades=Upgrades gt.blockmachines.multimachine.FOG.milestones=Milestones gt.blockmachines.multimachine.FOG.fuelinfotext=Once the structure of the Forge is built and the multiblock is formed, just simply turning it on is not sufficient to make it functional. The Forge must be supplied with a certain amount of Star Fuel (the item) to actually boot up. The amount of Star Fuel needed depends on the current fuel consumption factor, which can be set in the fuel configuration menu. By default the maximum is 5, but it can be increased later on with upgrades. Star Fuel scaling is as follows: factor*25*1.2^factor. Star Fuel can be supplied via an input bus, it gets consumed periodically and stored internally. Once there is enough Star Fuel stored in the multi, it turns on for real (allowing modules to connect) and converts the consumed Star Fuel into stored Stellar Fuel. From this point onwards, the Forge must be fueled via one of the liquid fuels (type can be selected in the fuel config menu). If there isn't enough of the selected fuel present in the input hatch, the stored fuel amount will decrease and if it reaches 0, the Forge enters the previous 'off' state where modules disconnect and it has to be supplied with Star Fuel again. The amount of internally stored Stellar Fuel (liquid) can be increased by turning on battery charging, this will cause the fuel usage to double, but half of it will be stored in the internal battery. -gt.blockmachines.multimachine.FOG.moduleinfotext=There are 4 types of modules that can be used in the Forge, the Helioflare Power Forge, Helioflux Melting Core, Heliothermal Plasma Fabricator and Heliofusion Exoticizer. These modules are separate multiblocks that have to be built into the Godforge structure at their designated spots. Once built, these modules have to connect to the Godforge, which happens automatically if all requirements for the respective module are met. Alternatively, there is a button to refresh their status without waiting for the timer. Each of these modules has its specialized functionality & requirements and is affected differently by certain upgrades. The first unlocked module is the §BHelioflare Power Forge§6, which simply put is a blast furnace even more powerful than the mega version. Additionally, this module has a furnace mode, turning it into a hyper powerful multi smelter. This module is unlocked by default and has 1024 base parallel. The second unlock is the §BHelioflux Melting Core§6, which also processes blast furnace recipes, but with a twist, the outputs are ejected in their molten form instead of hot/regular ingots. If an output does not have a molten form, it will output its regular form. This module has to be unlocked by an upgrade to function and has 512 base parallel. The third module is the §BHeliothermal Plasma Fabricator§6, which possesses a unique recipemap featuring direct material to plasma conversion recipes. These recipes are grouped by two properties, fusion tier and steps required, limiting which recipes can be processed before their respective upgrades are unlocked. Unlike regular fusion, these recipes produce the plasma of the input material. This module has 384 base parallel. The fourth and last module is the §BHeliofusion Exoticizer§6, a module capable of producing quark gluon plasma and later on magmatter. This module has unique automation challenges for both materials, so it is recommended to have two of these, as they have to be locked to either one of the materials. The common rule for both modes' automation challenges is as follows: the module outputs materials at the start of a recipe cycle and waits for the correct inputs to arrive before starting the actual processing of the output material. If producing quark-gluon plasma, the module outputs up to 7 different fluids/tiny piles with amounts between 1 and 64, and their corresponding plasmas and amounts have to be returned in order for the recipe to process. For each L of fluid, a bucket of plasma and for each tiny pile an ingot's worth of plasma must be returned for the recipe to work. If magmatter mode is active, the automation challenge changes. Now the module outputs 1-50L of tachyon rich temporal fluid, 51-100L of spatially enlarged fluid and one tiny pile of a high tier material. The challenge is to return both the tachyon rich and spatially enlarged fluids, plus as much plasma of the tiny pile's material (in ingots) as the difference between the amounts of spatially enlarged and tachyon rich fluid. Once all of these have been returned in the correct amounts, the recipe will start to process and output magmatter. This module has 64 base parallel. +gt.blockmachines.multimachine.FOG.moduleinfotext=There are 4 types of modules that can be used in the Forge, the Helioflare Power Forge, Helioflux Melting Core, Heliothermal Plasma Fabricator and Heliofusion Exoticizer. These modules are separate multiblocks that have to be built into the Godforge structure at their designated spots. Once built, these modules have to connect to the Godforge, which happens automatically if all requirements for the respective module are met. Alternatively, there is a button to refresh their status without waiting for the timer. Each of these modules has its specialized functionality & requirements and is affected differently by certain upgrades. The first unlocked module is the §BHelioflare Power Forge§6, which simply put is a blast furnace even more powerful than the mega version. Additionally, this module has a furnace mode, turning it into a hyper powerful multi smelter. This module is unlocked by default and has 1024 base parallel. The second unlock is the §BHelioflux Melting Core§6, which also processes blast furnace recipes, but with a twist, the outputs are ejected in their molten form instead of hot/regular ingots. If an output does not have a molten form, it will output its regular form. This module has to be unlocked by an upgrade to function and has 512 base parallel. The third module is the §BHeliothermal Plasma Fabricator§6, which possesses a unique recipemap featuring direct material to plasma conversion recipes. These recipes are grouped by two properties, fusion tier and steps required, limiting which recipes can be processed before their respective upgrades are unlocked. Unlike regular fusion, these recipes produce the plasma of the input material. This module has 384 base parallel. The fourth and last module is the §BHeliofusion Exoticizer§6, a module capable of producing quark gluon plasma and later on magmatter. This module has unique automation challenges for both materials, so it is recommended to have two of these, as they have to be locked to either one of the materials. The common rule for both modes' automation challenges is as follows: the module outputs materials at the start of a recipe cycle and waits for the correct inputs to arrive before starting the actual processing of the output material. If producing quark-gluon plasma, the module outputs up to 7 different fluids/tiny piles with amounts between 1 and 64, and their corresponding plasmas and amounts have to be returned in order for the recipe to process. For each L of fluid, a bucket of plasma and for each tiny pile an ingot's worth of plasma must be returned for the recipe to work. The tiny piles are always ejected in multiples of 9. If magmatter mode is active, the automation challenge changes. Now the module outputs 1-50L of tachyon rich temporal fluid, 51-100L of spatially enlarged fluid and one tiny pile of a high tier material. The challenge is to return both the tachyon rich and spatially enlarged fluids, plus as much plasma of the tiny pile's material (in ingots) as the difference between the amounts of spatially enlarged and tachyon rich fluid. Once all of these have been returned in the correct amounts, the recipe will start to process and output magmatter. This module has 64 base parallel. gt.blockmachines.multimachine.FOG.upgradeinfotext=Upgrades are the heart and soul of the Godforge, they unlock most of its functionality and processing power. The upgrade tree can be accessed via its button on the main gui and each upgrade node can be clicked for more information on its effects and unlock requirements. In general, each upgrade can only be unlocked if the prior one is unlocked and there are enough available graviton shards. One exception to this is the first upgrade, as that one has no prior upgrade. Some upgrades can also have extra material costs, which are denoted next to the unlock button if applicable. If an upgrade has more than 1 connected prior upgrade, then there are two options, either the upgrade requires ALL connected prior upgrades or AT LEAST ONE (indicated by the connection's color, red means ALL, blue means AT LEAST ONE). Upgrades can be refunded by simply pressing the unlock button again, but this only works if ALL connected later upgrades are not active/unlocked. The block of upgrades following the unlock of the Heliufusion Exoticizer module are special, as they are what is considered §Bthe Split§6. As the name suggests, only one path out of the three may be chosen at first, and the others will be locked. Each path has specialized buffs that are primarily targeted towards a specific module, and thus affect other module types with reduced effect (unless stated otherwise). The amount of unlockable paths depends on the amount of rings the Godforge has, which in turn are limited by later upgrades. gt.blockmachines.multimachine.FOG.milestoneinfotext=Milestones are essential for upgrading the Godforge, as they are the source of graviton shards, the main currency needed for unlocking upgrades. In essence, milestones are just what their name suggests, thresholds that when reached, grant graviton shards. There are four types of milestones, Charge, Conversion, Catalyst and Composition, each referring to a stat of the Godforge. Each milestone has 7 tiers, each being harder to reach than the last, but also granting more graviton shards. The first tier grants 1 graviton shard, the second 2, etc. The §BCharge§6 milestone scales off total power consumption of all modules combined, the first tier being unlocked at 1e15 EU consumed, and each subsequent milestone scaling by 9x. The §BConversion§6 milestone scales off total recipes processed across all modules (excluding the Helioflare Power Forge's furnace mode) and its first tier is unlocked at 10M processed recipes. Following tiers scale by 6x. The §BCatalyst§6 milestone is based on the Forge's fuel consumption, counted in Stellar Fuel units (the number entered in the fuel config menu). Reaching the first tier requires 10,000 fuel units to be consumed, and each tier above scales by 3x. Last but not least, the §BComposition§6 milestone works a bit differently, as it scales off the Forge's structure. Milestone levels are granted for each unique type of module present in the structure (Heliofusion Exoticizer modules on quark-gluon and magmatter mode count as unique) and for each additional ring built. Your research suggests that something strange might happen if all milestones reach their final tier... Make sure to check back! gt.blockmachines.multimachine.FOG.contributors=Contributors @@ -1128,23 +1127,54 @@ 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.cosmetics=Star Cosmetics -gt.blockmachines.multimachine.FOG.color=Color -gt.blockmachines.multimachine.FOG.misc=Miscellaneous -gt.blockmachines.multimachine.FOG.red=Red -gt.blockmachines.multimachine.FOG.green=Green -gt.blockmachines.multimachine.FOG.blue=Blue -gt.blockmachines.multimachine.FOG.gamma=Gamma -gt.blockmachines.multimachine.FOG.speed=Speed -gt.blockmachines.multimachine.FOG.spin=Spin -gt.blockmachines.multimachine.FOG.size=Size -gt.blockmachines.multimachine.FOG.apply=Apply -gt.blockmachines.multimachine.FOG.decimals=Accepts Decimals -gt.blockmachines.multimachine.FOG.integers=Accepts Integers 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 +# Godforge Star Cosmetics +fog.cosmetics.header=Star Cosmetics +fog.cosmetics.color=Color +fog.cosmetics.color.red=Red +fog.cosmetics.color.green=Green +fog.cosmetics.color.blue=Blue +fog.cosmetics.color.gamma=Gamma +fog.cosmetics.selectcolor.tooltip.1=Left click to select this Star Color +fog.cosmetics.selectcolor.tooltip.2=Shift-Left click to edit this Star Color (must be a custom color) +fog.cosmetics.starcolor=Custom Star Color +fog.cosmetics.customstarcolor=Custom... +fog.cosmetics.misc=Miscellaneous +fog.cosmetics.spin=Spin +fog.cosmetics.size=Size +fog.cosmetics.cyclespeed=Cycle speed between colors +fog.cosmetics.onlyintegers=Accepts Integers +fog.cosmetics.onlydecimals=Accepts Decimals +fog.cosmetics.starcolorname=Star Color Name: +fog.cosmetics.starcolorname.tooltip.1=Set the name for this Star Color (max 15 chars) +fog.cosmetics.starcolorname.tooltip.2=Must be unique! Will have a number appended otherwise +fog.cosmetics.colorlist.tooltip.1=Left click to select this Star Color +fog.cosmetics.colorlist.tooltip.2=Right click to remove this Star Color from the list +fog.cosmetics.applycolor=Apply +fog.cosmetics.applycolor.tooltip=Apply color to selected Star Color +fog.cosmetics.addcolor=Add +fog.cosmetics.addcolor.tooltip=Add to Star Color List +fog.cosmetics.resetcolor=Reset +fog.cosmetics.resetcolor.tooltip=Reset Current Color +fog.cosmetics.savecolors=Save +fog.cosmetics.savecolors.tooltip=Save this Star Color +fog.cosmetics.deletecolors=Delete +fog.cosmetics.deletecolors.tooltip=Delete this Star Color +fog.cosmetics.importcolors=Import +fog.cosmetics.importcolors.tooltip=Import a Star Color from text +fog.cosmetics.exportcolors=Export +fog.cosmetics.exportcolors.tooltip=Save exported Star Color to clipboard +fog.cosmetics.importer.import=Import Star Color +fog.cosmetics.importer.error=Invalid Star Color +fog.cosmetics.importer.valid=Valid Star Color +fog.cosmetics.importer.apply=Apply +fog.cosmetics.importer.apply.tooltip=Apply imported Star Color to color editor +fog.cosmetics.importer.reset=Reset +fog.cosmetics.importer.reset.tooltip=Reset imported Star Color + # Optical Circuits achievement.gt.metaitem.03.32155=Optical Assembly achievement.gt.metaitem.03.32156=Optical Computer diff --git a/src/main/resources/assets/tectech/textures/gui/background/white_glow_half.png b/src/main/resources/assets/tectech/textures/gui/background/white_glow_half.png Binary files differnew file mode 100644 index 0000000000..69f46d998d --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/background/white_glow_half.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_off.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_off.png Binary files differnew file mode 100644 index 0000000000..eab0aef166 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_off.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_on.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_on.png Binary files differnew file mode 100644 index 0000000000..bd39bf20a8 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/batch_mode_on.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_off.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_off.png Binary files differnew file mode 100644 index 0000000000..ea2eaab096 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_off.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_on.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_on.png Binary files differnew file mode 100644 index 0000000000..8cd41221fd --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/furnace_mode_on.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_off.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_off.png Binary files differnew file mode 100644 index 0000000000..b6278699b6 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_off.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_on.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_on.png Binary files differnew file mode 100644 index 0000000000..b8202b199b --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/input_separation_on.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_off.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_off.png Binary files differnew file mode 100644 index 0000000000..3bd40381cc --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_off.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_on.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_on.png Binary files differnew file mode 100644 index 0000000000..d48f2323c8 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/loaf_mode_on.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_locked.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_locked.png Binary files differnew file mode 100644 index 0000000000..5206242d36 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_locked.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_unlocked.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_unlocked.png Binary files differnew file mode 100644 index 0000000000..be51c795eb --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/recipe_unlocked.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_off.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_off.png Binary files differnew file mode 100644 index 0000000000..91ec06ce49 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_off.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_on.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_on.png Binary files differnew file mode 100644 index 0000000000..c53015c005 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/structure_check_on.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_both.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_both.png Binary files differnew file mode 100644 index 0000000000..3f15a3253d --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_both.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_disabled.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_disabled.png Binary files differnew file mode 100644 index 0000000000..3cc3c331e8 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_disabled.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_fluids.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_fluids.png Binary files differnew file mode 100644 index 0000000000..c7ecfc0675 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_fluids.png diff --git a/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_items.png b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_items.png Binary files differnew file mode 100644 index 0000000000..c41ccb26e7 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/overlay_button/voiding_items.png diff --git a/src/main/resources/assets/tectech/textures/gui/picture/heat_sink_16x8.png b/src/main/resources/assets/tectech/textures/gui/picture/heat_sink_16x8.png Binary files differnew file mode 100644 index 0000000000..b6a31a4923 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/picture/heat_sink_16x8.png diff --git a/src/main/resources/assets/tectech/textures/gui/picture/unselected_option.png b/src/main/resources/assets/tectech/textures/gui/picture/unselected_option.png Binary files differnew file mode 100644 index 0000000000..f1745d81a5 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/gui/picture/unselected_option.png diff --git a/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png b/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png Binary files differnew file mode 100644 index 0000000000..4acc83482e --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png diff --git a/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png.mcmeta b/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png.mcmeta new file mode 100644 index 0000000000..cc8a1f3c96 --- /dev/null +++ b/src/main/resources/assets/tectech/textures/items/fakeItemQGP.png.mcmeta @@ -0,0 +1 @@ +{"animation": {"frametime": 1}}
\ No newline at end of file diff --git a/src/test/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColorTest.java b/src/test/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColorTest.java new file mode 100644 index 0000000000..f30f0dcce9 --- /dev/null +++ b/src/test/java/tectech/thing/metaTileEntity/multi/godforge/color/ForgeOfGodsStarColorTest.java @@ -0,0 +1,21 @@ +package tectech.thing.metaTileEntity.multi.godforge.color; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; + +public class ForgeOfGodsStarColorTest { + + @Test + public void testSerializeToString() { + ForgeOfGodsStarColor starColor = new ForgeOfGodsStarColor("Test Color").setCycleSpeed(10) + .addColor(1, 2, 3, 4) + .addColor(71, 82, 155, 9) + .addColor(3, 8, 94, 20); + + String serialized = starColor.serializeToString(); + System.out.printf("Tested Star Color: %s\n", serialized); + ForgeOfGodsStarColor deserialized = ForgeOfGodsStarColor.deserialize(serialized); + assertEquals(starColor, deserialized); + } +} |