From ead617282ed1d0d8e1e8731418ee67c2b6acf0b6 Mon Sep 17 00:00:00 2001 From: cubefury Date: Tue, 16 Sep 2025 01:42:15 +0800 Subject: [PATCH 01/14] Added current user lock and Intercepting Stack handler. There are bugs: - scrolling behaviour is broken, proly due to how the stackhandler handles stuff in the backend. TODO: Change stack handler intercept to modular slot intercept - Does not clear the occupied state when player crashes or dies. TODO: Add event listener --- .../blocks/MTEVendingMachine.java | 42 ++++++++++++- .../blocks/gui/InterceptingStackHandler.java | 35 +++++++++++ .../blocks/gui/TradeMainPanel.java | 18 +++++- .../network/PacketTypeRegistry.java | 3 +- .../network/handlers/NetResetVMUser.java | 59 +++++++++++++++++++ .../assets/vendingmachine/lang/en_US.lang | 2 + 6 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java create mode 100644 src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index f329527..449073c 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -7,9 +7,11 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedBlockingQueue; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.ChatComponentTranslation; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; @@ -18,6 +20,7 @@ import com.cleanroommc.modularui.utils.item.ItemStackHandler; import com.cubefury.vendingmachine.Config; import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.blocks.gui.InterceptingStackHandler; import com.cubefury.vendingmachine.blocks.gui.MTEVendingMachineGui; import com.cubefury.vendingmachine.blocks.gui.TradeItemDisplay; import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync; @@ -45,6 +48,7 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.MTEMultiBlockBase; import gregtech.api.render.TextureFactory; +import gregtech.api.util.GTUtil; import gregtech.api.util.GTUtility; import gregtech.api.util.MultiblockTooltipBuilder; @@ -80,7 +84,7 @@ public class MTEVendingMachine extends MTEMultiBlockBase public int mUpdate = 0; public boolean mMachine = false; - public ItemStackHandler inputItems = new ItemStackHandler(INPUT_SLOTS); + public ItemStackHandler inputItems = new InterceptingStackHandler(INPUT_SLOTS, this); public ItemStackHandler outputItems = new ItemStackHandler(OUTPUT_SLOTS); public Queue outputBuffer = new ConcurrentLinkedQueue<>(); @@ -88,6 +92,8 @@ public class MTEVendingMachine extends MTEMultiBlockBase private boolean newBufferedOutputs = false; private int ticksSinceOutput = 0; + private EntityPlayer currentUser = null; + public MTEVendingMachine(final int aID, final String aName, final String aNameRegional) { super(aID, aName, aNameRegional); } @@ -476,4 +482,38 @@ public void construct(ItemStack stackSize, boolean hintsOnly) { 0, hintsOnly); } + + @Override + public boolean onRightclick(IGregTechTileEntity aBaseMetaTileEntity, EntityPlayer aPlayer) { + if (GTUtil.hasMultiblockInputConfiguration(aPlayer.getHeldItem())) { + if (aBaseMetaTileEntity.isServerSide()) { + if (GTUtil.loadMultiblockInputConfiguration(this, aPlayer)) { + aPlayer.addChatComponentMessage(new ChatComponentTranslation("GT5U.MULTI_MACHINE_CONFIG.LOAD")); + } else { + aPlayer + .addChatComponentMessage(new ChatComponentTranslation("GT5U.MULTI_MACHINE_CONFIG.LOAD.FAIL")); + } + } + return true; + } + if (canUse(aPlayer)) { + this.currentUser = aPlayer; + openGui(aPlayer); + } else { + aPlayer.addChatComponentMessage(new ChatComponentTranslation("vendingmachine.gui.error.player_using")); + } + return true; + } + + private boolean canUse(EntityPlayer aPlayer) { + return this.currentUser == null || this.currentUser == aPlayer; + } + + public EntityPlayer getCurrentUser() { + return this.currentUser; + } + + public void resetUse() { + this.currentUser = null; + } } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java new file mode 100644 index 0000000..f4e5b31 --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java @@ -0,0 +1,35 @@ +package com.cubefury.vendingmachine.blocks.gui; + +import net.minecraft.item.ItemStack; + +import com.cleanroommc.modularui.utils.item.ItemStackHandler; +import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.blocks.MTEVendingMachine; + +public class InterceptingStackHandler extends ItemStackHandler { + + private final MTEVendingMachine parent; + + public InterceptingStackHandler(int slots, MTEVendingMachine parent) { + super(slots); + this.parent = parent; + } + + @Override + public void setStackInSlot(int slot, ItemStack stack) { + if (stack != null && isValidIntercept(stack)) { + interceptStack(stack); + return; + } + super.setStackInSlot(slot, stack); + } + + private boolean isValidIntercept(ItemStack stack) { + return stack.getDisplayName() + .equals("Dirt"); + } + + private void interceptStack(ItemStack stack) { + VendingMachine.LOG.info("Intercepted stack {} {}", parent.getCurrentUser(), stack); + } +} diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index 9e23077..4abd3bd 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -17,7 +17,9 @@ import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cubefury.vendingmachine.Config; +import com.cubefury.vendingmachine.VendingMachine; import com.cubefury.vendingmachine.blocks.MTEVendingMachine; +import com.cubefury.vendingmachine.network.handlers.NetResetVMUser; import com.cubefury.vendingmachine.storage.NameCache; import com.cubefury.vendingmachine.trade.Trade; import com.cubefury.vendingmachine.trade.TradeCategory; @@ -93,9 +95,12 @@ public void onUpdate() { if (this.player == null && this.syncManager.isInitialised()) { this.player = syncManager.getPlayer(); } - if (gui.forceRefresh || (this.ticksOpen % Config.gui_refresh_interval == 0 && player != null && !shiftHeld)) { + if ( + MTEVendingMachineGui.forceRefresh + || (this.ticksOpen % Config.gui_refresh_interval == 0 && player != null && !shiftHeld) + ) { updateGui(); - gui.resetForceRefresh(); + MTEVendingMachineGui.resetForceRefresh(); } this.ticksOpen += 1; } @@ -245,4 +250,13 @@ private static int getRank(TradeItemDisplay t) { public void attemptPurchase(TradeItemDisplay display) { gui.attemptPurchase(display); } + + @Override + public void dispose() { + this.gui.getBase() + .resetUse(); + // We have to sync reset use manually since onClose() is only run client-side + NetResetVMUser.sendReset(this.gui.getBase()); + super.dispose(); + } } diff --git a/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java b/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java index 7237519..6876caf 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java +++ b/src/main/java/com/cubefury/vendingmachine/network/PacketTypeRegistry.java @@ -15,6 +15,7 @@ import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync; import com.cubefury.vendingmachine.network.handlers.NetBulkSync; import com.cubefury.vendingmachine.network.handlers.NetNameSync; +import com.cubefury.vendingmachine.network.handlers.NetResetVMUser; import com.cubefury.vendingmachine.network.handlers.NetSatisfiedQuestSync; import com.cubefury.vendingmachine.network.handlers.NetTradeDbSync; import com.cubefury.vendingmachine.network.handlers.NetTradeRequestSync; @@ -34,8 +35,8 @@ public void init() { NetTradeRequestSync.registerHandler(); NetSatisfiedQuestSync.registerHandler(); NetNameSync.registerHandler(); - NetBulkSync.registerHandler(); + NetResetVMUser.registerHandler(); } @Override diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java new file mode 100644 index 0000000..f171930 --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java @@ -0,0 +1,59 @@ +package com.cubefury.vendingmachine.network.handlers; + +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraft.world.World; +import net.minecraftforge.common.DimensionManager; + +import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.api.network.UnserializedPacket; +import com.cubefury.vendingmachine.api.util.Tuple2; +import com.cubefury.vendingmachine.blocks.MTEVendingMachine; +import com.cubefury.vendingmachine.network.PacketSender; +import com.cubefury.vendingmachine.network.PacketTypeRegistry; + +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; + +public class NetResetVMUser { + + private static final ResourceLocation ID_NAME = new ResourceLocation("vendingmachine:reset_vmuser"); + + public static void registerHandler() { + PacketTypeRegistry.INSTANCE.registerServerHandler(ID_NAME, NetResetVMUser::onServer); + } + + public static void sendReset(MTEVendingMachine base) { + IGregTechTileEntity baseTile = base.getBaseMetaTileEntity(); + if (baseTile == null) { + VendingMachine.LOG.warn("attempting to reset user for null base MTE"); + return; + } + NBTTagCompound payload = new NBTTagCompound(); + payload.setInteger("dim", baseTile.getWorld().provider.dimensionId); + payload.setInteger("x", baseTile.getXCoord()); + payload.setInteger("y", baseTile.getYCoord()); + payload.setInteger("z", baseTile.getZCoord()); + PacketSender.INSTANCE.sendToServer(new UnserializedPacket(ID_NAME, payload)); + } + + public static void onServer(Tuple2 message) { + World world = DimensionManager.getWorld( + message.first() + .getInteger("dim")); + TileEntity te = world.getTileEntity( + message.first() + .getInteger("x"), + message.first() + .getInteger("y"), + message.first() + .getInteger("z")); + if ( + te instanceof IGregTechTileEntity + && ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MTEVendingMachine + ) { + ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetUse(); + } + } +} diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang index be90e15..8e128f8 100644 --- a/src/main/resources/assets/vendingmachine/lang/en_US.lang +++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang @@ -18,6 +18,8 @@ vendingmachine.gui.cooldown_display.minute=m vendingmachine.gui.cooldown_display.hour=h vendingmachine.gui.cooldown_display.day=d +vendingmachine.gui.error.player_using=Someone is using the vending machine at the moment. + gt.blockmachines.multimachine.vendingmachine.name=Vending Machine vendingmachine.category.unknown=Unknown Category From 87c017aa3c646a3a41ab5a8c4167ef714a4888e5 Mon Sep 17 00:00:00 2001 From: cubefury Date: Wed, 17 Sep 2025 23:01:00 +0800 Subject: [PATCH 02/14] Swapped intercepting stack handler to intercepting slot --- .../blocks/MTEVendingMachine.java | 3 +- .../blocks/gui/InterceptingSlot.java | 28 +++++++++++++++ .../blocks/gui/InterceptingStackHandler.java | 35 ------------------- .../blocks/gui/MTEVendingMachineGui.java | 12 ++++++- .../blocks/gui/TradeMainPanel.java | 1 - 5 files changed, 40 insertions(+), 39 deletions(-) create mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java delete mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index 449073c..764165c 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -20,7 +20,6 @@ import com.cleanroommc.modularui.utils.item.ItemStackHandler; import com.cubefury.vendingmachine.Config; import com.cubefury.vendingmachine.VendingMachine; -import com.cubefury.vendingmachine.blocks.gui.InterceptingStackHandler; import com.cubefury.vendingmachine.blocks.gui.MTEVendingMachineGui; import com.cubefury.vendingmachine.blocks.gui.TradeItemDisplay; import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync; @@ -84,7 +83,7 @@ public class MTEVendingMachine extends MTEMultiBlockBase public int mUpdate = 0; public boolean mMachine = false; - public ItemStackHandler inputItems = new InterceptingStackHandler(INPUT_SLOTS, this); + public ItemStackHandler inputItems = new ItemStackHandler(INPUT_SLOTS); public ItemStackHandler outputItems = new ItemStackHandler(OUTPUT_SLOTS); public Queue outputBuffer = new ConcurrentLinkedQueue<>(); diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java new file mode 100644 index 0000000..2d4ce79 --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -0,0 +1,28 @@ +package com.cubefury.vendingmachine.blocks.gui; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +import com.cleanroommc.modularui.utils.item.ItemStackHandler; +import com.cleanroommc.modularui.widgets.slot.ModularSlot; +import com.cubefury.vendingmachine.VendingMachine; + +public class InterceptingSlot extends ModularSlot { + + public InterceptingSlot(ItemStackHandler inputItems, int index) { + super(inputItems, index); + } + + public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) { + if ( + newItem != null && newItem.getDisplayName() + .equals("Dirt") && !client + ) { + VendingMachine.LOG.info("intercept {} {}", newItem, player); + this.putStack(null); + return true; + } + return false; + } + +} diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java deleted file mode 100644 index f4e5b31..0000000 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingStackHandler.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.cubefury.vendingmachine.blocks.gui; - -import net.minecraft.item.ItemStack; - -import com.cleanroommc.modularui.utils.item.ItemStackHandler; -import com.cubefury.vendingmachine.VendingMachine; -import com.cubefury.vendingmachine.blocks.MTEVendingMachine; - -public class InterceptingStackHandler extends ItemStackHandler { - - private final MTEVendingMachine parent; - - public InterceptingStackHandler(int slots, MTEVendingMachine parent) { - super(slots); - this.parent = parent; - } - - @Override - public void setStackInSlot(int slot, ItemStack stack) { - if (stack != null && isValidIntercept(stack)) { - interceptStack(stack); - return; - } - super.setStackInSlot(slot, stack); - } - - private boolean isValidIntercept(ItemStack stack) { - return stack.getDisplayName() - .equals("Dirt"); - } - - private void interceptStack(ItemStack stack) { - VendingMachine.LOG.info("Intercepted stack {} {}", parent.getCurrentUser(), stack); - } -} diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index 93f1d45..61e6fad 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -259,9 +259,19 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) { return SlotGroupWidget.builder() .matrix("II", "II", "II") .key('I', index -> { + InterceptingSlot slot = new InterceptingSlot(base.inputItems, index); return new ItemSlot().slot( - new ModularSlot(base.inputItems, index).slotGroup("inputSlotGroup") + slot.slotGroup("inputSlotGroup") .changeListener((newItem, onlyAmountChanged, client, init) -> { + if ( + slot.intercept( + newItem, + client, + this.getBase() + .getCurrentUser()) + ) { + return; + } if (guiData.isClient()) { forceRefresh = true; } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index 4abd3bd..c2f657d 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -17,7 +17,6 @@ import com.cleanroommc.modularui.screen.ModularPanel; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cubefury.vendingmachine.Config; -import com.cubefury.vendingmachine.VendingMachine; import com.cubefury.vendingmachine.blocks.MTEVendingMachine; import com.cubefury.vendingmachine.network.handlers.NetResetVMUser; import com.cubefury.vendingmachine.storage.NameCache; From 172a6ee92e58a526198653902c6585fa6e6d9592 Mon Sep 17 00:00:00 2001 From: cubefury Date: Wed, 17 Sep 2025 23:07:10 +0800 Subject: [PATCH 03/14] Changed intercepting slot to intercept on both sides, but only perform post intercept actions on server side --- .../cubefury/vendingmachine/blocks/gui/InterceptingSlot.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index 2d4ce79..e4f883c 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -13,11 +13,11 @@ public InterceptingSlot(ItemStackHandler inputItems, int index) { super(inputItems, index); } + // intercept item on both ends, but only do the post-intercept actions on server side public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) { if ( newItem != null && newItem.getDisplayName() - .equals("Dirt") && !client - ) { + .equals("Dirt")) { VendingMachine.LOG.info("intercept {} {}", newItem, player); this.putStack(null); return true; From f8d766662c52a41b6e0529d9292255a978c3af08 Mon Sep 17 00:00:00 2001 From: cubefury Date: Thu, 18 Sep 2025 02:29:37 +0800 Subject: [PATCH 04/14] Added basic currency code --- .../blocks/gui/InterceptingSlot.java | 23 ++++- .../blocks/gui/MTEVendingMachineGui.java | 1 + .../blocks/gui/TradeMainPanel.java | 3 + .../network/handlers/NetTradeStateSync.java | 46 +++++++--- .../vendingmachine/trade/CurrencyItem.java | 91 +++++++++++++++++++ .../vendingmachine/trade/TradeDatabase.java | 8 +- .../vendingmachine/trade/TradeManager.java | 89 +++++++++++++++--- 7 files changed, 229 insertions(+), 32 deletions(-) create mode 100644 src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index e4f883c..b5f3726 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -1,11 +1,16 @@ package com.cubefury.vendingmachine.blocks.gui; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import com.cleanroommc.modularui.utils.item.ItemStackHandler; import com.cleanroommc.modularui.widgets.slot.ModularSlot; import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync; +import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; +import com.cubefury.vendingmachine.trade.TradeManager; public class InterceptingSlot extends ModularSlot { @@ -15,14 +20,26 @@ public InterceptingSlot(ItemStackHandler inputItems, int index) { // intercept item on both ends, but only do the post-intercept actions on server side public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) { - if ( - newItem != null && newItem.getDisplayName() - .equals("Dirt")) { + CurrencyItem mapped = mapToCurrency(newItem); + if (mapped != null) { VendingMachine.LOG.info("intercept {} {}", newItem, player); + TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); + if (!client) { + NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped); + } else { + MTEVendingMachineGui.setForceRefresh(); + } this.putStack(null); return true; } return false; } + private CurrencyItem mapToCurrency(ItemStack newItem) { + if (newItem == null) { + return null; + } + return CurrencyItem.fromItemStack(newItem); + } + } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index 61e6fad..e94a55d 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -270,6 +270,7 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) { this.getBase() .getCurrentUser()) ) { + // if we intercept, the server will send a refresh separately return; } if (guiData.isClient()) { diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index c2f657d..e692159 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -94,6 +94,9 @@ public void onUpdate() { if (this.player == null && this.syncManager.isInitialised()) { this.player = syncManager.getPlayer(); } + if (TradeManager.INSTANCE.hasCurrencyUpdate) { + MTEVendingMachineGui.setForceRefresh(); + } if ( MTEVendingMachineGui.forceRefresh || (this.ticksOpen % Config.gui_refresh_interval == 0 && player != null && !shiftHeld) diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java index 7c3d619..360d517 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java @@ -2,7 +2,7 @@ import java.util.UUID; -import javax.annotation.Nullable; +import javax.annotation.Nonnull; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; @@ -15,7 +15,9 @@ import com.cubefury.vendingmachine.network.PacketSender; import com.cubefury.vendingmachine.network.PacketTypeRegistry; import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.TradeDatabase; +import com.cubefury.vendingmachine.trade.TradeManager; import com.cubefury.vendingmachine.util.NBTConverter; import cpw.mods.fml.relauncher.Side; @@ -23,6 +25,8 @@ public class NetTradeStateSync { + // We can send tradestate + currency data, or just currency data + // The latter is far more lightweight, and will likely see higher traffic volume private static final ResourceLocation ID_NAME = new ResourceLocation("vendingmachine:tradestate_sync"); public static void registerHandler() { @@ -34,36 +38,41 @@ public static void registerHandler() { } // server side code for sending tradegroup data when player opens gui - public static void sendTradeState(@Nullable EntityPlayerMP player, boolean merge) { + public static void sendTradeState(@Nonnull EntityPlayerMP player, boolean merge) { TradeDatabase db = TradeDatabase.INSTANCE; UUID playerId = NameCache.INSTANCE.getUUIDFromPlayer(player); NBTTagCompound payload = new NBTTagCompound(); + payload.setString("dataType", "tradeState"); payload.setBoolean("merge", merge); NBTConverter.UuidValueType.PLAYER.writeId(playerId, payload); db.writeTradeStateToNBT(new NBTTagCompound(), playerId); - if (player == null) { // shouldn't happen, since we're only updating one player - PacketSender.INSTANCE.sendToAll(new UnserializedPacket(ID_NAME, payload)); - } else { - PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); - } + PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); + } + + public static void sendPlayerCurrency(@Nonnull EntityPlayerMP player, CurrencyItem currencyItem) { + NBTTagCompound payload = new NBTTagCompound(); + payload.setString("dataType", "currency"); + payload.setBoolean("merge", true); + currencyItem.writeToNBT(payload); + + PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); } @SideOnly(Side.CLIENT) public static void requestSync() { NBTTagCompound payload = new NBTTagCompound(); - payload.setString("requestType", "getTrades"); + payload.setString("requestType", "getTradeState"); PacketSender.INSTANCE.sendToServer(new UnserializedPacket(ID_NAME, payload)); } public static void onServer(Tuple2 message) { - TradeDatabase db = TradeDatabase.INSTANCE; String requestType = message.first() .getString("requestType"); - if (requestType.equals("getTrades")) { + if (requestType.equals("getTradeState")) { sendTradeState(message.second(), false); } else { VendingMachine.LOG.warn("Unknown trade state sync request type received: {}", requestType); @@ -81,8 +90,21 @@ public static void onClient(NBTTagCompound message) { ) { return; } - TradeDatabase db = TradeDatabase.INSTANCE; + String dataType = message.getString("dataType"); UUID player = NBTConverter.UuidValueType.PLAYER.readId(message); - db.populateTradeStateFromNBT(message, player, message.getBoolean("merge")); + boolean merge = message.getBoolean("merge"); + if (dataType.equals("tradeState")) { + TradeDatabase db = TradeDatabase.INSTANCE; + db.populateTradeStateFromNBT(message, player, merge); + } else if (dataType.equals("currency")) { + CurrencyItem currencyItem = CurrencyItem.fromNBT(message.getCompoundTag("currencyItem")); + if (currencyItem == null) { + VendingMachine.LOG.warn("Received invalid currency item from server"); + return; + } + TradeManager.INSTANCE.addCurrency(player, currencyItem); + } else { + VendingMachine.LOG.warn("Unknown trade state sync data received: {}", dataType); + } } } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java new file mode 100644 index 0000000..615b52c --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java @@ -0,0 +1,91 @@ +package com.cubefury.vendingmachine.trade; + +import java.util.HashMap; +import java.util.Map; + +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public class CurrencyItem { + + public CurrencyType type; + public int value; + private static final Map typeMap = new HashMap<>(); + + public static CurrencyItem fromNBT(NBTTagCompound nbt) { + CurrencyType type = CurrencyType.getTypeFromId(nbt.getString("type")); + if (type == null) { + return null; + } + return new CurrencyItem(type, nbt.getInteger("value")); + } + + public void writeToNBT(NBTTagCompound payload) { + payload.setString("type", this.type.id); + payload.setInteger("value", this.value); + } + + public enum CurrencyType { + + ADVENTURE("adventure", "dreamcraft:item.CoinAdventure"), + BEES("bees", "dreamcraft:item.CoinBees"), + BLOOD("blood", "dreamcraft:item.CoinBlood"), + CHEMIST("chemist", "dreamcraft:item.CoinChemist"), + COOK("cook", "dreamcraft:item.CoinCook"), + DARK_WIZARD("darkWizard", "dreamcraft:item.CoinDarkWizard"), + FARMER("farmer", "dreamcraft:item.CoinFarmer"), + FLOWER("flower", "dreamcraft:item.CoinFlower"), + FORESTRY("forestry", "dreamcraft:item.CoinForestry"), + SMITH("smith", "dreamcraft:item.CoinSmith"), + WITCH("witch", "dreamcraft:item.CoinWitch"), + SPACE("space", "dreamcraft:item.CoinSpace"), + SURVIVOR("survivor", "dreamcraft:item.CoinSurvivor"), + TECHNICIAN("technician", "dreamcraft:item.CoinTechnician"), + // comment before semicolon to reduce merge conflicts + ; + + public final String id; + public final String itemPrefix; + + CurrencyType(String id, String itemPrefix) { + this.id = id; + this.itemPrefix = itemPrefix; + typeMap.put(this.id, this); + } + + public static CurrencyType getTypeFromId(String type) { + return typeMap.get(type); + } + } + + public CurrencyItem(CurrencyType type, int value) { + this.type = type; + this.value = value; + } + + public static CurrencyItem fromItemStack(ItemStack newItem) { + String itemName = Item.itemRegistry.getNameForObject(newItem.getItem()); + for (CurrencyType type : CurrencyType.values()) { + if (itemName.startsWith(type.itemPrefix)) { + int currencyValue = mapSuffixToValue(itemName.substring(type.itemPrefix.length())); + if (currencyValue < 0) { + return null; + } + return new CurrencyItem(type, currencyValue * newItem.stackSize); + } + } + return null; + } + + private static int mapSuffixToValue(String suffix) { + return switch (suffix) { + case "" -> 1; + case "I" -> 10; + case "II" -> 100; + case "III" -> 1000; + case "IV" -> 10000; + default -> -1; + }; + } +} diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java index 71007ae..a31890c 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java @@ -85,7 +85,7 @@ public void readFromNBT(NBTTagCompound nbt, boolean merge) { TradeGroup tg = new TradeGroup(); newMetadataCount += tg.readFromNBT(trades.getCompoundTagAt(i)) ? 1 : 0; if (tradeGroups.containsKey(tg.getId())) { - VendingMachine.LOG.warn("Multiple trade groups with id {} exist in the file!", tg); + VendingMachine.LOG.error("Multiple trade groups with id {} exist in the file!", tg); continue; } tradeCategories.computeIfAbsent(tg.getCategory(), k -> new HashSet<>()); @@ -129,13 +129,11 @@ public void populateTradeStateFromNBT(NBTTagCompound nbt, UUID player, boolean m TradeHistory th = new TradeHistory(state.getLong("lastTrade"), state.getInteger("tradeCount")); tg.setTradeState(player, th); } + TradeManager.INSTANCE.populateCurrencyFromNBT(nbt, player, merge); } public NBTTagCompound writeTradeStateToNBT(NBTTagCompound nbt, UUID player) { NBTTagList tradeStateList = new NBTTagList(); - // This is not very efficient and can take a while to run if there are many trade groups. - // An alternative is to maintain two copies of this data, one indexing by tradegroup and - // another indexing by player uuid. Let's do that if it proves to be too slow. for (Map.Entry entry : tradeGroups.entrySet()) { TradeHistory history = entry.getValue() .getTradeState(player); @@ -148,11 +146,11 @@ public NBTTagCompound writeTradeStateToNBT(NBTTagCompound nbt, UUID player) { } } nbt.setTag("tradeState", tradeStateList); + nbt.setTag("playerCurrency", TradeManager.INSTANCE.writeCurrencyToNBT(player)); return nbt; } @SideOnly(Side.CLIENT) - @Optional.Method(modid = "NotEnoughItems") public void refreshNeiCache() { NeiRecipeCache.refreshCache(); } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java index 77137a3..205447f 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java @@ -10,7 +10,11 @@ import javax.annotation.Nonnull; -import com.cubefury.vendingmachine.util.BigItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; + +import com.cubefury.vendingmachine.VendingMachine; // This is a cache of available trades, maintained server-side // so we don't have to recompute what trades are available every time we send it @@ -20,11 +24,14 @@ public class TradeManager { private final Map> availableTrades = new HashMap<>(); - private final Map> pendingOutputs = new HashMap<>(); + private final Map> playerCurrency = new HashMap<>(); - private TradeManager() {} + // For writeback to file in original format, to prevent data loss + private final Map> invalidCurrency = new HashMap<>(); + + public boolean hasCurrencyUpdate = false; - public void init() {} + private TradeManager() {} public void addTradeGroup(UUID player, UUID tg) { synchronized (availableTrades) { @@ -87,14 +94,6 @@ public void recomputeAvailableTrades(UUID player) { } } - public void addPending(UUID player, List pending) { - if (!pendingOutputs.containsKey(player) || pendingOutputs.get(player) == null) { - pendingOutputs.put(player, new ArrayList<>()); - } - pendingOutputs.get(player) - .addAll(pending); - } - public List getTrades(UUID player) { long currentTimestamp = System.currentTimeMillis(); synchronized (availableTrades) { @@ -122,4 +121,70 @@ public List getTrades(UUID player) { return tradeList; } } + + public void populateCurrencyFromNBT(NBTTagCompound nbt, UUID player, boolean merge) { + NBTTagList tagList = nbt.getTagList("playerCurrency", Constants.NBT.TAG_COMPOUND); + if (!merge) { + this.playerCurrency.clear(); + this.invalidCurrency.clear(); + } + this.playerCurrency.computeIfAbsent(player, k -> new HashMap<>()); + for (int i = 0; i < tagList.tagCount(); i++) { + NBTTagCompound currencyEntry = tagList.getCompoundTagAt(i); + CurrencyItem.CurrencyType type = CurrencyItem.CurrencyType + .getTypeFromId(currencyEntry.getString("currency")); + if (type == null) { + VendingMachine.LOG.warn("Unknown currency type found: {}", currencyEntry.getString("currency")); + this.invalidCurrency.computeIfAbsent(player, k -> new ArrayList<>()); + this.invalidCurrency.get(player) + .add(currencyEntry); + continue; + } + int amount = currencyEntry.getInteger("amount"); + this.playerCurrency.get(player) + .computeIfAbsent(type, k -> 0); + this.playerCurrency.get(player) + .put( + type, + amount + (merge ? this.playerCurrency.get(player) + .get(type) : 0)); + } + this.hasCurrencyUpdate = true; + } + + public NBTTagList writeCurrencyToNBT(UUID player) { + NBTTagList nbt = new NBTTagList(); + if (this.playerCurrency.get(player) == null) { + return nbt; + } + for (Map.Entry entry : this.playerCurrency.get(player) + .entrySet()) { + NBTTagCompound currencyEntry = new NBTTagCompound(); + currencyEntry.setString("currency", entry.getKey().id); + currencyEntry.setInteger("amount", entry.getValue()); + nbt.appendTag(currencyEntry); + } + + if (this.invalidCurrency.get(player) != null) { + for (NBTTagCompound tag : this.invalidCurrency.get(player)) { + nbt.appendTag(tag); + } + } + return nbt; + } + + public void addCurrency(UUID playerId, CurrencyItem mapped) { + this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>()); + this.playerCurrency.get(playerId) + .computeIfAbsent(mapped.type, k -> 0); + this.playerCurrency.get(playerId) + .put( + mapped.type, + this.playerCurrency.get(playerId) + .get(mapped.type) + mapped.value); + this.hasCurrencyUpdate = true; + VendingMachine.LOG.info("currency received: {} {}", mapped.type.id, mapped.value); + + // TODO: Implement scheduled write + } } From 23630e891e76dfb6019a930254ec386950fec788 Mon Sep 17 00:00:00 2001 From: cubefury Date: Fri, 19 Sep 2025 19:21:53 +0800 Subject: [PATCH 05/14] Added currency tracking + saveload --- LICENSE.NewHorizonsCoreMod | 674 ++++++++++++++++++ README.md | 8 +- .../blocks/MTEVendingMachine.java | 10 +- .../blocks/gui/InterceptingSlot.java | 4 +- .../blocks/gui/MTEVendingMachineGui.java | 76 +- .../blocks/gui/TradeItemDisplayWidget.java | 9 +- .../blocks/gui/TradeMainPanel.java | 2 +- .../network/handlers/NetResetVMUser.java | 6 + .../vendingmachine/trade/CurrencyItem.java | 49 +- .../vendingmachine/trade/TradeManager.java | 4 +- .../assets/vendingmachine/lang/en_US.lang | 15 + .../textures/gui/icons/itemCoinAdventure.png | Bin 0 -> 3166 bytes .../textures/gui/icons/itemCoinBees.png | Bin 0 -> 3187 bytes .../textures/gui/icons/itemCoinBlood.png | Bin 0 -> 3238 bytes .../textures/gui/icons/itemCoinChemist.png | Bin 0 -> 3094 bytes .../textures/gui/icons/itemCoinCook.png | Bin 0 -> 3094 bytes .../textures/gui/icons/itemCoinDarkWizard.png | Bin 0 -> 3534 bytes .../textures/gui/icons/itemCoinFarmer.png | Bin 0 -> 3348 bytes .../textures/gui/icons/itemCoinFlower.png | Bin 0 -> 905 bytes .../textures/gui/icons/itemCoinForestry.png | Bin 0 -> 3358 bytes .../textures/gui/icons/itemCoinSmith.png | Bin 0 -> 3600 bytes .../textures/gui/icons/itemCoinSpace.png | Bin 0 -> 3055 bytes .../textures/gui/icons/itemCoinSurvivor.png | Bin 0 -> 3084 bytes .../textures/gui/icons/itemCoinTechnician.png | Bin 0 -> 3441 bytes .../textures/gui/icons/itemCoinWitch.png | Bin 0 -> 3150 bytes 25 files changed, 814 insertions(+), 43 deletions(-) create mode 100644 LICENSE.NewHorizonsCoreMod create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBlood.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinDarkWizard.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinForestry.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSmith.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSpace.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSurvivor.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinTechnician.png create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinWitch.png diff --git a/LICENSE.NewHorizonsCoreMod b/LICENSE.NewHorizonsCoreMod new file mode 100644 index 0000000..ef7e7ef --- /dev/null +++ b/LICENSE.NewHorizonsCoreMod @@ -0,0 +1,674 @@ +GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md index 3f16529..5bcf4d8 100644 --- a/README.md +++ b/README.md @@ -18,4 +18,10 @@ This can be used as a standalone mod with several dependencies. The vending mach ## Credits -We would like to thank the contributors of BetterQuesting for their implementation of networking and file serialization/deserialization, which are used in this project. We do not reference the classes directly to avoid having BetterQuesting as a required dependency. The BetterQuesting license may be found in the root directory of this project as LICENSE.betterquesting. +Credits to **BetterQuesting** for their implementation of networking and file serialization/deserialization, which are used in this project. We do not reference the classes directly to avoid having BetterQuesting as a required dependency. + +Credits to **NH Coremod** for the coin textures used in the GUI. + +The BetterQuesting license may be found in the root directory of this project as LICENSE.betterquesting. + +The NHCoreMod licenese may be found in the root directory of this project as LICENSE.NewHorizonsCoreMod. diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index 764165c..3f149b1 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -54,8 +54,6 @@ public class MTEVendingMachine extends MTEMultiBlockBase implements ISurvivalConstructable, ISecondaryDescribable, IAlignment { - public static final int CUSTOM_UI_HEIGHT = 300; - public static final int INPUT_SLOTS = 6; public static final int OUTPUT_SLOTS = 4; @@ -111,7 +109,6 @@ public void sendTradeRequest(TradeItemDisplay trade) { } public void addTradeRequest(TradeRequest trade) { - VendingMachine.LOG.info("received new trade request"); this.pendingTrades.add(trade); } @@ -283,12 +280,7 @@ protected boolean forceUseMui2() { NetAvailableTradeSync.requestSync(); NetTradeStateSync.requestSync(); } - return new MTEVendingMachineGui(this, CUSTOM_UI_HEIGHT); - } - - @Override - public int getGUIHeight() { - return CUSTOM_UI_HEIGHT; + return new MTEVendingMachineGui(this); } @Override diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index b5f3726..0dbde72 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -6,7 +6,6 @@ import com.cleanroommc.modularui.utils.item.ItemStackHandler; import com.cleanroommc.modularui.widgets.slot.ModularSlot; -import com.cubefury.vendingmachine.VendingMachine; import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync; import com.cubefury.vendingmachine.storage.NameCache; import com.cubefury.vendingmachine.trade.CurrencyItem; @@ -22,9 +21,8 @@ public InterceptingSlot(ItemStackHandler inputItems, int index) { public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) { CurrencyItem mapped = mapToCurrency(newItem); if (mapped != null) { - VendingMachine.LOG.info("intercept {} {}", newItem, player); - TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); if (!client) { + TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped); } else { MTEVendingMachineGui.setForceRefresh(); diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index e94a55d..a70bc7b 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -34,8 +34,11 @@ import com.cubefury.vendingmachine.blocks.MTEVendingMachine; import com.cubefury.vendingmachine.gui.GuiTextures; import com.cubefury.vendingmachine.gui.WidgetThemes; +import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.TradeCategory; import com.cubefury.vendingmachine.trade.TradeDatabase; +import com.cubefury.vendingmachine.trade.TradeManager; import com.cubefury.vendingmachine.util.BigItemStack; import com.cubefury.vendingmachine.util.Translator; @@ -46,7 +49,6 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { private final MTEVendingMachine base; - private final int height; public static boolean forceRefresh = false; @@ -58,15 +60,17 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { private PagedWidget.Controller tabController; private SearchBar searchBar; + public static final int CUSTOM_UI_HEIGHT = 320; + public static final int ITEMS_PER_ROW = 3; public static final int ITEM_HEIGHT = 25; public static final int ITEM_WIDTH = 47; - private static final int ROW_SEPARATOR_HEIGHT = 5; + private static final int COIN_COLUMN_WIDTH = 40; + private static final int COIN_COLUMN_ROW_COUNT = 4; - public MTEVendingMachineGui(MTEVendingMachine base, int height) { + public MTEVendingMachineGui(MTEVendingMachine base) { super(base); this.base = base; - this.height = height; this.tradeCategories.add(TradeCategory.ALL); this.tradeCategories.addAll(TradeDatabase.INSTANCE.getTradeCategories()); @@ -96,7 +100,8 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe this.guiData = guiData; registerSyncValues(syncManager); - ModularPanel panel = new TradeMainPanel("MTEMultiBlockBase", this, guiData, syncManager).size(178, height) + ModularPanel panel = new TradeMainPanel("MTEMultiBlockBase", this, guiData, syncManager) + .size(178, CUSTOM_UI_HEIGHT) .padding(4); panel.child(createCategoryTabs(this.tabController)); Flow mainColumn = new Column().width(170); @@ -104,6 +109,7 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe mainColumn.child(createTitleTextStyle(base.getLocalName())) .child(this.searchBar) .child(createTradeUI((TradeMainPanel) panel, this.tabController)); + mainColumn.child(createCoinInventoryRow()); } mainColumn.child(createInventoryRow(panel, syncManager)); panel.child(mainColumn); @@ -301,15 +307,17 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t .debugName("paged") .controller(tabController) .background(GuiTextures.TEXT_FIELD_BACKGROUND) - .heightRel(0.5f); + .height(146); for (TradeCategory category : this.tradeCategories) { - ListWidget tradeList = new ListWidget<>().debugName("items").heightRel(1.0f) + ListWidget tradeList = new ListWidget<>().debugName("items") .width(156) - .margin(1) + .top(1) + .height(144) .collapseDisabledChild(true); + tradeList.child(new Row().height(2)); // Higher first row top margin - Flow row = new TradeRow().height(ITEM_HEIGHT).margin(1).marginTop(4); + Flow row = new TradeRow().height(ITEM_HEIGHT+2).left(2); for (int i = 0; i < MTEVendingMachine.MAX_TRADES; i++) { int index = i; @@ -343,7 +351,7 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t if (i % ITEMS_PER_ROW == ITEMS_PER_ROW - 1) { tradeList.child(row); - row = new TradeRow().height(ITEM_HEIGHT).margin(1); + row = new TradeRow().height(ITEM_HEIGHT+2).left(2); } } if (row.hasChildren()) { @@ -359,6 +367,54 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t } // spotless:on + private static String getReadableStringFromCoinAmount(int amount) { + if (amount < 10000) { + return "" + amount; + } else if (amount < 1000000) { + return amount / 1000 + "K"; + } else { + return amount / 1000000 + "M"; + } + } + + private IWidget createCoinInventoryRow() { + Flow parent = new Row() // .background(GuiTextures.TEXT_FIELD_BACKGROUND) + .width(162) + .height(36) + .top(172) + .left(3); + Flow coinColumn = new Column().width(COIN_COLUMN_WIDTH); + int coinCount = 0; + Map currentAmount = TradeManager.INSTANCE.playerCurrency + .getOrDefault(NameCache.INSTANCE.getUUIDFromPlayer(getBase().getCurrentUser()), new HashMap<>()); + for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) { + coinColumn.child( + new Row().child( + type.texture.asWidget() + .size(12) + .left(0) + .addTooltipLine(type.getLocalizedName())) + .child( + IKey.dynamic( + () -> getReadableStringFromCoinAmount( + currentAmount.get(type) == null ? 0 : currentAmount.get(type))) + .scale(0.8f) + .asWidget() + .top(3) + .left(14) + .width(21)) + .height(14)); + if (++coinCount % COIN_COLUMN_ROW_COUNT == 0) { + parent.child(coinColumn.left(3 + COIN_COLUMN_WIDTH * (coinCount / COIN_COLUMN_ROW_COUNT - 1))); + coinColumn = new Column().width(COIN_COLUMN_WIDTH); + } + } + if (coinColumn.hasChildren()) { + parent.child(coinColumn.left(3 + COIN_COLUMN_WIDTH * (coinCount / COIN_COLUMN_ROW_COUNT))); + } + return parent; + } + // why is the original method private lmao private IWidget createInventoryRow(ModularPanel panel, PanelSyncManager syncManager) { return new Row().widthRel(1) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java index a40be03..65641ef 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplayWidget.java @@ -63,7 +63,14 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) { GuiDraw.drawOutline(1, 1, 45, 23, 0x883CFF00, 2); } if (this.display.hasCooldown || !this.display.enabled) { - GuiDraw.drawRoundedRect(1, 1, 45, 23, 0xBB000000, 1, 1); + GuiDraw.drawRoundedRect( + 1, + 1, + MTEVendingMachineGui.ITEM_WIDTH - 2, + MTEVendingMachineGui.ITEM_HEIGHT - 2, + 0xBB000000, + 1, + 1); } this.overlay( IKey.str(display.hasCooldown ? this.display.cooldownText : "") diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index e692159..6b7a937 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -257,7 +257,7 @@ public void attemptPurchase(TradeItemDisplay display) { public void dispose() { this.gui.getBase() .resetUse(); - // We have to sync reset use manually since onClose() is only run client-side + // We have to sync reset use manually since dispose() is only run client-side NetResetVMUser.sendReset(this.gui.getBase()); super.dispose(); } diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java index f171930..3f854b9 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java @@ -1,5 +1,7 @@ package com.cubefury.vendingmachine.network.handlers; +import java.util.Collections; + import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; @@ -11,8 +13,10 @@ import com.cubefury.vendingmachine.api.network.UnserializedPacket; import com.cubefury.vendingmachine.api.util.Tuple2; import com.cubefury.vendingmachine.blocks.MTEVendingMachine; +import com.cubefury.vendingmachine.handlers.SaveLoadHandler; import com.cubefury.vendingmachine.network.PacketSender; import com.cubefury.vendingmachine.network.PacketTypeRegistry; +import com.cubefury.vendingmachine.storage.NameCache; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; @@ -55,5 +59,7 @@ public static void onServer(Tuple2 message) { ) { ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetUse(); } + SaveLoadHandler.INSTANCE + .writeTradeState(Collections.singleton(NameCache.INSTANCE.getUUIDFromPlayer(message.second()))); } } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java index 615b52c..888d058 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java @@ -7,6 +7,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import com.cleanroommc.modularui.drawable.UITexture; +import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.util.Translator; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class CurrencyItem { public CurrencyType type; @@ -28,35 +35,47 @@ public void writeToNBT(NBTTagCompound payload) { public enum CurrencyType { - ADVENTURE("adventure", "dreamcraft:item.CoinAdventure"), - BEES("bees", "dreamcraft:item.CoinBees"), - BLOOD("blood", "dreamcraft:item.CoinBlood"), - CHEMIST("chemist", "dreamcraft:item.CoinChemist"), - COOK("cook", "dreamcraft:item.CoinCook"), - DARK_WIZARD("darkWizard", "dreamcraft:item.CoinDarkWizard"), - FARMER("farmer", "dreamcraft:item.CoinFarmer"), - FLOWER("flower", "dreamcraft:item.CoinFlower"), - FORESTRY("forestry", "dreamcraft:item.CoinForestry"), - SMITH("smith", "dreamcraft:item.CoinSmith"), - WITCH("witch", "dreamcraft:item.CoinWitch"), - SPACE("space", "dreamcraft:item.CoinSpace"), - SURVIVOR("survivor", "dreamcraft:item.CoinSurvivor"), - TECHNICIAN("technician", "dreamcraft:item.CoinTechnician"), + ADVENTURE("adventure", "dreamcraft:item.CoinAdventure", "gui/icons/itemCoinAdventure.png"), + BEES("bees", "dreamcraft:item.CoinBees", "gui/icons/itemCoinBees.png"), + BLOOD("blood", "dreamcraft:item.CoinBlood", "gui/icons/itemCoinBlood.png"), + CHEMIST("chemist", "dreamcraft:item.CoinChemist", "gui/icons/itemCoinChemist.png"), + COOK("cook", "dreamcraft:item.CoinCook", "gui/icons/itemCoinCook.png"), + DARK_WIZARD("darkWizard", "dreamcraft:item.CoinDarkWizard", "gui/icons/itemCoinDarkWizard.png"), + FARMER("farmer", "dreamcraft:item.CoinFarmer", "gui/icons/itemCoinFarmer.png"), + FLOWER("flower", "dreamcraft:item.CoinFlower", "gui/icons/itemCoinFlower.png"), + FORESTRY("forestry", "dreamcraft:item.CoinForestry", "gui/icons/itemCoinForestry.png"), + SMITH("smith", "dreamcraft:item.CoinSmith", "gui/icons/itemCoinSmith.png"), + SPACE("space", "dreamcraft:item.CoinSpace", "gui/icons/itemCoinSpace.png"), + SURVIVOR("survivor", "dreamcraft:item.CoinSurvivor", "gui/icons/itemCoinSurvivor.png"), + TECHNICIAN("technician", "dreamcraft:item.CoinTechnician", "gui/icons/itemCoinTechnician.png"), + WITCH("witch", "dreamcraft:item.CoinWitch", "gui/icons/itemCoinWitch.png"), // comment before semicolon to reduce merge conflicts ; public final String id; public final String itemPrefix; + public final UITexture texture; - CurrencyType(String id, String itemPrefix) { + CurrencyType(String id, String itemPrefix, String texture) { this.id = id; this.itemPrefix = itemPrefix; + this.texture = UITexture.builder() + .location(VendingMachine.MODID, texture) + .imageSize(32, 32) + .name("VM_UI_Coin_" + id) + .build(); + typeMap.put(this.id, this); } public static CurrencyType getTypeFromId(String type) { return typeMap.get(type); } + + @SideOnly(Side.CLIENT) + public String getLocalizedName() { + return Translator.translate("vendingmachine.coin." + this.id); + } } public CurrencyItem(CurrencyType type, int value) { diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java index 205447f..0981c40 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java @@ -24,7 +24,7 @@ public class TradeManager { private final Map> availableTrades = new HashMap<>(); - private final Map> playerCurrency = new HashMap<>(); + public final Map> playerCurrency = new HashMap<>(); // For writeback to file in original format, to prevent data loss private final Map> invalidCurrency = new HashMap<>(); @@ -184,7 +184,5 @@ public void addCurrency(UUID playerId, CurrencyItem mapped) { .get(mapped.type) + mapped.value); this.hasCurrencyUpdate = true; VendingMachine.LOG.info("currency received: {} {}", mapped.type.id, mapped.value); - - // TODO: Implement scheduled write } } diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang index 8e128f8..37b32a0 100644 --- a/src/main/resources/assets/vendingmachine/lang/en_US.lang +++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang @@ -31,3 +31,18 @@ vendingmachine.category.chemistry=Chemistry vendingmachine.category.magic=Magic vendingmachine.category.bees=Bees vendingmachine.category.misc=Miscellaneous + +vendingmachine.coin.adventure=Adventure +vendingmachine.coin.bees=Bees +vendingmachine.coin.blood=Blood Magic +vendingmachine.coin.chemist=Chemistry +vendingmachine.coin.cook=Cook +vendingmachine.coin.darkWizard=Dark Wizard +vendingmachine.coin.farmer=Farming +vendingmachine.coin.flower=Flower +vendingmachine.coin.forestry=Forestry +vendingmachine.coin.smith=Smith +vendingmachine.coin.space=Space +vendingmachine.coin.survivor=Survivor +vendingmachine.coin.technician=Technician +vendingmachine.coin.witch=Witchery diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinAdventure.png new file mode 100644 index 0000000000000000000000000000000000000000..ec3bc2cd643bf2502fac92712e718f596a4d4bf4 GIT binary patch literal 3166 zcmV-k459OhP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6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ources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinBees.png new file mode 100644 index 0000000000000000000000000000000000000000..98e159d6cb0643ce044b3c8acb57aa525c60ac08 GIT binary patch literal 3187 zcmV-(42<)MP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3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_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0005eNkl#QcAq&a8s20 zVRl^#FYyA@S)v?);*5s}N(a2S@)LS~>&Am4wbtj;@eQ+`_mvOP&))$j# zydH3BUuov$R-5WZsIt=OXXU4}VsI>Oi>NBBU zFoF=zc|RS_z7-MZ+=Bk;F*F4f6^24^umDQ<3rb+EfI2w^O&UfLEEALf^mW3v`UM6O zEx`D1czz<21iJuc9-5oL2-Mg>_maj)4-gC@V==Nx$Qh8hht~{rD6ku@p@F}d0;=8x z(J0Y#$QtnS2xqS<=P7tJ;n*WoPpi`fNL(bbclL-~LLP;*CCFiMXF|e;7wqa>MxSZW zR5*%TNE<{RRAC{-JNh4OVAwF2ukl@Q8-{%ZDJ0hjG)*$0!^s2u(qMVN#&NnhC2l7r52F@n=G}8P4xi{QqV2{RsT?uj97? Y0It8r*Q)^)hX4Qo07*qoM6N<$f*X?lD*ylh literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinChemist.png new file mode 100644 index 0000000000000000000000000000000000000000..c5f2ca3efc31a120e1a87d941c5c52bb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lfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0003&Nkl{CjLHuQn9$&&l z28GkHt3x*zW-nPG@P0Z213T2B6eRKP5t#;f2igI3X#6I6JD`*T%SY1y0|NsC3#?2= zZwC-t9uS)baMcA=O#`Fl07VWUH!ToK1GwUzCgngkHKPDm8?HZ-fuU(S!t$RC3=Hg0 z%ljD_82U3%TgJG|Av*+MO|eF_YIgz?14C0f1B0^}oq9%lPa*1mSewAvjP#xn*=Ydg k(@SQQr6I-<-#Z2j01iEWM=JH*hyVZp07*qoM6N<$f)^&H>;M1& literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinCook.png new file mode 100644 index 0000000000000000000000000000000000000000..a39e441552ae4482ee3611b8f9a7e7f87e8ffbc5 GIT binary patch literal 3094 zcmV+x4C(WUP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZH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B$tu_YjGLjgBK?GpThV}UwlmUyr_JgH};(6C;kS91P zJf}+B5<5L0iC~pvYHE8ZDm%kK=VLq*4s-!OsVQ@4vp4|wB)??)qDl-b!zA2_T>ytK zWV15IfYm<1@dK+lccq?=&Tcw-oK#h}BZ*Ka-ax@ivK|shCV(2d0EV5D#K-AydlVYm zY#34#dHiaCR*M6>(+$8j!Nk$?o4Nhr7@v8{P0=)U4rntuSO;i*`_3%kba^ml>-pF} z%DCH4x*>_CF6k$>_dEp^FW1D9usR|5E|?Mr`i5LIw%JevuxwE(Y7oL5+~HE)KK3MB zWt(7%Z5L=kfS(M(NoVhm-@aQKd0g@*lEeZw2)l42(JsD;?OhORz^M3n&E;?FBdirB zaN{6DAmUI8sR@5q5lyxBvtJX2(s0qL;{PwBzYl?b{&oCy0LPzcxp?QIRsaA107*qo IM6N<$g02CR%>V!Z literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFarmer.png new file mode 100644 index 0000000000000000000000000000000000000000..bd1661f5cd661a77a95f9c2c786502b98cdb660a GIT binary patch literal 3348 zcmV+v4eRoWP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o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t^lljaTKGk1 z3wt@ol4pv0_g`Z?X*h&NA(@r~lkSQj2+S{D98AMBj2J>~tg2s(t_Ogw1xiZnxt9Kcl~o efq(vY{9^#R_YWUe>EkT`0000 literal 0 HcmV?d00001 diff --git a/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinFlower.png new file mode 100644 index 0000000000000000000000000000000000000000..ce3c23a765836b09c97a85ba05ca66097758f9d0 GIT binary patch literal 905 zcmV;419tq0P)EX>4Tx04R}tkv&MmKpe$i(@I4u3U&~2$WWauh>AFB6^c+H)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1le0HIM~niU!cG~G7S z$%L5At%~7S2nZpHegtG@8FP}9g75gcM}V()ah~OW?$6Py<}C&UMB-Uym^SeS@${x` zaNZ}5vXZP4pA(OnbV1@rt}7nDaW1+n@XV;0NzW5UiN#_ED;>;ArbawP98)!&@`bF& zD(5ZETBXKX_v9~(hC`$Ekp)i2oUnIlo);kpS>b2L>KSJ@c#2#IQ#kACveN(J^P3vN7E?y_2xf=+fhCSNnsgCj`;bV;p>mj47;p9 z(Z>Nletl<QKH48MN=V&LQEXIQ9ljed2(F6&PW z&)+_QCq_0AM*5cnu(ZIyz`!tDMP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$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or.png b/src/main/resources/assets/vendingmachine/textures/gui/icons/itemCoinSurvivor.png new file mode 100644 index 0000000000000000000000000000000000000000..1c3362a9f905ea14f7ebc6b572752ab08f6a68d0 GIT binary patch literal 3084 zcmV+n4D<7eP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`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z0004bNklwdk$w|6r{R*t}0)rO9|DdM73oi8FWyd2Qnw~hStW*X5 zg0_PWn;2(ihzMNQEj{OX9+GkLNkQ*9pqoz|$M8IFVLursm_N;PYfU-O`Yi~fAlH1f z==)_6e>dLwEtpPbP)aSdU?Kt$fthm-HbrhlfmRwuLF1XF_5o8PRx@Fjx1r4(F#J|r oHN$nCivNE`zYl>w|2zH|0N*XPd6_^HNdN!<07*qoM6N<$f@5*hz5oCK literal 0 HcmV?d00001 From c51247b9ea4780b1b40809c04d22099ebd7eca3e Mon Sep 17 00:00:00 2001 From: cubefury Date: Fri, 19 Sep 2025 20:32:57 +0800 Subject: [PATCH 06/14] Removed player from VM current user when disconnect/death --- .../blocks/MTEVendingMachine.java | 6 ++- .../blocks/gui/TradeMainPanel.java | 2 +- .../vendingmachine/handlers/EventHandler.java | 46 +++++++++++++++++++ .../network/handlers/NetResetVMUser.java | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index 3f149b1..ee184be 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -504,7 +504,9 @@ public EntityPlayer getCurrentUser() { return this.currentUser; } - public void resetUse() { - this.currentUser = null; + public void resetCurrentUser(EntityPlayer aPlayer) { + if (this.currentUser == aPlayer) { + this.currentUser = null; + } } } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index 6b7a937..5755ac7 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -256,7 +256,7 @@ public void attemptPurchase(TradeItemDisplay display) { @Override public void dispose() { this.gui.getBase() - .resetUse(); + .resetCurrentUser(this.player); // We have to sync reset use manually since dispose() is only run client-side NetResetVMUser.sendReset(this.gui.getBase()); super.dispose(); diff --git a/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java b/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java index c5c2dbd..06febcf 100644 --- a/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java +++ b/src/main/java/com/cubefury/vendingmachine/handlers/EventHandler.java @@ -1,17 +1,26 @@ package com.cubefury.vendingmachine.handlers; import java.util.ArrayDeque; +import java.util.Collections; import java.util.UUID; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; +import javax.annotation.Nonnull; + +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; import net.minecraft.server.integrated.IntegratedServer; +import net.minecraft.tileentity.TileEntity; +import net.minecraftforge.event.entity.living.LivingDeathEvent; import org.apache.commons.lang3.Validate; +import com.cleanroommc.modularui.factory.PosGuiData; +import com.cleanroommc.modularui.screen.ModularContainer; import com.cubefury.vendingmachine.VendingMachine; +import com.cubefury.vendingmachine.blocks.MTEVendingMachine; import com.cubefury.vendingmachine.events.MarkDirtyDbEvent; import com.cubefury.vendingmachine.events.MarkDirtyNamesEvent; import com.cubefury.vendingmachine.network.handlers.NetBulkSync; @@ -24,6 +33,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import cpw.mods.fml.common.gameevent.TickEvent; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; public class EventHandler { @@ -72,6 +82,18 @@ public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) { UUID playerId = NameCache.INSTANCE.getUUIDFromPlayer(mpPlayer); } + @SubscribeEvent + public void onPlayerLogout(PlayerEvent.PlayerLoggedOutEvent event) { + terminateVendingSession(event.player); + } + + @SubscribeEvent + public void onPlayerDeath(LivingDeathEvent event) { + if (event.entityLiving instanceof EntityPlayer) { + terminateVendingSession((EntityPlayer) event.entityLiving); + } + } + @SuppressWarnings("UnstableApiUsage") public static ListenableFuture scheduleServerTask(Callable task) { Validate.notNull(task); @@ -123,4 +145,28 @@ public void onServerTick(TickEvent.ServerTickEvent event) { } } + private void terminateVendingSession(@Nonnull EntityPlayer player) { + VendingMachine.LOG.info("terminating session for {}", player); + if (VendingMachine.proxy.isClient()) { + return; + } + if ( + !(player.openContainer instanceof ModularContainer + && ((ModularContainer) player.openContainer).getGuiData() instanceof PosGuiData) + ) { + return; + } + TileEntity te = ((PosGuiData) ((ModularContainer) player.openContainer).getGuiData()).getTileEntity(); + + if ( + te instanceof IGregTechTileEntity + && ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MTEVendingMachine + ) { + VendingMachine.LOG.info("found VM MTE terminating session for {}", player); + ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetCurrentUser(player); + SaveLoadHandler.INSTANCE + .writeTradeState(Collections.singleton(NameCache.INSTANCE.getUUIDFromPlayer(player))); + } + } + } diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java index 3f854b9..b47ec77 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetResetVMUser.java @@ -57,7 +57,7 @@ public static void onServer(Tuple2 message) { te instanceof IGregTechTileEntity && ((IGregTechTileEntity) te).getMetaTileEntity() instanceof MTEVendingMachine ) { - ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetUse(); + ((MTEVendingMachine) ((IGregTechTileEntity) te).getMetaTileEntity()).resetCurrentUser(message.second()); } SaveLoadHandler.INSTANCE .writeTradeState(Collections.singleton(NameCache.INSTANCE.getUUIDFromPlayer(message.second()))); From a3bf7a88ec072b9588e891283b636727ace67441 Mon Sep 17 00:00:00 2001 From: cubefury Date: Fri, 19 Sep 2025 22:34:02 +0800 Subject: [PATCH 07/14] Changed writeback of placeholders to original item name when it was loaded. --- .../cubefury/vendingmachine/ClientProxy.java | 8 ------- .../cubefury/vendingmachine/CommonProxy.java | 5 ---- .../vendingmachine/util/BigItemStack.java | 24 +++++++++++++------ .../vendingmachine/util/ItemPlaceholder.java | 12 +++++----- 4 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/main/java/com/cubefury/vendingmachine/ClientProxy.java b/src/main/java/com/cubefury/vendingmachine/ClientProxy.java index 2e6bd39..a64f4a3 100644 --- a/src/main/java/com/cubefury/vendingmachine/ClientProxy.java +++ b/src/main/java/com/cubefury/vendingmachine/ClientProxy.java @@ -1,11 +1,9 @@ package com.cubefury.vendingmachine; -import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; import com.cubefury.vendingmachine.integration.nei.NEIConfig; -import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -28,12 +26,6 @@ public boolean isClient() { return true; } - @Override - public EntityPlayer getThePlayer() { - return FMLClientHandler.instance() - .getClientPlayerEntity(); - } - @Override public void registerHandlers() { super.registerHandlers(); diff --git a/src/main/java/com/cubefury/vendingmachine/CommonProxy.java b/src/main/java/com/cubefury/vendingmachine/CommonProxy.java index a075743..fe27b2d 100644 --- a/src/main/java/com/cubefury/vendingmachine/CommonProxy.java +++ b/src/main/java/com/cubefury/vendingmachine/CommonProxy.java @@ -2,7 +2,6 @@ import net.minecraft.command.ICommandManager; import net.minecraft.command.ServerCommandManager; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.server.MinecraftServer; import net.minecraftforge.common.MinecraftForge; @@ -49,8 +48,4 @@ public void registerHandlers() { .bus() .register(EventHandler.INSTANCE); } - - public EntityPlayer getThePlayer() { - return null; - } } diff --git a/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java b/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java index adeef95..0dc391e 100644 --- a/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java +++ b/src/main/java/com/cubefury/vendingmachine/util/BigItemStack.java @@ -94,14 +94,14 @@ public BigItemStack setOreDict(@Nonnull String ore) { /** * Shortcut method to the NBTTagCompound in the base ItemStack */ - public NBTTagCompound GetTagCompound() { + public NBTTagCompound getTagCompound() { return baseStack.getTagCompound(); } /** * Shortcut method to the NBTTagCompound in the base ItemStack */ - public void SetTagCompound(NBTTagCompound tags) { + public void setTagCompound(NBTTagCompound tags) { baseStack.setTagCompound(tags); } @@ -109,7 +109,7 @@ public void SetTagCompound(NBTTagCompound tags) { * Shortcut method to the NBTTagCompound in the base ItemStack */ @SuppressWarnings("WeakerAccess") - public boolean HasTagCompound() { + public boolean hasTagCompound() { return baseStack.hasTagCompound(); } @@ -186,14 +186,24 @@ public static BigItemStack loadItemStackFromNBT(@Nonnull NBTTagCompound nbt) // BigItemStack bigStack = new BigItemStack(miniStack); bigStack.stackSize = nbt.getInteger("Count"); bigStack.setOreDict(nbt.getString("OreDict")); - if (nbt.getShort("Damage") < 0) bigStack.baseStack.setItemDamage(OreDictionary.WILDCARD_VALUE); + if (nbt.getInteger("Damage") < 0) bigStack.baseStack.setItemDamage(OreDictionary.WILDCARD_VALUE); return bigStack; } public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - baseStack.writeToNBT(nbt); - String iRes = Item.itemRegistry.getNameForObject(baseStack.getItem()); - nbt.setString("id", iRes == null ? "vendingmachine.placeholder" : iRes); + String itemName = Item.itemRegistry.getNameForObject(this.baseStack.getItem()); + NBTTagCompound backupData = this.getTagCompound(); + if (itemName.equals("vendingmachine:placeholder") && backupData != null) { + nbt.setString("id", backupData.getString("orig_id")); + nbt.setInteger("Damage", backupData.getInteger("orig_meta")); + if (backupData.hasKey("orig_tag")) { + nbt.setTag("tag", backupData.getCompoundTag("orig_tag")); + } + } else { + baseStack.writeToNBT(nbt); + String iRes = Item.itemRegistry.getNameForObject(baseStack.getItem()); + nbt.setString("id", iRes == null ? "vendingmachine:placeholder" : iRes); + } nbt.setInteger("Count", this.stackSize); nbt.setString("OreDict", this.getOreDict()); return nbt; diff --git a/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java b/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java index 5f3a3cd..9caac56 100644 --- a/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java +++ b/src/main/java/com/cubefury/vendingmachine/util/ItemPlaceholder.java @@ -26,13 +26,13 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count NBTTagCompound nbt) { if (item == null) { BigItemStack stack = new BigItemStack(ItemPlaceholder.placeholder, count, damage); - stack.SetTagCompound(new NBTTagCompound()); - stack.GetTagCompound() + stack.setTagCompound(new NBTTagCompound()); + stack.getTagCompound() .setString("orig_id", name); - stack.GetTagCompound() + stack.getTagCompound() .setInteger("orig_meta", damage); if (nbt != null) { - stack.GetTagCompound() + stack.getTagCompound() .setTag("orig_tag", nbt); } return stack; @@ -53,7 +53,7 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count count, nbt.hasKey("orig_meta") ? nbt.getInteger("orig_meta") : damage).setOreDict(oreDict); if (nbt.hasKey("orig_tag")) { - stack.SetTagCompound(nbt.getCompoundTag("orig_tag")); + stack.setTagCompound(nbt.getCompoundTag("orig_tag")); } return stack; @@ -65,7 +65,7 @@ public static BigItemStack getBigItemStackFrom(Item item, String name, int count } BigItemStack stack = new BigItemStack(item, count, damage).setOreDict(oreDict); if (nbt != null) { - stack.SetTagCompound(nbt); + stack.setTagCompound(nbt); } return stack; From 60df75d18f41af95d9ee912ff715d1edd518b723 Mon Sep 17 00:00:00 2001 From: cubefury Date: Sat, 20 Sep 2025 03:45:52 +0800 Subject: [PATCH 08/14] Implemented Trade with currency items. --- .../blocks/MTEVendingMachine.java | 28 +++++++ .../blocks/gui/MTEVendingMachineGui.java | 13 ++- .../blocks/gui/TradeItemDisplay.java | 82 ++----------------- .../blocks/gui/TradeMainPanel.java | 20 ++++- .../blocks/gui/TradeQueueAdapter.java | 57 ------------- .../vendingmachine/trade/CurrencyItem.java | 3 +- .../cubefury/vendingmachine/trade/Trade.java | 37 +++++++-- .../vendingmachine/trade/TradeDatabase.java | 3 +- .../cubefury/vendingmachine/util/FileIO.java | 2 +- .../assets/vendingmachine/lang/en_US.lang | 28 +++---- 10 files changed, 109 insertions(+), 164 deletions(-) delete mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index ee184be..1025780 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -3,6 +3,8 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.lazy; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; +import java.util.HashMap; +import java.util.Map; import java.util.Queue; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -25,8 +27,11 @@ import com.cubefury.vendingmachine.network.handlers.NetAvailableTradeSync; import com.cubefury.vendingmachine.network.handlers.NetTradeRequestSync; import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync; +import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.Trade; import com.cubefury.vendingmachine.trade.TradeDatabase; +import com.cubefury.vendingmachine.trade.TradeManager; import com.cubefury.vendingmachine.trade.TradeRequest; import com.cubefury.vendingmachine.util.BigItemStack; import com.gtnewhorizon.structurelib.StructureLibAPI; @@ -198,6 +203,21 @@ private boolean processTradeOnServer(TradeRequest tradeRequest) { Trade trade = TradeDatabase.INSTANCE.getTradeGroupFromId(tradeRequest.tradeGroup) .getTrades() .get(tradeRequest.tradeGroupOrder); + Map coinInventory = TradeManager.INSTANCE.playerCurrency + .get(NameCache.INSTANCE.getUUIDFromPlayer(this.getCurrentUser())); + Map newCoinInventory = new HashMap<>(); + if (coinInventory == null) { + return false; + } + for (CurrencyItem ci : trade.fromCurrency) { + int oldValue = coinInventory.get(ci.type); + if (!coinInventory.containsKey(ci.type) || oldValue < ci.value) { + return false; + } else { + newCoinInventory.put(ci.type, oldValue - ci.value); + } + } + for (BigItemStack stack : trade.fromItems) { ItemStack requiredStack = stack.getBaseStack(); int requiredAmount = stack.stackSize; @@ -226,6 +246,14 @@ private boolean processTradeOnServer(TradeRequest tradeRequest) { } } + for (Map.Entry entry : newCoinInventory.entrySet()) { + if (entry.getValue() == 0) { + coinInventory.remove(entry.getKey()); + } else { + coinInventory.replace(entry.getKey(), entry.getValue()); + } + } + for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) { this.inputItems.setStackInSlot(i, inputSlots[i]); } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index a70bc7b..8d4c660 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -335,6 +335,9 @@ private IWidget createTradeUI(TradeMainPanel rootPanel, PagedWidget.Controller t } builder.emptyLine(); builder.addLine(IKey.str(Translator.translate("vendingmachine.gui.required_inputs")).style(IKey.DARK_GREEN, IKey.ITALIC)); + for (CurrencyItem currencyItem: cur.fromCurrency) { + builder.addLine(IKey.str(currencyItem.value + " " + currencyItem.type.getLocalizedName()).style(IKey.DARK_GREEN)); + } for (BigItemStack fromItem : cur.fromItems) { builder.addLine(IKey.str(fromItem.stackSize + " " + fromItem.getBaseStack().getDisplayName()).style(IKey.DARK_GREEN)); } @@ -385,7 +388,7 @@ private IWidget createCoinInventoryRow() { .left(3); Flow coinColumn = new Column().width(COIN_COLUMN_WIDTH); int coinCount = 0; - Map currentAmount = TradeManager.INSTANCE.playerCurrency + Map currentAmounts = TradeManager.INSTANCE.playerCurrency .getOrDefault(NameCache.INSTANCE.getUUIDFromPlayer(getBase().getCurrentUser()), new HashMap<>()); for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) { coinColumn.child( @@ -393,11 +396,15 @@ private IWidget createCoinInventoryRow() { type.texture.asWidget() .size(12) .left(0) - .addTooltipLine(type.getLocalizedName())) + .tooltipDynamic((builder) -> { + builder.clearText(); + builder.addLine(currentAmounts.getOrDefault(type, 0) + " " + type.getLocalizedName()); + builder.setAutoUpdate(true); + })) .child( IKey.dynamic( () -> getReadableStringFromCoinAmount( - currentAmount.get(type) == null ? 0 : currentAmount.get(type))) + currentAmounts.get(type) == null ? 0 : currentAmounts.get(type))) .scale(0.8f) .asWidget() .top(3) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java index 95548c0..1845e84 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeItemDisplay.java @@ -1,21 +1,18 @@ package com.cubefury.vendingmachine.blocks.gui; -import java.util.ArrayList; import java.util.List; import java.util.UUID; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.util.BigItemStack; -import com.cubefury.vendingmachine.util.NBTConverter; import codechicken.nei.api.ItemFilter; public class TradeItemDisplay { + public List fromCurrency; public List fromItems; public List toItems; public ItemStack display; @@ -28,9 +25,10 @@ public class TradeItemDisplay { public boolean enabled; public boolean tradeableNow; - public TradeItemDisplay(List fromItems, List toItems, ItemStack display, UUID tgID, - int tradeGroupOrder, String label, long cooldown, String cooldownText, boolean hasCooldown, boolean enabled, - boolean tradeableNow) { + public TradeItemDisplay(List fromCurrency, List fromItems, List toItems, + ItemStack display, UUID tgID, int tradeGroupOrder, String label, long cooldown, String cooldownText, + boolean hasCooldown, boolean enabled, boolean tradeableNow) { + this.fromCurrency = fromCurrency; this.fromItems = fromItems; this.toItems = toItems; this.display = display; @@ -44,74 +42,6 @@ public TradeItemDisplay(List fromItems, List toItems this.tradeableNow = tradeableNow; } - public static TradeItemDisplay readFromNBT(NBTTagCompound nbt) { - List newFromItems = new ArrayList<>(); - NBTTagList fromItemsList = nbt.getTagList("fromItems", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < fromItemsList.tagCount(); i++) { - newFromItems.add(BigItemStack.loadItemStackFromNBT(fromItemsList.getCompoundTagAt(i))); - } - List newToItems = new ArrayList<>(); - NBTTagList toItemsList = nbt.getTagList("toItems", Constants.NBT.TAG_COMPOUND); - for (int i = 0; i < fromItemsList.tagCount(); i++) { - newToItems.add(BigItemStack.loadItemStackFromNBT(toItemsList.getCompoundTagAt(i))); - } - return new TradeItemDisplay( - newFromItems, - newToItems, - ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("display")), - NBTConverter.UuidValueType.TRADEGROUP.readId(nbt), - nbt.getInteger("tradeGroupOrder"), - nbt.getString("label"), - nbt.getLong("cooldown"), - nbt.getString("cooldownText"), - nbt.getBoolean("hasCooldown"), - nbt.getBoolean("enabled"), - nbt.getBoolean("tradeableNow")); - } - - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - NBTTagList fromItemsNBT = new NBTTagList(); - for (BigItemStack bis : this.fromItems) { - fromItemsNBT.appendTag(bis.writeToNBT(new NBTTagCompound())); - } - nbt.setTag("fromItems", fromItemsNBT); - NBTTagList toItemsNBT = new NBTTagList(); - for (BigItemStack bis : this.toItems) { - toItemsNBT.appendTag(bis.writeToNBT(new NBTTagCompound())); - } - nbt.setTag("toItems", toItemsNBT); - nbt.setTag("display", this.display.writeToNBT(new NBTTagCompound())); - NBTConverter.UuidValueType.TRADEGROUP.writeId(this.tgID, nbt); - nbt.setInteger("tradeGroupOrder", this.tradeGroupOrder); - nbt.setString("label", this.label); - nbt.setLong("cooldown", this.cooldown); - nbt.setString("cooldownText", this.cooldownText); - nbt.setBoolean("hasCooldown", this.hasCooldown); - nbt.setBoolean("enabled", this.enabled); - nbt.setBoolean("tradeableNow", this.tradeableNow); - - return nbt; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof TradeItemDisplay)) { - return false; - } - TradeItemDisplay other = (TradeItemDisplay) obj; - return this.fromItems.equals(other.fromItems) && this.toItems.equals(other.toItems) - && ItemStack.areItemStacksEqual(this.display, other.display) - && ItemStack.areItemStackTagsEqual(this.display, other.display) - && this.tgID == other.tgID - && this.tradeGroupOrder == other.tradeGroupOrder - && this.label.equals(other.label) - && this.cooldown == other.cooldown - && this.cooldownText.equals(other.cooldownText) - && this.hasCooldown == other.hasCooldown - && this.enabled == other.enabled - && this.tradeableNow == other.tradeableNow; - } - public boolean satisfiesSearch(ItemFilter filter, String searchStringNoCase) { if (filter == null) { return this.label.toLowerCase() diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index 5755ac7..e9b5058 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -20,6 +20,7 @@ import com.cubefury.vendingmachine.blocks.MTEVendingMachine; import com.cubefury.vendingmachine.network.handlers.NetResetVMUser; import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.Trade; import com.cubefury.vendingmachine.trade.TradeCategory; import com.cubefury.vendingmachine.trade.TradeDatabase; @@ -68,7 +69,7 @@ public boolean onKeyRelease(char typedChar, int keyCode) { } public void updateGui() { - boolean test = true; + boolean test = false; if (test) { List testTGW = new ArrayList<>(); for (Map.Entry entry : TradeDatabase.INSTANCE.getTradeGroups() @@ -127,6 +128,18 @@ public ItemStack convertToItemStack(BigItemStack stack) { return display; } + public boolean checkCurrencySatisfied(List currencyItems, + Map availableItems) { + if (currencyItems == null) { + return true; + } + if (availableItems == null) { + return false; + } + return currencyItems.stream() + .allMatch(ci -> availableItems.containsKey(ci.type) && availableItems.get(ci.type) >= ci.value); + } + public boolean checkItemsSatisfied(List trade, Map availableItems) { for (BigItemStack bis : trade) { BigItemStack base = bis.copy(); @@ -173,6 +186,7 @@ public Map> formatTrades(List> formatTrades(List 0, tgw.enabled(), - checkItemsSatisfied(trade.fromItems, availableItems)); + checkItemsSatisfied(trade.fromItems, availableItems) && checkCurrencySatisfied( + trade.fromCurrency, + TradeManager.INSTANCE.playerCurrency.get(NameCache.INSTANCE.getUUIDFromPlayer(this.player)))); trades.get(category) .add(tid); diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java deleted file mode 100644 index 97d0f77..0000000 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeQueueAdapter.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.cubefury.vendingmachine.blocks.gui; - -import java.io.IOException; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Queue; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.network.PacketBuffer; - -import org.jetbrains.annotations.NotNull; - -import com.cleanroommc.modularui.utils.serialization.IByteBufAdapter; - -public class TradeQueueAdapter implements IByteBufAdapter> { - - @Override - public Queue deserialize(PacketBuffer buffer) throws IOException { - int size = buffer.readVarIntFromBuffer(); - Queue queue = new LinkedList<>(); - - for (int i = 0; i < size; i++) { - NBTTagCompound tag = buffer.readNBTTagCompoundFromBuffer(); - if (tag != null) { - queue.add(TradeItemDisplay.readFromNBT(tag)); - } - } - return queue; - } - - @Override - public void serialize(PacketBuffer buffer, Queue queue) throws IOException { - buffer.writeVarIntToBuffer(queue.size()); - for (TradeItemDisplay item : queue) { - buffer.writeNBTTagCompoundToBuffer(item.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public boolean areEqual(@NotNull Queue t1, @NotNull Queue t2) { - if (t1.size() != t2.size()) { - return false; - } - - Iterator it1 = t1.iterator(); - Iterator it2 = t2.iterator(); - - while (it1.hasNext() && it2.hasNext()) { - TradeItemDisplay d1 = it1.next(); - TradeItemDisplay d2 = it2.next(); - if (!d1.equals(d2)) { - return false; - } - } - return true; - } -} diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java index 888d058..8a055ef 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java @@ -28,9 +28,10 @@ public static CurrencyItem fromNBT(NBTTagCompound nbt) { return new CurrencyItem(type, nbt.getInteger("value")); } - public void writeToNBT(NBTTagCompound payload) { + public NBTTagCompound writeToNBT(NBTTagCompound payload) { payload.setString("type", this.type.id); payload.setInteger("value", this.value); + return payload; } public enum CurrencyType { diff --git a/src/main/java/com/cubefury/vendingmachine/trade/Trade.java b/src/main/java/com/cubefury/vendingmachine/trade/Trade.java index b0c2d51..a0f9a7c 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/Trade.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/Trade.java @@ -20,30 +20,51 @@ public class Trade { + public final List fromCurrency = new ArrayList<>(); public final List fromItems = new ArrayList<>(); public final List toItems = new ArrayList<>(); public BigItemStack displayItem = new BigItemStack(ItemPlaceholder.placeholder); public NBTTagCompound writeToNBT(NBTTagCompound nbt) { nbt.setTag("displayItem", displayItem.writeToNBT(new NBTTagCompound())); - NBTTagList fromItemsArray = new NBTTagList(); - for (BigItemStack stack : this.fromItems) { - fromItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound())); + + if (!this.fromCurrency.isEmpty()) { + NBTTagList fromCurrencyArray = new NBTTagList(); + for (CurrencyItem ci : this.fromCurrency) { + fromCurrencyArray.appendTag(ci.writeToNBT(new NBTTagCompound())); + } + nbt.setTag("fromCurrency", fromCurrencyArray); + } + + if (!this.fromItems.isEmpty()) { + NBTTagList fromItemsArray = new NBTTagList(); + for (BigItemStack stack : this.fromItems) { + fromItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound())); + } + nbt.setTag("fromItems", fromItemsArray); } - nbt.setTag("fromItems", fromItemsArray); - NBTTagList toItemsArray = new NBTTagList(); - for (BigItemStack stack : this.toItems) { - toItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound())); + if (!this.toItems.isEmpty()) { + NBTTagList toItemsArray = new NBTTagList(); + for (BigItemStack stack : this.toItems) { + toItemsArray.appendTag(JsonHelper.ItemStackToJson(stack, new NBTTagCompound())); + } + nbt.setTag("toItems", toItemsArray); } - nbt.setTag("toItems", toItemsArray); return nbt; } public void readFromNBT(NBTTagCompound nbt) { + fromCurrency.clear(); fromItems.clear(); toItems.clear(); + + NBTTagList currencyList = nbt.getTagList("fromCurrency", Constants.NBT.TAG_COMPOUND); + for (int i = 0; i < currencyList.tagCount(); i++) { + fromCurrency.add(CurrencyItem.fromNBT(currencyList.getCompoundTagAt(i))); + } + NBTTagList fromList = nbt.getTagList("fromItems", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < fromList.tagCount(); i++) { fromItems.add(JsonHelper.JsonToItemStack(fromList.getCompoundTagAt(i))); diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java index a31890c..a6e669a 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeDatabase.java @@ -103,8 +103,7 @@ public void readFromNBT(NBTTagCompound nbt, boolean merge) { } TradeManager.INSTANCE.recomputeAvailableTrades(null); - VendingMachine.LOG - .info("Loaded {} trade groups containing {} trade groups.", getTradeGroupCount(), getTradeCount()); + VendingMachine.LOG.info("Loaded {} trade groups containing {} trades.", getTradeGroupCount(), getTradeCount()); } public NBTTagCompound writeToNBT(NBTTagCompound nbt) { diff --git a/src/main/java/com/cubefury/vendingmachine/util/FileIO.java b/src/main/java/com/cubefury/vendingmachine/util/FileIO.java index 5185eea..54468bd 100644 --- a/src/main/java/com/cubefury/vendingmachine/util/FileIO.java +++ b/src/main/java/com/cubefury/vendingmachine/util/FileIO.java @@ -46,7 +46,7 @@ public static JsonObject ReadFromFile(File file) { return GSON.fromJson(br, JsonObject.class); } catch (Exception e) { VendingMachine.LOG.error("Error reading JSON from file: ", e); - File backup = new File(file.getParent(), "malformed_" + file.getName() + ".json"); + File backup = new File(file.getParent(), "malformed_" + file.getName()); VendingMachine.LOG.error("Creating backup at: {}", backup.getAbsolutePath()); CopyPaste(file, backup); diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang index 37b32a0..6df9fe1 100644 --- a/src/main/resources/assets/vendingmachine/lang/en_US.lang +++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang @@ -32,17 +32,17 @@ vendingmachine.category.magic=Magic vendingmachine.category.bees=Bees vendingmachine.category.misc=Miscellaneous -vendingmachine.coin.adventure=Adventure -vendingmachine.coin.bees=Bees -vendingmachine.coin.blood=Blood Magic -vendingmachine.coin.chemist=Chemistry -vendingmachine.coin.cook=Cook -vendingmachine.coin.darkWizard=Dark Wizard -vendingmachine.coin.farmer=Farming -vendingmachine.coin.flower=Flower -vendingmachine.coin.forestry=Forestry -vendingmachine.coin.smith=Smith -vendingmachine.coin.space=Space -vendingmachine.coin.survivor=Survivor -vendingmachine.coin.technician=Technician -vendingmachine.coin.witch=Witchery +vendingmachine.coin.adventure=Adventure Coin +vendingmachine.coin.bees=Bees Coin +vendingmachine.coin.blood=Blood Magic Coin +vendingmachine.coin.chemist=Chemistry Coin +vendingmachine.coin.cook=Cook Coin +vendingmachine.coin.darkWizard=Dark Wizard Coin +vendingmachine.coin.farmer=Farming Coin +vendingmachine.coin.flower=Flower Coin +vendingmachine.coin.forestry=Forestry Coin +vendingmachine.coin.smith=Smith Coin +vendingmachine.coin.space=Space Coin +vendingmachine.coin.survivor=Survivor Coin +vendingmachine.coin.technician=Technician Coin +vendingmachine.coin.witch=Witchery Coin From 852843b1846c5f5a7420b39f700c00e3d0c34087 Mon Sep 17 00:00:00 2001 From: cubefury Date: Sat, 20 Sep 2025 13:25:46 +0800 Subject: [PATCH 09/14] Added Coin Eject --- .../blocks/MTEVendingMachine.java | 33 ++++++ .../blocks/gui/InterceptingSlot.java | 2 +- .../blocks/gui/MTEVendingMachineGui.java | 99 +++++++++--------- .../vendingmachine/gui/GuiTextures.java | 6 ++ .../network/handlers/NetBulkSync.java | 1 + .../network/handlers/NetTradeStateSync.java | 16 +-- .../vendingmachine/trade/CurrencyItem.java | 34 ++++-- .../vendingmachine/trade/TradeManager.java | 25 +++-- .../assets/vendingmachine/lang/en_US.lang | 1 + .../textures/gui/overlay/coinEject.png | Bin 0 -> 927 bytes 10 files changed, 143 insertions(+), 74 deletions(-) create mode 100644 src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java index 1025780..5181784 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/MTEVendingMachine.java @@ -9,11 +9,13 @@ import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.LinkedBlockingQueue; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.ChatComponentTranslation; +import net.minecraft.world.World; import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.ForgeDirection; @@ -537,4 +539,35 @@ public void resetCurrentUser(EntityPlayer aPlayer) { this.currentUser = null; } } + + public void spawnItem(ItemStack stack) { + if (stack == null || this.getBaseMetaTileEntity() == null) { + return; + } + World world = this.getBaseMetaTileEntity() + .getWorld(); + int posX = this.getBaseMetaTileEntity() + .getXCoord(); + int posY = this.getBaseMetaTileEntity() + .getYCoord(); + int posZ = this.getBaseMetaTileEntity() + .getZCoord(); + int offsetX = this.getExtendedFacing() + .getDirection().offsetX; + int offsetY = this.getExtendedFacing() + .getDirection().offsetY; + int offsetZ = this.getExtendedFacing() + .getDirection().offsetZ; + final EntityItem itemEntity = new EntityItem( + world, + posX + offsetX * 0.5, + posY + offsetY * 0.5, + posZ + offsetZ * 0.5, + stack); + itemEntity.delayBeforeCanPickup = 0; + itemEntity.motionX = 0.05f * offsetX; + itemEntity.motionY = 0.05f * offsetY; + itemEntity.motionZ = 0.05f * offsetZ; + world.spawnEntityInWorld(itemEntity); + } } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index 0dbde72..0f4c994 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -22,7 +22,7 @@ public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) CurrencyItem mapped = mapToCurrency(newItem); if (mapped != null) { if (!client) { - TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); + TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped, true); NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped); } else { MTEVendingMachineGui.setForceRefresh(); diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index 8d4c660..e067c41 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -4,10 +4,11 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; import com.cleanroommc.modularui.api.drawable.IKey; @@ -34,6 +35,7 @@ import com.cubefury.vendingmachine.blocks.MTEVendingMachine; import com.cubefury.vendingmachine.gui.GuiTextures; import com.cubefury.vendingmachine.gui.WidgetThemes; +import com.cubefury.vendingmachine.network.handlers.NetTradeStateSync; import com.cubefury.vendingmachine.storage.NameCache; import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.TradeCategory; @@ -53,6 +55,7 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { public static boolean forceRefresh = false; private boolean ejectItems = false; + private boolean ejectCoins = false; private final Map> displayedTrades = new HashMap<>(); private final List tradeCategories = new ArrayList<>(); @@ -172,54 +175,40 @@ private SearchBar createSearchBar() { .height(10); } - private void ejectItems() { - if (!this.guiData.isClient()) { - if (base.getBaseMetaTileEntity() == null) { - VendingMachine.LOG.info("Unable to eject items as the base MTE for the Vending Machine was null."); - } else { - World world = base.getBaseMetaTileEntity() - .getWorld(); - int posX = base.getBaseMetaTileEntity() - .getXCoord(); - int posY = base.getBaseMetaTileEntity() - .getYCoord(); - int posZ = base.getBaseMetaTileEntity() - .getZCoord(); - int offsetX = base.getExtendedFacing() - .getDirection().offsetX; - int offsetY = base.getExtendedFacing() - .getDirection().offsetY; - int offsetZ = base.getExtendedFacing() - .getDirection().offsetZ; - for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) { - ItemStack stack = base.inputItems.getStackInSlot(i); - if (stack != null) { - ItemStack extracted = base.inputItems.extractItem(i, stack.stackSize, false); - if (extracted == null) { // if somehow it got pulled out already - continue; - } - final EntityItem itemEntity = new EntityItem( - world, - posX + offsetX * 0.5, - posY + offsetY * 0.5, - posZ + offsetZ * 0.5, - new ItemStack(extracted.getItem(), extracted.stackSize, extracted.getItemDamage())); - if (extracted.hasTagCompound()) { - itemEntity.getEntityItem() - .setTagCompound( - (NBTTagCompound) extracted.getTagCompound() - .copy()); - } - itemEntity.delayBeforeCanPickup = 0; - itemEntity.motionX = 0.05f * offsetX; - itemEntity.motionY = 0.05f * offsetY; - itemEntity.motionZ = 0.05f * offsetZ; - world.spawnEntityInWorld(itemEntity); - } + private void ejectItems(String type) { + if (this.guiData.isClient()) { + return; + } + if (type.equals("input")) { + for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) { + ItemStack stack = base.inputItems.getStackInSlot(i); + if (stack != null) { + base.inputItems.setStackInSlot(i, null); + base.spawnItem(stack.copy()); + } + } + ejectItems = false; + } else if (type.equals("coins")) { + UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser()); + if (!TradeManager.INSTANCE.playerCurrency.containsKey(currentUser)) { + ejectCoins = false; + return; + } + + Map coins = TradeManager.INSTANCE.playerCurrency + .getOrDefault(currentUser, new HashMap<>()); + for (Map.Entry entry : coins.entrySet()) { + for (ItemStack ejectable : new CurrencyItem(entry.getKey(), entry.getValue()).itemize()) { + base.spawnItem(ejectable); } } + TradeManager.INSTANCE.playerCurrency.get(currentUser) + .clear(); + NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser()); + ejectCoins = false; + } else { + VendingMachine.LOG.warn("Eject items called with unknown item type: {}", type); } - ejectItems = false; } private IWidget createIOColumn(PanelSyncManager syncManager) { @@ -245,7 +234,14 @@ private IWidget createIOColumn(PanelSyncManager syncManager) { new ToggleButton().overlay(GTGuiTextures.OVERLAY_BUTTON_CYCLIC) .tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.item_eject"))) .syncHandler("ejectItems") - .center()) + .right(6)) + .child( + new ToggleButton().overlay( + GuiTextures.EJECT_COINS.asIcon() + .size(14)) + .tooltipBuilder(t -> t.addLine(IKey.lang("vendingmachine.gui.coin_eject"))) + .syncHandler("ejectCoins") + .left(6)) .top(80) .height(18)) .child( @@ -443,10 +439,17 @@ protected void registerSyncValues(PanelSyncManager syncManager) { BooleanSyncValue ejectItemsSyncer = new BooleanSyncValue(() -> this.ejectItems, val -> { this.ejectItems = val; if (this.ejectItems) { - ejectItems(); + ejectItems("input"); + } + }); + BooleanSyncValue ejectCoinsSyncer = new BooleanSyncValue(() -> this.ejectCoins, val -> { + this.ejectCoins = val; + if (this.ejectCoins) { + ejectItems("coins"); } }); syncManager.syncValue("ejectItems", ejectItemsSyncer); + syncManager.syncValue("ejectCoins", ejectCoinsSyncer); } public void attemptPurchase(TradeItemDisplay display) { diff --git a/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java b/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java index 5892355..8ee5829 100644 --- a/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java +++ b/src/main/java/com/cubefury/vendingmachine/gui/GuiTextures.java @@ -71,6 +71,12 @@ public final class GuiTextures { .name("background_output") .build(); + public static final UITexture EJECT_COINS = UITexture.builder() + .location(VendingMachine.MODID, "gui/overlay/coinEject") + .imageSize(16, 16) + .name("coin_eject") + .build(); + public static final TabTexture TAB_LEFT = TabTexture .of(UITexture.fullImage(VendingMachine.MODID, "gui/tabs_left", true), GuiAxis.X, false, 32, 28, 4); } diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java index 2a80342..26746fa 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetBulkSync.java @@ -52,6 +52,7 @@ public static void sendSync(@Nonnull EntityPlayerMP player) { NetNameSync.sendNames(new EntityPlayerMP[] { player }, new UUID[] { playerId }, null); NetTradeDbSync.sendDatabase(player, false); + NetTradeStateSync.sendTradeState(player, false); } private static void onServer(Tuple2 message) { diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java index 360d517..7e536d9 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java @@ -61,6 +61,13 @@ public static void sendPlayerCurrency(@Nonnull EntityPlayerMP player, CurrencyIt PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); } + public static void resetPlayerCurrency(@Nonnull EntityPlayerMP player) { + NBTTagCompound payload = new NBTTagCompound(); + payload.setString("dataType", "currency"); + payload.setBoolean("merge", false); + PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); + } + @SideOnly(Side.CLIENT) public static void requestSync() { NBTTagCompound payload = new NBTTagCompound(); @@ -94,15 +101,10 @@ public static void onClient(NBTTagCompound message) { UUID player = NBTConverter.UuidValueType.PLAYER.readId(message); boolean merge = message.getBoolean("merge"); if (dataType.equals("tradeState")) { - TradeDatabase db = TradeDatabase.INSTANCE; - db.populateTradeStateFromNBT(message, player, merge); + TradeDatabase.INSTANCE.populateTradeStateFromNBT(message, player, merge); } else if (dataType.equals("currency")) { CurrencyItem currencyItem = CurrencyItem.fromNBT(message.getCompoundTag("currencyItem")); - if (currencyItem == null) { - VendingMachine.LOG.warn("Received invalid currency item from server"); - return; - } - TradeManager.INSTANCE.addCurrency(player, currencyItem); + TradeManager.INSTANCE.addCurrency(player, currencyItem, merge); } else { VendingMachine.LOG.warn("Unknown trade state sync data received: {}", dataType); } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java index 8a055ef..3b1a132 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java @@ -1,6 +1,8 @@ package com.cubefury.vendingmachine.trade; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import net.minecraft.item.Item; @@ -19,6 +21,8 @@ public class CurrencyItem { public CurrencyType type; public int value; private static final Map typeMap = new HashMap<>(); + private static final String[] coinSuffixes = new String[] { "IV", "III", "II", "I", "" }; + private static final int[] coinValues = new int[] { 10000, 1000, 100, 10, 1 }; public static CurrencyItem fromNBT(NBTTagCompound nbt) { CurrencyType type = CurrencyType.getTypeFromId(nbt.getString("type")); @@ -34,6 +38,22 @@ public NBTTagCompound writeToNBT(NBTTagCompound payload) { return payload; } + public List itemize() { + List outputs = new ArrayList<>(); + if (this.type == null || this.value <= 0) { + return outputs; + } + for (int i = 0; i < coinValues.length; i++) { + while (this.value > coinValues[i]) { + Item outputItem = (Item) Item.itemRegistry.getObject(this.type.itemPrefix + coinSuffixes[i]); + int stackSize = Math.min(this.value / coinValues[i], outputItem.getItemStackLimit()); + outputs.add(new ItemStack(outputItem, stackSize)); + this.value -= stackSize * coinValues[i]; + } + } + return outputs; + } + public enum CurrencyType { ADVENTURE("adventure", "dreamcraft:item.CoinAdventure", "gui/icons/itemCoinAdventure.png"), @@ -99,13 +119,11 @@ public static CurrencyItem fromItemStack(ItemStack newItem) { } private static int mapSuffixToValue(String suffix) { - return switch (suffix) { - case "" -> 1; - case "I" -> 10; - case "II" -> 100; - case "III" -> 1000; - case "IV" -> 10000; - default -> -1; - }; + for (int i = 0; i < coinSuffixes.length; i++) { + if (suffix.equals(coinSuffixes[i])) { + return coinValues[i]; + } + } + return -1; } } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java index 0981c40..cc32151 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java @@ -173,16 +173,21 @@ public NBTTagList writeCurrencyToNBT(UUID player) { return nbt; } - public void addCurrency(UUID playerId, CurrencyItem mapped) { - this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>()); - this.playerCurrency.get(playerId) - .computeIfAbsent(mapped.type, k -> 0); - this.playerCurrency.get(playerId) - .put( - mapped.type, - this.playerCurrency.get(playerId) - .get(mapped.type) + mapped.value); + public void addCurrency(UUID playerId, CurrencyItem mapped, boolean merge) { + if (!merge) { + this.playerCurrency.get(playerId) + .clear(); + } + if (mapped != null) { + this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>()); + this.playerCurrency.get(playerId) + .computeIfAbsent(mapped.type, k -> 0); + this.playerCurrency.get(playerId) + .put( + mapped.type, + this.playerCurrency.get(playerId) + .get(mapped.type) + mapped.value); + } this.hasCurrencyUpdate = true; - VendingMachine.LOG.info("currency received: {} {}", mapped.type.id, mapped.value); } } diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang index 6df9fe1..95c833f 100644 --- a/src/main/resources/assets/vendingmachine/lang/en_US.lang +++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang @@ -10,6 +10,7 @@ vendingmachine.gui.neiColor.conditionDefault=000000 vendingmachine.gui.neiColor.conditionSatisfied=55D441 vendingmachine.gui.neiColor.conditionUnsatisfied=A87A5E vendingmachine.gui.item_eject=Eject Items +vendingmachine.gui.coin_eject=Eject Coins vendingmachine.gui.search=Search vendingmachine.gui.required_inputs=Requires: diff --git a/src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png b/src/main/resources/assets/vendingmachine/textures/gui/overlay/coinEject.png new file mode 100644 index 0000000000000000000000000000000000000000..ab26b18a7f6b7cd552518296086fc825fd1fb884 GIT binary patch literal 927 zcmV;Q17Q4#P)1q~8j=(jN5Qq=;KyRs!Nplu2UkH5`~Y!ua#D1W691PJTEuv8+>dwn9(V5mp;2L) z6&eRL-8R$7gqY2(is4rX2qB7o1Y~9zbCQ&T@A$e$fUkFPp5=e;&(W*qEd~Tc;#p>x zHt`1W^rmfa-Y1T-lB^P+6OWm6LE=ZQD;~dbF1jr6%&3`3&l5+9#bO659n4CmMm$9v zQ#GCPg{;Ra=Pk}!rN&zKyGn%>^RL6AovVi>1}_t z0nB`oUT${ujJ0}MVHvMIY#kfu;50Pkn?O*vrT7U)^?dTZ_D^a03F zSE(D|;1C!sQueyfySqDk`}a(%zaQGQa%$yu~&Wb1wqKoJvIJ5;PR|hAZ99*p8 zDmZlz9NfhhYR};~j3LdN=^Os0lw9ul+>>0}XhI0Q=6px9y=Z<*Xm01yIs#xWI25%X zUwLv5YEOVu!NG_<;Q7TpsJ#KIuv0;&D3F2#3W%j4q{B@i0D#w(=l0?LQ64YNL4MJG zycNVZAfADmsdIVyRJjIAV1Hp!s|Pfi=b=2k>kT~vJnu#IPuvYL?aTA z$U?3512B)>Ou@oT0D!3s2mzOy=S3L*4>2xW5-J4+H8zy{Ofi0d@%#5MP$J zpd|o-d^kbwh~@)?1PK1v0Tn+GFV8@rzXd9ZEOdq7`nW}a Date: Sat, 20 Sep 2025 18:23:33 +0800 Subject: [PATCH 10/14] Added Individual coin dispense + saved previous search & vending machine tab --- .../vendingmachine/blocks/gui/CoinButton.java | 42 +++++ .../blocks/gui/InterceptingSlot.java | 4 +- .../blocks/gui/MTEVendingMachineGui.java | 150 ++++++++++++------ .../vendingmachine/blocks/gui/SearchBar.java | 1 + .../blocks/gui/TradeMainPanel.java | 7 + .../blocks/gui/VendingPageButton.java | 23 +++ .../network/handlers/NetTradeStateSync.java | 34 ++-- .../vendingmachine/trade/TradeManager.java | 12 +- .../assets/vendingmachine/lang/en_US.lang | 3 +- 9 files changed, 207 insertions(+), 69 deletions(-) create mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java create mode 100644 src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java new file mode 100644 index 0000000..88f4b14 --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/CoinButton.java @@ -0,0 +1,42 @@ +package com.cubefury.vendingmachine.blocks.gui; + +import org.jetbrains.annotations.NotNull; + +import com.cleanroommc.modularui.api.drawable.IDrawable; +import com.cleanroommc.modularui.api.widget.Interactable; +import com.cleanroommc.modularui.widgets.ToggleButton; +import com.cubefury.vendingmachine.trade.CurrencyItem; + +public class CoinButton extends ToggleButton { + + private final TradeMainPanel panel; + private final CurrencyItem.CurrencyType type; + + public CoinButton(TradeMainPanel panel, CurrencyItem.CurrencyType type) { + super(); + background(IDrawable.EMPTY); + selectedBackground(IDrawable.EMPTY); + + this.panel = panel; + this.type = type; + } + + @Override + public @NotNull Result onMousePressed(int mouseButton) { + if (!panel.shiftHeld) { + return Result.IGNORE; + } + switch (mouseButton) { + case 0: + next(); + Interactable.playButtonClickSound(); + return Result.SUCCESS; + case 1: + prev(); + Interactable.playButtonClickSound(); + return Result.SUCCESS; + } + return Result.IGNORE; + } + +} diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index 0f4c994..1381668 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -22,10 +22,8 @@ public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) CurrencyItem mapped = mapToCurrency(newItem); if (mapped != null) { if (!client) { - TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped, true); + TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped); - } else { - MTEVendingMachineGui.setForceRefresh(); } this.putStack(null); return true; diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index e067c41..f15de86 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -6,10 +6,8 @@ import java.util.Map; import java.util.UUID; -import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import com.cleanroommc.modularui.api.drawable.IKey; import com.cleanroommc.modularui.api.widget.IWidget; @@ -22,7 +20,6 @@ import com.cleanroommc.modularui.widget.ParentWidget; import com.cleanroommc.modularui.widget.SingleChildWidget; import com.cleanroommc.modularui.widgets.ListWidget; -import com.cleanroommc.modularui.widgets.PageButton; import com.cleanroommc.modularui.widgets.PagedWidget; import com.cleanroommc.modularui.widgets.SlotGroupWidget; import com.cleanroommc.modularui.widgets.ToggleButton; @@ -56,12 +53,16 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { private boolean ejectItems = false; private boolean ejectCoins = false; + private final Map ejectSingleCoin = new HashMap<>(); private final Map> displayedTrades = new HashMap<>(); private final List tradeCategories = new ArrayList<>(); private PosGuiData guiData; - private PagedWidget.Controller tabController; - private SearchBar searchBar; + private final PagedWidget.Controller tabController; + private final SearchBar searchBar; + + public static String lastSearch = ""; + public static int lastPage = 0; public static final int CUSTOM_UI_HEIGHT = 320; @@ -75,6 +76,10 @@ public MTEVendingMachineGui(MTEVendingMachine base) { super(base); this.base = base; + for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) { + ejectSingleCoin.put(type, false); + } + this.tradeCategories.add(TradeCategory.ALL); this.tradeCategories.addAll(TradeDatabase.INSTANCE.getTradeCategories()); @@ -112,7 +117,7 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe mainColumn.child(createTitleTextStyle(base.getLocalName())) .child(this.searchBar) .child(createTradeUI((TradeMainPanel) panel, this.tabController)); - mainColumn.child(createCoinInventoryRow()); + mainColumn.child(createCoinInventoryRow((TradeMainPanel) panel)); } mainColumn.child(createInventoryRow(panel, syncManager)); panel.child(mainColumn); @@ -123,6 +128,13 @@ public ModularPanel build(PosGuiData guiData, PanelSyncManager syncManager, UISe return panel; } + public void restorePreviousSettings() { + if (this.tabController.isInitialised()) { + this.tabController.setPage(lastPage); + } + this.searchBar.setText(lastSearch); + } + public IWidget createCategoryTabs(PagedWidget.Controller tabController) { Flow tabColumn = new Column().width(40) .height(100) @@ -133,7 +145,7 @@ public IWidget createCategoryTabs(PagedWidget.Controller tabController) { for (int i = 0; i < this.tradeCategories.size(); i++) { int index = i; tabColumn.child( - new PageButton(i, tabController).tab(GuiTextures.TAB_LEFT, -1) + new VendingPageButton(i, tabController).tab(GuiTextures.TAB_LEFT, -1) .overlay( this.tradeCategories.get(i) .getTexture() @@ -175,40 +187,66 @@ private SearchBar createSearchBar() { .height(10); } - private void ejectItems(String type) { + // Eject code is in GUI instead of MTE since the syncers are per-gui instance + private void doEjectCoin(CurrencyItem.CurrencyType type) { if (this.guiData.isClient()) { return; } - if (type.equals("input")) { - for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) { - ItemStack stack = base.inputItems.getStackInSlot(i); - if (stack != null) { - base.inputItems.setStackInSlot(i, null); - base.spawnItem(stack.copy()); - } - } - ejectItems = false; - } else if (type.equals("coins")) { - UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser()); - if (!TradeManager.INSTANCE.playerCurrency.containsKey(currentUser)) { - ejectCoins = false; - return; + UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser()); + if ( + !TradeManager.INSTANCE.playerCurrency.containsKey(currentUser) + || !TradeManager.INSTANCE.playerCurrency.get(currentUser) + .containsKey(type) + ) { + this.ejectSingleCoin.put(type, false); + return; + } + for (ItemStack ejectable : new CurrencyItem( + type, + TradeManager.INSTANCE.playerCurrency.get(currentUser) + .get(type)).itemize()) { + base.spawnItem(ejectable); + } + TradeManager.INSTANCE.resetCurrency(currentUser, type); + NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser(), type); + this.ejectSingleCoin.put(type, false); + } + + private void doEjectCoins() { + if (this.guiData.isClient()) { + return; + } + + UUID currentUser = NameCache.INSTANCE.getUUIDFromPlayer(base.getCurrentUser()); + if (!TradeManager.INSTANCE.playerCurrency.containsKey(currentUser)) { + ejectCoins = false; + return; + } + + Map coins = TradeManager.INSTANCE.playerCurrency + .getOrDefault(currentUser, new HashMap<>()); + for (Map.Entry entry : coins.entrySet()) { + for (ItemStack ejectable : new CurrencyItem(entry.getKey(), entry.getValue()).itemize()) { + base.spawnItem(ejectable); } + } + TradeManager.INSTANCE.resetCurrency(currentUser, null); + NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser(), null); + ejectCoins = false; + } - Map coins = TradeManager.INSTANCE.playerCurrency - .getOrDefault(currentUser, new HashMap<>()); - for (Map.Entry entry : coins.entrySet()) { - for (ItemStack ejectable : new CurrencyItem(entry.getKey(), entry.getValue()).itemize()) { - base.spawnItem(ejectable); - } + private void doEjectItems() { + if (this.guiData.isClient()) { + return; + } + for (int i = 0; i < MTEVendingMachine.INPUT_SLOTS; i++) { + ItemStack stack = base.inputItems.getStackInSlot(i); + if (stack != null) { + base.inputItems.setStackInSlot(i, null); + base.spawnItem(stack.copy()); } - TradeManager.INSTANCE.playerCurrency.get(currentUser) - .clear(); - NetTradeStateSync.resetPlayerCurrency((EntityPlayerMP) base.getCurrentUser()); - ejectCoins = false; - } else { - VendingMachine.LOG.warn("Eject items called with unknown item type: {}", type); } + ejectItems = false; } private IWidget createIOColumn(PanelSyncManager syncManager) { @@ -265,16 +303,11 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) { return new ItemSlot().slot( slot.slotGroup("inputSlotGroup") .changeListener((newItem, onlyAmountChanged, client, init) -> { - if ( - slot.intercept( - newItem, - client, - this.getBase() - .getCurrentUser()) - ) { - // if we intercept, the server will send a refresh separately - return; - } + slot.intercept( + newItem, + client, + this.getBase() + .getCurrentUser()); if (guiData.isClient()) { forceRefresh = true; } @@ -376,7 +409,7 @@ private static String getReadableStringFromCoinAmount(int amount) { } } - private IWidget createCoinInventoryRow() { + private IWidget createCoinInventoryRow(TradeMainPanel panel) { Flow parent = new Row() // .background(GuiTextures.TEXT_FIELD_BACKGROUND) .width(162) .height(36) @@ -389,12 +422,19 @@ private IWidget createCoinInventoryRow() { for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) { coinColumn.child( new Row().child( - type.texture.asWidget() + new CoinButton(panel, type).overlay( + type.texture.asIcon() + .size(12)) .size(12) .left(0) + .syncHandler("ejectCoin_" + type.id) .tooltipDynamic((builder) -> { builder.clearText(); builder.addLine(currentAmounts.getOrDefault(type, 0) + " " + type.getLocalizedName()); + builder.emptyLine(); + builder.addLine( + IKey.str(Translator.translate("vendingmachine.gui.single_coin_type_eject_hint")) + .style(IKey.GRAY, IKey.ITALIC)); builder.setAutoUpdate(true); })) .child( @@ -433,23 +473,33 @@ private IWidget createInventoryRow(ModularPanel panel, PanelSyncManager syncMana @Override protected void registerSyncValues(PanelSyncManager syncManager) { super.registerSyncValues(syncManager); - syncManager.registerSlotGroup("inputSlotGroup", 7, true); - syncManager.registerSlotGroup("outputSlotGroup", 1, false); + syncManager.registerSlotGroup("inputSlotGroup", 6, true); + syncManager.registerSlotGroup("outputSlotGroup", 4, false); BooleanSyncValue ejectItemsSyncer = new BooleanSyncValue(() -> this.ejectItems, val -> { this.ejectItems = val; if (this.ejectItems) { - ejectItems("input"); + doEjectItems(); } }); BooleanSyncValue ejectCoinsSyncer = new BooleanSyncValue(() -> this.ejectCoins, val -> { this.ejectCoins = val; if (this.ejectCoins) { - ejectItems("coins"); + doEjectCoins(); } }); syncManager.syncValue("ejectItems", ejectItemsSyncer); syncManager.syncValue("ejectCoins", ejectCoinsSyncer); + + for (CurrencyItem.CurrencyType type : CurrencyItem.CurrencyType.values()) { + BooleanSyncValue ejectCoinSyncer = new BooleanSyncValue(() -> this.ejectSingleCoin.get(type), val -> { + this.ejectSingleCoin.put(type, val); + if (val) { + doEjectCoin(type); + } + }); + syncManager.syncValue("ejectCoin_" + type.id, ejectCoinSyncer); + } } public void attemptPurchase(TradeItemDisplay display) { diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java index a758b07..72de631 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/SearchBar.java @@ -94,6 +94,7 @@ public void onUpdate() { super.onUpdate(); String curText = getText(); if (!curText.equals(previousText)) { + MTEVendingMachineGui.lastSearch = curText; gui.setForceRefresh(); } previousText = curText; diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index e9b5058..5f4c319 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -15,6 +15,7 @@ import com.cleanroommc.modularui.factory.PosGuiData; import com.cleanroommc.modularui.screen.ModularPanel; +import com.cleanroommc.modularui.screen.ModularScreen; import com.cleanroommc.modularui.value.sync.PanelSyncManager; import com.cubefury.vendingmachine.Config; import com.cubefury.vendingmachine.blocks.MTEVendingMachine; @@ -277,4 +278,10 @@ public void dispose() { NetResetVMUser.sendReset(this.gui.getBase()); super.dispose(); } + + @Override + public void onOpen(ModularScreen screen) { + super.onOpen(screen); + gui.restorePreviousSettings(); + } } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java new file mode 100644 index 0000000..100eea1 --- /dev/null +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/VendingPageButton.java @@ -0,0 +1,23 @@ +package com.cubefury.vendingmachine.blocks.gui; + +import org.jetbrains.annotations.NotNull; + +import com.cleanroommc.modularui.widgets.PageButton; +import com.cleanroommc.modularui.widgets.PagedWidget; + +public class VendingPageButton extends PageButton { + + private final int index; + + public VendingPageButton(int index, PagedWidget.Controller controller) { + super(index, controller); + + this.index = index; + } + + @Override + public @NotNull Result onMousePressed(int mouseButton) { + MTEVendingMachineGui.lastPage = this.index; + return super.onMousePressed(mouseButton); + } +} diff --git a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java index 7e536d9..c6cd086 100644 --- a/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java +++ b/src/main/java/com/cubefury/vendingmachine/network/handlers/NetTradeStateSync.java @@ -3,6 +3,7 @@ import java.util.UUID; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; @@ -54,17 +55,18 @@ public static void sendTradeState(@Nonnull EntityPlayerMP player, boolean merge) public static void sendPlayerCurrency(@Nonnull EntityPlayerMP player, CurrencyItem currencyItem) { NBTTagCompound payload = new NBTTagCompound(); - payload.setString("dataType", "currency"); - payload.setBoolean("merge", true); + payload.setString("dataType", "currency_add"); currencyItem.writeToNBT(payload); PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); } - public static void resetPlayerCurrency(@Nonnull EntityPlayerMP player) { + public static void resetPlayerCurrency(@Nonnull EntityPlayerMP player, @Nullable CurrencyItem.CurrencyType type) { NBTTagCompound payload = new NBTTagCompound(); - payload.setString("dataType", "currency"); - payload.setBoolean("merge", false); + payload.setString("dataType", "currency_reset"); + if (type != null) { + payload.setString("type", type.id); + } PacketSender.INSTANCE.sendToPlayers(new UnserializedPacket(ID_NAME, payload), player); } @@ -99,14 +101,20 @@ public static void onClient(NBTTagCompound message) { } String dataType = message.getString("dataType"); UUID player = NBTConverter.UuidValueType.PLAYER.readId(message); - boolean merge = message.getBoolean("merge"); - if (dataType.equals("tradeState")) { - TradeDatabase.INSTANCE.populateTradeStateFromNBT(message, player, merge); - } else if (dataType.equals("currency")) { - CurrencyItem currencyItem = CurrencyItem.fromNBT(message.getCompoundTag("currencyItem")); - TradeManager.INSTANCE.addCurrency(player, currencyItem, merge); - } else { - VendingMachine.LOG.warn("Unknown trade state sync data received: {}", dataType); + switch (dataType) { + case "tradeState" -> { + boolean merge = message.getBoolean("merge"); + TradeDatabase.INSTANCE.populateTradeStateFromNBT(message, player, merge); + } + case "currency_add" -> { + CurrencyItem currencyItem = CurrencyItem.fromNBT(message.getCompoundTag("currencyItem")); + + TradeManager.INSTANCE.addCurrency(player, currencyItem); + } + case "currency_reset" -> TradeManager.INSTANCE.resetCurrency( + player, + message.hasKey("type") ? CurrencyItem.CurrencyType.getTypeFromId(message.getString("type")) : null); + default -> VendingMachine.LOG.warn("Unknown trade state sync data received: {}", dataType); } } } diff --git a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java index cc32151..8dda1bb 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/TradeManager.java @@ -173,11 +173,19 @@ public NBTTagList writeCurrencyToNBT(UUID player) { return nbt; } - public void addCurrency(UUID playerId, CurrencyItem mapped, boolean merge) { - if (!merge) { + public void resetCurrency(UUID playerId, CurrencyItem.CurrencyType type) { + this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>()); + if (type == null) { this.playerCurrency.get(playerId) .clear(); + } else { + this.playerCurrency.get(playerId) + .put(type, 0); } + this.hasCurrencyUpdate = true; + } + + public void addCurrency(UUID playerId, CurrencyItem mapped) { if (mapped != null) { this.playerCurrency.computeIfAbsent(playerId, k -> new HashMap<>()); this.playerCurrency.get(playerId) diff --git a/src/main/resources/assets/vendingmachine/lang/en_US.lang b/src/main/resources/assets/vendingmachine/lang/en_US.lang index 95c833f..47b908a 100644 --- a/src/main/resources/assets/vendingmachine/lang/en_US.lang +++ b/src/main/resources/assets/vendingmachine/lang/en_US.lang @@ -10,7 +10,8 @@ vendingmachine.gui.neiColor.conditionDefault=000000 vendingmachine.gui.neiColor.conditionSatisfied=55D441 vendingmachine.gui.neiColor.conditionUnsatisfied=A87A5E vendingmachine.gui.item_eject=Eject Items -vendingmachine.gui.coin_eject=Eject Coins +vendingmachine.gui.coin_eject=Eject All Coins +vendingmachine.gui.single_coin_type_eject_hint=Shift-Click to Extract vendingmachine.gui.search=Search vendingmachine.gui.required_inputs=Requires: From c6e69c20f488938d67fba7605fa8a0c36cd62cee Mon Sep 17 00:00:00 2001 From: cubefury Date: Sun, 21 Sep 2025 14:09:47 +0800 Subject: [PATCH 11/14] Fixed ghost coins. --- .../blocks/gui/InterceptingSlot.java | 2 +- .../blocks/gui/MTEVendingMachineGui.java | 22 ++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java index 1381668..e040010 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/InterceptingSlot.java @@ -21,11 +21,11 @@ public InterceptingSlot(ItemStackHandler inputItems, int index) { public boolean intercept(ItemStack newItem, boolean client, EntityPlayer player) { CurrencyItem mapped = mapToCurrency(newItem); if (mapped != null) { + this.putStack(null); if (!client) { TradeManager.INSTANCE.addCurrency(NameCache.INSTANCE.getUUIDFromPlayer(player), mapped); NetTradeStateSync.sendPlayerCurrency((EntityPlayerMP) player, mapped); } - this.putStack(null); return true; } return false; diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index f15de86..6041d25 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -56,6 +56,8 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { private final Map ejectSingleCoin = new HashMap<>(); private final Map> displayedTrades = new HashMap<>(); private final List tradeCategories = new ArrayList<>(); + private final List inputSlots = new ArrayList<>(); + private boolean hasInputsChanged = false; private PosGuiData guiData; private final PagedWidget.Controller tabController; @@ -300,16 +302,22 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) { .matrix("II", "II", "II") .key('I', index -> { InterceptingSlot slot = new InterceptingSlot(base.inputItems, index); + this.inputSlots.add(slot); return new ItemSlot().slot( slot.slotGroup("inputSlotGroup") .changeListener((newItem, onlyAmountChanged, client, init) -> { - slot.intercept( + boolean hasCoin = slot.intercept( newItem, client, this.getBase() .getCurrentUser()); - if (guiData.isClient()) { + if (client) { forceRefresh = true; + return; + } + // server side force refresh + if (hasCoin) { + this.refreshInputSlots(); } })); }) @@ -317,7 +325,6 @@ private SlotGroupWidget createInputRow(PanelSyncManager syncManager) { } private SlotGroupWidget createOutputSlots() { - // we use slot group widget in case we want to increase the number of output slots in the future return SlotGroupWidget.builder() .matrix("II", "II") .key('I', index -> { @@ -545,4 +552,13 @@ public String getSearchBarText() { return this.searchBar.getText(); } + // server-side sync for all input slots + // during next tick after any input + private void refreshInputSlots() { + for (InterceptingSlot slot : this.inputSlots) { + slot.getSyncHandler() + .forceSyncItem(); + } + } + } From e9eec8c42f00cc8f5cf191095673537c85e9c037 Mon Sep 17 00:00:00 2001 From: cubefury Date: Sun, 21 Sep 2025 15:53:42 +0800 Subject: [PATCH 12/14] Freeze items in place when holding shift --- .../blocks/gui/MTEVendingMachineGui.java | 24 +++++++++-- .../blocks/gui/TradeMainPanel.java | 42 +++++++++++++++++-- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java index 6041d25..3c48cf9 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/MTEVendingMachineGui.java @@ -4,7 +4,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.UUID; +import java.util.stream.Collectors; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; @@ -57,7 +59,6 @@ public class MTEVendingMachineGui extends MTEMultiBlockBaseGui { private final Map> displayedTrades = new HashMap<>(); private final List tradeCategories = new ArrayList<>(); private final List inputSlots = new ArrayList<>(); - private boolean hasInputsChanged = false; private PosGuiData guiData; private final PagedWidget.Controller tabController; @@ -525,7 +526,7 @@ public static void resetForceRefresh() { forceRefresh = false; } - public void updateSlots(Map> trades) { + public void updateTradeDisplay(Map> trades) { synchronized (displayedTrades) { for (Map.Entry> entry : displayedTrades.entrySet()) { int displayedSize = trades.get(entry.getKey()) == null ? 0 @@ -533,13 +534,13 @@ public void updateSlots(Map> trades) { .size(); for (int i = 0; i < MTEVendingMachine.MAX_TRADES; i++) { if (i < displayedSize) { - displayedTrades.get(entry.getKey()) + entry.getValue() .get(i) .setDisplay( trades.get(entry.getKey()) .get(i)); } else { - displayedTrades.get(entry.getKey()) + entry.getValue() .get(i) .setDisplay(null); } @@ -548,6 +549,21 @@ public void updateSlots(Map> trades) { } } + public Map> getTradeDisplayData() { + Map> currentData = new HashMap<>(); + synchronized (displayedTrades) { + this.displayedTrades.forEach((k, v) -> { + currentData.put( + k, + v.stream() + .map(TradeItemDisplayWidget::getDisplay) + .filter(Objects::nonNull) + .collect(Collectors.toList())); + }); + } + return currentData; + } + public String getSearchBarText() { return this.searchBar.getText(); } diff --git a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java index 5f4c319..adbc310 100644 --- a/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java +++ b/src/main/java/com/cubefury/vendingmachine/blocks/gui/TradeMainPanel.java @@ -78,14 +78,51 @@ public void updateGui() { testTGW.add(new TradeGroupWrapper(entry.getValue(), -1, true)); } Map> trades = formatTrades(testTGW); - gui.updateSlots(trades); + gui.updateTradeDisplay(trades); + } else if (shiftHeld) { + this.updateTradeInformation(gui.getTradeDisplayData()); } else { Map> trades = formatTrades( TradeManager.INSTANCE.getTrades(NameCache.INSTANCE.getUUIDFromPlayer(syncManager.getPlayer()))); - gui.updateSlots(trades); + gui.updateTradeDisplay(trades); } } + private void updateTradeInformation(Map> currentData) { + Map availableItems = this.guiData.isClient() && this.gui.getBase() != null + ? getAvailableItems() + : new HashMap<>(); + + Map tradeGroups = new HashMap<>(); + TradeManager.INSTANCE.getTrades(NameCache.INSTANCE.getUUIDFromPlayer(syncManager.getPlayer())) + .forEach( + (tg) -> { + tradeGroups.put( + tg.trade() + .getId(), + tg); + }); + currentData.forEach((k, v) -> { + for (TradeItemDisplay tid : v) { + TradeGroupWrapper cur = tradeGroups.get(tid.tgID); + tid.enabled = cur != null && cur.enabled(); + tid.hasCooldown = cur.cooldown() > 0; + tid.cooldown = cur.cooldown(); + tid.cooldownText = convertCooldownText(cur.cooldown()); + tid.tradeableNow = checkItemsSatisfied( + cur.trade() + .getTrades() + .get(tid.tradeGroupOrder).fromItems, + availableItems) + && checkCurrencySatisfied( + cur.trade() + .getTrades() + .get(tid.tradeGroupOrder).fromCurrency, + TradeManager.INSTANCE.playerCurrency.get(NameCache.INSTANCE.getUUIDFromPlayer(this.player))); + } + }); + } + @Override public void onUpdate() { @@ -167,7 +204,6 @@ public Map getAvailableItems() { } public Map> formatTrades(List tradeGroups) { - Map availableItems = this.guiData.isClient() && this.gui.getBase() != null ? getAvailableItems() : new HashMap<>(); From 6d567eb54e7b885cc660a77461e8a038b6e6621f Mon Sep 17 00:00:00 2001 From: cubefury Date: Tue, 23 Sep 2025 20:14:32 +0800 Subject: [PATCH 13/14] Coin display on questbook. --- .../betterquesting/gui/PanelQBTrade.java | 13 +++++++++++++ .../cubefury/vendingmachine/trade/CurrencyItem.java | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java b/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java index a6b621f..78dfc7a 100644 --- a/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java +++ b/src/main/java/com/cubefury/vendingmachine/integration/betterquesting/gui/PanelQBTrade.java @@ -1,5 +1,6 @@ package com.cubefury.vendingmachine.integration.betterquesting.gui; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.Trade; import betterquesting.api.utils.BigItemStack; @@ -29,6 +30,7 @@ public void initPanel() { super.initPanel(); int x_offset = 0; + for (int i = 0; i < trade.fromItems.size(); i++) { BigItemStack stack = trade.fromItems.get(i) .toBQBigItemStack(); @@ -40,6 +42,17 @@ public void initPanel() { x_offset += 20; } + for (int i = 0; i < trade.fromCurrency.size(); i++) { + CurrencyItem currencyItem = trade.fromCurrency.get(i); + BigItemStack stack = new BigItemStack(currencyItem.getItemRepresentation()); + GuiRectangle rectangle = new GuiRectangle(x_offset, 0, 18, 18, 0); + PanelItemSlot is = PanelItemSlotBuilder.forValue(stack, rectangle) + .showCount(true) + .build(); + this.addPanel(is); + x_offset += 20; + } + // +1px buffer on each side to regularize slightly smaller icon size (16px vs 18px of items) this.addPanel( new PanelGeneric( diff --git a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java index 3b1a132..a0535af 100644 --- a/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java +++ b/src/main/java/com/cubefury/vendingmachine/trade/CurrencyItem.java @@ -54,6 +54,11 @@ public List itemize() { return outputs; } + public ItemStack getItemRepresentation() { + Item outputItem = (Item) Item.itemRegistry.getObject(this.type.itemPrefix); + return new ItemStack(outputItem, value); + } + public enum CurrencyType { ADVENTURE("adventure", "dreamcraft:item.CoinAdventure", "gui/icons/itemCoinAdventure.png"), From 70a7d1a83701604dbad5d52aeb7b1b61ff6d4337 Mon Sep 17 00:00:00 2001 From: cubefury Date: Tue, 23 Sep 2025 20:30:16 +0800 Subject: [PATCH 14/14] Coin display in NEI. --- .../vendingmachine/integration/nei/NeiRecipeHandler.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java b/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java index 6b5477e..3e5f78a 100644 --- a/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java +++ b/src/main/java/com/cubefury/vendingmachine/integration/nei/NeiRecipeHandler.java @@ -25,6 +25,7 @@ import com.cubefury.vendingmachine.integration.betterquesting.BqAdapter; import com.cubefury.vendingmachine.integration.betterquesting.BqCondition; import com.cubefury.vendingmachine.storage.NameCache; +import com.cubefury.vendingmachine.trade.CurrencyItem; import com.cubefury.vendingmachine.trade.Trade; import com.cubefury.vendingmachine.util.BigItemStack; import com.cubefury.vendingmachine.util.Translator; @@ -330,6 +331,14 @@ private void loadInputs(Trade trade) { inputs.add(new PositionedStack(extractStacks(stack), x, y)); index++; } + for (CurrencyItem ci : trade.fromCurrency) { + if (index >= GRID_COUNT) { + break; + } + int x = xOffset + index * SLOT_SIZE; + inputs.add(new PositionedStack(ci.getItemRepresentation(), x, y)); + index++; + } } private void loadOutputs(Trade trade) {