refactored code

This commit is contained in:
J-onasJones 2024-10-04 20:51:13 +02:00
parent 16ccbdb0c7
commit 9fa8b78dce
5 changed files with 20 additions and 72 deletions

View file

@ -12,7 +12,7 @@ public class NotEnoughCursedness implements ModInitializer {
// It is considered best practice to use your mod id as the logger's name. // 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. // That way, it's clear which mod wrote info, warnings, and errors.
public static String MOD_ID = "nec"; public static String MOD_ID = "nec";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); //public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
@Override @Override
@ -20,11 +20,5 @@ public class NotEnoughCursedness implements ModInitializer {
ModBlocks.register(); ModBlocks.register();
ModItems.register(); ModItems.register();
ModRegistries.registerModStuffs(); ModRegistries.registerModStuffs();
} }
} }

View file

@ -1,11 +1,7 @@
package me.jonasjones.nec.block; package me.jonasjones.nec.block;
import me.jonasjones.nec.util.ModRegistries;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block; import net.minecraft.block.*;
import net.minecraft.block.Blocks;
import net.minecraft.block.PillarBlock;
import net.minecraft.block.StairsBlock;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
@ -16,18 +12,18 @@ import static net.minecraft.registry.Registries.BLOCK;
import static net.minecraft.registry.Registries.ITEM; import static net.minecraft.registry.Registries.ITEM;
public class ModBlocks { public class ModBlocks {
public static final Block GREEN_BIRCH_LOG = new PillarBlock(FabricBlockSettings.copyOf(Blocks.BIRCH_LOG).strength(4.0f)); public static Block GREEN_BIRCH_LOG;
public static final Block BLAZE_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(4.0F)); public static Block BLAZE_BLOCK;
public static final Block GUN_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(4.0F)); public static Block GUN_BLOCK;
public static final Block DIAMOND_ORE_ORE = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_ORE).strength(4.0F)); public static Block DIAMOND_ORE_ORE;
public static final Block DEEPSLATE_DIAMOND_ORE_ORE = new Block(FabricBlockSettings.copyOf(Blocks.DEEPSLATE_DIAMOND_ORE).strength(4.0F)); public static Block DEEPSLATE_DIAMOND_ORE_ORE;
public static final Block JAVA_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F)); public static Block JAVA_BLOCK;
public static final Block POCKET_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F)); public static Block POCKET_BLOCK;
public static Block FLETCHING_STAIRS_BLOCK = null; public static Block FLETCHING_STAIRS_BLOCK = null;
private static BlockItem GUN_BLOCK_ITEM; public static BlockItem GUN_BLOCK_ITEM;
private static Block GUN_BLOCK_BLOCK; public static Block GUN_BLOCK_BLOCK;
private static BlockItem BLAZE_BLOCK_ITEM; public static BlockItem BLAZE_BLOCK_ITEM;
private static Block BLAZE_BLOCK_BLOCK; public static Block BLAZE_BLOCK_BLOCK;
public static BlockItem GREEN_BIRCH_LOG_ITEM; public static BlockItem GREEN_BIRCH_LOG_ITEM;
public static Block GREEEN_BIRCH_LOG_BLOCK; public static Block GREEEN_BIRCH_LOG_BLOCK;
public static BlockItem DIAMOND_ORE_ORE_ITEM; public static BlockItem DIAMOND_ORE_ORE_ITEM;
@ -40,42 +36,38 @@ public class ModBlocks {
public static Block POCKET_BLOCK_BLOCK; public static Block POCKET_BLOCK_BLOCK;
public static BlockItem FLETCHING_STAIRS_TIEM; public static BlockItem FLETCHING_STAIRS_TIEM;
public static Block FLETCHING_STAIRS_BLOCK_BLOCK; public static Block FLETCHING_STAIRS_BLOCK_BLOCK;
//public static final Block GREEN_BIRCH_WOOD = new PillarBlock(FabricBlockSettings.of(Material.WOOD).strength(4.0f));
//public static final Block STRIPPED_GREEN_BIRCH_LOG = new PillarBlock(FabricBlockSettings.of(Material.WOOD).strength(4.0f));
//public static final Block STRIPPED_GREEN_BIRCH_WOOD = new PillarBlock(FabricBlockSettings.of(Material.WOOD).strength(4.0f));
public static void register() { public static void register() {
BLAZE_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F));
BLAZE_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "blaze_block"), BLAZE_BLOCK); BLAZE_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "blaze_block"), BLAZE_BLOCK);
BLAZE_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "blaze_block"), new BlockItem(BLAZE_BLOCK, new Item.Settings())); BLAZE_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "blaze_block"), new BlockItem(BLAZE_BLOCK, new Item.Settings()));
ModRegistries.register_item(BLAZE_BLOCK_ITEM);
GREEN_BIRCH_LOG = new PillarBlock(FabricBlockSettings.copyOf(Blocks.BIRCH_LOG).strength(4.0f));
GREEEN_BIRCH_LOG_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "green_birch_log"), GREEN_BIRCH_LOG); GREEEN_BIRCH_LOG_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "green_birch_log"), GREEN_BIRCH_LOG);
GREEN_BIRCH_LOG_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "green_birch_log"), new BlockItem(GREEN_BIRCH_LOG, new Item.Settings())); GREEN_BIRCH_LOG_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "green_birch_log"), new BlockItem(GREEN_BIRCH_LOG, new Item.Settings()));
ModRegistries.register_item(GREEN_BIRCH_LOG_ITEM);
GUN_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F));
GUN_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "gun_block"), GUN_BLOCK); GUN_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "gun_block"), GUN_BLOCK);
GUN_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "gun_block"), new BlockItem(GUN_BLOCK, new Item.Settings())); GUN_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "gun_block"), new BlockItem(GUN_BLOCK, new Item.Settings()));
ModRegistries.register_item(GUN_BLOCK_ITEM);
DIAMOND_ORE_ORE = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_ORE).strength(5.0F));
DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "diamond_ore_ore"), DIAMOND_ORE_ORE); DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "diamond_ore_ore"), DIAMOND_ORE_ORE);
DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "diamond_ore_ore"), new BlockItem(DIAMOND_ORE_ORE, new Item.Settings())); DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "diamond_ore_ore"), new BlockItem(DIAMOND_ORE_ORE, new Item.Settings()));
ModRegistries.register_item(DIAMOND_ORE_ORE_ITEM);
DEEPSLATE_DIAMOND_ORE_ORE = new Block(FabricBlockSettings.copyOf(Blocks.DEEPSLATE_DIAMOND_ORE).strength(5.0F));
DEEPSLATE_DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), DEEPSLATE_DIAMOND_ORE_ORE); DEEPSLATE_DIAMOND_ORE_ORE_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), DEEPSLATE_DIAMOND_ORE_ORE);
DEEPSLATE_DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), new BlockItem(DEEPSLATE_DIAMOND_ORE_ORE, new Item.Settings())); DEEPSLATE_DIAMOND_ORE_ORE_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "deepslate_diamond_ore_ore"), new BlockItem(DEEPSLATE_DIAMOND_ORE_ORE, new Item.Settings()));
ModRegistries.register_item(DEEPSLATE_DIAMOND_ORE_ORE_ITEM);
JAVA_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F));
JAVA_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "java_block"), JAVA_BLOCK); JAVA_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "java_block"), JAVA_BLOCK);
JAVA_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "java_block"), new BlockItem(JAVA_BLOCK, new Item.Settings())); JAVA_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "java_block"), new BlockItem(JAVA_BLOCK, new Item.Settings()));
ModRegistries.register_item(JAVA_BLOCK_ITEM);
POCKET_BLOCK = new Block(FabricBlockSettings.copyOf(Blocks.DIAMOND_BLOCK).strength(5.0F));
POCKET_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "pocket_block"), POCKET_BLOCK); POCKET_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "pocket_block"), POCKET_BLOCK);
POCKET_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "pocket_block"), new BlockItem(POCKET_BLOCK, new Item.Settings())); POCKET_BLOCK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "pocket_block"), new BlockItem(POCKET_BLOCK, new Item.Settings()));
ModRegistries.register_item(POCKET_BLOCK_ITEM);
FLETCHING_STAIRS_BLOCK = new StairsBlock(GREEEN_BIRCH_LOG_BLOCK.getDefaultState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS).strength(1.0F)); FLETCHING_STAIRS_BLOCK = new StairsBlock(GREEEN_BIRCH_LOG_BLOCK.getDefaultState(), FabricBlockSettings.copyOf(Blocks.OAK_STAIRS).strength(1.0F));
FLETCHING_STAIRS_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "fletching_stairs"), FLETCHING_STAIRS_BLOCK); FLETCHING_STAIRS_BLOCK_BLOCK = Registry.register(BLOCK, Identifier.of(MOD_ID, "fletching_stairs"), FLETCHING_STAIRS_BLOCK);
FLETCHING_STAIRS_TIEM = Registry.register(ITEM, Identifier.of(MOD_ID, "fletching_stairs"), new BlockItem(FLETCHING_STAIRS_BLOCK, new Item.Settings())); FLETCHING_STAIRS_TIEM = Registry.register(ITEM, Identifier.of(MOD_ID, "fletching_stairs"), new BlockItem(FLETCHING_STAIRS_BLOCK, new Item.Settings()));
ModRegistries.register_item(FLETCHING_STAIRS_TIEM);
} }
} }

