Skip to content

Commit 63935bb

Browse files
fix: AI comments
1 parent 0f854a0 commit 63935bb

8 files changed

Lines changed: 12 additions & 116 deletions

File tree

src/client/java/com/tcm/MineTale/block/workbenches/screen/CampfireWorkbenchScreen.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
import net.minecraft.world.item.ItemStack;
1919
import net.minecraft.network.chat.Component;
2020

21-
// FurnaceScreen
22-
2321
public class CampfireWorkbenchScreen extends AbstractRecipeBookScreen<CampfireWorkbenchMenu> {
2422
private static final Identifier TEXTURE =
2523
Identifier.fromNamespaceAndPath(MineTale.MOD_ID, "textures/gui/container/furnace_workbench.png");
@@ -42,7 +40,6 @@ public CampfireWorkbenchScreen(CampfireWorkbenchMenu menu, Inventory inventory,
4240
private static MineTaleRecipeBookComponent createRecipeBookComponent(CampfireWorkbenchMenu menu) {
4341
ItemStack tabIcon = new ItemStack(ModBlocks.CAMPFIRE_WORKBENCH_BLOCK.asItem());
4442

45-
// CHANGE THIS: Replace CRAFTING_MISC with your custom category
4643
List<RecipeBookComponent.TabInfo> tabs = List.of(
4744
new RecipeBookComponent.TabInfo(tabIcon.getItem(), ModRecipeDisplay.CAMPFIRE_SEARCH)
4845
);
@@ -60,25 +57,6 @@ protected void init() {
6057
this.imageHeight = 166;
6158

6259
super.init();
63-
64-
// // The component is already created by the constructor, just initialize its UI state
65-
// this.recipeBookComponent.init(this.width, this.height, this.minecraft, false);
66-
// this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth);
67-
68-
// // Add the toggle button
69-
// this.addRenderableWidget(new ImageButton(
70-
// this.leftPos + 5,
71-
// this.height / 2 - 49,
72-
// 20, 18,
73-
// RecipeBookComponent.RECIPE_BUTTON_SPRITES,
74-
// (button) -> {
75-
// this.recipeBookComponent.toggleVisibility();
76-
// this.leftPos = this.recipeBookComponent.updateScreenPosition(this.width, this.imageWidth);
77-
// button.setPosition(this.leftPos + 5, this.height / 2 - 49);
78-
// }
79-
// ));
80-
81-
// this.addWidget(this.recipeBookComponent);
8260
}
8361

8462
/**
@@ -108,20 +86,9 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
10886
// 1. Always render the dark background tint first
10987
renderBackground(graphics, mouseX, mouseY, delta);
11088

111-
// 2. Add a null check before calling ANY methods on the component
112-
// if (this.recipeBookComponent != null) {
113-
// this.recipeBookComponent.render(graphics, mouseX, mouseY, delta);
114-
// }
115-
11689
// 3. Call super (this draws your slots and items)
11790
super.render(graphics, mouseX, mouseY, delta);
11891

119-
// 4. Ghost recipes and Tooltips also need the null check
120-
// if (this.recipeBookComponent != null) {
121-
// this.recipeBookComponent.renderGhostRecipe(graphics, true);
122-
// this.recipeBookComponent.renderTooltip(graphics, this.leftPos, this.topPos, this.hoveredSlot);
123-
// }
124-
12592
renderTooltip(graphics, mouseX, mouseY);
12693
}
12794

src/main/java/com/tcm/MineTale/block/workbenches/entity/AbstractFurnaceWorkbenchEntity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ private void smeltItem(ItemStack input) {
126126
* fills any empty slots in the queue.
127127
*/
128128
public void fulfillRecipeFromNearby(WorkbenchRecipe recipe) {
129-
if (this.level == null || this.level.isClientSide()) return;
130-
129+
if (this.level == null || this.level.isClientSide() || recipe.ingredients().isEmpty()) return;
130+
131131
// Assuming your WorkbenchRecipe has a method to get its input ingredient
132132
// If it's a standard furnace-style recipe, it likely has one ingredient.
133133
Ingredient ingredient = recipe.ingredients().get(0);

src/main/java/com/tcm/MineTale/block/workbenches/entity/AbstractWorkbenchEntity.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,6 @@ public static void tick(Level level, BlockPos pos, BlockState state, AbstractWor
7676
entity.inventory.getItem(2)
7777
);
7878

79-
// DEBUG 1: Is the machine even seeing the pork?
80-
if (!entity.inventory.getItem(Constants.INPUT_START).isEmpty()) {
81-
System.out.println("Slot 1 (Input) contains: " + entity.inventory.getItem(Constants.INPUT_START).getItem().toString());
82-
}
83-
84-
if (!entity.inventory.getItem(Constants.FUEL_SLOT).isEmpty()) {
85-
System.out.println("Slot 0 (Fuel) contains: " + entity.inventory.getItem(Constants.FUEL_SLOT).getItem().toString());
86-
}
87-
8879
// 2. Fetch the RecipeManager from the server
8980
if (level.getServer() == null) return;
9081
var recipeManager = level.getServer().getRecipeManager();

src/main/java/com/tcm/MineTale/block/workbenches/menu/AbstractWorkbenchContainerMenu.java

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public AbstractWorkbenchContainerMenu(@Nullable MenuType<?> menuType, int syncId
5151
super(menuType, syncId);
5252

5353
this.outputEnd = outputEnd;
54-
this.inputEnd = Constants.INPUT_START + 1;
54+
this.inputEnd = inputEnd;
5555

5656
checkContainerSize(container, outputEnd + 1);
5757
checkContainerDataCount(data, containerDataSize);
@@ -180,57 +180,6 @@ public int getBurnProgress() {
180180
return this.data.get(0) * 13 / i; // fuelTime
181181
}
182182

183-
/**
184-
* Performs a shift-click transfer between this container and the player's inventory.
185-
*
186-
* Moves the clicked stack into the player's inventory if it came from the container, or into the appropriate container
187-
* slots if it came from the player's inventory. Fuel items are moved to the fuel slot; all other items are moved to the
188-
* input slots. If the transfer cannot be completed, no changes are applied to the source slot.
189-
*
190-
* @param player the player performing the transfer
191-
* @param index the index of the slot that was shift-clicked
192-
* @return the original ItemStack from the clicked slot, or ItemStack.EMPTY if the transfer failed
193-
*/
194-
// @Override
195-
// public ItemStack quickMoveStack(Player player, int index) {
196-
// ItemStack itemStack = ItemStack.EMPTY;
197-
// Slot slot = this.slots.get(index);
198-
// if (slot != null && slot.hasItem()) {
199-
// ItemStack itemStack2 = slot.getItem();
200-
// itemStack = itemStack2.copy();
201-
202-
// // From Furnace to Player
203-
// int containerSlots = this.outputEnd + 1;
204-
// int playerStart = containerSlots;
205-
// int playerEnd = playerStart + 36;
206-
207-
// // From Furnace to Player
208-
// if (index < containerSlots) {
209-
// if (!this.moveItemStackTo(itemStack2, playerStart, playerEnd, true)) {
210-
// return ItemStack.EMPTY;
211-
// }
212-
// }
213-
// // From Player to Furnace
214-
// else {
215-
// // If it's fuel, try fuel slot
216-
// if (isFuel(itemStack2)) {
217-
// if (!this.moveItemStackTo(itemStack2, Constants.FUEL_SLOT, Constants.FUEL_SLOT + 1, false)) return ItemStack.EMPTY;
218-
// }
219-
// // Otherwise, try inputs
220-
// else if (!this.moveItemStackTo(itemStack2, Constants.INPUT_START, this.inputEnd, false)) {
221-
// return ItemStack.EMPTY;
222-
// }
223-
// }
224-
225-
// if (itemStack2.isEmpty()) {
226-
// slot.setByPlayer(ItemStack.EMPTY);
227-
// } else {
228-
// slot.setChanged();
229-
// }
230-
// }
231-
// return itemStack;
232-
// }
233-
234183
@Override
235184
public ItemStack quickMoveStack(Player player, int index) {
236185
ItemStack itemStack = ItemStack.EMPTY;
@@ -240,11 +189,7 @@ public ItemStack quickMoveStack(Player player, int index) {
240189
ItemStack itemStack2 = slot.getItem();
241190
itemStack = itemStack2.copy();
242191

243-
// Indices:
244-
// 0-6: Workbench (0: Fuel, 1-2: Input, 3-6: Output)
245-
// 7-33: Player Inventory
246-
// 34-42: Player Hotbar
247-
int workbenchSlotsEnd = 7;
192+
int workbenchSlotsEnd = this.outputEnd + 1;
248193

249194
// CASE 1: Moving from Workbench to Player Inventory
250195
if (index < workbenchSlotsEnd) {
@@ -258,16 +203,16 @@ public ItemStack quickMoveStack(Player player, int index) {
258203
else {
259204
if (this.isFuel(itemStack2)) {
260205
// 1. Try the Fuel Slot (Index 0)
261-
if (!this.moveItemStackTo(itemStack2, 0, 1, false)) {
206+
if (!this.moveItemStackTo(itemStack2, Constants.FUEL_SLOT, Constants.FUEL_SLOT + 1, false)) {
262207
// 2. If fuel is full, try the Input slots (Indices 1 to 3) as backup
263-
if (!this.moveItemStackTo(itemStack2, 1, 3, false)) {
208+
if (!this.moveItemStackTo(itemStack2, Constants.INPUT_START, this.inputEnd + 1, false)) {
264209
return ItemStack.EMPTY;
265210
}
266211
}
267212
} else {
268213
// 3. Not fuel? Go straight to Input slots (Indices 1 to 3)
269214
// This ensures Slot 1 is checked BEFORE Slot 2
270-
if (!this.moveItemStackTo(itemStack2, 1, 3, false)) {
215+
if (!this.moveItemStackTo(itemStack2, Constants.INPUT_START, this.inputEnd + 1, false)) {
271216
return ItemStack.EMPTY;
272217
}
273218
}
@@ -320,10 +265,6 @@ public void clearCraftingContent() {
320265

321266
@Override
322267
public boolean recipeMatches(RecipeHolder<WorkbenchRecipe> holder) {
323-
// Use the block entity's logic to see if current inputs match
324-
AbstractWorkbenchContainerMenu.this.getBlockEntity(); // Just to ensure it exists
325-
// Note: Ensure your sub-classes provide createRecipeInput() or similar logic
326-
holder.value().matches(null, serverLevel);
327268
return holder.value().matches(
328269
AbstractWorkbenchContainerMenu.this.createRecipeInput(),
329270
serverLevel
@@ -352,7 +293,7 @@ public boolean recipeMatches(RecipeHolder<WorkbenchRecipe> holder) {
352293
public void fillStackedContents(StackedItemContents contents) {
353294
// You MUST manually add the items from your SimpleContainer
354295
// to the contents for the recipe book to "simulate" correctly.
355-
for (int i = 0; i < this.container.getContainerSize(); i++) {
296+
for (int i = Constants.INPUT_START; i <= this.inputEnd; i++) {
356297
contents.accountStack(this.container.getItem(i));
357298
}
358299
}
@@ -364,7 +305,7 @@ public void fillCraftSlotsStackedContents(StackedItemContents contents) {
364305

365306
// 2. Tell the server what is already in the workbench slots
366307
// This allows the server to 'add' to the existing count
367-
for (int i = 0; i < this.container.getContainerSize(); i++) {
308+
for (int i = Constants.INPUT_START; i <= this.inputEnd; i++) {
368309
contents.accountStack(this.container.getItem(i));
369310
}
370311
}

src/main/java/com/tcm/MineTale/block/workbenches/menu/CampfireWorkbenchMenu.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
public class CampfireWorkbenchMenu extends AbstractWorkbenchContainerMenu {
2020
private static final int containerDataSize = 4;
2121

22+
@Nullable
2223
private final AbstractWorkbenchEntity blockEntity;
2324

2425
/**

src/main/java/com/tcm/MineTale/recipe/WorkbenchRecipe.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,6 @@ public record WorkbenchRecipe(
4444
*/
4545
@Override
4646
public boolean matches(WorkbenchRecipeInput input, Level level) {
47-
System.out.println("Matches input: " + input);
48-
System.out.println("Matches ingredients: " + ingredients);
49-
5047
if (input == null || ingredients.isEmpty()) return false;
5148

5249
ItemStack slotA = input.inputA();
@@ -122,7 +119,6 @@ public PlacementInfo placementInfo() {
122119
*/
123120
@Override
124121
public RecipeBookCategory recipeBookCategory() {
125-
// Using null as we are using a custom workbench
126122
return ModRecipeDisplay.CAMPFIRE_SEARCH;
127123
}
128124

src/main/java/com/tcm/MineTale/recipe/WorkbenchRecipeDisplay.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public record WorkbenchRecipeDisplay(List<SlotDisplay> ingredients,
2525
public WorkbenchRecipeDisplay(WorkbenchRecipe recipe) {
2626
this(
2727
recipe.ingredients().stream().map(Ingredient::display).toList(),
28-
new SlotDisplay.ItemStackSlotDisplay(recipe.results().get(0)),
28+
new SlotDisplay.ItemStackSlotDisplay(recipe.results().isEmpty() ? ItemStack.EMPTY : recipe.results().get(0)),
2929
new SlotDisplay.ItemStackSlotDisplay(new ItemStack(ModBlocks.FURNACE_WORKBENCH_BLOCK_T1))
3030
);
3131
}

src/main/java/com/tcm/MineTale/registry/ModTiers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public record FurnaceTier(
1818

1919
public static FurnaceTier getTierFromInt(int id) {
2020
return TIER_MAP.keySet().stream()
21-
.filter(t -> t.cookTime() == id)
21+
.filter(t -> t.id() == id)
2222
.findFirst()
2323
.orElse(TIER_1);
2424
}

0 commit comments

Comments
 (0)