Refactored src
This commit is contained in:
parent
d5047d4323
commit
53bc474698
5 changed files with 84 additions and 49 deletions
|
|
@ -1,75 +1,32 @@
|
||||||
package com.skdevstudios.util_rings;
|
package com.skdevstudios.util_rings;
|
||||||
|
|
||||||
import com.mojang.logging.LogUtils;
|
import com.skdevstudios.util_rings.init.CreativeTabInit;
|
||||||
import net.minecraft.core.registries.Registries;
|
import com.skdevstudios.util_rings.init.ItemsInit;
|
||||||
import net.minecraft.network.chat.Component;
|
|
||||||
import net.minecraft.world.item.CreativeModeTab;
|
|
||||||
import net.minecraft.world.item.CreativeModeTabs;
|
|
||||||
import net.minecraft.world.item.Item;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.eventbus.api.IEventBus;
|
import net.minecraftforge.eventbus.api.IEventBus;
|
||||||
import net.minecraftforge.fml.ModLoadingContext;
|
import net.minecraftforge.fml.ModLoadingContext;
|
||||||
import net.minecraftforge.fml.common.Mod;
|
import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
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
|
// The value here should match an entry in the META-INF/mods.toml file
|
||||||
@Mod(UtilRings.MODID)
|
@Mod(UtilRings.MODID)
|
||||||
public class UtilRings
|
public class UtilRings
|
||||||
{
|
{
|
||||||
// Define mod id in a common place for everything to reference
|
// Define mod id in a common place for everything to reference
|
||||||
public static final String MODID = "util_rings";
|
public static final String MODID = "util_rings";
|
||||||
// Directly reference a slf4j logger
|
public static final String MOD_VERSION = "1.20-1.0.0.0";
|
||||||
private static final Logger LOGGER = LogUtils.getLogger();
|
|
||||||
// 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 crafting material item named util_rings:iron_ring
|
|
||||||
public static final RegistryObject<Item> IRON_RING = ITEMS.register("iron_ring", () -> new Item(new Item.Properties().stacksTo(1)));
|
|
||||||
// Creates a crafting material item named util_rings:volcanic_glass_ring
|
|
||||||
public static final RegistryObject<Item> VOLCANIC_GLASS_RING = ITEMS.register("volcanic_glass_ring", () -> new Item(new Item.Properties().stacksTo(1)));
|
|
||||||
|
|
||||||
// Creates a creative tab with the id "util_rings:rings_tab" for the example item, that is placed after the combat tab
|
|
||||||
public static final RegistryObject<CreativeModeTab> UTIL_RINGS_TAB = CREATIVE_MODE_TABS.register("rings_tab", () -> CreativeModeTab.builder()
|
|
||||||
.title(Component.translatable("itemGroup.rings_tab"))
|
|
||||||
.withTabsBefore(CreativeModeTabs.COMBAT)
|
|
||||||
.icon(() -> IRON_RING.get().getDefaultInstance())
|
|
||||||
.displayItems((parameters, output) -> {
|
|
||||||
output.accept(IRON_RING.get());
|
|
||||||
output.accept(VOLCANIC_GLASS_RING.get());
|
|
||||||
})
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
|
|
||||||
public UtilRings()
|
public UtilRings()
|
||||||
{
|
{
|
||||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
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 items get registered
|
// Register the Deferred Register to the mod event bus so items get registered
|
||||||
ITEMS.register(modEventBus);
|
ItemsInit.ITEMS.register(modEventBus);
|
||||||
// Register the Deferred Register to the mod event bus so tabs get registered
|
// Register the Deferred Register to the mod event bus so tabs get registered
|
||||||
CREATIVE_MODE_TABS.register(modEventBus);
|
CreativeTabInit.CREATIVE_MODE_TABS.register(modEventBus);
|
||||||
// Register ourselves for server and other game events we are interested in
|
// Register ourselves for server and other game events we are interested in
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
// Register our mod's ForgeConfigSpec so that Forge can create and load the config file for us
|
// 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);
|
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()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.skdevstudios.util_rings.init;
|
||||||
|
|
||||||
|
import com.skdevstudios.util_rings.UtilRings;
|
||||||
|
|
||||||
|
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 CreativeTabInit {
|
||||||
|
// Create a Deferred Register to hold CreativeModeTabs which will all be registered under the "util_rings" namespace
|
||||||
|
public static final DeferredRegister<CreativeModeTab> CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, UtilRings.MODID);
|
||||||
|
|
||||||
|
// Creates a creative tab with the id "util_rings:rings_tab" for the example item, that is placed after the combat tab
|
||||||
|
public static final RegistryObject<CreativeModeTab> UTIL_RINGS_TAB = CREATIVE_MODE_TABS.register("rings_tab", () -> CreativeModeTab.builder()
|
||||||
|
.title(Component.translatable("itemGroup.rings_tab"))
|
||||||
|
.withTabsBefore(CreativeModeTabs.COMBAT)
|
||||||
|
.icon(() -> ItemsInit.IRON_RING.get().getDefaultInstance())
|
||||||
|
.displayItems((parameters, output) -> {
|
||||||
|
output.accept(ItemsInit.IRON_RING.get());
|
||||||
|
output.accept(ItemsInit.VOLCANIC_GLASS_RING.get());
|
||||||
|
})
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.skdevstudios.util_rings.init;
|
||||||
|
|
||||||
|
import com.skdevstudios.util_rings.UtilRings;
|
||||||
|
|
||||||
|
import net.minecraft.world.item.Item;
|
||||||
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
import net.minecraftforge.registries.ForgeRegistries;
|
||||||
|
import net.minecraftforge.registries.RegistryObject;
|
||||||
|
|
||||||
|
public class ItemsInit {
|
||||||
|
// 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, UtilRings.MODID);
|
||||||
|
|
||||||
|
public static final RegistryObject<Item> IRON_RING = ITEMS.register("iron_ring", () -> new Item(new Item.Properties().stacksTo(1)));
|
||||||
|
public static final RegistryObject<Item> VOLCANIC_GLASS_RING = ITEMS.register("volcanic_glass_ring", () -> new Item(new Item.Properties().stacksTo(1)));
|
||||||
|
}
|
||||||
17
src/main/resources/data/util_rings/recipes/iron_ring.json
Normal file
17
src/main/resources/data/util_rings/recipes/iron_ring.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
" # ",
|
||||||
|
"# #",
|
||||||
|
" # "
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"#": {
|
||||||
|
"item": "minecraft:iron_nugget"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"item": "util_rings:iron_ring",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shapeless",
|
||||||
|
"ingredients": [
|
||||||
|
{
|
||||||
|
"item": "util_rings:iron_ring"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:lava_bucket"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"item": "minecraft:water_bucket"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"result": {
|
||||||
|
"item": "util_rings:volcanic_glass_ring",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in a new issue