View file

@ -9,14 +9,11 @@ import net.minecraft.advancement.*;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer; import java.util.function.Consumer;
import net.minecraft.advancement.criterion.AbstractCriterion;
import net.minecraft.advancement.criterion.ConsumeItemCriterion;
import net.minecraft.advancement.criterion.InventoryChangedCriterion; import net.minecraft.advancement.criterion.InventoryChangedCriterion;
import net.minecraft.advancement.criterion.TickCriterion; import net.minecraft.advancement.criterion.TickCriterion;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import static me.jonasjones.nec.block.ModBlocks.*; import static me.jonasjones.nec.block.ModBlocks.*;
import static me.jonasjones.nec.item.ModItems.AK47_ITEM; import static me.jonasjones.nec.item.ModItems.AK47_ITEM;

View file

@ -1,7 +1,6 @@
package me.jonasjones.nec.item; package me.jonasjones.nec.item;
import me.jonasjones.nec.item.materials.DirtToolMaterial; import me.jonasjones.nec.item.materials.DirtToolMaterial;
import me.jonasjones.nec.util.ModRegistries;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.SwordItem; import net.minecraft.item.SwordItem;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
@ -22,30 +21,23 @@ public class ModItems {
public static void register() { public static void register() {
SwordItem DIRT_SWORD = new SwordItem(DirtToolMaterial.INSTANCE, new Item.Settings()); SwordItem DIRT_SWORD = new SwordItem(DirtToolMaterial.INSTANCE, new Item.Settings());
DIRT_SWORD_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "dirt_sword"), DIRT_SWORD); DIRT_SWORD_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "dirt_sword"), DIRT_SWORD);
//ModRegistries.register_item(DIRT_SWORD_ITEM);
Item STEEL = new Item(new Item.Settings()); Item STEEL = new Item(new Item.Settings());
STEEL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "steel"), STEEL); STEEL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "steel"), STEEL);
//ModRegistries.register_item(STEEL_ITEM);
Item NEGATIVE_FLINT = new Item(new Item.Settings()); Item NEGATIVE_FLINT = new Item(new Item.Settings());
NEGATIVE_FLINT_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "negative_flint"), NEGATIVE_FLINT); NEGATIVE_FLINT_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "negative_flint"), NEGATIVE_FLINT);
//ModRegistries.register_item(NEGATIVE_FLINT_ITEM);
Item LETTER = new Item(new Item.Settings()); Item LETTER = new Item(new Item.Settings());
LETTER_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "letter"), LETTER); LETTER_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "letter"), LETTER);
//ModRegistries.register_item(LETTER_ITEM);
Item CHAINMAIL = new Item(new Item.Settings()); Item CHAINMAIL = new Item(new Item.Settings());
CHAINMAIL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "chainmail"), CHAINMAIL); CHAINMAIL_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "chainmail"), CHAINMAIL);
//ModRegistries.register_item(CHAINMAIL_ITEM);
Item AK47 = new Item(new Item.Settings()); Item AK47 = new Item(new Item.Settings());
AK47_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "ak_47"), AK47); AK47_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "ak_47"), AK47);
//ModRegistries.register_item(AK47_ITEM);
Item HELMET_ON_A_STICK = new Item(new Item.Settings()); Item HELMET_ON_A_STICK = new Item(new Item.Settings());
HELMET_ON_A_STICK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "helmet_on_a_stick"), HELMET_ON_A_STICK); HELMET_ON_A_STICK_ITEM = Registry.register(ITEM, Identifier.of(MOD_ID, "helmet_on_a_stick"), HELMET_ON_A_STICK);
//ModRegistries.register_item(HELMET_ON_A_STICK_ITEM);
} }
} }

