added all required functionality and components
This commit is contained in:
parent
a0529c915a
commit
5f74554bb7
26 changed files with 472 additions and 154 deletions
|
|
@ -0,0 +1,3 @@
|
|||
// 1.20.1 2023-10-17T04:52:58.4280102 Item Models: yatcm
|
||||
f084529b8d39478eaa552294fe1baf17c3818451 assets/yatcm/models/item/tiny_charcoal.json
|
||||
9d4c50f8e5dfc12eb25079160be87c75aecf317e assets/yatcm/models/item/tiny_coal.json
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
// 1.20.1 2023-10-17T04:52:58.4257407 Recipes
|
||||
dd593abc29b12386dbb82c1dedbaf96ac74bd0f6 data/minecraft/advancements/recipes/misc/charcoal.json
|
||||
1b4f73deca67cc5110fcfbfff723f690f2148246 data/minecraft/advancements/recipes/misc/coal.json
|
||||
31ae2ebccf20165d74cfdc70e1f58ad2a7bfea91 data/minecraft/recipes/charcoal.json
|
||||
f90bcddd73b317914120b8efb379231375bd2299 data/minecraft/recipes/coal.json
|
||||
d296d70ec0c6e2222296b2bfb228daf0c40c75e5 data/yatcm/advancements/recipes/misc/tiny_charcoal.json
|
||||
8bb3080374772c5d65f929e8012d274ff737a51e data/yatcm/advancements/recipes/misc/tiny_coal.json
|
||||
0f827f9d95020e8fea7ac387e9161b0408608676 data/yatcm/recipes/tiny_charcoal.json
|
||||
5c12214c5946ef19f98862ddb0f6c543f92c3f34 data/yatcm/recipes/tiny_coal.json
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
// 1.20.1 2023-10-17T05:55:19.9702561 Languages: en_us
|
||||
c58f70c944269cd7b06d4d7172dd4e375caca7db assets/yatcm/lang/en_us.json
|
||||
5
src/generated/resources/assets/yatcm/lang/en_us.json
Normal file
5
src/generated/resources/assets/yatcm/lang/en_us.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"item.yatcm.tiny_charcoal": "Tiny Charcoal",
|
||||
"item.yatcm.tiny_coal": "Tiny Coal",
|
||||
"itemGroup.yatcm_tab": "Yet Another Tiny Coal Mod"
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "yatcm:item/tiny_charcoal"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent": "minecraft:item/generated",
|
||||
"textures": {
|
||||
"layer0": "yatcm:item/tiny_coal"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "minecraft:charcoal"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
},
|
||||
"has_tiny_coal": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"yatcm:tiny_charcoal"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_tiny_coal",
|
||||
"has_the_recipe"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"minecraft:charcoal"
|
||||
]
|
||||
},
|
||||
"sends_telemetry_event": false
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "minecraft:coal"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
},
|
||||
"has_tiny_coal": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"yatcm:tiny_coal"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_tiny_coal",
|
||||
"has_the_recipe"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"minecraft:coal"
|
||||
]
|
||||
},
|
||||
"sends_telemetry_event": false
|
||||
}
|
||||
33
src/generated/resources/data/minecraft/recipes/charcoal.json
Normal file
33
src/generated/resources/data/minecraft/recipes/charcoal.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "minecraft:charcoal"
|
||||
}
|
||||
}
|
||||
33
src/generated/resources/data/minecraft/recipes/coal.json
Normal file
33
src/generated/resources/data/minecraft/recipes/coal.json
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
},
|
||||
{
|
||||
"item": "yatcm:tiny_coal"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"item": "minecraft:coal"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_charcoal": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"minecraft:charcoal"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "yatcm:tiny_charcoal"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_charcoal",
|
||||
"has_the_recipe"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"yatcm:tiny_charcoal"
|
||||
]
|
||||
},
|
||||
"sends_telemetry_event": false
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"parent": "minecraft:recipes/root",
|
||||
"criteria": {
|
||||
"has_coal": {
|
||||
"conditions": {
|
||||
"items": [
|
||||
{
|
||||
"items": [
|
||||
"minecraft:coal"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"trigger": "minecraft:inventory_changed"
|
||||
},
|
||||
"has_the_recipe": {
|
||||
"conditions": {
|
||||
"recipe": "yatcm:tiny_coal"
|
||||
},
|
||||
"trigger": "minecraft:recipe_unlocked"
|
||||
}
|
||||
},
|
||||
"requirements": [
|
||||
[
|
||||
"has_coal",
|
||||
"has_the_recipe"
|
||||
]
|
||||
],
|
||||
"rewards": {
|
||||
"recipes": [
|
||||
"yatcm:tiny_coal"
|
||||
]
|
||||
},
|
||||
"sends_telemetry_event": false
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:charcoal"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"count": 8,
|
||||
"item": "yatcm:tiny_charcoal"
|
||||
}
|
||||
}
|
||||
13
src/generated/resources/data/yatcm/recipes/tiny_coal.json
Normal file
13
src/generated/resources/data/yatcm/recipes/tiny_coal.json
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"category": "misc",
|
||||
"ingredients": [
|
||||
{
|
||||
"item": "minecraft:coal"
|
||||
}
|
||||
],
|
||||
"result": {
|
||||
"count": 8,
|
||||
"item": "yatcm:tiny_coal"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,63 +1,13 @@
|
|||
package com.skdevstudios.yatcm;
|
||||
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.common.ForgeConfigSpec;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.event.config.ModConfigEvent;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
// An example config class. This is not required, but it's a good idea to have one to keep your config organized.
|
||||
// Demonstrates how to use Forge's config APIs
|
||||
@Mod.EventBusSubscriber(modid = YATCM.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
@Mod.EventBusSubscriber(modid = ModConstants.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class Config
|
||||
{
|
||||
private static final ForgeConfigSpec.Builder BUILDER = new ForgeConfigSpec.Builder();
|
||||
|
||||
private static final ForgeConfigSpec.BooleanValue LOG_DIRT_BLOCK = BUILDER
|
||||
.comment("Whether to log the dirt block on common setup")
|
||||
.define("logDirtBlock", true);
|
||||
|
||||
private static final ForgeConfigSpec.IntValue MAGIC_NUMBER = BUILDER
|
||||
.comment("A magic number")
|
||||
.defineInRange("magicNumber", 42, 0, Integer.MAX_VALUE);
|
||||
|
||||
public static final ForgeConfigSpec.ConfigValue<String> MAGIC_NUMBER_INTRODUCTION = BUILDER
|
||||
.comment("What you want the introduction message to be for the magic number")
|
||||
.define("magicNumberIntroduction", "The magic number is... ");
|
||||
|
||||
// a list of strings that are treated as resource locations for items
|
||||
private static final ForgeConfigSpec.ConfigValue<List<? extends String>> ITEM_STRINGS = BUILDER
|
||||
.comment("A list of items to log on common setup.")
|
||||
.defineListAllowEmpty("items", List.of("minecraft:iron_ingot"), Config::validateItemName);
|
||||
|
||||
static final ForgeConfigSpec SPEC = BUILDER.build();
|
||||
|
||||
public static boolean logDirtBlock;
|
||||
public static int magicNumber;
|
||||
public static String magicNumberIntroduction;
|
||||
public static Set<Item> items;
|
||||
|
||||
private static boolean validateItemName(final Object obj)
|
||||
{
|
||||
return obj instanceof final String itemName && ForgeRegistries.ITEMS.containsKey(new ResourceLocation(itemName));
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
static void onLoad(final ModConfigEvent event)
|
||||
{
|
||||
logDirtBlock = LOG_DIRT_BLOCK.get();
|
||||
magicNumber = MAGIC_NUMBER.get();
|
||||
magicNumberIntroduction = MAGIC_NUMBER_INTRODUCTION.get();
|
||||
|
||||
// convert the list of strings into a set of items
|
||||
items = ITEM_STRINGS.get().stream()
|
||||
.map(itemName -> ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName)))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,128 +1,34 @@
|
|||
package com.skdevstudios.yatcm;
|
||||
|
||||
import com.mojang.logging.LogUtils;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.world.food.FoodProperties;
|
||||
import net.minecraft.world.item.BlockItem;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockBehaviour;
|
||||
import net.minecraft.world.level.material.MapColor;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import com.skdevstudios.yatcm.init.ModCreativeTabInit;
|
||||
import com.skdevstudios.yatcm.items.ModItems;
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
|
||||
import net.minecraftforge.event.server.ServerStartingEvent;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.ModLoadingContext;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.config.ModConfig;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
|
||||
// The value here should match an entry in the META-INF/mods.toml file
|
||||
@Mod(YATCM.MODID)
|
||||
@Mod(ModConstants.MODID)
|
||||
public class YATCM
|
||||
{
|
||||
// Define mod id in a common place for everything to reference
|
||||
public static final String MODID = "yatcm";
|
||||
// Directly reference a slf4j logger
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
// Create a Deferred Register to hold Blocks which will all be registered under the "examplemod" namespace
|
||||
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MODID);
|
||||
// Create a Deferred Register to hold Items which will all be registered under the "examplemod" namespace
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID);
|
||||
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MODID);
|
||||
|
||||
// Creates a new Block with the id "examplemod:example_block", combining the namespace and path
|
||||
public static final RegistryObject<Block> EXAMPLE_BLOCK = BLOCKS.register("example_block", () -> new Block(BlockBehaviour.Properties.of().mapColor(MapColor.STONE)));
|
||||
// Creates a new BlockItem with the id "examplemod:example_block", combining the namespace and path
|
||||
public static final RegistryObject<Item> EXAMPLE_BLOCK_ITEM = ITEMS.register("example_block", () -> new BlockItem(EXAMPLE_BLOCK.get(), new Item.Properties()));
|
||||
|
||||
// Creates a new food item with the id "examplemod:example_id", nutrition 1 and saturation 2
|
||||
public static final RegistryObject<Item> EXAMPLE_ITEM = ITEMS.register("example_item", () -> new Item(new Item.Properties().food(new FoodProperties.Builder()
|
||||
.alwaysEat().nutrition(1).saturationMod(2f).build())));
|
||||
|
||||
// Creates a creative tab with the id "examplemod:example_tab" for the example item, that is placed after the combat tab
|
||||
public static final RegistryObject<CreativeModeTab> EXAMPLE_TAB = CREATIVE_MODE_TABS.register("example_tab", () -> CreativeModeTab.builder()
|
||||
.withTabsBefore(CreativeModeTabs.COMBAT)
|
||||
.icon(() -> EXAMPLE_ITEM.get().getDefaultInstance())
|
||||
.displayItems((parameters, output) -> {
|
||||
output.accept(EXAMPLE_ITEM.get()); // Add the example item to the tab. For your own tabs, this method is preferred over the event
|
||||
}).build());
|
||||
|
||||
public YATCM()
|
||||
{
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
|
||||
// Register the commonSetup method for modloading
|
||||
modEventBus.addListener(this::commonSetup);
|
||||
|
||||
// Register the Deferred Register to the mod event bus so blocks get registered
|
||||
BLOCKS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so items get registered
|
||||
ITEMS.register(modEventBus);
|
||||
ModItems.ITEMS.register(modEventBus);
|
||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
||||
CREATIVE_MODE_TABS.register(modEventBus);
|
||||
|
||||
ModCreativeTabInit.CREATIVE_MODE_TABS.register(modEventBus);
|
||||
// Register ourselves for server and other game events we are interested in
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
|
||||
// Register the item to a creative tab
|
||||
modEventBus.addListener(this::addCreative);
|
||||
|
||||
// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
|
||||
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.SPEC);
|
||||
}
|
||||
|
||||
private void commonSetup(final FMLCommonSetupEvent event)
|
||||
{
|
||||
// Some common setup code
|
||||
LOGGER.info("HELLO FROM COMMON SETUP");
|
||||
|
||||
if (Config.logDirtBlock)
|
||||
LOGGER.info("DIRT BLOCK >> {}", ForgeRegistries.BLOCKS.getKey(Blocks.DIRT));
|
||||
|
||||
LOGGER.info(Config.magicNumberIntroduction + Config.magicNumber);
|
||||
|
||||
Config.items.forEach((item) -> LOGGER.info("ITEM >> {}", item.toString()));
|
||||
}
|
||||
|
||||
// Add the example block item to the building blocks tab
|
||||
private void addCreative(BuildCreativeModeTabContentsEvent event)
|
||||
{
|
||||
if (event.getTabKey() == CreativeModeTabs.BUILDING_BLOCKS)
|
||||
event.accept(EXAMPLE_BLOCK_ITEM);
|
||||
}
|
||||
|
||||
// You can use SubscribeEvent and let the Event Bus discover methods to call
|
||||
@SubscribeEvent
|
||||
public void onServerStarting(ServerStartingEvent event)
|
||||
{
|
||||
// Do something when the server starts
|
||||
LOGGER.info("HELLO from server starting");
|
||||
}
|
||||
|
||||
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent
|
||||
@Mod.EventBusSubscriber(modid = MODID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
public static class ClientModEvents
|
||||
{
|
||||
@SubscribeEvent
|
||||
public static void onClientSetup(FMLClientSetupEvent event)
|
||||
{
|
||||
// Some client setup code
|
||||
LOGGER.info("HELLO FROM CLIENT SETUP");
|
||||
LOGGER.info("MINECRAFT NAME >> {}", Minecraft.getInstance().getUser().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.skdevstudios.yatcm.datagen;
|
||||
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.data.event.GatherDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
|
||||
@Mod.EventBusSubscriber(modid = ModConstants.MODID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class DataGenerators {
|
||||
@SubscribeEvent
|
||||
public static void gatherData(GatherDataEvent event) {
|
||||
DataGenerator generator = event.getGenerator();
|
||||
PackOutput packOutput = generator.getPackOutput();
|
||||
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
|
||||
|
||||
generator.addProvider(true, new ModRecipeProvider(packOutput));
|
||||
generator.addProvider(true, new ModItemModelProvider(packOutput, existingFileHelper));
|
||||
generator.addProvider(true, new ModLanguageProvider(packOutput));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.skdevstudios.yatcm.datagen;
|
||||
|
||||
// import org.checkerframework.framework.qual.Unused;
|
||||
// import org.openjdk.nashorn.internal.ir.annotations.Ignore;
|
||||
|
||||
import com.skdevstudios.yatcm.items.ModItems;
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
// import io.netty.util.SuppressForbidden;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.client.model.generators.ItemModelBuilder;
|
||||
import net.minecraftforge.client.model.generators.ItemModelProvider;
|
||||
import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItemModelProvider extends ItemModelProvider{
|
||||
|
||||
public ModItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
|
||||
super(output, ModConstants.MODID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerModels() {
|
||||
simpleItem(ModItems.TINY_COAL);
|
||||
simpleItem(ModItems.TINY_CHARCOAL);
|
||||
}
|
||||
|
||||
private ItemModelBuilder simpleItem(RegistryObject<Item> item) {
|
||||
return withExistingParent(item.getId().getPath(),
|
||||
new ResourceLocation("item/generated")).texture("layer0",
|
||||
new ResourceLocation(ModConstants.MODID,"item/" + item.getId().getPath()));
|
||||
}
|
||||
|
||||
// private ItemModelBuilder handheldItem(RegistryObject<Item> item) {
|
||||
// return withExistingParent(item.getId().getPath(),
|
||||
// new ResourceLocation("item/handheld")).texture("layer0",
|
||||
// new ResourceLocation(ModConstants.MODID,"item/" + item.getId().getPath()));
|
||||
// }
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.skdevstudios.yatcm.datagen;
|
||||
|
||||
import com.skdevstudios.yatcm.items.ModItems;
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraftforge.common.data.LanguageProvider;
|
||||
|
||||
public class ModLanguageProvider extends LanguageProvider {
|
||||
|
||||
public ModLanguageProvider(PackOutput output) {
|
||||
super(output, ModConstants.MODID, "en_us");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTranslations() {
|
||||
this.addItem(ModItems.TINY_COAL, "Tiny Coal");
|
||||
this.addItem(ModItems.TINY_CHARCOAL, "Tiny Charcoal");
|
||||
this.add("itemGroup.yatcm_tab", "Yet Another Tiny Coal Mod");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.skdevstudios.yatcm.datagen;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import com.skdevstudios.yatcm.items.ModItems;
|
||||
|
||||
import net.minecraft.advancements.critereon.ItemPredicate;
|
||||
import net.minecraft.data.PackOutput;
|
||||
import net.minecraft.data.recipes.FinishedRecipe;
|
||||
import net.minecraft.data.recipes.RecipeCategory;
|
||||
import net.minecraft.data.recipes.RecipeProvider;
|
||||
import net.minecraft.data.recipes.ShapelessRecipeBuilder;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraftforge.common.crafting.conditions.IConditionBuilder;
|
||||
|
||||
public class ModRecipeProvider extends RecipeProvider implements IConditionBuilder{
|
||||
|
||||
public ModRecipeProvider(PackOutput pOutput) {
|
||||
super(pOutput);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildRecipes(Consumer<FinishedRecipe> pWriter) {
|
||||
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.TINY_COAL.get(), 8)
|
||||
.requires(Items.COAL)
|
||||
.unlockedBy("has_coal", inventoryTrigger(ItemPredicate.Builder.item().of(Items.COAL).build()))
|
||||
.save(pWriter);
|
||||
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, ModItems.TINY_CHARCOAL.get(), 8)
|
||||
.requires(Items.CHARCOAL)
|
||||
.unlockedBy("has_charcoal", inventoryTrigger(ItemPredicate.Builder.item().of(Items.CHARCOAL).build()))
|
||||
.save(pWriter);
|
||||
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Items.COAL, 1)
|
||||
.requires(ModItems.TINY_COAL.get(), 8)
|
||||
.unlockedBy("has_tiny_coal", inventoryTrigger(ItemPredicate.Builder.item().of(ModItems.TINY_COAL.get()).build()))
|
||||
.save(pWriter);
|
||||
ShapelessRecipeBuilder.shapeless(RecipeCategory.MISC, Items.CHARCOAL, 1)
|
||||
.requires(ModItems.TINY_CHARCOAL.get(), 8)
|
||||
.unlockedBy("has_tiny_coal", inventoryTrigger(ItemPredicate.Builder.item().of(ModItems.TINY_CHARCOAL.get()).build()))
|
||||
.save(pWriter);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.skdevstudios.yatcm.init;
|
||||
|
||||
import com.skdevstudios.yatcm.items.ModItems;
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.CreativeModeTab;
|
||||
import net.minecraft.world.item.CreativeModeTabs;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModCreativeTabInit {
|
||||
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "examplemod" namespace
|
||||
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ModConstants.MODID);
|
||||
|
||||
// Creates a creative tab with the id "yatcm:yatcm_tab" for the tiny_coal and tiny_charcoal items, that is placed after the combat tab.
|
||||
public static final RegistryObject<CreativeModeTab> YATCM_TAB = CREATIVE_MODE_TABS.register("yatcm_tab", () -> CreativeModeTab.builder()
|
||||
.withTabsBefore(CreativeModeTabs.COMBAT)
|
||||
.title(Component.translatable("itemGroup.yatcm_tab"))
|
||||
.icon(() -> ModItems.TINY_COAL.get().getDefaultInstance())
|
||||
.displayItems((parameters, output) -> {
|
||||
output.accept(ModItems.TINY_COAL.get());
|
||||
output.accept(ModItems.TINY_CHARCOAL.get());
|
||||
})
|
||||
.build());
|
||||
}
|
||||
20
src/main/java/com/skdevstudios/yatcm/items/FuelItem.java
Normal file
20
src/main/java/com/skdevstudios/yatcm/items/FuelItem.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package com.skdevstudios.yatcm.items;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.crafting.RecipeType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FuelItem extends Item {
|
||||
private int burnTime = 0;
|
||||
|
||||
public FuelItem(Properties pProperties, int burnTime) {
|
||||
super(pProperties);
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBurnTime(ItemStack itemStack, @Nullable RecipeType<?> recipeType) {
|
||||
return this.burnTime;
|
||||
}
|
||||
}
|
||||
16
src/main/java/com/skdevstudios/yatcm/items/ModItems.java
Normal file
16
src/main/java/com/skdevstudios/yatcm/items/ModItems.java
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package com.skdevstudios.yatcm.items;
|
||||
|
||||
import com.skdevstudios.yatcm.util.ModConstants;
|
||||
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraftforge.registries.DeferredRegister;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.RegistryObject;
|
||||
|
||||
public class ModItems {
|
||||
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ModConstants.MODID);
|
||||
|
||||
public static final RegistryObject<Item> TINY_COAL = ITEMS.register("tiny_coal", () -> new FuelItem(new Item.Properties().stacksTo(64), 200));
|
||||
public static final RegistryObject<Item> TINY_CHARCOAL = ITEMS.register("tiny_charcoal", () -> new FuelItem(new Item.Properties().stacksTo(64), 200));
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package com.skdevstudios.yatcm.util;
|
||||
|
||||
public class ModConstants {
|
||||
public static final String MODID = "yatcm";
|
||||
public static final String MOD_NAME = "Yet Another Tiny Coal Mod";
|
||||
}
|
||||
BIN
src/main/resources/assets/yatcm/textures/item/tiny_charcoal.png
Normal file
BIN
src/main/resources/assets/yatcm/textures/item/tiny_charcoal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 547 B |
BIN
src/main/resources/assets/yatcm/textures/item/tiny_coal.png
Normal file
BIN
src/main/resources/assets/yatcm/textures/item/tiny_coal.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 550 B |
Reference in a new issue