generated from matshou/forge-1.15.2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolves #4
- Loading branch information
Showing
13 changed files
with
174 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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 { | ||
|
||
// 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); | ||
} | ||
|
||
@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(FOOD_VALUE, FOOD_SATURATION); | ||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/resources/assets/cococakes/blockstates/golden_cake.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/resources/assets/cococakes/models/block/golden_cake.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice1.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice2.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice3.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice4.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice5.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/cococakes/models/block/golden_cake_slice6.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/cococakes/models/item/golden_cake.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent": "item/generated", | ||
"textures": { | ||
"layer0": "cococakes:golden_cake" | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/resources/data/cococakes/recipes/golden_cake.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} |