Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
55f13280e0 | ||
|
|
a9817ebe7d | ||
|
|
b74146b7f9 | ||
|
|
402392cb90 | ||
|
|
4000f89258 | ||
|
|
58ca2d3b4d |
@@ -39,6 +39,8 @@ run/usercache.json
|
|||||||
run/.fabric
|
run/.fabric
|
||||||
run/crash-reports
|
run/crash-reports
|
||||||
run/xaero
|
run/xaero
|
||||||
|
run/screenshots
|
||||||
|
run/Xaero*
|
||||||
|
|
||||||
# java
|
# java
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,29 @@
|
|||||||
package de.jottyfan.minecraft;
|
package de.jottyfan.minecraft;
|
||||||
|
|
||||||
import net.fabricmc.api.ModInitializer;
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.resources.Identifier;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.item.ModItems;
|
||||||
|
import de.jottyfan.minecraft.tab.ModTab;
|
||||||
|
import net.fabricmc.api.ModInitializer;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Mfmd2627 implements ModInitializer {
|
public class Mfmd2627 implements ModInitializer {
|
||||||
public static final String MOD_ID = "mfmd2627";
|
public static final String MOD_ID = "mfmd2627";
|
||||||
|
|
||||||
// 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 Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
// This code runs as soon as Minecraft is in a mod-load-ready state.
|
LOGGER.debug("initializing {}", MOD_ID);
|
||||||
// However, some things (like resources) may still be uninitialized.
|
List<Item> items = ModItems.registerItems();
|
||||||
// Proceed with mild caution.
|
ModTab.registerItemGroup(items);
|
||||||
|
|
||||||
LOGGER.info("Hello Fabric world!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Identifier id(String path) {
|
|
||||||
return Identifier.fromNamespaceAndPath(MOD_ID, path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package de.jottyfan.minecraft;
|
||||||
|
|
||||||
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Mfmd2627Client implements ClientModInitializer {
|
||||||
|
@Override
|
||||||
|
public void onInitializeClient() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package de.jottyfan.minecraft.item;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ModItems extends ModItemsRegistrator {
|
||||||
|
public static final Item STUB = registerItem("stub");
|
||||||
|
public static final Item RUBY = registerItem("ruby");
|
||||||
|
|
||||||
|
public static final List<Item> registerItems() {
|
||||||
|
List<Item> registeredItems = new ArrayList<>();
|
||||||
|
registeredItems.add(STUB);
|
||||||
|
registeredItems.add(RUBY);
|
||||||
|
return registeredItems;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package de.jottyfan.minecraft.item;
|
||||||
|
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.Mfmd2627;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.Item.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public abstract class ModItemsRegistrator {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register a new item with the name
|
||||||
|
*
|
||||||
|
* @param name the name of the item
|
||||||
|
* @return the registered item
|
||||||
|
*/
|
||||||
|
public static final Item registerItem(String name) {
|
||||||
|
return registerItem(name, new Item.Properties(), Item::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register a new item with the name, the properties and the Item class reference
|
||||||
|
*
|
||||||
|
* @param name the name of the item
|
||||||
|
* @param the properties; create it with <code style="color: gray">new Item.Properties();</code>
|
||||||
|
* @param the function; create it with <code style="color: gray">Item::new</code>
|
||||||
|
* @return the registered item
|
||||||
|
*/
|
||||||
|
public static final Item registerItem(String name, Properties properties, Function<Item.Properties, Item> function) {
|
||||||
|
Identifier identifier = Identifier.fromNamespaceAndPath(Mfmd2627.MOD_ID, name);
|
||||||
|
Item item = function.apply(properties.setId(ResourceKey.create(Registries.ITEM, identifier)).modelId(identifier)
|
||||||
|
.useItemDescriptionPrefix());
|
||||||
|
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package de.jottyfan.minecraft.tab;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.Mfmd2627;
|
||||||
|
import de.jottyfan.minecraft.item.ModItems;
|
||||||
|
import net.fabricmc.fabric.api.creativetab.v1.FabricCreativeModeTab;
|
||||||
|
import net.minecraft.core.Registry;
|
||||||
|
import net.minecraft.core.registries.BuiltInRegistries;
|
||||||
|
import net.minecraft.core.registries.Registries;
|
||||||
|
import net.minecraft.network.chat.Component;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.resources.ResourceKey;
|
||||||
|
import net.minecraft.world.item.CreativeModeTab;
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ModTab {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* register the items in an own tab for the creative menu
|
||||||
|
*
|
||||||
|
* @param items the items
|
||||||
|
*/
|
||||||
|
public static final void registerItemGroup(List<Item> items) {
|
||||||
|
ResourceKey<CreativeModeTab> tabKey = ResourceKey.create(Registries.CREATIVE_MODE_TAB,
|
||||||
|
Identifier.fromNamespaceAndPath(Mfmd2627.MOD_ID, "itemgroup"));
|
||||||
|
|
||||||
|
CreativeModeTab quicklyTab = FabricCreativeModeTab.builder().icon(() -> new ItemStack(ModItems.STUB))
|
||||||
|
.title(Component.translatable("tab.mfmd2627")).displayItems((params, output) -> {
|
||||||
|
for (Item item : items) {
|
||||||
|
output.accept(item);
|
||||||
|
}
|
||||||
|
}).build();
|
||||||
|
|
||||||
|
Registry.register(BuiltInRegistries.CREATIVE_MODE_TAB, tabKey, quicklyTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "mfmd2627:item/ruby"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "mfmd2627:item/stub"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"item.mfmd2627.stub": "Stummel",
|
||||||
|
"item.mfmd2627.ruby": "Rubin",
|
||||||
|
"tab.mfmd2627": "Mfmd2627"
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"item.mfmd2627.stub": "Stub",
|
||||||
|
"item.mfmd2627.ruby": "Ruby",
|
||||||
|
"tab.mfmd2627": "Mfmd2627"
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "mfmd2627:item/ruby"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"parent": "minecraft:item/generated",
|
||||||
|
"textures": {
|
||||||
|
"layer0": "mfmd2627:item/stub"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 470 B |
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
@@ -3,7 +3,7 @@
|
|||||||
"id": "mfmd2627",
|
"id": "mfmd2627",
|
||||||
"version": "${version}",
|
"version": "${version}",
|
||||||
"name": "mfmd2627",
|
"name": "mfmd2627",
|
||||||
"description": "A mod for learning how to develop mods in a group",
|
"description": "Learn how to develop mods in a group",
|
||||||
"authors": [
|
"authors": [
|
||||||
"The GTA team"
|
"The GTA team"
|
||||||
],
|
],
|
||||||
@@ -17,6 +17,9 @@
|
|||||||
"entrypoints": {
|
"entrypoints": {
|
||||||
"main": [
|
"main": [
|
||||||
"de.jottyfan.minecraft.Mfmd2627"
|
"de.jottyfan.minecraft.Mfmd2627"
|
||||||
|
],
|
||||||
|
"client": [
|
||||||
|
"de.jottyfan.minecraft.Mfmd2627Client"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"depends": {
|
"depends": {
|
||||||
|
|||||||
Reference in New Issue
Block a user