View file

@ -4,9 +4,7 @@ import me.jonasjones.nec.block.ModBlocks;
import me.jonasjones.nec.item.ModItems; import me.jonasjones.nec.item.ModItems;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; import net.fabricmc.fabric.api.registry.FlammableBlockRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; import net.fabricmc.fabric.api.registry.StrippableBlockRegistry;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
@ -20,27 +18,12 @@ public class ModRegistries {
public static ItemGroup NEC_GROUP = null; public static ItemGroup NEC_GROUP = null;
public static void registerModStuffs() { public static void registerModStuffs() {
registerFuels();
registerCommands();
registerEvents();
registerStrippables(); registerStrippables();
registerFlammableBlock(); registerFlammableBlock();
register_itemGroup(); register_itemGroup();
} }
private static void registerFuels() {
FuelRegistry registry = FuelRegistry.INSTANCE;
//registry.add(ModItems.LILAC_FLOWER_BULB, 200);
}
private static void registerCommands() {
//CommandRegistrationCallback.EVENT.register(SetHomeCommand::register);
//CommandRegistrationCallback.EVENT.register(ReturnHomeCommand::register);
}
private static void registerStrippables() { private static void registerStrippables() {
//StrippableBlockRegistry.register(ModBlocks.GREEEN_BIRCH_LOG_BLOCK, ModBlocks.STRIPPED_JACARANDA_LOG);
StrippableBlockRegistry.register(ModBlocks.GREEEN_BIRCH_LOG_BLOCK, ModBlocks.GREEEN_BIRCH_LOG_BLOCK); StrippableBlockRegistry.register(ModBlocks.GREEEN_BIRCH_LOG_BLOCK, ModBlocks.GREEEN_BIRCH_LOG_BLOCK);
} }
@ -50,16 +33,6 @@ public class ModRegistries {
instance.add(ModBlocks.GREEN_BIRCH_LOG, 5, 5); instance.add(ModBlocks.GREEN_BIRCH_LOG, 5, 5);
} }
private static void registerEvents() {
//ServerPlayerEvents.COPY_FROM.register(new ModPlayerEventCopyFrom());
}
public static void register_item(BlockItem CUSTOM_ITEM) {
//ItemGroupEvents.modifyEntriesEvent(ITEM_GROUP).register(content -> {
// content.add(CUSTOM_ITEM);
//});
}
public static void register_itemGroup() { public static void register_itemGroup() {
NEC_GROUP = FabricItemGroup.builder() NEC_GROUP = FabricItemGroup.builder()
.icon(() -> new ItemStack(ModItems.DIRT_SWORD_ITEM)) .icon(() -> new ItemStack(ModItems.DIRT_SWORD_ITEM))