mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-04 09:58:00 +01:00
Return the empty container when eating stacked food with containers
This commit is contained in:
parent
34bdd7f135
commit
7140ce6d0e
1 changed files with 12 additions and 1 deletions
|
@ -4,8 +4,10 @@ import java.util.Optional;
|
||||||
|
|
||||||
import net.minecraft.advancement.criterion.Criteria;
|
import net.minecraft.advancement.criterion.Criteria;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.ItemUsage;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.stat.Stats;
|
import net.minecraft.stat.Stats;
|
||||||
import net.minecraft.util.UseAction;
|
import net.minecraft.util.UseAction;
|
||||||
|
@ -29,7 +31,16 @@ public class ConsumableItem extends Item {
|
||||||
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
|
serverPlayerEntity.incrementStat(Stats.USED.getOrCreateStat(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
return stack.isEmpty() ? Optional.ofNullable(getRecipeRemainder()).map(Item::getDefaultStack).orElse(ItemStack.EMPTY) : stack;
|
if (stack.isEmpty()) {
|
||||||
|
return stack.isEmpty() ? Optional.ofNullable(getRecipeRemainder()).map(Item::getDefaultStack).orElse(ItemStack.EMPTY) : stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user instanceof PlayerEntity player) {
|
||||||
|
return Optional.ofNullable(getRecipeRemainder()).map(Item::getDefaultStack).map(remainder -> {
|
||||||
|
return ItemUsage.exchangeStack(stack, player, remainder);
|
||||||
|
}).orElse(stack);
|
||||||
|
}
|
||||||
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue