Skip to content

Commit

Permalink
完善:刀的基础功能
Browse files Browse the repository at this point in the history
  • Loading branch information
MCZME committed Aug 11, 2024
1 parent 1d12939 commit fa3c0e0
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.21 2024-08-08T18:35:43.0608317 Languages: zh_cn for mod: lingshi
4da2b2e0b4727bd49396896000019baab4eb2e48 assets/lingshi/lang/zh_cn.json
// 1.21 2024-08-11T20:03:29.7270915 Languages: zh_cn for mod: lingshi
ceb883a13057e1c30eaabbc27de7a3819e5e58b5 assets/lingshi/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
// 1.21 2024-08-10T17:02:48.5453931 Tags for minecraft:block mod id lingshi
// 1.21 2024-08-11T19:15:15.9707849 Tags for minecraft:block mod id lingshi
8f3ae1f87856cf69d686ec0be92f6b700f51bd30 data/lingshi/tags/block/heat_source.json
e00d57f2828f9f55903e8c8c9f4b95dfeca4135d data/minecraft/tags/block/mineable/axe.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 @@ -3,6 +3,7 @@
"block.lingshi.rice": "稻米",
"block.lingshi.rice_seedling": "稻苗",
"block.lingshi.tea_tree": "茶树",
"item.lingshi.iron_knife": "铁菜刀",
"item.lingshi.rice_of_ear": "稻穗",
"item.lingshi.tea_leaf": "茶叶",
"lingshi.lingshi_tab": "灵食"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"minecraft:campfire",
"minecraft:magma_block"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ protected void addTranslations() {
this.add(ModItems.TEA_LEAF.get(), "茶叶");

this.add(ModItems.CHOPPING_BOARD.get(), "砧板");
this.add(ModItems.IRON_KNIFE.get(), "铁菜刀");
}
}
6 changes: 6 additions & 0 deletions src/main/java/mczme/lingshi/common/data/tag/BlockTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import mczme.lingshi.lingshi;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.world.level.block.Blocks;
import net.neoforged.neoforge.common.data.BlockTagsProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

import static mczme.lingshi.common.tag.ModTags.*;
import static net.minecraft.tags.BlockTags.*;

public class BlockTags extends BlockTagsProvider {
Expand All @@ -22,5 +24,9 @@ public BlockTags(PackOutput output, CompletableFuture<HolderLookup.Provider> loo
protected void addTags(HolderLookup.@NotNull Provider pProvider) {
// 斧 可挖掘
tag(MINEABLE_WITH_AXE).add(ModBlocks.CHOPPING_BOARD.get());

// 热源方块
tag(HEAT_SOURCE).add(Blocks.CAMPFIRE,
Blocks.MAGMA_BLOCK);
}
}
10 changes: 4 additions & 6 deletions src/main/java/mczme/lingshi/common/item/KnifeItem.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package mczme.lingshi.common.item;

import net.minecraft.tags.TagKey;
import net.minecraft.world.item.DiggerItem;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tier;
import net.minecraft.world.level.block.Block;

public class KnifeItem extends DiggerItem {
public class KnifeItem extends SwordItem {

public KnifeItem(Tier pTier, TagKey<Block> pBlocks, Properties pProperties) {
super(pTier, pBlocks, pProperties);
public KnifeItem(Tier pTier, Properties pProperties) {
super(pTier, pProperties);
}
}
5 changes: 5 additions & 0 deletions src/main/java/mczme/lingshi/common/registry/ModItems.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package mczme.lingshi.common.registry;

import mczme.lingshi.common.item.KnifeItem;
import mczme.lingshi.lingshi;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SwordItem;
import net.minecraft.world.item.Tiers;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;

Expand All @@ -23,6 +26,8 @@ public class ModItems {

public static final Supplier<Item> CHOPPING_BOARD = registerWithCreateTab("chopping_board", () -> new BlockItem(ModBlocks.CHOPPING_BOARD.get(), new Item.Properties()));

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))));

private static Supplier<Item> registerWithCreateTab(String item_name, Supplier<Item> itemSupplier) {
Supplier<Item> item = ITEMS.register(item_name, itemSupplier);
ITEMS_LIST.add(item);
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/mczme/lingshi/common/tag/ModTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mczme.lingshi.common.tag;

import mczme.lingshi.lingshi;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.level.block.Block;

public class ModTags {

public static final TagKey<Block> HEAT_SOURCE = modTag(Registries.BLOCK, "heat_source");

private static <T> TagKey<T> modTag(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> pRegistry, String name) {
return TagKey.create(pRegistry, ResourceLocation.fromNamespaceAndPath(lingshi.MODID, name));
}

}
16 changes: 16 additions & 0 deletions src/main/java/mczme/lingshi/common/tag/NeoforgeTags.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package mczme.lingshi.common.tag;

import mczme.lingshi.lingshi;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;

public class NeoforgeTags {

public static final TagKey<Item> KNIFE = neoforgeTag(Registries.ITEM, "knife");

private static <T> TagKey<T> neoforgeTag(net.minecraft.resources.ResourceKey<? extends net.minecraft.core.Registry<T>> pRegistry, String name) {
return TagKey.create(pRegistry, ResourceLocation.fromNamespaceAndPath("neoforge", name));
}
}

0 comments on commit fa3c0e0

Please sign in to comment.