Skip to content

Commit

Permalink
添加:炉灶以及相关实现
Browse files Browse the repository at this point in the history
  • Loading branch information
MCZME committed Aug 28, 2024
1 parent 95c97bb commit b4dfb89
Show file tree
Hide file tree
Showing 31 changed files with 283 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// 1.21 2024-08-22T18:03:26.4830973 Loot Tables
// 1.21 2024-08-28T08:40:40.9916727 Loot Tables
032b2242788b8411178136ca48214246ef2af8a9 data/lingshi/loot_table/blocks/chopping_board.json
63e60d75a79e0a64eb6338f6bc98dddd6a8d6a0b data/lingshi/loot_table/blocks/cooking_pot.json
67cc122cf5e7e5865ff9bc81fec6e8371225b0d6 data/lingshi/loot_table/blocks/skillet.json
ac9b000c0cff0859a940afc1f40de52b939a1c68 data/lingshi/loot_table/blocks/stove.json
c843630bb0739aad37078f0119c9cc31f5316c3a data/lingshi/loot_table/blocks/tea_leaf.json
3cd0ced47f090fec162cddcb8b2f75284fa134cb data/lingshi/loot_table/blocks/tea_tree.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.21 2024-08-28T02:42:11.0001379 Item Models: lingshi
// 1.21 2024-08-28T08:40:40.9896745 Item Models: lingshi
bad0cb5e093fa42331c2d4a1157d1a7b5b3fc588 assets/lingshi/models/item/chopping_board.json
7bc27021669767547c0b0bd606195e5f80cea272 assets/lingshi/models/item/cooked_rice.json
8106af92df770f5e2062db0b6aaed967fe386d87 assets/lingshi/models/item/cooking_pot.json
Expand All @@ -11,3 +11,4 @@ abe8ae1523c26af167289fe958382b2477d96ea1 assets/lingshi/models/item/rice_of_ear.
57cfb1f90de649ab0f56f107cb56e1d0d2f87ae6 assets/lingshi/models/item/rice_seedling.json
cff85c127954ba63ac8129929c0d7346bf8f305d assets/lingshi/models/item/skillet.json
da8fb27d7e9b15fbd96ca8a49b328776550bb2b3 assets/lingshi/models/item/spatula.json
24a37cc616a84374e2aa09a4eaee7d756a35fa10 assets/lingshi/models/item/stove.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 2024-08-28T02:42:11.0041386 Languages: zh_cn for mod: lingshi
b2ef29629af36b1f8e45f0739bad28409bf893ba assets/lingshi/lang/zh_cn.json
// 1.21 2024-08-28T08:40:40.9956752 Languages: zh_cn for mod: lingshi
f05d3fc257903f3b78dc6d4a231fd0aded91d8c7 assets/lingshi/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// 1.21 2024-08-28T03:29:31.4157872 Recipes
// 1.21 2024-08-28T10:28:02.876575 Recipes
b8cb7428b718c0ca190af49165cd25554d27fa19 data/lingshi/advancement/recipes/cooking_pot/cooked_rice.json
7d0ef4cd02c38f4648e712a935f0ea32fb50aeff data/lingshi/advancement/recipes/cooking_pot/cooked_rice_1.json
d918a2369d899974ffa38d6a363553af9e97fdee data/lingshi/advancement/recipes/cooking_pot/cooked_rice_2.json
6a319c97da924f9ab21b5d264c18cb8ad9da8755 data/lingshi/advancement/recipes/decorations/chopping_board.json
316ee6a89da986357d408cff58db9554636fc16a data/lingshi/advancement/recipes/decorations/cooking_pot.json
0486b842988b1d1ac0abb797a91d26077583679e data/lingshi/advancement/recipes/decorations/pot_lid.json
0a4b54bfda8aa98f1a26bbf1d8231c76ed12e770 data/lingshi/advancement/recipes/decorations/skillet.json
129f0de548d7a7b62ee9dcaeb54da65d7095a009 data/lingshi/advancement/recipes/decorations/stove.json
e4ccb4f32d90b93ef63a3f2a17e843c6a8b2322b data/lingshi/advancement/recipes/skillet/baked_potato.json
c9b88b929d6f4b7d68c10c6a3915182cb096d363 data/lingshi/advancement/recipes/skillet/cooked_beef.json
0235c27183fa0a2f93fdf2a6726f2f9d1acc95b7 data/lingshi/advancement/recipes/skillet/cooked_chicken.json
Expand Down Expand Up @@ -38,3 +39,4 @@ e72067c16cd3f5e2ec6a11abb0c7a9e41d3e3fd4 data/lingshi/recipe/skillet/cooked_salm
1f718cba48b75cc98ae479a6765f76506c0eea3a data/lingshi/recipe/skillet/egg_fried_rice.json
0c39fdabe7970065856b4adc9e9f3eae7690ea2d data/lingshi/recipe/skillet/fried_egg.json
3563171190654e76637de2fa78a6c750389674d7 data/lingshi/recipe/spatula.json
94e898969747627f5a3d3be60b0b66fd528c13e9 data/lingshi/recipe/stove.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 2024-08-08T18:35:43.0628337 Block States: lingshi
// 1.21 2024-08-28T10:28:02.8785778 Block States: lingshi
c5265867b72222a7b9a0c319c8593c91a69953ab assets/lingshi/blockstates/chopping_board.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 1.21 2024-08-28T02:56:53.2804386 Tags for minecraft:block mod id lingshi
// 1.21 2024-08-28T08:40:40.9936741 Tags for minecraft:block mod id lingshi
639716446e0ad4bc759f5d086b91d0e4a9215ab7 data/lingshi/tags/block/can_support.json
8f3ae1f87856cf69d686ec0be92f6b700f51bd30 data/lingshi/tags/block/heat_source.json
32c23f06ab44da6f1bd718c63c5ae376f033b411 data/lingshi/tags/block/heat_source.json
e00d57f2828f9f55903e8c8c9f4b95dfeca4135d data/minecraft/tags/block/mineable/axe.json
5edc606bce3187f422626ac4390c718b9b4f881b data/minecraft/tags/block/mineable/pickaxe.json
1 change: 1 addition & 0 deletions src/generated/resources/assets/lingshi/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"block.lingshi.rice": "稻米",
"block.lingshi.rice_seedling": "稻苗",
"block.lingshi.skillet": "平底锅",
"block.lingshi.stove": "炉灶",
"block.lingshi.tea_tree": "茶树",
"gui.lingshi.cooking_pot_menu": "烹饪锅",
"gui.lingshi.skillet_menu": "平底锅",
Expand Down
3 changes: 3 additions & 0 deletions src/generated/resources/assets/lingshi/models/item/stove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "lingshi:block/stove"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_iron_ingot": {
"conditions": {
"items": [
{
"items": "minecraft:mud_bricks"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "lingshi:stove"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_iron_ingot"
]
],
"rewards": {
"recipes": [
"lingshi:stove"
]
}
}
21 changes: 21 additions & 0 deletions src/generated/resources/data/lingshi/loot_table/blocks/stove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "lingshi:stove"
}
],
"rolls": 1.0
}
],
"random_sequence": "lingshi:blocks/stove"
}
20 changes: 20 additions & 0 deletions src/generated/resources/data/lingshi/recipe/stove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"A": {
"item": "minecraft:campfire"
},
"X": {
"item": "minecraft:mud_bricks"
}
},
"pattern": [
"X X",
"XAX"
],
"result": {
"count": 1,
"id": "lingshi:stove"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"values": [
"minecraft:campfire",
"minecraft:magma_block"
"minecraft:magma_block",
"lingshi:stove"
]
}
52 changes: 52 additions & 0 deletions src/main/java/mczme/lingshi/common/block/StoveBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package mczme.lingshi.common.block;

