Skip to content

Commit

Permalink
Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Lithewings committed Jun 26, 2024
1 parent fa956de commit 7e19612
Show file tree
Hide file tree
Showing 34 changed files with 354 additions and 7 deletions.
45 changes: 38 additions & 7 deletions src/main/java/com/equilibrium/MITEequilibrium.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,53 @@
package com.equilibrium;

import com.equilibrium.block.ModBlocksTest;
import com.equilibrium.item.Ingots;
import com.equilibrium.item.ModItemGroup;
import com.equilibrium.item.ModItems;
import com.equilibrium.item.Tools;
import net.fabricmc.api.ModInitializer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class MITEequilibrium implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
// That way, it's clear which mod wrote info, warnings, and errors.

public static final String MOD_ID = "miteequilibrium";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);





@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
//物品栏添加
ModItemGroup.registerModItemGroup();


//物品添加测试
ModItems.registerModItemTest();
//方块添加测试
ModBlocksTest.registerModBlocks();

//以下开始正式添加物品:


//添加工具物品
Tools.registerModItemTools();
//添加锭
Ingots.registerModItemIngots();












LOGGER.info("Hello Fabric world!");
}
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/com/equilibrium/block/ModBlocksTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.equilibrium.block;

import net.minecraft.block.*;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

import static net.minecraft.block.Blocks.register;

public class ModBlocksTest {

public static final Block EXAMPLE_BLOCK = new Block(Block.Settings.create().strength(4.0f));
//strength中第一个为硬度,第二个为爆炸抗性
















public static void registerModBlocks(){
Registry.register(Registries.BLOCK, Identifier.of("miteequilibrium", "example_block"), EXAMPLE_BLOCK);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium", "example_block"), new BlockItem(EXAMPLE_BLOCK, new Item.Settings()));
}
}
34 changes: 34 additions & 0 deletions src/main/java/com/equilibrium/item/Ingots.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.equilibrium.item;


import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class Ingots {

//以下开始添加物品:
public static final Item adamantium= new Item(new Item.Settings());
public static final Item ancient_metal = new Item(new Item.Settings());
public static final Item copper = new Item(new Item.Settings());
public static final Item gold = new Item(new Item.Settings());
public static final Item mithril = new Item(new Item.Settings());
public static final Item silver = new Item(new Item.Settings());




public static void registerModItemIngots() {
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","adamantium"), adamantium);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","ancient_metal"), ancient_metal);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","copper"), copper);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","gold"), gold);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","mithril"), mithril);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","silver"), silver);




}
}
60 changes: 60 additions & 0 deletions src/main/java/com/equilibrium/item/ModItemGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.equilibrium.item;

import com.equilibrium.MITEequilibrium;
import com.equilibrium.block.ModBlocksTest;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;

public class ModItemGroup {
//自定义物品栏
public static final ItemGroup modGroup = Registry.register(Registries.ITEM_GROUP, Identifier.of(MITEequilibrium.MOD_ID,"testgroup"),
//注册名小写
FabricItemGroup.builder().displayName(Text.translatable("itemgroup.testgroup"))
//itemgroup.testgroup是不加翻译前的物品栏名字
.icon(()->new ItemStack(ModItems.test)).entries((displayContext, entries) ->
//这里开始添加物品
{
entries.add(ModItems.test);
entries.add(Items.BOOK);//可以加原版物品
entries.add(ModBlocksTest.EXAMPLE_BLOCK);

}
).build());

//工具栏
public static final ItemGroup modTools = Registry.register(Registries.ITEM_GROUP, Identifier.of(MITEequilibrium.MOD_ID,"toolsgroup"),
FabricItemGroup.builder().displayName(Text.translatable("itemgroup.toolsgroup"))
.icon(()->new ItemStack(Tools.adamantium_axe)).entries((displayContext, entries) ->
{
entries.add(Tools.adamantium_axe);
}
).build());

//锭栏
public static final ItemGroup modIngots = Registry.register(Registries.ITEM_GROUP, Identifier.of(MITEequilibrium.MOD_ID,"ingotsgroup"),
FabricItemGroup.builder().displayName(Text.translatable("itemgroup.ingotsgroup"))
.icon(()->new ItemStack(Ingots.adamantium)).entries((displayContext, entries) ->
{
entries.add(Ingots.adamantium);
entries.add(Ingots.copper);
entries.add(Ingots.ancient_metal);
entries.add(Ingots.gold);
entries.add(Ingots.mithril);
entries.add(Ingots.silver);
}
).build());





public static void registerModItemGroup(){

}
}
61 changes: 61 additions & 0 deletions src/main/java/com/equilibrium/item/ModItems.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.equilibrium.item;


import com.equilibrium.MITEequilibrium;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class ModItems {
//Add a “test” Item
public static final Item test = new Item(new Item.Settings());
//以下开始添加物品:



































public static void registerModItemTest() {
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","test"), test);
//give @s miteequilibrium:test以获取该物品
//注册名必须小写
//Identifier.of("miteequilibrium","test")中,第一个是modid,第二个是物品注册id
//寻找纹理时,"layer0": "miteequilibrium:item/test",也就是要一一对应
}
}

34 changes: 34 additions & 0 deletions src/main/java/com/equilibrium/item/Tools.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.equilibrium.item;


import net.minecraft.item.Item;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier;

public class Tools {

//以下开始添加物品:
public static final Item adamantium_axe= new Item(new Item.Settings());
public static final Item adamantium_battle_axe = new Item(new Item.Settings());
public static final Item adamantium_dagger = new Item(new Item.Settings());
public static final Item adamantium_hatchet = new Item(new Item.Settings());






public static void registerModItemTools() {
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","adamantium_axe"), adamantium_axe);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","adamantium_battle_axe"), adamantium_battle_axe);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","adamantium_dagger"), adamantium_dagger);
Registry.register(Registries.ITEM, Identifier.of("miteequilibrium","adamantium_hatchet"), adamantium_hatchet);






}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"variants": {
"": { "model": "miteequilibrium:block/example_block" }
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/miteequilibrium/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"item.miteequilibrium.test": "Test",
"block.miteequilibrium.example_block": "TestBlock",
"itemgroup.testgroup": "MITEequilibrium"

}
5 changes: 5 additions & 0 deletions src/main/resources/assets/miteequilibrium/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"item.miteequilibrium.test": "测试物品",
"block.miteequilibrium.example_block": "测试方块",
"itemgroup.testgroup": "测试物品栏"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "miteequilibrium:block/example_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/adamantium"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/adamantium_axe"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/adamantium_battle_axe"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/adamantium_dagger"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/adamantium_hatchet"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/ancient_metal"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/copper"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "miteequilibrium:block/example_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/gold"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "miteequilibrium:item/mithril"
}
}
Loading

0 comments on commit 7e19612

Please sign in to comment.