Added apple pie slices

This commit is contained in:
Sollace 2022-09-30 00:54:09 +02:00
parent e1659c32b2
commit cc1b91de20
8 changed files with 37 additions and 6 deletions

View file

@ -12,6 +12,7 @@ import net.minecraft.fluid.FluidState;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.*;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents;
import net.minecraft.stat.Stats;
import net.minecraft.state.StateManager;
@ -45,9 +46,12 @@ public class PieBlock extends Block implements Waterloggable {
};
}
public PieBlock(Settings settings) {
private final ItemConvertible sliceItem;
public PieBlock(Settings settings, ItemConvertible sliceItem) {
super(settings);
setDefaultState(getDefaultState().with(STOMPED, false).with(WATERLOGGED, false));
this.sliceItem = sliceItem;
}
@Deprecated
@ -62,6 +66,11 @@ public class PieBlock extends Block implements Waterloggable {
ItemStack itemStack = player.getStackInHand(hand);
if (world.isClient) {
if (itemStack.getItem() == Items.SHEARS) {
return ActionResult.SUCCESS;
}
if (tryEat(world, pos, state, player).isAccepted()) {
return ActionResult.SUCCESS;
}
@ -71,6 +80,14 @@ public class PieBlock extends Block implements Waterloggable {
}
}
if (itemStack.getItem() == Items.SHEARS) {
SoundEmitter.playSoundAt(player, SoundEvents.BLOCK_BEEHIVE_SHEAR, SoundCategory.NEUTRAL, 1, 1);
removeSlice(world, pos, state, player);
SoundEmitter.playSoundAt(player, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.NEUTRAL, 0.5F, world.getRandom().nextFloat() * 0.1F + 0.9F);
Block.dropStack(world, pos, sliceItem.asItem().getDefaultStack());
return ActionResult.SUCCESS;
}
return tryEat(world, pos, state, player);
}
@ -80,7 +97,7 @@ public class PieBlock extends Block implements Waterloggable {
}
player.incrementStat(Stats.EAT_CAKE_SLICE);
player.getHungerManager().add(state.get(STOMPED) ? 1 : 2, 0.1f);
int bites = state.get(BITES);
world.emitGameEvent(player, GameEvent.EAT, pos);
SoundEmitter.playSoundAt(player, SoundEvents.ENTITY_GENERIC_EAT, 0.5F, world.getRandom().nextFloat() * 0.1F + 0.9F);
if (world instanceof World ww && (!player.canConsume(false) || world.getRandom().nextInt(10) == 0)) {
@ -89,13 +106,19 @@ public class PieBlock extends Block implements Waterloggable {
}, 5);
}
removeSlice(world, pos, state, player);
return ActionResult.SUCCESS;
}
protected void removeSlice(WorldAccess world, BlockPos pos, BlockState state, PlayerEntity player) {
int bites = state.get(BITES);
if (bites < MAX_BITES) {
world.setBlockState(pos, state.with(BITES, bites + 1), Block.NOTIFY_ALL);
} else {
world.removeBlock(pos, false);
world.emitGameEvent(player, GameEvent.BLOCK_DESTROY, pos);
}
return ActionResult.SUCCESS;
}
@Override

View file

@ -66,7 +66,7 @@ public interface UBlocks {
Block SOUR_APPLE = register("sour_apple", new FruitBlock(FabricBlockSettings.of(Material.GOURD, MapColor.GREEN).sounds(BlockSoundGroup.WOOD), Direction.DOWN, SOUR_APPLE_LEAVES, FruitBlock.DEFAULT_SHAPE));
Block SOUR_APPLE_SPROUT = register("sour_apple_sprout", new SproutBlock(0xE5FFCC88, () -> UItems.SOUR_APPLE_SEEDS, () -> UTreeGen.SOUR_APPLE_TREE.sapling().map(Block::getDefaultState).get()));
Block APPLE_PIE = register("apple_pie", new PieBlock(FabricBlockSettings.of(Material.CAKE, MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS)));
Block APPLE_PIE = register("apple_pie", new PieBlock(FabricBlockSettings.of(Material.CAKE, MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS), () -> UItems.APPLE_PIE_SLICE));
SegmentedCropBlock OATS = register("oats", SegmentedCropBlock.create(11, 5, AbstractBlock.Settings.copy(Blocks.WHEAT), () -> UItems.OAT_SEEDS, null, () -> UBlocks.OATS_STEM));
SegmentedCropBlock OATS_STEM = register("oats_stem", OATS.createNext(5));

View file

@ -84,6 +84,7 @@ public interface UItems {
Item JUICE = register("juice", new DrinkableItem(new Item.Settings().group(ItemGroup.FOOD).recipeRemainder(Items.GLASS_BOTTLE).maxCount(1).food(UFoodComponents.JUICE)));
Item BURNED_JUICE = register("burned_juice", new DrinkableItem(new Item.Settings().group(ItemGroup.FOOD).recipeRemainder(Items.GLASS_BOTTLE).maxCount(1).food(UFoodComponents.BURNED_JUICE)));
Item APPLE_PIE = register("apple_pie", new BlockItem(UBlocks.APPLE_PIE, new Item.Settings().group(ItemGroup.FOOD).maxCount(1)));
Item APPLE_PIE_SLICE = register("apple_pie_slice", new Item(new Item.Settings().group(ItemGroup.FOOD).maxCount(16).food(UFoodComponents.PIE)));
Item GOLDEN_FEATHER = register("golden_feather", new Item(new Item.Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.MATERIALS)));
Item GOLDEN_WING = register("golden_wing", new Item(new Item.Settings().rarity(Rarity.UNCOMMON).group(ItemGroup.MATERIALS)));

View file

@ -15,10 +15,10 @@ public interface UFoodComponents {
FoodComponent DAFODIL_DAISY_SANDWICH = builder(3, 2).build();
FoodComponent HAY_BURGER = builder(7, 1.4F).build();
FoodComponent HAY_FRIES = builder(4, 2).build();
FoodComponent SALAD = builder(3, 1).build();
FoodComponent PIE = builder(3, 1.26F).build();
FoodComponent CIDER = builder(2, 1.7F).alwaysEdible().build();
FoodComponent JUICE = builder(2, 2).alwaysEdible().build();
FoodComponent JUICE = builder(2, 1.8F).alwaysEdible().build();
FoodComponent BURNED_JUICE = builder(3, 1).build();
FoodComponent RANDOM_FOLIAGE = builder(2, 1).build();

View file

@ -63,6 +63,7 @@
"item.unicopia.green_apple_seeds": "Granny Smith Apple Seeds",
"item.unicopia.sweet_apple_seeds": "Sweet Apple Seeds",
"item.unicopia.sour_apple_seeds": "Sour Apple Seeds",
"item.unicopia.apple_pie_slice": "Slice Of Apple Pie",
"item.unicopia.oats": "Oats",
"item.unicopia.imported_oats": "Fancy Imported Oats",

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "unicopia:item/apple_pie_slice"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB