From 41764259cb3d851f581e63be4b8ddd8f1233cdde Mon Sep 17 00:00:00 2001 From: 90 Date: Mon, 15 Jul 2024 18:59:40 +0100 Subject: [PATCH] Add "unlearn" button to Transmutation Terminal --- .../screen/TransmutationTerminalScreen.java | 5 +++ .../menu/TransmutationTerminalMenu.java | 41 +++++++++++++++--- .../appliede/transmutation_terminal.json | 18 +++++++- .../ae2/textures/guis/appliede/terminal.png | Bin 1327 -> 1754 bytes .../resources/assets/appliede/lang/en_us.json | 1 + 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/src/main/java/gripe/_90/appliede/client/screen/TransmutationTerminalScreen.java b/src/main/java/gripe/_90/appliede/client/screen/TransmutationTerminalScreen.java index 8699233..68a4e12 100644 --- a/src/main/java/gripe/_90/appliede/client/screen/TransmutationTerminalScreen.java +++ b/src/main/java/gripe/_90/appliede/client/screen/TransmutationTerminalScreen.java @@ -52,10 +52,15 @@ protected void updateBeforeRender() { toggleShiftButton.setState(menu.shiftToTransmute); learnAllButton.setState(attemptingToLearn); setTextHidden("learned", menu.learnedLabelTicks <= 0); + setTextHidden("unlearned", menu.unlearnedLabelTicks <= 0); if (menu.learnedLabelTicks > 0) { menu.decrementLearnedTicks(); } + + if (menu.unlearnedLabelTicks > 0) { + menu.decrementUnlearnedTicks(); + } } private void learnAll(boolean learned) { diff --git a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java index c4a26f1..56e668c 100644 --- a/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java +++ b/src/main/java/gripe/_90/appliede/menu/TransmutationTerminalMenu.java @@ -1,5 +1,6 @@ package gripe._90.appliede.menu; +import moze_intel.projecte.api.ItemInfo; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; @@ -27,12 +28,15 @@ public class TransmutationTerminalMenu extends MEStorageMenu { TransmutationTerminalMenu::new, TransmutationTerminalHost.class) .build("transmutation_terminal"); protected static final SlotSemantic TRANSMUTE = SlotSemantics.register("APPLIEDE_TRANSMUTE", false); + protected static final SlotSemantic UNLEARN = SlotSemantics.register("APPLIEDE_UNLEARN", false); private static final String ACTION_SET_SHIFT = "setShiftDestination"; private static final String ACTION_HIDE_LEARNED = "hideLearnedText"; + private static final String ACTION_HIDE_UNLEARNED = "hideUnlearnedText"; private final TransmutationTerminalHost host; private final Slot transmuteSlot = new FakeSlot(InternalInventory.empty(), 0); + private final Slot unlearnSlot = new FakeSlot(InternalInventory.empty(), 0); @GuiSync(1) public boolean shiftToTransmute; @@ -40,6 +44,9 @@ public class TransmutationTerminalMenu extends MEStorageMenu { @GuiSync(2) public int learnedLabelTicks; + @GuiSync(3) + public int unlearnedLabelTicks; + public TransmutationTerminalMenu(int id, Inventory ip, TransmutationTerminalHost host) { this(TYPE, id, ip, host, true); } @@ -50,7 +57,9 @@ public TransmutationTerminalMenu( this.host = host; registerClientAction(ACTION_SET_SHIFT, Boolean.class, host::setShiftToTransmute); registerClientAction(ACTION_HIDE_LEARNED, () -> learnedLabelTicks--); + registerClientAction(ACTION_HIDE_UNLEARNED, () -> unlearnedLabelTicks--); addSlot(transmuteSlot, TRANSMUTE); + addSlot(unlearnSlot, UNLEARN); } @Override @@ -64,6 +73,23 @@ public void doAction(ServerPlayer player, InventoryAction action, int slot, long reduced.setCount(reduced.getCount() - transmuted); setCarried(reduced.getCount() <= 0 ? ItemStack.EMPTY : reduced); } + + if (s.equals(unlearnSlot) && !getCarried().isEmpty()) { + var node = host.getActionableNode(); + + if (node != null) { + var knowledge = node.getGrid().getService(KnowledgeService.class); + + if (knowledge.isTrackingPlayer(player)) { + var provider = knowledge.getProviderFor(player.getUUID()).get(); + provider.removeKnowledge(getCarried()); + provider.syncKnowledgeChange(player, ItemInfo.fromStack(getCarried()), false); + unlearnedLabelTicks = 300; + learnedLabelTicks = 0; + broadcastChanges(); + } + } + } } private int transmuteItem(ItemStack stack, boolean singleItem, Player player) { @@ -74,13 +100,7 @@ private int transmuteItem(ItemStack stack, boolean singleItem, Player player) { return 0; } - var grid = node.getGrid(); - - if (grid == null) { - return 0; - } - - var knowledge = grid.getService(KnowledgeService.class); + var knowledge = node.getGrid().getService(KnowledgeService.class); if (!knowledge.isTrackingPlayer(player)) { return 0; @@ -112,6 +132,7 @@ public void setShiftToTransmute(boolean transmute) { public void showLearned() { learnedLabelTicks = 300; + unlearnedLabelTicks = 0; broadcastChanges(); } @@ -121,6 +142,12 @@ public void decrementLearnedTicks() { } } + public void decrementUnlearnedTicks() { + if (isClientSide()) { + sendClientAction(ACTION_HIDE_UNLEARNED); + } + } + @Override public ItemStack quickMoveStack(Player player, int idx) { if (shiftToTransmute) { diff --git a/src/main/resources/assets/ae2/screens/appliede/transmutation_terminal.json b/src/main/resources/assets/ae2/screens/appliede/transmutation_terminal.json index 074a038..f3ebb5a 100644 --- a/src/main/resources/assets/ae2/screens/appliede/transmutation_terminal.json +++ b/src/main/resources/assets/ae2/screens/appliede/transmutation_terminal.json @@ -1,8 +1,12 @@ { "includes": ["../terminals/terminal.json"], "slots": { + "APPLIEDE_UNLEARN": { + "left": 71, + "bottom": 118 + }, "APPLIEDE_TRANSMUTE": { - "left": 80, + "left": 89, "bottom": 118 } }, @@ -31,7 +35,17 @@ }, "color": "MUTED_TEXT_COLOR", "position": { - "left": 18, + "left": 8, + "bottom": 114 + } + }, + "unlearned": { + "text": { + "translate": "gui.appliede.unlearned" + }, + "color": "MUTED_TEXT_COLOR", + "position": { + "left": 8, "bottom": 114 } } diff --git a/src/main/resources/assets/ae2/textures/guis/appliede/terminal.png b/src/main/resources/assets/ae2/textures/guis/appliede/terminal.png index 752900576baf4e7453562e33c1f610c01d88f00c..0f400d433190442d46b1fd5f5fe1e4e0b85e3cc2 100644 GIT binary patch literal 1754 zcmbu9c~BEZ6vj7^UbQ352KN+6KNgVyPcojTn=c6Z+F{`Pxs_I*q$#aab{ zK>z?$Z1#{3005D1Apou@UtEqC`v9Pr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mWZ%+avhz#nMOd{k11|-h6Vei0S3YKc~ah>yJh^e(`J2@wQ@GKj+VqoQ)AGdw-ps z#kga~jt}b;BwYiq?4Oo8^NH7ktG}4l?NwwL96*j^VGzJzyx7~kPW`h@|379we}DDQ zKkvvCZ<}X4*RTB3y_%e93^s)qlFp=U{?(h%XLwo!Qn}X~!@}?!YD-{1Sc)n4#v23HFN1({p^{J8T&arDZJmVHP z+-Lsm$hnQ({nZQ&3=B*R91IFr7zzx0j2sLT6s(zMUjA+QreC)4%*($r)=YaZa3y?Y zI(Rf3DbdAcQw9wTbF?s)v3(dEQvn<}>- zF~3W!N(}@X6uHz3dN!HtU;pmQZwCgpCm$}azjpHPg~uOi6&RF@>ng8V z?Ub*Q*~ib4&@-JuK0d#0W7VFGTp4z3j1uQn9kN3U{{1`|%E)m*;)?y>_15nhubejz z=LBkv_{VN& zXxNV5^FLi*`#f#)`n6LJ{aVGqlJMZ&v~REfi#|Ahzf2@=ez~SY{11}{d{^rCe*d)R z*WH`U@vr~cZD3+p!_cPohE>4sJU`Qf1sf*!pS3CA#1W;avHivc7#EfE-2XEs-d^*w zCa=#j`aGw#{zoRph`kJkhvrp2grvufZ)f36i2@Amz*~YF#E9!Mm7k!mWlhyCsVwkiqHJRf z6FB*An0jt@Lm8{ta{l63yO}=wfCJ!7Rkq(78S~|_5H;AcNCPn2SgNjL1iXw%@`-qN_Q g98{!{1{yy8WIy2+p4`5#QW&Ju)78&qol`;+0FcDrsQ>@~ diff --git a/src/main/resources/assets/appliede/lang/en_us.json b/src/main/resources/assets/appliede/lang/en_us.json index 3e9cd6b..b527f2e 100644 --- a/src/main/resources/assets/appliede/lang/en_us.json +++ b/src/main/resources/assets/appliede/lang/en_us.json @@ -17,6 +17,7 @@ "gui.appliede.shift_transmuting": "Shift-Click set to Transmute.", "gui.appliede.toggle_storage": "Click to switch to Storage mode.", "gui.appliede.toggle_transmutation": "Click to switch to Transmutation mode.", + "gui.appliede.unlearned": "Unlearned!", "key.appliede.emc": "EMC", "key.appliede.emc_tiered": "EMC^%s", "tooltip.appliede.transmutable": "Transmutable from EMC (Shift+Click/Scroll)",