import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.phys.BlockHitResult;

public class StoveBlock extends Block {

public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
public static final BooleanProperty LIT = BlockStateProperties.LIT;

public StoveBlock(Properties properties) {
super(properties);
this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LIT, true));
}

public ItemInteractionResult useItemOn(ItemStack pStack, BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHitResult){
return super.useItemOn(pStack, pState, pLevel, pPos, pPlayer, pHand, pHitResult);
}

@Override
public void stepOn(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity) {
if (!pEntity.isSteppingCarefully() && pEntity instanceof LivingEntity) {
pEntity.hurt(pLevel.damageSources().hotFloor(), 1.0F);
}
super.stepOn(pLevel, pPos, pState, pEntity);
}

@Override
public BlockState getStateForPlacement(BlockPlaceContext pContext) {
return this.defaultBlockState().setValue(FACING, pContext.getHorizontalDirection());
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> pBuilder) {
pBuilder.add(FACING, LIT);
}
}
1 change: 1 addition & 0 deletions src/main/java/mczme/lingshi/common/data/ItemModels.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ protected void registerModels() {

basicItem(ModItems.OIL_BUCKET.get());

withExistingParent(String.valueOf(ModItems.STOVE.get()), modLoc("block/stove"));
withExistingParent(String.valueOf(ModItems.COOKING_POT.get()), modLoc("block/cooking_pot"));
withExistingParent(String.valueOf(ModItems.CHOPPING_BOARD.get()), modLoc("block/chopping_board"));
withExistingParent(String.valueOf(ModItems.SKILLET.get()), modLoc("block/skillet"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ protected void addTranslations() {
this.add(ModItems.COOKING_POT.get(), "烹饪锅");
this.add(ModItems.POT_LID.get(),"锅盖");

this.add(ModItems.STOVE.get(), "炉灶");
this.add(ModItems.OIL_BUCKET.get(),"油桶");

this.add(ModItems.FRIED_EGG.get(),"煎鸡蛋");
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/mczme/lingshi/common/data/loot/BlockLoot.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class BlockLoot extends BlockLootSubProvider {
ModBlocks.TEA_LEAF.get(),
ModBlocks.CHOPPING_BOARD.get(),
ModBlocks.SKILLET.get(),
ModBlocks.COOKING_POT.get()
ModBlocks.COOKING_POT.get(),
ModBlocks.STOVE.get()
);

public BlockLoot(HolderLookup.Provider lookupProvider) {
Expand All @@ -31,6 +32,7 @@ protected void generate() {
dropSelf(ModBlocks.CHOPPING_BOARD.get());
dropSelf(ModBlocks.SKILLET.get());
dropSelf(ModBlocks.COOKING_POT.get());
dropSelf(ModBlocks.STOVE.get());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ protected void buildRecipes(RecipeOutput output) {
.define('A', Items.IRON_INGOT)
.unlockedBy("has_iron_ingot", has(ItemTags.TERRACOTTA))
.save(output);
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModItems.STOVE.get())
.pattern("X X")
.pattern("XAX")
.define('X', Items.MUD_BRICKS)
.define('A', Items.CAMPFIRE)
.unlockedBy("has_iron_ingot", has(Items.MUD_BRICKS))
.save(output);
}

}
2 changes: 1 addition & 1 deletion src/main/java/mczme/lingshi/common/data/tag/BlockTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected void addTags(HolderLookup.@NotNull Provider pProvider) {
tag(MINEABLE_WITH_PICKAXE).add(ModBlocks.COOKING_POT.get());
tag(MINEABLE_WITH_PICKAXE).add(ModBlocks.SKILLET.get());
// 热源方块
tag(HEAT_SOURCE).add(Blocks.CAMPFIRE, Blocks.MAGMA_BLOCK);
tag(HEAT_SOURCE).add(Blocks.CAMPFIRE, Blocks.MAGMA_BLOCK,ModBlocks.STOVE.get());

// 可以支撑方块
tag(CAN_SUPPORT).add(Blocks.CAMPFIRE);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mczme/lingshi/common/item/PotLid.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public InteractionResult useOn(UseOnContext pContext) {
if(pContext.getLevel().getBlockState(pContext.getClickedPos()).is(ModBlocks.COOKING_POT.get())){
if(!pContext.getLevel().getBlockState(pContext.getClickedPos()).getValue(COVER)) {
pContext.getLevel().setBlockAndUpdate(pContext.getClickedPos(), pContext.getLevel().getBlockState(pContext.getClickedPos()).setValue(COVER, true));
pContext.getItemInHand().consume(1, pContext.getPlayer());
}
return InteractionResult.SUCCESS;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mczme/lingshi/common/registry/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ModBlocks {
BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_PLANKS));

public static final Supplier<LiquidBlock> OIL_LIQUID_BLOCK = BLOCKS.register("oil_liquid_block",()->new OilBlock(ModFluids.OIL_SOURCE.get(),BlockBehaviour.Properties.ofFullCopy(Blocks.WATER)));
public static final Supplier<StoveBlock> STOVE = BLOCKS.register("stove", ()->new StoveBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.FURNACE)));

public static void register(IEventBus modEventBus) {
BLOCKS.register(modEventBus);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/mczme/lingshi/common/registry/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ModItems {
public static final Supplier<Item> SPATULA = registerWithCreateTab("spatula", () -> new SpatulaItem(new Item.Properties().stacksTo(1)));
public static final Supplier<Item> IRON_KNIFE = registerWithCreateTab("iron_knife", () -> new KnifeItem(Tiers.IRON, new Item.Properties().attributes(SwordItem.createAttributes(Tiers.IRON, 3, -2.4F))));

public static final Supplier<Item> STOVE = registerWithCreateTab("stove", () -> new BlockItem(ModBlocks.STOVE.get(), new Item.Properties()));
public static final Supplier<Item> OIL_BUCKET = registerWithCreateTab("oil_bucket", () -> new BucketItem(ModFluids.OIL_SOURCE.get(), new Item.Properties().craftRemainder(Items.BUCKET).stacksTo(1)));

public static final Supplier<Item> STRANGE_FOOD = registerWithCreateTab("strange_food", () -> new Item(new Item.Properties()));
Expand Down
34 changes: 34 additions & 0 deletions src/main/resources/assets/lingshi/blockstates/stove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"variants": {
"facing=east,lit=false": {
"model": "lingshi:block/stove",
"y": 270
},
"facing=east,lit=true": {
"model": "lingshi:block/stove_fire",
"y": 270
},
"facing=north,lit=false": {
"model": "lingshi:block/stove",
"y": 180
},
"facing=north,lit=true": {
"model": "lingshi:block/stove_fire",
"y": 180
},
"facing=south,lit=false": {
"model": "lingshi:block/stove"
},
"facing=south,lit=true": {
"model": "lingshi:block/stove_fire"
},
"facing=west,lit=false": {
"model": "lingshi:block/stove",
"y": 90
},
"facing=west,lit=true": {
"model": "lingshi:block/stove_fire",
"y": 90
}
}
}
54 changes: 54 additions & 0 deletions src/main/resources/assets/lingshi/models/block/stove.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"credit": "Made with Blockbench",
"textures": {
"1": "lingshi:block/stove_front",
"2": "lingshi:block/stove_top",
"3": "lingshi:block/stove_side",
"particle": "lingshi:block/stove_front"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 16, 16],
"faces": {
"north": {"uv": [0, 0, 16, 16], "texture": "#1"},
"east": {"uv": [0, 0, 16, 16], "texture": "#3"},
"south": {"uv": [0, 0, 16, 16], "texture": "#3"},
"west": {"uv": [0, 0, 16, 16], "texture": "#3"},
"up": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#2"},
"down": {"uv": [0, 0, 16, 16], "rotation": 90, "texture": "#3"}
}
}
],
"display": {
"thirdperson_righthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"thirdperson_lefthand": {
"rotation": [75, 45, 0],
"translation": [0, 2.5, 0],
"scale": [0.375, 0.375, 0.375]
},
"firstperson_righthand": {
"rotation": [0, 45, 0],
"scale": [0.4, 0.4, 0.4]
},
"firstperson_lefthand": {
"rotation": [0, 225, 0],
"scale": [0.4, 0.4, 0.4]
},
"ground": {
"translation": [0, 3, 0],
"scale": [0.25, 0.25, 0.25]
},
"gui": {
"rotation": [30, 225, 0],
"scale": [0.625, 0.625, 0.625]
},
"fixed": {
"scale": [0.5, 0.5, 0.5]
}
}
}
Loading

0 comments on commit b4dfb89

Please sign in to comment.