Skip to content

Commit

Permalink
Port Clipboard to GT (#44)
Browse files Browse the repository at this point in the history
* Start on clipboard GUI

* Complete everything up to the actual rendering

* Don't forget the buttons

* Remove TileEntity systems, since they're not really needed

* Wait, this shouldn't be an MTE :thonk:

* Fiddle around with blockstates

* Add proper clipboard-placing behavior

* Add a clipboard back

* Begin movement to MTE, by Yefancy's request

* Remove aged TE code

* Complete step two of four

* A husk of a renderMetaTileEntityDynamic

* Fix model rendering

* Pull in FakeModularGui and FakeModularUIContainer, and start on a few helper functions

* Create a Death Ray

* Complete check 3/4

* Fix references to removed class

* Tweak clipboard's location

* Remove more old code

* Get GUI interactivity online! (4/4) :lets:

* Add crafting recipe, and fix some minor issues

* ...Why was that there?

* Fix more various bugs

* Fix more bugs

* Fix more bugs

* Fix non-in-world GUI, and add explainer text to tooltip

* Fix certain formatting and extraneous import problems

* Fix certain formatting and extraneous import problems

* Reformat GregFakePlayer

* Yeet ModelCache.java

* Keep removing useless imports

* Behaviour -> Behavior (as per Tech's request)

* Implement @tech22's suggestions

* Continue transition to behavior

* Apply all of Kila's suggestions that could be simply implemented

* Fix up ClipboardBehavior.java

* Fix up MetaTileEntityClipboard.java

* Continue removing unnecessary checks from PlayerInventoryHolder.java

* Add Max's textures!

* Squashed commit of the following:

commit 713fd9e
Author: ALongStringOfNumbers <[email protected]>
Date:   Fri Aug 20 23:33:54 2021 -0700

    Fix for null materials being entered into the washedIn pair (#98)

commit e0d55c8
Author: ALongStringOfNumbers <[email protected]>
Date:   Fri Aug 20 22:59:08 2021 -0700

    Allow specifying the amount of fluid for chemical bath processing (#97)

commit 98e3bef
Author: froot <[email protected]>
Date:   Fri Aug 20 22:38:12 2021 -0700

    Material Tree JEI page returns (#66)

commit 0f6c8b7
Author: KilaBash <[email protected]>
Date:   Sat Aug 21 13:11:31 2021 +0800

    GuideBook stuff (#46)

commit 63adb22
Author: ALongStringOfNumbers <[email protected]>
Date:   Fri Aug 20 22:05:50 2021 -0700

    Fix infinite Energy emitter decrement amperage not working (#94)

commit f0c9a84
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 23:54:37 2021 -0500

    fix oilsands recipe

commit 0dc9f97
Author: ALongStringOfNumbers <[email protected]>
Date:   Fri Aug 20 21:44:06 2021 -0700

    Fix Infinite Emitter breaking particles (#93)

commit f8f1284
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 23:08:35 2021 -0500

    remove multi fluid pipes for Wood

commit 0672a79
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 22:21:01 2021 -0500

    fix primitive multis workable

    fix diamond composition

commit c50fdb2
Author: BraggestSage833 <[email protected]>
Date:   Fri Aug 20 23:18:33 2021 -0400

    fix the default output side on quantum tanks/chest  (#92)

commit 5c46453
Author: PrototypeTrousers <[email protected]>
Date:   Fri Aug 20 23:24:16 2021 -0300

    "Better Idling" for MTEs (#91)

    Co-authored-by: Exa <[email protected]>

commit 835b5b9
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 21:12:55 2021 -0500

    make battery tooltips better

commit 78e37f7
Author: Tech22 <[email protected]>
Date:   Fri Aug 20 03:53:31 2021 -0400

    add tiered superconductors

commit 4eb9133
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 02:13:06 2021 -0500

    add new EV-UV batteries

commit 1e6ff1e
Author: DStrand1 <[email protected]>
Date:   Fri Aug 20 01:00:52 2021 -0500

    remove line from build.gradle

commit 312c188
Author: DStrand1 <[email protected]>
Date:   Thu Aug 19 19:39:11 2021 -0500

    fix log warning about missing recipe property

commit d76afa3
Author: Rongmario <[email protected]>
Date:   Thu Aug 19 07:32:25 2021 +0100

    Add config to turn on/off GT adding loot (#87)

commit 4fa4e3f
Author: brachy84 <[email protected]>
Date:   Thu Aug 19 08:30:20 2021 +0200

    Fix issue from #80 (#88)

commit c7e9f84
Author: brachy84 <[email protected]>
Date:   Thu Aug 19 08:27:07 2021 +0200

    Pipefixes (#80)

    * i forgor release()

commit aba97f0
Author: DStrand1 <[email protected]>
Date:   Wed Aug 18 23:23:30 2021 -0500

    clean out dead prefixes (will cause ID shift)

commit 0bbdc65
Author: DStrand1 <[email protected]>
Date:   Wed Aug 18 23:21:03 2021 -0500

    clean up current batteries

commit b59f0dc
Author: DStrand1 <[email protected]>
Date:   Wed Aug 18 22:13:06 2021 -0500

    finish Supercon value on WireProperty

commit 5018bbe
Author: DStrand1 <[email protected]>
Date:   Tue Aug 17 23:24:12 2021 -0500

    add some missing iconset files from gregicality

commit ce2d5fe
Author: DStrand1 <[email protected]>
Date:   Tue Aug 17 22:39:13 2021 -0500

    add `heat` getter to fusion reactor

commit 3e599b5
Author: DStrand1 <[email protected]>
Date:   Tue Aug 17 20:50:58 2021 -0500

    remove ExNi stuff (in Gregification)

commit 0cb6427
Author: Dane Strandboge <[email protected]>
Date:   Tue Aug 17 01:21:31 2021 -0500

    Primitive Multi Rewrite (#85)

    * new PBF working

    * implement primitive recipes

    * finish PBF

    * refactor Coke Oven

    * update changelog

    * fix tech memeing on me

commit 61a52db
Author: DStrand1 <[email protected]>
Date:   Mon Aug 16 21:47:28 2021 -0500

    update changelog for #75

commit d51ae3e
Author: bruberu <[email protected]>
Date:   Mon Aug 16 21:46:42 2021 -0500

    Add Highlighting to the Crafting Station (#75)

commit 36ef039
Author: DStrand1 <[email protected]>
Date:   Mon Aug 16 21:03:29 2021 -0500

    relocate `RecipeMapSteamMultiblockController`

commit 13b7827
Author: DStrand1 <[email protected]>
Date:   Mon Aug 16 02:00:04 2021 -0500

    clean up components, make constructor public

commit 77ce62e
Author: brachy84 <[email protected]>
Date:   Mon Aug 16 08:58:55 2021 +0200

    rework creative energy (#84)

commit 48b1284
Author: DStrand1 <[email protected]>
Date:   Mon Aug 16 01:33:26 2021 -0500

    add circuit markers to CraftingComponent

commit 2100c86
Author: DStrand1 <[email protected]>
Date:   Mon Aug 16 00:55:09 2021 -0500

    rework crafting component loading

commit 612bc74
Author: Rongmario <[email protected]>
Date:   Mon Aug 16 02:11:59 2021 +0100

    De-enumify MaterialIconSet + MaterialIconType (#82)

    - Names are converted to the right format in the ctor

commit 826556a
Author: DStrand1 <[email protected]>
Date:   Sun Aug 15 17:11:57 2021 -0500

    pull changes from upstream #1710

commit 0ef0b33
Author: DStrand1 <[email protected]>
Date:   Sun Aug 15 17:08:44 2021 -0500

    add some MetaItem MaterialInfos

commit 523627d
Author: Rongmario <[email protected]>
Date:   Sun Aug 15 16:33:16 2021 +0100

    No longer hardcode biomes for primitive water pump (#81)

    - Now utilizes Forge's BiomeDictionary types

    - Ocean/River => `Type.WATER` (1000)
    - Swamp => `Type.SWAMP` and `Type.WET` (800)
    - Jungle => `Type.JUNGLE` (350)
    - Snow => `Type.SNOWY` (300)
    - Plains/Forest => `Type.PLAINS` and `Type.FOREST` (250)
    - Taiga => `Type.COLD` (175)
    - Beach => `Type.BEACH` (170)

commit 85b3e98
Author: DStrand1 <[email protected]>
Date:   Sun Aug 15 01:34:08 2021 -0500

    update changelog for EnergyNet updates

commit 7a9b1db
Author: brachy84 <[email protected]>
Date:   Sun Aug 15 08:32:02 2021 +0200

    Electric pipes rework (#78)

commit 757264a
Author: BraggestSage833 <[email protected]>
Date:   Sun Aug 15 02:17:23 2021 -0400

    reinstate metaArmor classes (#79)

commit 11ecde2
Author: DStrand1 <[email protected]>
Date:   Sun Aug 15 00:57:00 2021 -0500

    remove energy field projector, cleanup

commit 73f6bdc
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 22:38:35 2021 -0500

    update changelog for buffers

commit dc81fa8
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 22:37:29 2021 -0500

    port the Buffer to CEu

commit fa1b388
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 19:59:18 2021 -0500

    pull changes from upstream #1701

commit 2bede3b
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 19:48:36 2021 -0500

    merge changes from upstream #1709

commit db8a4a9
Author: Tech22 <[email protected]>
Date:   Sat Aug 14 20:45:52 2021 -0400

    change isotope element symbols to a dash

commit 6eff9e6
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 19:45:39 2021 -0500

    fix Water missing fluid tooltip

commit ecae98a
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 19:14:34 2021 -0500

    add `.chancedOutputs` builder call for List

commit 5a40354
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 18:08:29 2021 -0500

    add some missing material flags

commit 59fb179
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 14:43:23 2021 -0500

    buff Indium (small over tiny dust)

commit 6f82857
Author: Tech22 <[email protected]>
Date:   Sat Aug 14 12:49:04 2021 -0400

    change distillation EUt to reflect config

commit 9e10cf2
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 02:27:23 2021 -0500

    add more changes, fix some mistakes

commit 82fb254
Author: Dane Strandboge <[email protected]>
Date:   Sat Aug 14 02:03:55 2021 -0500

    fix some changelog mistakes

commit 4289c65
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 02:01:26 2021 -0500

    add GTCEu changelog (probably missed something)

commit 90c4e2f
Author: DStrand1 <[email protected]>
Date:   Sat Aug 14 00:55:44 2021 -0500

    fix DT outputs sometimes on wrong layers

commit 859bcb9
Author: brachy84 <[email protected]>
Date:   Sat Aug 14 07:03:57 2021 +0200

    Fluid pipes rework, MultiFluid Pipes (#53)

commit ba74b2f
Author: Rongmario <[email protected]>
Date:   Fri Aug 13 21:56:25 2021 +0100

    Made material tool enchantability not implicitly tied to icon sets (#76)

    * Made material tool enchantability not implicitly tied to icon sets

    - Nano Saber gets 33 enchantability, it inherited platinum's enchantability before but right now platinum doesn't have the tool property
    - Deprecated old static helper method to get a material enchantability (delete outright?)

    * Remove deprecated method

commit 1b3c241
Author: Tech22 <[email protected]>
Date:   Fri Aug 13 02:58:17 2021 -0400

    infinite water cover tweaks

commit 9a7af7d
Author: Tech22 <[email protected]>
Date:   Fri Aug 13 02:30:35 2021 -0400

    add recipes to adjustables, simple washer

commit d4b0dfa
Author: DStrand1 <[email protected]>
Date:   Fri Aug 13 01:22:47 2021 -0500

    add infinite water cover

commit 664bd32
Author: Tech22 <[email protected]>
Date:   Fri Aug 13 00:44:57 2021 -0400

    add simple washer

commit 807092a
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 23:42:24 2021 -0500

    Revert "remove RecipeMap minimums"

    This reverts commit 201c564.

commit 806dfd2
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 22:08:39 2021 -0500

    small cleanup on OreProperty

commit bf2e397
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 22:06:24 2021 -0500

    require DustProperty for oreByProducts

commit eb03b82
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 21:57:28 2021 -0500

    port Native EU to FE

commit d1bceee
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 21:39:32 2021 -0500

    port Diodes from Gregicality

commit 3c4a9cf
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 21:06:28 2021 -0500

    Squashed commit of the following:

    commit 22cf316
    Author: DStrand1 <[email protected]>
    Date:   Thu Aug 12 21:05:58 2021 -0500

        Revert "clean up duplicated code in energy hatch"

        This reverts commit 44b1b7f.

    commit 44b1b7f
    Author: DStrand1 <[email protected]>
    Date:   Thu Aug 12 20:07:39 2021 -0500

        clean up duplicated code in energy hatch

    commit 0163764
    Author: Tech22 <[email protected]>
    Date:   Thu Aug 12 15:51:32 2021 -0400

        adjustable energy hatches

    commit 6acee86
    Author: Tech22 <[email protected]>
    Date:   Thu Aug 12 14:57:21 2021 -0400

        adjustable transformers

commit 45e27fa
Author: Tech22 <[email protected]>
Date:   Thu Aug 12 03:28:29 2021 -0400

    fix off-centered lignite gem texture

commit 254ea67
Author: Tech22 <[email protected]>
Date:   Thu Aug 12 03:26:32 2021 -0400

    better coke oven jei page

commit 19ce515
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 02:05:19 2021 -0500

    add method for addons to register MTEs easily

commit f0c75f2
Author: DStrand1 <[email protected]>
Date:   Thu Aug 12 00:19:46 2021 -0500

    merge material changes from multi PR

commit 308d436
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 23:06:11 2021 -0500

    more code cleanup

commit 3789f4b
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 22:40:41 2021 -0500

    clean up configs a bit

commit 052fd4e
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 20:36:08 2021 -0500

    add registration, CT method

commit b6cad8c
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 20:30:45 2021 -0500

    port MetaOreDictItem

commit c1e9780
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 19:58:54 2021 -0500

    make addOrePrefix take varargs

commit afe3e35
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 19:54:46 2021 -0500

    make `addOrePrefix` public

commit 09600d2
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 19:30:58 2021 -0500

    make OrePrefix constructor public

commit cde0631
Author: Tech22 <[email protected]>
Date:   Wed Aug 11 18:59:45 2021 -0400

    fix extra facade material recipes being registered

commit 292ff21
Author: Tech22 <[email protected]>
Date:   Wed Aug 11 18:47:10 2021 -0400

    use dimension names for gas collector property

commit 189f645
Author: Tech22 <[email protected]>
Date:   Wed Aug 11 10:41:27 2021 -0400

    fix missing resource location

commit 724b20e
Author: Tech22 <[email protected]>
Date:   Wed Aug 11 10:36:10 2021 -0400

    add missing components to H2S and FeCl3

commit 18c4373
Author: Tech22 <[email protected]>
Date:   Wed Aug 11 02:19:53 2021 -0400

    prevent DT jei page overlaps

commit 201c564
Author: DStrand1 <[email protected]>
Date:   Wed Aug 11 01:20:18 2021 -0500

    remove RecipeMap minimums

commit 9a307e1
Author: TechLord22 <[email protected]>
Date:   Wed Aug 11 01:30:34 2021 -0400

    Add Cryogenic Air Recipes (#74)

commit d1a5619
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 23:58:21 2021 -0500

    clean up tool classes impl

commit 41ff7ce
Author: BraggestSage833 <[email protected]>
Date:   Wed Aug 11 00:51:19 2021 -0400

    Update ToolWrench.java (#70)

commit cdd9923
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 23:46:33 2021 -0500

    clean up steam-era recipe duration and EUt

commit e53885d
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 23:19:16 2021 -0500

    :monkey: dust blocks :monkey:

commit 81f2eef
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 23:13:29 2021 -0500

    rename bricked steel hull

commit 8f5ad1d
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 22:58:53 2021 -0500

    make steam great again

commit 346ce2c
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 21:05:59 2021 -0500

    rework Steam Machine logic

commit 8288ff0
Author: DStrand1 <[email protected]>
Date:   Tue Aug 10 20:22:02 2021 -0500

    wipe recipe cache on multiblock deformation

commit f1e6a95
Author: Tech22 <[email protected]>
Date:   Tue Aug 10 19:10:51 2021 -0400

    make NaOH not power positive, change cumene to consume H3PO4

commit b37cdf2
Author: DStrand1 <[email protected]>
Date:   Mon Aug 9 22:49:04 2021 -0500

    fix issues in UniversalDistillationBuilder

commit 30cf93c
Author: BraggestSage833 <[email protected]>
Date:   Mon Aug 9 20:28:52 2021 -0400

    Quantum Tanks/Chests can now disallow input from their export face via screwdriver  (#69)

commit 95d1f58
Author: Tech22 <[email protected]>
Date:   Mon Aug 9 18:54:31 2021 -0400

    fix crate guis

commit a4634bd
Author: Tech22 <[email protected]>
Date:   Mon Aug 9 17:56:17 2021 -0400

    fix drum TOP display

commit b1ac5e5
Author: Tech22 <[email protected]>
Date:   Mon Aug 9 02:23:41 2021 -0400

    add toolstats to Flint

commit a22aa35
Author: Tech22 <[email protected]>
Date:   Mon Aug 9 02:12:04 2021 -0400

    fix missing filter and crate recipes

commit 019ed53
Author: DStrand1 <[email protected]>
Date:   Mon Aug 9 01:04:54 2021 -0500

    remove ULV from overclock button

commit 98a6ca6
Author: TechLord22 <[email protected]>
Date:   Mon Aug 9 02:04:08 2021 -0400

    Add Gas Collectors (#68)

    * add dimension-specific gas collectors

commit 17d8f74
Author: Tech22 <[email protected]>
Date:   Mon Aug 9 01:53:14 2021 -0400

    add polished stone autoclave recipes

commit 90b8e04
Author: DStrand1 <[email protected]>
Date:   Mon Aug 9 00:25:49 2021 -0500

    trim lossless wire configs

commit 4f36d36
Author: DStrand1 <[email protected]>
Date:   Mon Aug 9 00:16:30 2021 -0500

    clean up MetaTileEntities

commit 161a216
Author: DStrand1 <[email protected]>
Date:   Sun Aug 8 23:12:45 2021 -0500

    add UV-UXV circuit assembler lang keys

commit a65bbaa
Author: DStrand1 <[email protected]>
Date:   Sun Aug 8 22:05:16 2021 -0500

    fix crash on furnace recipe removal

commit 932be0f
Author: DStrand1 <[email protected]>
Date:   Sun Aug 8 21:57:13 2021 -0500

    add debug logging to recipe removals

commit 7f557a9
Author: DStrand1 <[email protected]>
Date:   Sun Aug 8 21:09:03 2021 -0500

    config to disable in-world concrete

commit 2cd6159
Author: ALongStringOfNumbers <[email protected]>
Date:   Sun Aug 8 18:29:28 2021 -0700

    A bunch of small cleanups (#67)

    * Slight cleanup of unused constructors
    Slight fix to Assembly Line JEI page
    Remove Legacy method of specifying surface rocks

    * Fix typo in Electric Furnace recipe map localization

* compatibility

* Fix remaining issues

Co-authored-by: Yefancy <[email protected]>
  • Loading branch information
bruberu and Yefancy authored Aug 21, 2021
1 parent 713fd9e commit 7589589
Show file tree
Hide file tree
Showing 44 changed files with 1,689 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public BlockMachine() {
setHardness(6.0f);
setResistance(6.0f);
setTranslationKey("unnamed");
setHarvestLevel("wrench", 1);
setDefaultState(getDefaultState().withProperty(OPAQUE, true));
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/gregtech/api/cover/ICoverable.java
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,8 @@ static Cuboid6 getCoverPlateBox(EnumFacing side, double plateThickness) {
throw new UnsupportedOperationException();
}
}

public default boolean canRenderMachineGrid() {
return true;
}
}
6 changes: 6 additions & 0 deletions src/main/java/gregtech/api/gui/GuiTextures.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class GuiTextures {
public static final TextureArea BORDERED_BACKGROUND = AdoptableTextureArea.fullImage("textures/gui/base/bordered_background.png", 195, 136, 4, 4);
public static final TextureArea BOXED_BACKGROUND = AdoptableTextureArea.fullImage("textures/gui/base/boxed_background.png", 256, 174, 11, 11);

public static final TextureArea BLANK = AdoptableTextureArea.fullImage("textures/gui/base/blank.png", 1, 1, 0, 0);
public static final TextureArea DISPLAY = TextureArea.fullImage("textures/gui/base/display.png");
public static final TextureArea FLUID_SLOT = AdoptableTextureArea.fullImage("textures/gui/base/fluid_slot.png", 18, 18, 1, 1);
public static final TextureArea FLUID_TANK_BACKGROUND = TextureArea.fullImage("textures/gui/base/fluid_tank_background.png");
public static final TextureArea FLUID_TANK_OVERLAY = TextureArea.fullImage("textures/gui/base/fluid_tank_overlay.png");
public static final TextureArea SLOT = AdoptableTextureArea.fullImage("textures/gui/base/slot.png", 18, 18, 1, 1);
public static final TextureArea SLOT_DARKENED = TextureArea.fullImage("textures/gui/base/darkened_slot.png");


//FLUID & ITEM OUTPUT BUTTONS
public static final TextureArea BLOCKS_INPUT = TextureArea.fullImage("textures/gui/widget/button_blocks_input.png");
public static final TextureArea BUTTON = TextureArea.fullImage("textures/gui/widget/button.png");
Expand All @@ -32,8 +34,12 @@ public class GuiTextures {
public static final TextureArea BUTTON_FILTER_NBT = TextureArea.fullImage("textures/gui/widget/button_filter_nbt.png");
public static final TextureArea BUTTON_FLUID_OUTPUT = TextureArea.fullImage("textures/gui/widget/button_fluid_output.png");
public static final TextureArea BUTTON_ITEM_OUTPUT = TextureArea.fullImage("textures/gui/widget/button_item_output.png");
public static final TextureArea BUTTON_LEFT = TextureArea.fullImage("textures/gui/widget/left.png");
public static final TextureArea BUTTON_OVERCLOCK = TextureArea.fullImage("textures/gui/widget/button_overclock.png");
public static final TextureArea BUTTON_RIGHT = TextureArea.fullImage("textures/gui/widget/right.png");
public static final TextureArea BUTTON_SWITCH_VIEW = TextureArea.fullImage("textures/gui/widget/button_switch_view.png");
public static final TextureArea CLIPBOARD_BUTTON = TextureArea.fullImage("textures/gui/widget/clipboard_button.png");
public static final SizedTextureArea CLIPBOARD_TEXT_BOX = AdoptableTextureArea.fullImage("textures/gui/widget/clipboard_text_box.png", 9, 18, 1, 1);
public static final TextureArea DISTRIBUTION_MODE = TextureArea.fullImage("textures/gui/widget/button_distribution_mode.png");
public static final TextureArea LOCK = TextureArea.fullImage("textures/gui/widget/lock.png");
public static final TextureArea SWITCH = TextureArea.fullImage("textures/gui/widget/switch.png");
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/gregtech/api/gui/Widget.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,23 +275,23 @@ protected void writeClientAction(int id, Consumer<PacketBuffer> packetBufferWrit
}

@SideOnly(Side.CLIENT)
protected void drawBorder(int x, int y, int width, int height, int stroke, int stroke_width) {
public void drawBorder(int x, int y, int width, int height, int stroke, int stroke_width) {
drawGradientRect(x - stroke_width, y - stroke_width, width + 2 * stroke_width, stroke_width, stroke, stroke);
drawGradientRect(x - stroke_width, y + height, width + 2 * stroke_width, stroke_width, stroke, stroke);
drawGradientRect(x - stroke_width, y - stroke_width, stroke_width, height + 2 * stroke_width, stroke, stroke);
drawGradientRect(x + width, y - stroke_width, stroke_width, height + 2 * stroke_width, stroke, stroke);
}

@SideOnly(Side.CLIENT)
protected void drawHoveringText(ItemStack itemStack, List<String> tooltip, int maxTextWidth, int mouseX, int mouseY) {
public void drawHoveringText(ItemStack itemStack, List<String> tooltip, int maxTextWidth, int mouseX, int mouseY) {
Minecraft mc = Minecraft.getMinecraft();
GuiUtils.drawHoveringText(itemStack, tooltip, mouseX, mouseY,
sizes.getScreenWidth(),
sizes.getScreenHeight(), maxTextWidth, mc.fontRenderer);
}

@SideOnly(Side.CLIENT)
protected void drawStringSized(String text, double x, double y, int color, boolean dropShadow, float scale, boolean center) {
public void drawStringSized(String text, double x, double y, int color, boolean dropShadow, float scale, boolean center) {
GlStateManager.pushMatrix();
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
double scaledTextWidth = center ? fontRenderer.getStringWidth(text) * scale : 0.0;
Expand All @@ -302,15 +302,15 @@ protected void drawStringSized(String text, double x, double y, int color, boole
}

@SideOnly(Side.CLIENT)
protected void drawStringFixedCorner(String text, double x, double y, int color, boolean dropShadow, float scale) {
public void drawStringFixedCorner(String text, double x, double y, int color, boolean dropShadow, float scale) {
FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;
double scaledWidth = fontRenderer.getStringWidth(text) * scale;
double scaledHeight = fontRenderer.FONT_HEIGHT * scale;
drawStringSized(text, x - scaledWidth, y - scaledHeight, color, dropShadow, scale, false);
}

@SideOnly(Side.CLIENT)
protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
public static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable String altTxt) {
GlStateManager.pushMatrix();
GlStateManager.translate(0.0F, 0.0F, 32.0F);
GlStateManager.color(1F, 1F, 1F, 1F);
Expand All @@ -331,7 +331,7 @@ protected static void drawItemStack(ItemStack itemStack, int x, int y, @Nullable
}

@SideOnly(Side.CLIENT)
protected static List<String> getItemToolTip(ItemStack itemStack) {
public static List<String> getItemToolTip(ItemStack itemStack) {
Minecraft mc = Minecraft.getMinecraft();
ITooltipFlag flag = mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL;
List<String> tooltip = itemStack.getTooltip(mc.player, flag);
Expand All @@ -346,7 +346,7 @@ protected static List<String> getItemToolTip(ItemStack itemStack) {
}

@SideOnly(Side.CLIENT)
protected static void drawSelectionOverlay(int x, int y, int width, int height) {
public static void drawSelectionOverlay(int x, int y, int width, int height) {
GlStateManager.disableDepth();
GlStateManager.colorMask(true, true, true, false);
drawGradientRect(x, y, width, height, -2130706433, -2130706433);
Expand All @@ -356,14 +356,14 @@ protected static void drawSelectionOverlay(int x, int y, int width, int height)
}

@SideOnly(Side.CLIENT)
protected static void drawSolidRect(int x, int y, int width, int height, int color) {
public static void drawSolidRect(int x, int y, int width, int height, int color) {
Gui.drawRect(x, y, x + width, y + height, color);
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
GlStateManager.enableBlend();
}

@SideOnly(Side.CLIENT)
protected static void drawGradientRect(int x, int y, int width, int height, int startColor, int endColor) {
public static void drawGradientRect(int x, int y, int width, int height, int startColor, int endColor) {
drawGradientRect(x, y, width, height, startColor, endColor, false);
}

Expand Down
123 changes: 123 additions & 0 deletions src/main/java/gregtech/api/gui/impl/FakeModularGui.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package gregtech.api.gui.impl;

import gregtech.api.gui.IRenderContext;
import gregtech.api.gui.ModularUI;
import gregtech.api.gui.Widget;
import gregtech.api.util.RenderUtil;
import gregtech.common.gui.impl.FakeModularUIContainerClipboard;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.List;
import java.util.Optional;

import static gregtech.api.gui.impl.ModularUIGui.*;

@SideOnly(Side.CLIENT)
public class FakeModularGui implements IRenderContext {
public final ModularUI modularUI;
public FakeModularUIContainerClipboard container;
protected Minecraft mc;
protected FontRenderer fr;

public FakeModularGui(ModularUI modularUI, FakeModularUIContainerClipboard fakeModularUIContainer){
this.modularUI = modularUI;
this.container = fakeModularUIContainer;
this.modularUI.updateScreenSize(this.modularUI.getWidth(), this.modularUI.getHeight());
this.mc = Minecraft.getMinecraft();
this.fr = mc.fontRenderer;
}

public void updateScreen() {
modularUI.guiWidgets.values().forEach(Widget::updateScreen);
}

public void handleWidgetUpdate(int windowId, int widgetId, PacketBuffer updateData) {
if (windowId == container.windowId) {
Widget widget = modularUI.guiWidgets.get(Optional.of(widgetId));
int updateId = updateData.readVarInt();
if (widget != null) {
widget.readUpdateInfo(updateId, updateData);
}
}
}

public void drawScreen(double x, double y, float partialTicks) {
float halfW = modularUI.getWidth() / 2f;
float halfH = modularUI.getHeight() / 2f;
float scale = 0.5f / Math.max(halfW, halfH);
int mouseX = (int) ((x / scale) + (halfW > halfH? 0: (halfW - halfH)));
int mouseY = (int) ((y / scale) + (halfH > halfW? 0: (halfH - halfW)));

GlStateManager.translate(-scale * halfW, -scale * halfH, 0.01);
GlStateManager.scale(scale, scale, 1);
GlStateManager.depthMask(false);

drawGuiContainerBackgroundLayer(partialTicks, mouseX, mouseY);

GlStateManager.scale(1, 1, 0);
drawGuiContainerForegroundLayer(mouseX, mouseY);

for (int i = 0; i < this.container.inventorySlots.size(); ++i) {
Slot slot = this.container.inventorySlots.get(i);
if (!slot.getStack().isEmpty() && slot.xPos < mouseX && mouseX < slot.xPos + 18 && slot.yPos < mouseY && mouseY < slot.yPos + 18) {
Widget.drawSolidRect(slot.xPos, slot.yPos, 18, 18, 0X8fffffff);
renderToolTip(slot.getStack(), slot.xPos, slot.yPos);
}
}

GlStateManager.depthMask(true);
GlStateManager.color(1.0f, 1.0f, 1.0f);
GlStateManager.disableLighting();
}

protected void renderToolTip(ItemStack stack, int x, int y) {
FontRenderer font = stack.getItem().getFontRenderer(stack);
GuiUtils.preItemToolTip(stack);
GuiUtils.drawHoveringText(this.getItemToolTip(stack), x, y, modularUI.getScreenWidth(), modularUI.getScreenHeight(), -1, (font == null ? fr : font));
net.minecraftforge.fml.client.config.GuiUtils.postItemToolTip();
}

protected List<String> getItemToolTip(ItemStack itemStack) {
List<String> list = itemStack.getTooltip(mc.player, mc.gameSettings.advancedItemTooltips ? ITooltipFlag.TooltipFlags.ADVANCED : ITooltipFlag.TooltipFlags.NORMAL);
list.set(0, itemStack.getItem().getForgeRarity(itemStack).getColor() + list.get(0));
for (int i = 1; i < list.size(); ++i) {
list.set(i, TextFormatting.GRAY + list.get(i));
}
return list;
}

public void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(rColorForOverlay, gColorForOverlay, bColorForOverlay, 1.0F);
modularUI.backgroundPath.draw(0, 0, modularUI.getWidth(), modularUI.getHeight());
for (Widget widget : modularUI.guiWidgets.values()) {
GlStateManager.pushMatrix();
GlStateManager.color(1.0f, 1.0f, 1.0f);
GlStateManager.enableBlend();
widget.drawInBackground(mouseX, mouseY, this);
GlStateManager.popMatrix();
}
}

public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
for (Widget widget : modularUI.guiWidgets.values()) {
GlStateManager.pushMatrix();
GlStateManager.color(1.0f, 1.0f, 1.0f);
widget.drawInForeground(mouseX, mouseY);
GlStateManager.popMatrix();
}
}

public boolean mouseClicked(int mouseX, int mouseY, int mouseButton) {
return modularUI.guiWidgets.values().stream().anyMatch(widget -> widget.mouseClicked(mouseX, mouseY, mouseButton));
}
}
149 changes: 149 additions & 0 deletions src/main/java/gregtech/api/gui/widgets/ImageCycleButtonWidget.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
package gregtech.api.gui.widgets;

import gregtech.api.gui.GuiTextures;
import gregtech.api.gui.IRenderContext;
import gregtech.api.gui.Widget;
import gregtech.api.gui.resources.SizedTextureArea;
import gregtech.api.gui.resources.TextureArea;
import gregtech.api.util.GTUtility;
import gregtech.api.util.Position;
import gregtech.api.util.Size;
import gregtech.api.util.function.BooleanConsumer;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.resources.I18n;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import java.util.Arrays;
import java.util.List;
import java.util.function.*;

public class ImageCycleButtonWidget extends Widget {

protected TextureArea buttonTexture;
private int textColor = 0xFFFFFF;
private IntSupplier currentOptionSupplier;
private IntConsumer setOptionExecutor;
private int optionCount;
private final int RIGHT_MOUSE = 1;
protected int currentOption;
protected String tooltipHoverString;
protected long hoverStartTime = -1L;
protected boolean isMouseHovered;

public ImageCycleButtonWidget(int xPosition, int yPosition, int width, int height, TextureArea buttonTexture, int optionCount, IntSupplier currentOptionSupplier, IntConsumer setOptionExecutor) {
super(new Position(xPosition, yPosition), new Size(width, height));
this.buttonTexture = buttonTexture;
this.currentOptionSupplier = currentOptionSupplier;
this.setOptionExecutor = setOptionExecutor;
this.optionCount = optionCount;
}


public ImageCycleButtonWidget(int xPosition, int yPosition, int width, int height, TextureArea buttonTexture, int optionCount, BooleanSupplier supplier, BooleanConsumer updater) {
super(new Position(xPosition, yPosition), new Size(width, height));
this.buttonTexture = buttonTexture;
this.currentOptionSupplier = () -> supplier.getAsBoolean() ? 1 : 0;
this.setOptionExecutor = (value) -> updater.apply(value >= 1);
this.optionCount = optionCount;
}

public ImageCycleButtonWidget setTooltipHoverString(String hoverString) {
this.tooltipHoverString = hoverString;
return this;
}

public ImageCycleButtonWidget setButtonTexture(TextureArea texture) {
this.buttonTexture = texture;
return this;
}

public ImageCycleButtonWidget setTextColor(int textColor) {
this.textColor = textColor;
return this;
}

@Override
@SideOnly(Side.CLIENT)
public void drawInBackground(int mouseX, int mouseY, IRenderContext context) {
Position pos = getPosition();
Size size = getSize();
if (buttonTexture instanceof SizedTextureArea) {
((SizedTextureArea) buttonTexture).drawHorizontalCutSubArea(pos.x, pos.y, size.width, size.height, (float)currentOption / optionCount, (float)1 / optionCount);
} else {
buttonTexture.drawSubArea(pos.x, pos.y, size.width, size.height, 0.0, (float)currentOption / optionCount, 1.0, (float)1 / optionCount);
}
}

@Override
public void drawInForeground(int mouseX, int mouseY) {
boolean isHovered = isMouseOverElement(mouseX, mouseY);
boolean wasHovered = isMouseHovered;
if (isHovered && !wasHovered) {
this.isMouseHovered = true;
this.hoverStartTime = System.currentTimeMillis();
} else if (!isHovered && wasHovered) {
this.isMouseHovered = false;
this.hoverStartTime = 0L;
} else if (isHovered) {
long timeSinceHover = System.currentTimeMillis() - hoverStartTime;
if (timeSinceHover > 1000L && tooltipHoverString != null) {
List<String> hoverList = Arrays.asList(I18n.format(tooltipHoverString).split("/n"));
drawHoveringText(ItemStack.EMPTY, hoverList, 300, mouseX, mouseY);
}
}
}

@Override
public void detectAndSendChanges() {
super.detectAndSendChanges();
if (currentOptionSupplier.getAsInt() != currentOption) {
this.currentOption = currentOptionSupplier.getAsInt();
writeUpdateInfo(1, buf -> buf.writeVarInt(currentOption));
}
}

@Override
public void readUpdateInfo(int id, PacketBuffer buffer) {
super.readUpdateInfo(id, buffer);
if (id == 1) {
this.currentOption = buffer.readVarInt();
}
}

@Override
@SideOnly(Side.CLIENT)
public boolean mouseClicked(int mouseX, int mouseY, int button) {
super.mouseClicked(mouseX, mouseY, button);
if (isMouseOverElement(mouseX, mouseY)) {
//Allow only the RMB to reverse cycle
if(button == RIGHT_MOUSE) {
//Wrap from the first option to the last if needed
this.currentOption = currentOption == 0 ? optionCount - 1 : currentOption - 1;
} else {
this.currentOption = (currentOption + 1) % optionCount;
}
writeClientAction(1, buf -> buf.writeVarInt(currentOption));
playButtonClickSound();
return true;
}
return false;
}


@Override
public void handleClientAction(int id, PacketBuffer buffer) {
super.handleClientAction(id, buffer);
if (id == 1) {
this.currentOption = MathHelper.clamp(buffer.readVarInt(), 0, optionCount);
setOptionExecutor.accept(currentOption);
}
}

}
Loading

0 comments on commit 7589589

Please sign in to comment.