Skip to content

Commit de91490

Browse files
committed
Fixed Curry not getting taste rating during shift click crafting.
1 parent 74f07ba commit de91490

5 files changed

Lines changed: 77 additions & 35 deletions

File tree

common/src/main/java/generations/gg/generations/core/generationscore/common/api/events/CurryEvents.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import generations.gg.generations.core.generationscore.common.world.item.curry.CurryTasteRating;
1111
import generations.gg.generations.core.generationscore.common.world.item.curry.CurryType;
1212
import net.minecraft.server.level.ServerPlayer;
13+
import net.minecraft.world.entity.player.Player;
1314
import net.minecraft.world.item.ItemStack;
1415
import org.jetbrains.annotations.NotNull;
1516
import org.jetbrains.annotations.Nullable;

common/src/main/java/generations/gg/generations/core/generationscore/common/world/container/CookingPotContainer.java

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import generations.gg.generations.core.generationscore.common.world.level.block.entities.CookingPotBlockEntity;
77
import generations.gg.generations.core.generationscore.common.world.container.slots.CurryResultSlot;
88
import generations.gg.generations.core.generationscore.common.world.container.slots.PredicateSlotItemHandler;
9+
import net.minecraft.nbt.CompoundTag;
910
import net.minecraft.tags.ItemTags;
1011
import net.minecraft.world.entity.player.Inventory;
1112
import net.minecraft.world.entity.player.Player;
@@ -67,36 +68,62 @@ public boolean stillValid(@NotNull Player playerIn) {
6768

6869
@Override
6970
public @NotNull ItemStack quickMoveStack(@NotNull Player playerIn, int index) {
70-
ItemStack stack = ItemStack.EMPTY;
7171
Slot slot = this.slots.get(index);
72+
if (!slot.hasItem()) return ItemStack.EMPTY;
7273

73-
if (slot.hasItem()) {
74-
ItemStack slotStack = slot.getItem();
75-
stack = slotStack.copy();
76-
77-
if (index < 14) {
78-
if (!this.moveItemStackTo(slotStack, 14, 49, false)) return ItemStack.EMPTY;
79-
if (index == 13) slot.onQuickCraft(slotStack, stack);
80-
} else if (index < 50) {
81-
if (isBerryOrMaxMushrooms(stack)) {
82-
if (!this.moveItemStackTo(slotStack, 0, 10, false)) return ItemStack.EMPTY;
83-
} else if (isBowl(stack)) {
84-
if (!this.moveItemStackTo(slotStack, 10, 11, false)) return ItemStack.EMPTY;
85-
} else if (isCurryIngredientOrMaxHoney(stack)) {
86-
if (!this.moveItemStackTo(slotStack, 11, 12, false)) return ItemStack.EMPTY;
87-
} else if (isLog(stack)) {
88-
if (!this.moveItemStackTo(slotStack, 12, 13, false)) return ItemStack.EMPTY;
89-
}
74+
ItemStack slotStack = slot.getItem();
75+
ItemStack originalStack = slotStack.copy(); // Copy to retain original data
76+
77+
// Store NBT for debugging before we move it
78+
CompoundTag originalNBT = slotStack.hasTag() ? slotStack.getTag().copy() : null;
79+
80+
// Debug Log: Initial State
81+
System.out.println("[DEBUG] Shift-Click Event:");
82+
System.out.println(" - Clicked Slot Index: " + index);
83+
System.out.println(" - Original Stack: " + originalStack);
84+
System.out.println(" - Original NBT: " + (originalNBT != null ? originalNBT : "None"));
85+
86+
boolean moved = false;
87+
88+
// If the slot is the crafting output (slot 13), ensure crafting logic is applied before moving
89+
if (index == 13) {
90+
System.out.println(" - Crafting Slot Detected! Running `onTake()` before moving.");
91+
slot.onTake(playerIn, slotStack);
92+
}
93+
94+
if (index < 14) {
95+
this.moveItemStackTo(slotStack, 14, 49, false);
96+
} else if (index < 50) {
97+
if (isBerryOrMaxMushrooms(originalStack)) {
98+
this.moveItemStackTo(slotStack, 0, 10, false);
99+
} else if (isBowl(originalStack)) {
100+
this.moveItemStackTo(slotStack, 10, 11, false);
101+
} else if (isCurryIngredientOrMaxHoney(originalStack)) {
102+
this.moveItemStackTo(slotStack, 11, 12, false);
103+
} else if (isLog(originalStack)) {
104+
this.moveItemStackTo(slotStack, 12, 13, false);
90105
}
106+
}
107+
108+
if (!ItemStack.matches(slotStack, originalStack)) {
109+
slotStack.setTag(originalNBT);
110+
}
91111

92-
if (slotStack.getCount() == 0) slot.safeInsert(ItemStack.EMPTY);
93-
else slot.setChanged();
112+
if (slotStack.getCount() == 0) {
113+
slot.safeInsert(ItemStack.EMPTY);
114+
} else {
115+
slot.setChanged();
116+
}
117+
118+
if (slotStack.getCount() == originalStack.getCount()) {
119+
return ItemStack.EMPTY;
120+
}
94121

95-
if (slotStack.getCount() == stack.getCount()) return ItemStack.EMPTY;
96-
slot.onTake(playerIn, stack);
122+
if (index == 13) {
123+
slot.onTake(playerIn, originalStack);
97124
}
98125

99-
return stack;
126+
return originalStack;
100127
}
101128

102129
public static boolean isLog(ItemStack stack) {

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/curry/CurryData.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ public CurryData(CurryType mainIngredient, List<Berry> berries) {
4848
this(mainIngredient, berries, CurryTasteRating.Unknown);
4949
}
5050

51-
public Flavor getFlavor() {
51+
public CurryData(@Nullable Flavor flavor, CurryType curryType, int experience, double healthPercentage, boolean canHealStatus, boolean canRestorePP, int friendship, CurryTasteRating rating) {
52+
this.flavor = flavor;
53+
this.curryType = curryType;
54+
this.experience = experience;
55+
this.healthPercentage = healthPercentage;
56+
this.canHealStatus = canHealStatus;
57+
this.canRestorePP = canRestorePP;
58+
this.friendship = friendship;
59+
this.rating = rating;
60+
}
61+
62+
public @Nullable Flavor getFlavor() {
5263
return flavor;
5364
}
5465

@@ -144,15 +155,16 @@ public static CurryData fromNbt(CompoundTag nbt) {
144155
return curry;
145156
}
146157

147-
var flavor = nbt.getInt("flavor");
148-
149-
return curry.setFlavor(flavor == -1 ? null : Flavor.values()[flavor])
150-
.setCurryType(CurryType.getCurryTypeFromIndex(nbt.getInt("type")))
151-
.setRating(CurryTasteRating.fromId(nbt.getInt("rating")))
152-
.setExperience(nbt.getInt("experience"))
153-
.setHealthPercentage(nbt.getDouble("healthPercentage"))
154-
.setCanHealStatus(nbt.getBoolean("canHealStatus"))
155-
.setCanRestorePP(nbt.getBoolean("canRestorePP"))
156-
.setFriendship(nbt.getInt("friendship"));
158+
var flavorId = nbt.getInt("flavor");
159+
var flavor = flavorId == -1 ? null : Flavor.values()[flavorId];
160+
var type = CurryType.getCurryTypeFromIndex(nbt.getInt("type"));
161+
var experience = nbt.getInt("experience");
162+
var healthPercentage = nbt.getDouble("healthPercentage");
163+
var canHealStatus = nbt.getBoolean("canHealStatus");
164+
var canRestorePP = nbt.getBoolean("canRestorePP");
165+
var friendship = nbt.getInt("friendship");
166+
var rating = CurryTasteRating.fromId(nbt.getInt("rating"));
167+
168+
return new CurryData(flavor, type, experience, healthPercentage, canHealStatus, canRestorePP, friendship, rating);
157169
}
158170
}

common/src/main/java/generations/gg/generations/core/generationscore/common/world/item/curry/ItemCurry.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ class ItemCurry(properties: Properties) : Item(properties.stacksTo(64)), Pokemon
5555

5656
override fun onCraftedBy(stack: ItemStack, level: Level, player: Player) {
5757
if (player is ServerPlayer) {
58+
5859
val data = getData(stack)
5960
val rating = CurryEvents.MODIFY_RATING.invoker().modifyRating(CurryTasteRating.Koffing, player, data)!! //CurryDex.of(player).currentTaste
61+
6062
data.setRating(rating)
6163
rating.configureData(data)
6264
setData(stack, data)

common/src/main/resources/data/generations_core/dialogues/zygarde_cell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
{
6161
"text": "50%",
6262
"value": "50",
63-
"isVisible": "v.cells >= 10",
63+
"isVisible": "v.cells >= ",
6464
"action": [
6565
"v.form = '50%';",
6666
"v.cells_needed = 50;",

0 commit comments

Comments
 (0)