Skip to content

Commit 981db2c

Browse files
JustinasLaclaude
andauthored
fix: keep other plugins' slot display for food on their furniture (#59)
PlateManager.addItem had a stray semicolon after its furniture check, so every food item placed on any InteractibleFurniture slot got the cooking display pose (flat, full size). Salt on magic pedestals showed oversized. Only apply cooking display data to Cooking-owned furniture. Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent aa4601a commit 981db2c

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

‎src/main/java/net/tfminecraft/cooking/cache/FurnitureCache.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,10 @@ public static boolean isBowl(Furniture f) {
9090
public static boolean isMealHolder(Furniture f) {
9191
return isBowl(f) || isPlate(f);
9292
}
93+
94+
// Other plugins' furniture (pedestals, displays) keeps its own slot display.
95+
public static boolean isCookingFurniture(Furniture f) {
96+
return f.getType() != null
97+
&& f.getType().getItemPath().toLowerCase().startsWith("ia.tfmc_cooking:");
98+
}
9399
}

‎src/main/java/net/tfminecraft/cooking/manager/PlateManager.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ public void interact(FurnitureInteractEvent e) {
244244
@EventHandler
245245
public void addItem(FurnitureSlotItemAddEvent e) {
246246
Furniture f = e.getFurniture();
247-
if(FurnitureCache.isMealHolder(f));
247+
if(!FurnitureCache.isCookingFurniture(f)) return;
248248
ItemStack item = e.getItem();
249249
FoodItem fi = FoodItem.fromItem(item);
250250
if(fi == null) return;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.tfminecraft.cooking.cache;
2+
3+
import static org.junit.jupiter.api.Assertions.assertFalse;
4+
import static org.junit.jupiter.api.Assertions.assertTrue;
5+
import static org.mockito.Mockito.mock;
6+
import static org.mockito.Mockito.when;
7+
8+
import org.junit.jupiter.api.Test;
9+
10+
import net.tfminecraft.interactiblefurniture.furniture.Furniture;
11+
import net.tfminecraft.interactiblefurniture.furniture.FurnitureType;
12+
13+
class CookingFurnitureTest {
14+
15+
@Test
16+
void cookingFurnitureIsRecognised() {
17+
assertTrue(FurnitureCache.isCookingFurniture(furniture("ia.tfmc_cooking:plate")));
18+
}
19+
20+
@Test
21+
void magicPedestalIsNotCookingFurniture() {
22+
assertFalse(FurnitureCache.isCookingFurniture(furniture("ia.tfmc:pedestal")));
23+
}
24+
25+
@Test
26+
void furnitureWithoutTypeIsNotCookingFurniture() {
27+
assertFalse(FurnitureCache.isCookingFurniture(mock(Furniture.class)));
28+
}
29+
30+
private static Furniture furniture(String itemPath) {
31+
FurnitureType type = mock(FurnitureType.class);
32+
when(type.getItemPath()).thenReturn(itemPath);
33+
Furniture furniture = mock(Furniture.class);
34+
when(furniture.getType()).thenReturn(type);
35+
return furniture;
36+
}
37+
}

0 commit comments

Comments
 (0)