Skip to content

Commit 566db9e

Browse files
committed
Add ContainedFood item
Better "StewItem" in which foods can stack and still be eaten 1 at a time
1 parent 378dcb6 commit 566db9e

File tree

6 files changed

+45
-6
lines changed

6 files changed

+45
-6
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ loader_version=0.14.21
1010

1111

1212
# Mod Properties
13-
mod_version=0.3.1
13+
mod_version=0.4.0
1414
maven_group=barch.mc_extended
1515
archives_base_name=mc-extended
1616

src/main/java/barch/mc_extended/Foods/Cheese.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class Cheese {
2525
.saturationModifier(12)
2626
.build();
2727

28-
public static final Item BACON_AND_MUSHROOMS = new StewItem(new FabricItemSettings().food(BACON_AND_MUSHROOMS_FOOD_COMPONENT));
28+
public static final Item BACON_AND_MUSHROOMS = new ContainedFood(new FabricItemSettings().food(BACON_AND_MUSHROOMS_FOOD_COMPONENT).maxCount(16), Items.BOWL);
2929

3030
public static void RegisterAll() {
3131

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package barch.mc_extended.Foods;
2+
3+
import net.minecraft.entity.LivingEntity;
4+
import net.minecraft.entity.player.PlayerEntity;
5+
import net.minecraft.item.Item;
6+
import net.minecraft.item.ItemStack;
7+
import net.minecraft.world.World;
8+
9+
public class ContainedFood extends Item {
10+
private final Item giveBack;
11+
12+
public ContainedFood(Settings settings, Item giveBack) {
13+
super(settings);
14+
this.giveBack = giveBack;
15+
}
16+
17+
@Override
18+
public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
19+
ItemStack itemStack = super.finishUsing(stack, world, user);
20+
if (user instanceof PlayerEntity && ((PlayerEntity)user).getAbilities().creativeMode) {
21+
return itemStack;
22+
}
23+
24+
if (itemStack.getCount() < 1) {
25+
return new ItemStack(this.giveBack);
26+
}
27+
28+
user.dropItem(this.giveBack, 1);
29+
return itemStack;
30+
}
31+
}

src/main/java/barch/mc_extended/Foods/Onion.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class Onion {
7676
public static final Item FRIED_ONION = new Item(new FabricItemSettings().food(FRIED_ONION_FOOD_COMPONANT));
7777

7878
// onion sauce
79-
public static final Item ONION_TOMATO_SAUCE = new StewItem(new FabricItemSettings().food(ONION_SAUCE_FOOD_COMPONANT).maxCount(1));
79+
public static final Item ONION_TOMATO_SAUCE = new ContainedFood(new FabricItemSettings().food(ONION_SAUCE_FOOD_COMPONANT), Items.BOWL);
8080

8181

8282
// onion feature

src/main/java/barch/mc_extended/Foods/Tomato.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public class Tomato {
7676
public static final Item ROAST_TOMATO = new Item(new FabricItemSettings().food(ROAST_TOMATO_FOOD_COMPONANT));
7777

7878
// tomato sauce
79-
public static final Item TOMATO_SAUCE = new StewItem(new FabricItemSettings().food(TOMATO_SAUCE_FOOD_COMPONANT).maxCount(1));
79+
public static final Item TOMATO_SAUCE = new ContainedFood(new FabricItemSettings().food(TOMATO_SAUCE_FOOD_COMPONANT), Items.BOWL);
8080

8181

8282
// tomato feature

src/main/resources/changelog.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2023-9-8
9+
### Changed
10+
- all stews are now "ContainedFoods"
11+
- tomato sauce
12+
- onion tomato sauce
13+
- bacon and mushrooms
14+
815
## [0.3.1] - 2023-9-8
916
### Fixed
1017
- bacon and mushrooms model
@@ -292,8 +299,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
292299
- deepslate ruby ore
293300
- ruby block
294301

295-
[0.3.0]: https://github.com/BarchamMal/MC-Extended/commit/
296-
[0.3.1]: https://github.com/BarchamMal/MC-Extended/commit/97641cc3b4809d947953fd8fa6c8d16cbb0ba7e4
302+
[0.4.0]: https://github.com/BarchamMal/MC-Extended/commit/
303+
[0.3.1]: https://github.com/BarchamMal/MC-Extended/commit/378dcb6ab5cea2841aa15ba7db474b11b56b5538
304+
[0.3.0]: https://github.com/BarchamMal/MC-Extended/commit/97641cc3b4809d947953fd8fa6c8d16cbb0ba7e4
297305
[0.2.5]: https://github.com/BarchamMal/MC-Extended/commit/97641cc3b4809d947953fd8fa6c8d16cbb0ba7e4
298306
[0.2.4]: https://github.com/BarchamMal/MC-Extended/commit/c7b83a5135e549532c4dd4b6657f140957cfd31f
299307
[0.2.3]: https://github.com/BarchamMal/MC-Extended/commit/747cc0ceb81f4288abf79e40784574a3411c76ac

0 commit comments

Comments
 (0)