From fd763db86c7235e8a7d7cca45cef518a6411a789 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 11:44:09 +0200 Subject: [PATCH 1/7] Add golden cake blockstate json --- .../assets/cococakes/blockstates/golden_cake.json | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/resources/assets/cococakes/blockstates/golden_cake.json diff --git a/src/main/resources/assets/cococakes/blockstates/golden_cake.json b/src/main/resources/assets/cococakes/blockstates/golden_cake.json new file mode 100644 index 0000000..c960e90 --- /dev/null +++ b/src/main/resources/assets/cococakes/blockstates/golden_cake.json @@ -0,0 +1,11 @@ +{ + "variants": { + "bites=0": { "model": "cococakes:block/golden_cake" }, + "bites=1": { "model": "cococakes:block/golden_cake_slice1" }, + "bites=2": { "model": "cococakes:block/golden_cake_slice2" }, + "bites=3": { "model": "cococakes:block/golden_cake_slice3" }, + "bites=4": { "model": "cococakes:block/golden_cake_slice4" }, + "bites=5": { "model": "cococakes:block/golden_cake_slice5" }, + "bites=6": { "model": "cococakes:block/golden_cake_slice6" } + } +} \ No newline at end of file From 9b0fb7a990aa39e98b5b47576650ffbc305fe9b6 Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 11:44:28 +0200 Subject: [PATCH 2/7] Add golden cake model jsons --- .../assets/cococakes/models/block/golden_cake.json | 9 +++++++++ .../cococakes/models/block/golden_cake_slice1.json | 10 ++++++++++ .../cococakes/models/block/golden_cake_slice2.json | 10 ++++++++++ .../cococakes/models/block/golden_cake_slice3.json | 10 ++++++++++ .../cococakes/models/block/golden_cake_slice4.json | 10 ++++++++++ .../cococakes/models/block/golden_cake_slice5.json | 10 ++++++++++ .../cococakes/models/block/golden_cake_slice6.json | 10 ++++++++++ .../assets/cococakes/models/item/golden_cake.json | 6 ++++++ 8 files changed, 75 insertions(+) create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice1.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice2.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice3.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice4.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice5.json create mode 100644 src/main/resources/assets/cococakes/models/block/golden_cake_slice6.json create mode 100644 src/main/resources/assets/cococakes/models/item/golden_cake.json diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake.json b/src/main/resources/assets/cococakes/models/block/golden_cake.json new file mode 100644 index 0000000..ed7f117 --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake.json @@ -0,0 +1,9 @@ +{ + "parent": "block/cake", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice1.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice1.json new file mode 100644 index 0000000..566784a --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice1.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice1", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice2.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice2.json new file mode 100644 index 0000000..93f472e --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice2.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice2", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice3.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice3.json new file mode 100644 index 0000000..2045cc4 --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice3.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice3", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice4.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice4.json new file mode 100644 index 0000000..7041ded --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice4.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice4", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice5.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice5.json new file mode 100644 index 0000000..b1d8a69 --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice5.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice5", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/block/golden_cake_slice6.json b/src/main/resources/assets/cococakes/models/block/golden_cake_slice6.json new file mode 100644 index 0000000..cd01ffd --- /dev/null +++ b/src/main/resources/assets/cococakes/models/block/golden_cake_slice6.json @@ -0,0 +1,10 @@ +{ + "parent": "block/cake_slice6", + "textures": { + "particle": "cococakes:golden_cake_side", + "bottom": "cococakes:golden_cake_bottom", + "top": "cococakes:golden_cake_top", + "side": "cococakes:golden_cake_side", + "inside": "cococakes:golden_cake_inner" + } +} diff --git a/src/main/resources/assets/cococakes/models/item/golden_cake.json b/src/main/resources/assets/cococakes/models/item/golden_cake.json new file mode 100644 index 0000000..246402c --- /dev/null +++ b/src/main/resources/assets/cococakes/models/item/golden_cake.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "cococakes:golden_cake" + } +} From 41ede3d844482863d463c156a32014c4816c0b9e Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 11:44:53 +0200 Subject: [PATCH 3/7] Add golden cake localization --- src/main/resources/assets/cococakes/lang/en_US.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/cococakes/lang/en_US.json b/src/main/resources/assets/cococakes/lang/en_US.json index 51aee0b..986c464 100644 --- a/src/main/resources/assets/cococakes/lang/en_US.json +++ b/src/main/resources/assets/cococakes/lang/en_US.json @@ -2,5 +2,6 @@ "itemGroup.cococakes": "CocoCakes", "item.cococakes.cocoa_powder": "Cocoa Powder", "item.cococakes.choco_milk_bucket": "Chocolate Milk Bucket", - "block.cococakes.choco_cake": "Chocolate Cake" + "block.cococakes.choco_cake": "Chocolate Cake", + "block.cococakes.golden_cake": "Golden Cake" } From 9c2a8cff8d13607623a7be4150885a2315dceb3f Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 11:46:13 +0200 Subject: [PATCH 4/7] Add golden cake mod block entry --- src/main/java/io/yooksi/cococakes/block/ModBlocks.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/yooksi/cococakes/block/ModBlocks.java b/src/main/java/io/yooksi/cococakes/block/ModBlocks.java index 67b9d55..2ace5fc 100644 --- a/src/main/java/io/yooksi/cococakes/block/ModBlocks.java +++ b/src/main/java/io/yooksi/cococakes/block/ModBlocks.java @@ -9,6 +9,8 @@ public enum ModBlocks { CHOCOLATE_CAKE(new ModCake(0.5f, SoundType.CLOTH), "choco_cake"), + GOLDEN_CAKE(new ModCake(0.5f, SoundType.CLOTH, MaterialColor.GOLD), "golden_cake"); + private final Block block; ModBlocks(Block block, String name) { From f31b01d93ec55bb0dcd44a57a088ee3119112a3e Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 13:39:29 +0200 Subject: [PATCH 5/7] Create custom class for golden cake --- .../io/yooksi/cococakes/block/GoldenCake.java | 55 +++++++++++++++++++ .../io/yooksi/cococakes/block/ModBlocks.java | 3 +- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 src/main/java/io/yooksi/cococakes/block/GoldenCake.java diff --git a/src/main/java/io/yooksi/cococakes/block/GoldenCake.java b/src/main/java/io/yooksi/cococakes/block/GoldenCake.java new file mode 100644 index 0000000..c1587a6 --- /dev/null +++ b/src/main/java/io/yooksi/cococakes/block/GoldenCake.java @@ -0,0 +1,55 @@ +package io.yooksi.cococakes.block; + +import net.minecraft.block.BlockState; +import net.minecraft.block.SoundType; +import net.minecraft.block.material.MaterialColor; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.stats.Stats; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.world.IWorld; +import net.minecraft.world.World; + +public class GoldenCake extends ModCake { + + protected GoldenCake(float hardness, SoundType sound) { + super(hardness, sound, MaterialColor.GOLD); + } + + @Override + public ActionResultType onBlockActivated(BlockState state, World worldIn, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult p_225533_6_) { + + if (worldIn.isRemote) { + ItemStack itemstack = player.getHeldItem(handIn); + if (eatCake(worldIn, pos, state, player) == ActionResultType.SUCCESS) { + return ActionResultType.SUCCESS; + } + else if (itemstack.isEmpty()) { + return ActionResultType.CONSUME; + } + } + return eatCake(worldIn, pos, state, player); + } + + private ActionResultType eatCake(IWorld world, BlockPos blockPos, BlockState state, PlayerEntity player) { + + if (!player.canEat(false)) { + return ActionResultType.PASS; + } + else { + player.addStat(Stats.EAT_CAKE_SLICE); + player.getFoodStats().addStats(2, 0.1F); + int i = state.get(BITES); + if (i < 6) { + world.setBlockState(blockPos, state.with(BITES, i + 1), 3); + } + else { + world.removeBlock(blockPos, false); + } + return ActionResultType.SUCCESS; + } + } +} diff --git a/src/main/java/io/yooksi/cococakes/block/ModBlocks.java b/src/main/java/io/yooksi/cococakes/block/ModBlocks.java index 2ace5fc..279f37f 100644 --- a/src/main/java/io/yooksi/cococakes/block/ModBlocks.java +++ b/src/main/java/io/yooksi/cococakes/block/ModBlocks.java @@ -3,13 +3,12 @@ import io.yooksi.cococakes.CocoCakes; import net.minecraft.block.Block; import net.minecraft.block.SoundType; -import net.minecraft.block.material.MaterialColor; import net.minecraft.util.ResourceLocation; public enum ModBlocks { CHOCOLATE_CAKE(new ModCake(0.5f, SoundType.CLOTH), "choco_cake"), - GOLDEN_CAKE(new ModCake(0.5f, SoundType.CLOTH, MaterialColor.GOLD), "golden_cake"); + GOLDEN_CAKE(new GoldenCake(0.5f, SoundType.CLOTH), "golden_cake"); private final Block block; From 29f8f3be7803035d3c9142bbbc4decf77aae9cca Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 13:40:21 +0200 Subject: [PATCH 6/7] Increase golden cake food values --- src/main/java/io/yooksi/cococakes/block/GoldenCake.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/yooksi/cococakes/block/GoldenCake.java b/src/main/java/io/yooksi/cococakes/block/GoldenCake.java index c1587a6..7ada1cc 100644 --- a/src/main/java/io/yooksi/cococakes/block/GoldenCake.java +++ b/src/main/java/io/yooksi/cococakes/block/GoldenCake.java @@ -15,6 +15,11 @@ public class GoldenCake extends ModCake { + // TODO: Perhaps move these values to mod config + + private final int FOOD_VALUE = 4; + private final float FOOD_SATURATION = 0.2f; + protected GoldenCake(float hardness, SoundType sound) { super(hardness, sound, MaterialColor.GOLD); } @@ -41,7 +46,7 @@ private ActionResultType eatCake(IWorld world, BlockPos blockPos, BlockState sta } else { player.addStat(Stats.EAT_CAKE_SLICE); - player.getFoodStats().addStats(2, 0.1F); + player.getFoodStats().addStats(FOOD_VALUE, FOOD_SATURATION); int i = state.get(BITES); if (i < 6) { world.setBlockState(blockPos, state.with(BITES, i + 1), 3); From 549a51537af0273081761d8b4be245f68343708f Mon Sep 17 00:00:00 2001 From: Matthew Cain Date: Mon, 20 Apr 2020 13:55:31 +0200 Subject: [PATCH 7/7] Add golden cake recipe json --- .../data/cococakes/recipes/golden_cake.json | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/resources/data/cococakes/recipes/golden_cake.json diff --git a/src/main/resources/data/cococakes/recipes/golden_cake.json b/src/main/resources/data/cococakes/recipes/golden_cake.json new file mode 100644 index 0000000..f901a4c --- /dev/null +++ b/src/main/resources/data/cococakes/recipes/golden_cake.json @@ -0,0 +1,24 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + " # ", + "#X#", + " # " + ], + "key": { + "#": { + "item": "minecraft:gold_ingot" + }, + "X": [ + { + "item": "minecraft:cake" + }, + { + "item": "cococakes:choco_cake" + } + ] + }, + "result": { + "item": "cococakes:golden_cake" + } +} \ No newline at end of file