Skip to content

Commit 773ef6f

Browse files
committed
Merge branch 'api-12' into api-14
# Conflicts: # neoforge/src/main/resource-templates/META-INF/neoforge.mods.toml # src/main/java/org/spongepowered/common/item/recipe/crafting/shapeless/SpongeShapelessRecipe.java # src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java
2 parents 274e264 + 776a487 commit 773ef6f

File tree

3 files changed

+22
-11
lines changed

3 files changed

+22
-11
lines changed

neoforge/src/main/resource-templates/META-INF/neoforge.mods.toml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ description = "{{ description }}"
1616

1717
[[dependencies.spongeneo]]
1818
modId="neoforge"
19-
mandatory=true
19+
type="required"
2020
versionRange="[{{ neoForgeVersion }},)"
2121
ordering="AFTER"
22-
side="BOTH"
2322

2423
[[dependencies.spongeneo]]
2524
modId="sponge"
26-
mandatory=true
25+
type="required"
2726
versionRange="[{{ version }}]"
2827
ordering="AFTER"
29-
side="BOTH"
3028

3129

3230
[[mods]]
@@ -40,10 +38,9 @@ description="The SpongeAPI implementation targeting vanilla Minecraft and 3rd pa
4038

4139
[[dependencies.sponge]]
4240
modId="spongeapi"
43-
mandatory=true
41+
type="required"
4442
versionRange="[{{ apiVersion }},)"
4543
ordering="AFTER"
46-
side="BOTH"
4744

4845

4946
[[mods]]
@@ -55,6 +52,11 @@ credits="SpongePowered and Contributors"
5552
authors="SpongePowered"
5653
description="A Minecraft plugin API"
5754

55+
5856
["lithium:options"]
5957
"mixin.world.tick_scheduler"=false
6058
"mixin.collections.entity_filtering"=false
59+
60+
[[dependencies.spongeneo]]
61+
modId="adventure_platform_neoforge"
62+
type="incompatible"

src/main/java/org/spongepowered/common/item/recipe/crafting/shapeless/SpongeShapelessRecipe.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public boolean matches(final CraftingInput $$0, final Level $$1) {
7272
if (this.onlyVanillaIngredients) {
7373
return super.matches($$0, $$1);
7474
}
75-
return SpongeShapelessRecipe.matches($$0.items(), ((ShapelessRecipeAccessor) this).accessor$ingredients());
75+
return SpongeShapelessRecipe.matches($$0, ((ShapelessRecipeAccessor) this).accessor$ingredients());
7676
}
7777

7878
@Override
@@ -93,19 +93,22 @@ public ItemStack assemble(final CraftingInput $$0, final HolderLookup.Provider $
9393
}
9494

9595
private static boolean
96-
matches(List<ItemStack> stacks, List<Ingredient> ingredients) {
96+
matches(CraftingInput input, List<Ingredient> ingredients) {
9797
final int elements = ingredients.size();
98-
if (stacks.size() < elements) {
98+
if (input.ingredientCount() != elements) {
99+
// The amount of non-empty stacks doesn't match the amount of ingredients
99100
return false;
100101
}
101102

103+
final List<ItemStack> stacks = input.items();
102104
// find matched stack -> ingredient list
103105
final Map<Integer, List<Integer>> matchesMap = new HashMap<>();
104106
for (int i = 0; i < ingredients.size(); i++) {
105107
Ingredient ingredient = ingredients.get(i);
106108
boolean noMatch = true;
107109
for (int j = 0; j < stacks.size(); j++) {
108-
if (ingredient.test(stacks.get(j))) {
110+
final ItemStack stack = stacks.get(j);
111+
if (!stack.isEmpty() && ingredient.test(stack)) {
109112
matchesMap.computeIfAbsent(j, k -> new ArrayList<>()).add(i);;
110113
noMatch = false;
111114
}
@@ -116,7 +119,8 @@ public ItemStack assemble(final CraftingInput $$0, final HolderLookup.Provider $
116119
}
117120
}
118121

119-
if (matchesMap.isEmpty()) {
122+
if (matchesMap.size() != elements) {
123+
// At least one stack had no matching ingredient
120124
return false;
121125
}
122126

src/mixins/java/org/spongepowered/common/mixin/tracker/server/level/ServerPlayerGameModeMixin_Tracker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
import com.llamalad7.mixinextras.sugar.Share;
3232
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef;
3333
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
34+
import net.minecraft.network.protocol.game.ClientboundSetHealthPacket;
3435
import net.minecraft.server.level.ServerLevel;
3536
import net.minecraft.server.level.ServerPlayer;
3637
import net.minecraft.server.level.ServerPlayerGameMode;
3738
import net.minecraft.world.InteractionHand;
3839
import net.minecraft.world.InteractionResult;
3940
import net.minecraft.world.entity.player.Player;
41+
import net.minecraft.world.food.FoodData;
4042
import net.minecraft.world.inventory.AbstractContainerMenu;
4143
import net.minecraft.world.item.ItemStack;
4244
import net.minecraft.world.item.context.UseOnContext;
@@ -105,6 +107,9 @@ public abstract class ServerPlayerGameModeMixin_Tracker {
105107
((ServerPlayerGameModeBridge) this).bridge$setInteractBlockRightClickCancelled(event.isCancelled());
106108
if (event.isCancelled()) {
107109
this.player.inventoryMenu.sendAllDataToRemote();
110+
// Eating a cake increases the food level on client-side
111+
final FoodData foodData = player.getFoodData();
112+
this.player.connection.send(new ClientboundSetHealthPacket(player.getHealth(), foodData.getFoodLevel(), foodData.getSaturationLevel()));
108113
return InteractionResult.FAIL;
109114
}
110115

0 commit comments

Comments
 (0)