diff --git a/src/main/java/com/minelittlepony/unicopia/block/PieBlock.java b/src/main/java/com/minelittlepony/unicopia/block/PieBlock.java index 1ebb41af..7c9db33a 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/PieBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/PieBlock.java @@ -1,6 +1,7 @@ package com.minelittlepony.unicopia.block; import com.minelittlepony.unicopia.*; +import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.util.SoundEmitter; import net.minecraft.block.*; @@ -35,11 +36,11 @@ public class PieBlock extends Block implements Waterloggable { private static final VoxelShape[] SHAPES; static { - final int PIE_HEIGHT = 5; - final VoxelShape WEDGE = Block.createCuboidShape(1, 0, 1, 8, PIE_HEIGHT, 8); - final float OFFSET_AMOUNT = 7F/16F; + final int PIE_HEIGHT = 4; + final VoxelShape WEDGE = Block.createCuboidShape(2, 0, 2, 8, PIE_HEIGHT, 8); + final float OFFSET_AMOUNT = 6F/16F; SHAPES = new VoxelShape[] { - Block.createCuboidShape(1, 0, 1, 15, PIE_HEIGHT, 15), + Block.createCuboidShape(2, 0, 2, 14, PIE_HEIGHT, 14), VoxelShapes.union(WEDGE, WEDGE.offset(OFFSET_AMOUNT, 0, 0), WEDGE.offset(OFFSET_AMOUNT, 0, OFFSET_AMOUNT)), VoxelShapes.union(WEDGE, WEDGE.offset(OFFSET_AMOUNT, 0, 0)), WEDGE @@ -47,11 +48,15 @@ public class PieBlock extends Block implements Waterloggable { } private final ItemConvertible sliceItem; + private final ItemConvertible normalItem; + private final ItemConvertible stompedItem; - public PieBlock(Settings settings, ItemConvertible sliceItem) { + public PieBlock(Settings settings, ItemConvertible sliceItem, ItemConvertible normalItem, ItemConvertible stompedItem) { super(settings); setDefaultState(getDefaultState().with(STOMPED, false).with(WATERLOGGED, false)); this.sliceItem = sliceItem; + this.normalItem = normalItem; + this.stompedItem = stompedItem; } @Deprecated @@ -122,6 +127,11 @@ public class PieBlock extends Block implements Waterloggable { } } + @Override + public ItemStack getPickStack(BlockView world, BlockPos pos, BlockState state) { + return (state.get(STOMPED) ? stompedItem : normalItem).asItem().getDefaultStack(); + } + @Override public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) { if (state.get(STOMPED)) { @@ -179,7 +189,9 @@ public class PieBlock extends Block implements Waterloggable { @Deprecated @Override public BlockState getPlacementState(ItemPlacementContext ctx) { - return super.getDefaultState().with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER); + return super.getDefaultState() + .with(WATERLOGGED, ctx.getWorld().getFluidState(ctx.getBlockPos()).getFluid() == Fluids.WATER) + .with(STOMPED, ctx.getStack().isOf(UItems.APPLE_PIE_HOOF)); } @Deprecated diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index 6e7d3437..e313f357 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -7,9 +7,6 @@ import com.minelittlepony.unicopia.Unicopia; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.minelittlepony.unicopia.server.world.UTreeGen; -import com.terraformersmc.terraform.boat.api.TerraformBoatType; -import com.terraformersmc.terraform.boat.api.TerraformBoatTypeRegistry; - import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; @@ -102,26 +99,30 @@ public interface UBlocks { Block SOUR_APPLE = register("sour_apple", new FruitBlock(Settings.create().mapColor(MapColor.GREEN), 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(Settings.create().solid().mapColor(MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WET_GRASS).pistonBehavior(PistonBehavior.DESTROY), () -> UItems.APPLE_PIE_SLICE)); + Block APPLE_PIE = register("apple_pie", new PieBlock(Settings.create().solid().mapColor(MapColor.ORANGE).strength(0.5F).sounds(BlockSoundGroup.WOOL).pistonBehavior(PistonBehavior.DESTROY), + () -> UItems.APPLE_PIE_SLICE, + () -> UItems.APPLE_PIE, + () -> UItems.APPLE_PIE_HOOF + )); 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)); SegmentedCropBlock OATS_CROWN = register("oats_crown", OATS_STEM.createNext(5)); - static T register(String name, T item) { + private static T register(String name, T item) { return register(Unicopia.id(name), item); } - static T register(String name, T block, RegistryKey group) { + private static T register(String name, T block, RegistryKey group) { return register(Unicopia.id(name), block, group); } static T register(Identifier id, T block, RegistryKey group) { - BlockItem.BLOCK_ITEMS.put(block, UItems.register(id, ItemGroupRegistry.register(new BlockItem(block, new Item.Settings()), group))); + ItemGroupRegistry.register(id, new BlockItem(block, new Item.Settings()), group); return register(id, block); } - static T register(Identifier id, T block) { + private static T register(Identifier id, T block) { if (block instanceof TintedBlock) { TintedBlock.REGISTRY.add(block); } @@ -151,11 +152,5 @@ public interface UBlocks { FlammableBlockRegistry.getDefaultInstance().add(BANANAS, 5, 20); UBlockEntities.bootstrap(); - - Registry.register(TerraformBoatTypeRegistry.INSTANCE, Unicopia.id("palm"), new TerraformBoatType.Builder() - .planks(PALM_PLANKS.asItem()) - .item(UItems.PALM_BOAT) - .build()); - } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index a2d47ea6..7c3c2650 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -1,8 +1,5 @@ package com.minelittlepony.unicopia.item; -import java.util.ArrayList; -import java.util.List; - import com.minelittlepony.unicopia.*; import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UWoodTypes; @@ -12,6 +9,8 @@ import com.minelittlepony.unicopia.item.enchantment.UEnchantments; import com.minelittlepony.unicopia.item.group.ItemGroupRegistry; import com.minelittlepony.unicopia.item.group.UItemGroups; import com.minelittlepony.unicopia.item.toxin.UFoodComponents; +import com.terraformersmc.terraform.boat.api.TerraformBoatType; +import com.terraformersmc.terraform.boat.api.TerraformBoatTypeRegistry; import com.terraformersmc.terraform.boat.api.item.TerraformBoatItemHelper; import net.minecraft.entity.vehicle.BoatEntity; @@ -21,16 +20,12 @@ import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.registry.CompostingChanceRegistry; import net.fabricmc.fabric.api.registry.FuelRegistry; import net.minecraft.sound.SoundEvent; -import net.minecraft.util.Identifier; import net.minecraft.util.Rarity; import net.minecraft.registry.Registry; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.Registries; public interface UItems { - - List ITEMS = new ArrayList<>(); - Item GREEN_APPLE = register("green_apple", AppleItem.registerTickCallback(new Item(new Item.Settings().food(FoodComponents.APPLE))), ItemGroups.FOOD_AND_DRINK); Item SWEET_APPLE = register("sweet_apple", AppleItem.registerTickCallback(new Item(new Item.Settings().food(FoodComponents.APPLE))), ItemGroups.FOOD_AND_DRINK); Item SOUR_APPLE = register("sour_apple", AppleItem.registerTickCallback(new Item(new Item.Settings().food(FoodComponents.APPLE))), ItemGroups.FOOD_AND_DRINK); @@ -96,6 +91,7 @@ public interface UItems { Item JUICE = register("juice", new DrinkableItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE).maxCount(1).food(UFoodComponents.JUICE)), ItemGroups.FOOD_AND_DRINK); Item BURNED_JUICE = register("burned_juice", new DrinkableItem(new Item.Settings().recipeRemainder(Items.GLASS_BOTTLE).maxCount(1).food(UFoodComponents.BURNED_JUICE)), ItemGroups.FOOD_AND_DRINK); Item APPLE_PIE = register("apple_pie", new BlockItem(UBlocks.APPLE_PIE, new Item.Settings().maxCount(1)), ItemGroups.FOOD_AND_DRINK); + Item APPLE_PIE_HOOF = register("apple_pie_hoof", new AliasedBlockItem(UBlocks.APPLE_PIE, new Item.Settings().maxCount(1)), ItemGroups.FOOD_AND_DRINK); Item APPLE_PIE_SLICE = register("apple_pie_slice", new Item(new Item.Settings().maxCount(16).food(UFoodComponents.PIE)), ItemGroups.FOOD_AND_DRINK); Item LOVE_BOTTLE = register("love_bottle", new DrinkableItem(new Item.Settings().food(UFoodComponents.LOVE_BOTTLE).maxCount(1).recipeRemainder(Items.GLASS_BOTTLE)), ItemGroups.FOOD_AND_DRINK); @@ -157,21 +153,12 @@ public interface UItems { Item BAT_BADGE = register(Race.BAT); Item CHANGELING_BADGE = register(Race.CHANGELING); - static T register(String name, T item, RegistryKey group) { - return ItemGroupRegistry.register(register(name, item), group); + private static T register(String name, T item, RegistryKey group) { + return ItemGroupRegistry.register(Unicopia.id(name), item, group); } - @Deprecated - static T register(String name, T item) { - return register(Unicopia.id(name), item); - } - - static T register(Identifier id, T item) { - if (item instanceof BlockItem bi && bi.getBlock() == null) { - throw new NullPointerException("Registered block item did not have a block " + id); - } - ITEMS.add(item); - return Registry.register(Registries.ITEM, id, item); + private static T register(String name, T item) { + return ItemGroupRegistry.register(Unicopia.id(name), item); } static MusicDiscItem register(String name, SoundEvent sound, int seconds) { @@ -221,5 +208,10 @@ public interface UItems { UEnchantments.bootstrap(); URecipes.bootstrap(); UItemGroups.bootstrap(); + + Registry.register(TerraformBoatTypeRegistry.INSTANCE, Unicopia.id("palm"), new TerraformBoatType.Builder() + .planks(UBlocks.PALM_PLANKS.asItem()) + .item(PALM_BOAT) + .build()); } } diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java index 071f258f..3998f13b 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/ItemGroupRegistry.java @@ -16,9 +16,11 @@ import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.tag.TagKey; import net.minecraft.text.Text; +import net.minecraft.util.Identifier; import net.minecraft.util.Util; public interface ItemGroupRegistry { + List ITEMS = new ArrayList<>(); Map, Set> REGISTRY = new HashMap<>(); static List getVariations(Item item) { @@ -33,6 +35,18 @@ public interface ItemGroupRegistry { return item; } + static T register(Identifier id, T item, RegistryKey group) { + return register(register(id, item), group); + } + + static T register(Identifier id, T item) { + if (item instanceof BlockItem bi && bi.getBlock() == null) { + throw new NullPointerException("Registered block item did not have a block " + id); + } + ITEMS.add(item); + return Registry.register(Registries.ITEM, id, item); + } + static RegistryKey createDynamic(String name, Supplier icon, Supplier> items) { RegistryKey key = RegistryKey.of(RegistryKeys.ITEM_GROUP, Unicopia.id(name)); Registry.register(Registries.ITEM_GROUP, key.getValue(), FabricItemGroup.builder().entries((context, entries) -> { diff --git a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java index 080a07b0..077863d4 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java +++ b/src/main/java/com/minelittlepony/unicopia/item/group/UItemGroups.java @@ -13,7 +13,7 @@ import net.minecraft.registry.RegistryKey; public interface UItemGroups { RegistryKey ALL_ITEMS = ItemGroupRegistry.createDynamic("items", UItems.EMPTY_JAR::getDefaultStack, () -> { - return Stream.concat(Stream.of(Items.APPLE), UItems.ITEMS.stream() + return Stream.concat(Stream.of(Items.APPLE), ItemGroupRegistry.ITEMS.stream() .filter(item -> !(item instanceof ChameleonItem) || ((ChameleonItem)item).isFullyDisguised())); }); RegistryKey HORSE_FEED = ItemGroupRegistry.createDynamic("horsefeed", UItems.ZAP_APPLE::getDefaultStack, () -> { diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 57d1b0dc..0850d8cc 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -103,6 +103,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_hoof": "Apple Pie with a Hoofprint", "item.unicopia.apple_pie_slice": "Slice Of Apple Pie", "item.unicopia.oats": "Oats", diff --git a/src/main/resources/assets/unicopia/models/block/pie_corner.json b/src/main/resources/assets/unicopia/models/block/pie_corner.json index b9094606..4051e694 100644 --- a/src/main/resources/assets/unicopia/models/block/pie_corner.json +++ b/src/main/resources/assets/unicopia/models/block/pie_corner.json @@ -3,8 +3,8 @@ "particle": "#top" }, "elements": [ - { "from": [ 1, 0, 1 ], - "to": [ 8, 5, 8 ], + { "from": [ 2, 0, 2 ], + "to": [ 8, 4, 8 ], "faces": { "up": { "uv": [ 1, 1, 8, 8 ], "texture": "#top" }, "down": { "uv": [ 1, 8, 8, 15 ], "texture": "#bottom" }, diff --git a/src/main/resources/assets/unicopia/models/block/pie_elbow.json b/src/main/resources/assets/unicopia/models/block/pie_elbow.json index 4059b688..bfd91d78 100644 --- a/src/main/resources/assets/unicopia/models/block/pie_elbow.json +++ b/src/main/resources/assets/unicopia/models/block/pie_elbow.json @@ -3,8 +3,8 @@ "particle": "#top" }, "elements": [ - { "from": [ 1, 0, 1 ], - "to": [ 15, 5, 8 ], + { "from": [ 2, 0, 2 ], + "to": [ 14, 4, 8 ], "faces": { "up": { "uv": [ 1, 1, 15, 8 ], "texture": "#top" }, "down": { "uv": [ 1, 8, 15, 15 ], "texture": "#bottom" }, @@ -15,7 +15,7 @@ } }, { "from": [ 8, 0, 8 ], - "to": [ 15, 5, 15 ], + "to": [ 14, 4, 14 ], "faces": { "up": { "uv": [ 8, 8, 15, 15 ], "texture": "#top" }, "down": { "uv": [ 8, 1, 15, 8 ], "texture": "#bottom" }, diff --git a/src/main/resources/assets/unicopia/models/block/pie_full.json b/src/main/resources/assets/unicopia/models/block/pie_full.json index 15099405..f0687e00 100644 --- a/src/main/resources/assets/unicopia/models/block/pie_full.json +++ b/src/main/resources/assets/unicopia/models/block/pie_full.json @@ -3,8 +3,8 @@ "particle": "#top" }, "elements": [ - { "from": [ 1, 0, 1 ], - "to": [ 15, 5, 15 ], + { "from": [ 2, 0, 2 ], + "to": [ 14, 4, 14 ], "faces": { "up": { "uv": [ 1, 1, 15, 15 ], "texture": "#top" }, "down": { "uv": [ 1, 1, 15, 15 ], "texture": "#bottom" }, diff --git a/src/main/resources/assets/unicopia/models/block/pie_straight.json b/src/main/resources/assets/unicopia/models/block/pie_straight.json index 78c39eb5..9d1b6ba7 100644 --- a/src/main/resources/assets/unicopia/models/block/pie_straight.json +++ b/src/main/resources/assets/unicopia/models/block/pie_straight.json @@ -3,8 +3,8 @@ "particle": "#top" }, "elements": [ - { "from": [ 1, 0, 1 ], - "to": [ 15, 5, 8 ], + { "from": [ 2, 0, 2 ], + "to": [ 14, 4, 8 ], "faces": { "up": { "uv": [ 1, 1, 15, 8 ], "texture": "#top" }, "down": { "uv": [ 1, 8, 15, 15 ], "texture": "#bottom" }, diff --git a/src/main/resources/assets/unicopia/models/item/apple_pie_hoof.json b/src/main/resources/assets/unicopia/models/item/apple_pie_hoof.json new file mode 100644 index 00000000..ec8b8f2d --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/apple_pie_hoof.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "unicopia:item/apple_pie_hoof" + } +} diff --git a/src/main/resources/assets/unicopia/textures/item/apple_pie.png b/src/main/resources/assets/unicopia/textures/item/apple_pie.png index 2a77e66f..a88f10a6 100644 Binary files a/src/main/resources/assets/unicopia/textures/item/apple_pie.png and b/src/main/resources/assets/unicopia/textures/item/apple_pie.png differ diff --git a/src/main/resources/assets/unicopia/textures/item/apple_pie_hoof.png b/src/main/resources/assets/unicopia/textures/item/apple_pie_hoof.png new file mode 100644 index 00000000..8e6e8b97 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/item/apple_pie_hoof.png differ diff --git a/src/main/resources/data/unicopia/recipes/cutting/apple_pie_from_apple_pie.json b/src/main/resources/data/unicopia/recipes/cutting/apple_pie_from_apple_pie.json new file mode 100644 index 00000000..9ae5f5c2 --- /dev/null +++ b/src/main/resources/data/unicopia/recipes/cutting/apple_pie_from_apple_pie.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { "item": "farmersdelight:apple_pie" } + ], + "result": { + "item": "unicopia:apple_pie" + } +} \ No newline at end of file diff --git a/src/main/resources/data/unicopia/recipes/cutting/apple_pie_to_apple_pie.json b/src/main/resources/data/unicopia/recipes/cutting/apple_pie_to_apple_pie.json new file mode 100644 index 00000000..0fc42b7f --- /dev/null +++ b/src/main/resources/data/unicopia/recipes/cutting/apple_pie_to_apple_pie.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { "item": "unicopia:apple_pie" } + ], + "result": { + "item": "farmersdelight:apple_pie" + } +} \ No newline at end of file