WikiChree.COM
新規
編集
添付
管理
PitaQ Wiki
Pitan作マイクラMODの解説Wiki
≡
目次
FrontPage
Video/FabricのMOD開発講座
MOD解説
自作系
Item Alchemy
Ender Cane
Simple Uncrafting Table
Advanced Reborn
Enhanced Quarries
PipePlus
Space Cube
Storage Box for Fabric
[Fork]
↑
検索
AND検索
OR検索
最新の10件
2025-06-19
Universal Wrench
2025-06-16
dev/MCPitanLib
dev/MCPitanLib/Item Addition/en
RecentDeleted
dev/MCPitanLib/Overview/en
dev/MCPitanLib/Overview
2025-06-09
FrontPage
Memory Usage Title
Ender Cane
Mod Sound Volume Options
↑
ツールボックス
新しいページの作成
最近更新したページ
全ページ
ヘルプ
↑
カウンター
総計:
0
今日:
0
昨日:
0
現在:
4
トップ
ヘルプ
PukiWiki
dev/MCPitanLib/Item Addition/en をテンプレートにして作成
開始行:
* How to Add Items with MCPitanLib [#x39c2589]
This guide explains the basic steps to add a new item to ...
It references the implementation in ''ExampleMod.java'' a...
**Prerequisites [#v110afc8]
- MCPitanLib is already integrated into your project.
- Your mod's main class (e.g., ''ExampleMod'') inherits f...
**Steps [#ucbcb02b]
*** 1. Prepare MOD ID and Registry [#l02c5ab2]
Define the MOD ID used for identifying your mod and get t...
#gcode(java){{
public class ExampleMod extends CommonModInitializer {
public static final String MOD_ID = "examplemod"; // ...
public static CompatRegistryV2 registry;
@Override
public void init() {
registry = super.registry; // Get the registry fr...
// ... other initialization processes ...
}
// Helper method to easily create an Identifier using...
public static CompatIdentifier _id(String path) {
return CompatIdentifier.of(MOD_ID, path);
}
@Override
public String getId() {
return MOD_ID;
}
// ...
}
}}
*** 2. Define Item ID [#a8fc76fb]
Define the ID for the item you want to add using ''Compat...
This will be in the format ''MOD_ID:item_name''.
#gcode(java){{
public class ExampleMod extends CommonModInitializer {
// ... (code from above) ...
// Define the Item ID
public static CompatIdentifier EXAMPLE_ITEM_ID = _id(...
// ...
}
}}
*** 3. Prepare Item Instance and Settings [#rbbefa46]
Create an instance of the item to be added.
With MCPitanLib, you typically use the ''CompatItem'' cla...
- '''''CompatibleItemSettings.of()''''': Configures basic...
- '''''CompatItem''''': The most basic item class, which ...
#gcode(java){{
// Defined within ExampleMod.java, either in the init met...
// Variable to hold the registration result of the item (...
public static RegistryResult<Item> EXAMPLE_ITEM;
// Register the item within the init method
@Override
public void init() {
// ...
registry = super.registry;
// ...
// Register the item
EXAMPLE_ITEM = registry.registerItem(EXAMPLE_ITEM_ID,...
new CompatItem(CompatibleItemSettings.of(EXAM...
// .maxCount(16) // For example, if y...
.addGroup(ItemGroups.INGREDIENTS) // ...
)
);
// ...
}
}}
'''Points:'''
- ''CompatibleItemSettings.of(CompatIdentifier id)'': Pas...
- ''.addGroup(ItemGroups.INGREDIENTS)'': Adds the created...
- ''() -> new CompatItem(...)'': Passes a lambda expressi...
*** 4. (Optional) Create a Custom Item Class [#x60ffdd1]
If you want to create an item with more complex behavior,...
#gcode(java){{
// Example: An item with special behavior on right-click
public class MyCustomItem extends CompatItem {
public MyCustomItem(CompatibleItemSettings settings) {
super(settings);
}
@Override
public public StackActionResult onRightClick(ItemUseE...
// Action on right-click
if (!e.isClient())
e.player.sendMessage(TextUtil.literal("Custom...
return e.success();
}
}
// Registration in ExampleMod.java
// ...
public static RegistryResult<Item> MY_CUSTOM_ITEM;
public static CompatIdentifier MY_CUSTOM_ITEM_ID = _id("m...
// ...
// Inside the init method
MY_CUSTOM_ITEM = registry.registerItem(MY_CUSTOM_ITEM_ID,...
new MyCustomItem(CompatibleItemSettings.of(MY_CUS...
.addGroup(ItemGroups.TOOLS) // Add to the...
)
);
// ...
}}
*** Summary [#nef17c9c]
Using MCPitanLib, you can easily add cross-platform compa...
The key classes and methods are:
- ''CompatRegistryV2#registerItem(CompatIdentifier id, Su...
- ''CompatIdentifier#of(String modId, String path)''
- ''CompatItem''
- ''CompatibleItemSettings#of(CompatIdentifier id)''
For more detailed settings or custom behaviors, please re...
終了行:
* How to Add Items with MCPitanLib [#x39c2589]
This guide explains the basic steps to add a new item to ...
It references the implementation in ''ExampleMod.java'' a...
**Prerequisites [#v110afc8]
- MCPitanLib is already integrated into your project.
- Your mod's main class (e.g., ''ExampleMod'') inherits f...
**Steps [#ucbcb02b]
*** 1. Prepare MOD ID and Registry [#l02c5ab2]
Define the MOD ID used for identifying your mod and get t...
#gcode(java){{
public class ExampleMod extends CommonModInitializer {
public static final String MOD_ID = "examplemod"; // ...
public static CompatRegistryV2 registry;
@Override
public void init() {
registry = super.registry; // Get the registry fr...
// ... other initialization processes ...
}
// Helper method to easily create an Identifier using...
public static CompatIdentifier _id(String path) {
return CompatIdentifier.of(MOD_ID, path);
}
@Override
public String getId() {
return MOD_ID;
}
// ...
}
}}
*** 2. Define Item ID [#a8fc76fb]
Define the ID for the item you want to add using ''Compat...
This will be in the format ''MOD_ID:item_name''.
#gcode(java){{
public class ExampleMod extends CommonModInitializer {
// ... (code from above) ...
// Define the Item ID
public static CompatIdentifier EXAMPLE_ITEM_ID = _id(...
// ...
}
}}
*** 3. Prepare Item Instance and Settings [#rbbefa46]
Create an instance of the item to be added.
With MCPitanLib, you typically use the ''CompatItem'' cla...
- '''''CompatibleItemSettings.of()''''': Configures basic...
- '''''CompatItem''''': The most basic item class, which ...
#gcode(java){{
// Defined within ExampleMod.java, either in the init met...
// Variable to hold the registration result of the item (...
public static RegistryResult<Item> EXAMPLE_ITEM;
// Register the item within the init method
@Override
public void init() {
// ...
registry = super.registry;
// ...
// Register the item
EXAMPLE_ITEM = registry.registerItem(EXAMPLE_ITEM_ID,...
new CompatItem(CompatibleItemSettings.of(EXAM...
// .maxCount(16) // For example, if y...
.addGroup(ItemGroups.INGREDIENTS) // ...
)
);
// ...
}
}}
'''Points:'''
- ''CompatibleItemSettings.of(CompatIdentifier id)'': Pas...
- ''.addGroup(ItemGroups.INGREDIENTS)'': Adds the created...
- ''() -> new CompatItem(...)'': Passes a lambda expressi...
*** 4. (Optional) Create a Custom Item Class [#x60ffdd1]
If you want to create an item with more complex behavior,...
#gcode(java){{
// Example: An item with special behavior on right-click
public class MyCustomItem extends CompatItem {
public MyCustomItem(CompatibleItemSettings settings) {
super(settings);
}
@Override
public public StackActionResult onRightClick(ItemUseE...
// Action on right-click
if (!e.isClient())
e.player.sendMessage(TextUtil.literal("Custom...
return e.success();
}
}
// Registration in ExampleMod.java
// ...
public static RegistryResult<Item> MY_CUSTOM_ITEM;
public static CompatIdentifier MY_CUSTOM_ITEM_ID = _id("m...
// ...
// Inside the init method
MY_CUSTOM_ITEM = registry.registerItem(MY_CUSTOM_ITEM_ID,...
new MyCustomItem(CompatibleItemSettings.of(MY_CUS...
.addGroup(ItemGroups.TOOLS) // Add to the...
)
);
// ...
}}
*** Summary [#nef17c9c]
Using MCPitanLib, you can easily add cross-platform compa...
The key classes and methods are:
- ''CompatRegistryV2#registerItem(CompatIdentifier id, Su...
- ''CompatIdentifier#of(String modId, String path)''
- ''CompatItem''
- ''CompatibleItemSettings#of(CompatIdentifier id)''
For more detailed settings or custom behaviors, please re...
ページ名:
目次
FrontPage
Video/FabricのMOD開発講座
MOD解説
自作系
Item Alchemy
Ender Cane
Simple Uncrafting Table
Advanced Reborn
Enhanced Quarries
PipePlus
Space Cube
Storage Box for Fabric
[Fork]
↑
検索
AND検索
OR検索
最新の10件
2025-06-19
Universal Wrench
2025-06-16
dev/MCPitanLib
dev/MCPitanLib/Item Addition/en
RecentDeleted
dev/MCPitanLib/Overview/en
dev/MCPitanLib/Overview
2025-06-09
FrontPage
Memory Usage Title
Ender Cane
Mod Sound Volume Options
↑
ツールボックス
新しいページの作成
最近更新したページ
全ページ
ヘルプ
↑
カウンター
総計:
0
今日:
0
昨日:
0
現在:
4