Skip to content

Commit

Permalink
Add command ‘hello io’
Browse files Browse the repository at this point in the history
  • Loading branch information
trdthg committed Nov 16, 2024
1 parent aee6808 commit 9dcdf3c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ run
runs
run-data

repo
jdk
.env
.vscode
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.PHONY: build
build:
./gradlew build
26 changes: 4 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
# WIP CodeBio

Installation information
=======
## build

This template repository can be directly cloned to get you started with a new
mod. Simply create a new repository cloned from this one, by following the
instructions provided by [GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
如何构建:

Once you have your clone, simply open the repository in the IDE of your choice. The usual recommendation for an IDE is either IntelliJ IDEA or Eclipse.

If at any point you are missing libraries in your IDE, or you've run into problems you can
run `gradlew --refresh-dependencies` to refresh the local cache. `gradlew clean` to reset everything
{this does not affect your code} and then start the process again.

Mapping Names:
============
By default, the MDK is configured to use the official mapping names from Mojang for methods and fields
in the Minecraft codebase. These names are covered by a specific license. All modders should be aware of this
license. For the latest license text, refer to the mapping file itself, or the reference copy here:
https://github.com/NeoForged/NeoForm/blob/main/Mojang.md

Additional Resources:
==========
Community Documentation: https://docs.neoforged.net/
NeoForged Discord: https://discord.neoforged.net/
`make build` 或者: `.gradle build`
34 changes: 34 additions & 0 deletions src/main/java/com/example/examplemod/events/ModEvents.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.example.examplemod.events;

import org.slf4j.Logger;

import com.example.examplemod.ExampleMod;
import com.mojang.logging.LogUtils;

import net.minecraft.commands.Commands;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.event.RegisterCommandsEvent;
import net.neoforged.neoforge.event.entity.player.PlayerEvent;
import net.neoforged.neoforge.server.command.ConfigCommand;

@EventBusSubscriber(modid = ExampleMod.MODID)
public class ModEvents {
private static final Logger LOGGER = LogUtils.getLogger();

@SubscribeEvent
public static void onCommandsRegister(RegisterCommandsEvent event) {
event.getDispatcher().register(Commands.literal("hello")
.then(Commands.literal("io").executes((command) -> {
LOGGER.info("OIOIOI!");
return 0;
})));
ConfigCommand.register(event.getDispatcher());
}

@SubscribeEvent
public static void onPlayerCloneEvent(PlayerEvent.Clone event) {
event.getOriginal().getPersistentData().putIntArray(ExampleMod.MODID + "homepos",
event.getOriginal().getPersistentData().getIntArray(ExampleMod.MODID + "homepos"));
}
}

0 comments on commit 9dcdf3c

Please sign in to comment.