package net.kelsoncraft.test; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback; import net.fabricmc.fabric.api.registry.FuelRegistry; import net.kelsoncraft.test.block.CustomBlocks; import net.kelsoncraft.test.item.CustomItems; import net.kelsoncraft.test.item.CustomItemGroups; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.Text; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import static net.minecraft.server.command.CommandManager.*; public class KelsonCraftTest implements ModInitializer { // 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 String MOD_ID = "kelsoncraft-test"; public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); // This crashed it for some reason, so I had to move it into the onInitialize. // The method like below that they were using in the wiki didn't work, so I had to change it to what I did under this code. //public static final CustomItem CUSTOM_ITEM = new CustomItem(new FabricItemSettings()); // Try to use something like this to make particles, not sure how that would work. //ParticleTypes.DRIPPING_LAVA // Try to create a basic portable crafting command // Try to modify the value of the EnderChestInventory from 27 to something higher (Possibly with a mixin). // Try to create a BossBar at the top of the screen, either with a command or something else. // BossBar ServerBossBar // I have no idea how this would work. //DamageSources dmgsource = new DamageSources(); // I wonder how to set status effects with this: StatusEffects // Could I do anything with this?: HostileEntity // Try and use this to modify the hunger somehow: HungerManager // This might be fun to modify, to change the attack cool downs if this is the code: ItemCooldownManager // This shows the players walk speed, if they can fly and all that: PlayerAbilities // Looks like this is the equivalent of me doing if (sender instanceof Player) in Spigot. // if (entity instanceof ServerPlayerEntity) // The minecart code mostly seems to be in: AbstractMinecartEntity // I wonder if I can spawn a mob with a command using this: EntityType // LightningEntity @Override public void onInitialize() { // This code runs as soon as Minecraft is in a mod-load-ready state. // However, some things (like resources) may still be uninitialized. // Proceed with mild caution. // Initialize the item // This works, but it's better to do what I'm doing above with CUSTOM_ITEM. //Registry.register(Registries.ITEM, new Identifier("kelsoncraft-test", "custom_item"), new CustomItem(new FabricItemSettings().maxCount(16))); // Basic command test, just shows "Called /test with no arguments" CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("test") .executes(context -> { // For versions below 1.19, replace "Text.literal" with "new LiteralText". // For versions below 1.20, remode "() ->" directly. context.getSource().sendFeedback(() -> Text.literal("Called /test with no arguments"), false); return 1; }))); // I wonder how to get the player name with a command. CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess, environment) -> dispatcher.register(literal("test1") .executes(context -> { context.getSource().sendFeedback(() -> Text.literal("Hello player %s"), false); return 1; }))); // This is a way to use the item as fuel FuelRegistry.INSTANCE.add(CustomItems.CUSTOM_ITEM, 300); // Register items CustomItemGroups.registerItemGroups(); CustomItems.RegisterCustomItems(); // Register blocks CustomBlocks.registerModBlocks(); LOGGER.info("Hello Fabric world!"); } }