Skip to content

Commit

Permalink
Remove items from the queue when they are smelted or picked up
Browse files Browse the repository at this point in the history
  • Loading branch information
paulyhedral committed Nov 23, 2024
1 parent 3079a47 commit 21766f6
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,38 @@ public void onItemCrafted(final ItemCraftedEvent event) {
public void onItemSmelted(final ItemSmeltedEvent event) {
CraftTracker.LOGGER.debug("EventHandler#onItemSmelted: {}", event);

if (event.getPlayer().level.isClientSide) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
var itemId = event.getSmelting().getItem().getRegistryName();
var quantity = event.getSmelting().getCount();
var player = Minecraft.getInstance().player;

CraftingQueueManager.INSTANCE.removeProduct(player, itemId, quantity);
});
}
else {
// send packet
PacketHandler.sendToPlayer((ServerPlayer)event.getPlayer(), new QueueCommandData(RECALCULATE));
}
}

@SubscribeEvent
public void onItemPickedUp(final ItemPickupEvent event) {
CraftTracker.LOGGER.debug("EventHandler#onItemPickedUp: {}", event);

if (event.getPlayer().level.isClientSide) {
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> {
var itemId = event.getStack().getItem().getRegistryName();
var quantity = event.getStack().getCount();
var player = Minecraft.getInstance().player;

CraftingQueueManager.INSTANCE.removeProduct(player, itemId, quantity);
});
}
else {
// send packet
PacketHandler.sendToPlayer((ServerPlayer)event.getPlayer(), new QueueCommandData(RECALCULATE));
}
}

}

0 comments on commit 21766f6

Please sign in to comment.