Skip to content

Conversation

@MatisseAD
Copy link
Owner

Summary

  • Introduce ExchangeBlock and its block entity to handle coin trades
  • Add ExchangeMenu with offer/demand slots
  • Track exchange rates with PriceManager and register supporting menus and entities

Testing

  • bash ./gradlew build (fails: Plugin [id: 'net.minecraftforge.gradle', version: '[6.0.16,6.2)'] was not found)

https://chatgpt.com/codex/tasks/task_e_68acc3014dcc832ea93bdf13420ecef6

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a cryptocurrency exchange system for the Minecraft mod, allowing players to trade between Bitcoin and Ethereum through an interactive block-based interface. The implementation includes price management with fluctuating exchange rates and a complete GUI system for handling trades.

Key changes:

  • Added ExchangeBlock with block entity for handling cryptocurrency trades
  • Implemented dynamic price management system with randomized exchange rates
  • Created exchange menu GUI with offer/demand slot mechanics

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/main/java/fr/jachou/cryptoworld/util/PriceManager.java Manages exchange rates between Bitcoin and Ethereum with random price fluctuations
src/main/java/fr/jachou/cryptoworld/menu/ModMenus.java Registers the exchange menu type for the GUI system
src/main/java/fr/jachou/cryptoworld/menu/ExchangeMenu.java Implements the container menu for the exchange interface with offer/demand slots
src/main/java/fr/jachou/cryptoworld/blockentity/ModBlockEntities.java Registers the exchange block entity type
src/main/java/fr/jachou/cryptoworld/blockentity/ExchangeBlockEntity.java Handles exchange logic, inventory management, and trade calculations
src/main/java/fr/jachou/cryptoworld/block/ExchangeBlock.java Implements the physical exchange block with player interaction
src/main/java/fr/jachou/cryptoworld/block/ModBlocks.java Registers the exchange block
src/main/java/fr/jachou/cryptoworld/CryptoWorld.java Initializes new registries and price manager
Multiple datagen files Adds exchange block to creative tabs, loot tables, and block state generation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


public static void updateRandom() {
// Randomly vary BTC to ETH rate between 1 and 4
PRICES.put(ModItems.BITCOIN.get(), 1 + RANDOM.nextInt(4));
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exchange rates are inconsistent. If 1 BTC equals 2 ETH, then 2 ETH should equal 1 BTC, meaning the Ethereum rate should be 1, not 2. This creates an arbitrage opportunity where players can infinitely multiply their currency.

Suggested change
PRICES.put(ModItems.BITCOIN.get(), 1 + RANDOM.nextInt(4));
PRICES.put(ModItems.ETHEREUM.get(), 1); // 2 ETH -> 1 BTC
}
public static void updateRandom() {
// Randomly vary BTC to ETH rate between 1 and 4
int btcRate = 1 + RANDOM.nextInt(4);
PRICES.put(ModItems.BITCOIN.get(), btcRate);
PRICES.put(ModItems.ETHEREUM.get(), 1); // reciprocal: 2 ETH -> 1 BTC
PRICES.put(ModItems.BITCOIN.get(), btcRate);
PRICES.put(ModItems.ETHEREUM.get(), 1); // reciprocal: 2 ETH -> 1 BTC

Copilot uses AI. Check for mistakes.

public static void updateRandom() {
// Randomly vary BTC to ETH rate between 1 and 4
PRICES.put(ModItems.BITCOIN.get(), 1 + RANDOM.nextInt(4));
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updateRandom method only updates the Bitcoin rate but doesn't update the corresponding Ethereum rate. This creates inconsistent exchange rates where the inverse relationship is not maintained.

Suggested change
PRICES.put(ModItems.BITCOIN.get(), 1 + RANDOM.nextInt(4));
int btcToEth = 1 + RANDOM.nextInt(4);
PRICES.put(ModItems.BITCOIN.get(), btcToEth);
PRICES.put(ModItems.ETHEREUM.get(), btcToEth); // Maintain inverse relationship

Copilot uses AI. Check for mistakes.

@Override
public ItemStack quickMoveStack(Player player, int index) {
return ItemStack.EMPTY;
Copy link

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quickMoveStack method returns EMPTY without implementing shift-click functionality. This prevents players from using shift-click to move items, which is a standard Minecraft GUI expectation.

Suggested change
return ItemStack.EMPTY;
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.slots.get(index);
if (slot != null && slot.hasItem()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.copy();
// Container slots: 0 (offer), 1 (demand/output)
int containerSlots = 2;
int playerInventoryStart = containerSlots;
int playerInventoryEnd = playerInventoryStart + 27; // 3 rows * 9 columns
int hotbarStart = playerInventoryEnd;
int hotbarEnd = hotbarStart + 9;
if (index < containerSlots) {
// Move from container to player inventory
if (!this.moveItemStackTo(itemstack1, playerInventoryStart, hotbarEnd, true)) {
return ItemStack.EMPTY;
}
slot.onQuickCraft(itemstack1, itemstack);
} else {
// Move from player inventory/hotbar to container offer slot (slot 0)
if (!this.slots.get(0).mayPlace(itemstack1)) {
return ItemStack.EMPTY;
}
if (!this.moveItemStackTo(itemstack1, 0, 1, false)) {
return ItemStack.EMPTY;
}
}
if (itemstack1.isEmpty()) {
slot.set(ItemStack.EMPTY);
} else {
slot.setChanged();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.EMPTY;
}
slot.onTake(player, itemstack1);
}
return itemstack;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants