Skip to content

Instantly share code, notes, and snippets.

View TelepathicGrunt's full-sized avatar
🦎
Just chilling around!

TelepathicGrunt TelepathicGrunt

🦎
Just chilling around!
View GitHub Profile
@TelepathicGrunt
TelepathicGrunt / Mod.java
Last active July 15, 2025 22:43
Fabric classload register
public class Mod implements ModInitializer {
public static final String MODID = "mod";
@Override
public void onInitialize() {
ModItems.initItems();
}
}
@TelepathicGrunt
TelepathicGrunt / Mod.java
Last active July 15, 2025 22:43
Fabric non-classload register
public class Mod implements ModInitializer {
public static final String MODID = "mod";
@Override
public void onInitialize() {
ModItems.registerItems();
}
}
@TelepathicGrunt
TelepathicGrunt / Mod.java
Last active July 15, 2025 22:43
Non-deferred NeoForge
@Mod(Mod.MODID)
public class Mod {
public static final String MODID = "mod";
public Mod(IEventBus modEventBus, ModContainer modContainer) {
modEventBus.addListener(ModItems::ModRegisterEvent);
}
}
@TelepathicGrunt
TelepathicGrunt / Mod.java
Last active July 15, 2025 22:43
Deferred NeoForge
@Mod(Mod.MODID)
public class Mod {
public static final String MODID = "mod";
public Mod(IEventBus modEventBus, ModContainer modContainer) {
ModItems.ITEMS.register(modEventBus);
}
}
public class StructureBiomeCheckCommand {
public static void createCommand(CommandDispatcher<CommandSourceStack> dispatcher, CommandBuildContext buildContext) {
String commandString = "checkvalidstructurebiomes";
LiteralCommandNode<CommandSourceStack> source = dispatcher.register(Commands.literal(commandString)
.requires((permission) -> permission.hasPermission(2))
.executes(cs -> {
checkBiomesForStructures(cs);
return 1;
}));

NOTE: Gist contents is moved to this repo for easier maintaining and record-keeping: https://github.com/neoforged/.github/tree/main/changes/technical_changes

A small selection of changes that were done in NeoForge since it's creation. This is not all of them. Most changes can be seen in PRs and Commits on the NeoForged GitHub organization's repositories.


Mod Loader

  1. Multiple mod entry points allowed now. Can even specify an entry point to be client only for better client code separation.
    https://docs.neoforged.net/docs/concepts/sides#mod

  2. Capability refactor to split it into Data Attachment and Capabilities separately and cleaner.https://docs.neoforged.net/docs/datastorage/attachmentshttps://docs.neoforged.net/docs/datastorage/capabilities
public static List<BlockPos> matchingBlocksOfKindInRange(Level level, BlockPos centerPos, int radius, Predicate<BlockState> predicate) {
List<BlockPos> validPos = new ObjectArrayList<>();
// Figure out how many chunk radius we need to search outward to encompass the radius properly
ChunkPos maxChunkPos = new ChunkPos(
SectionPos.blockToSectionCoord(centerPos.getX() + radius),
SectionPos.blockToSectionCoord(centerPos.getZ() + radius)
);
ChunkPos minChunkPos = new ChunkPos(
@TelepathicGrunt
TelepathicGrunt / NetworkingComparison.md
Last active June 7, 2024 11:40
Forge 1.19.2 networking vs Fabric 1.19.2 networking

Forge

Packet class

public record CrystallineFlowerEnchantmentPacket(int containerId, List<EnchantmentSkeleton> enchantmentSkeletons) {
    public static Gson gson = new GsonBuilder().create();

    public static void sendToClient(ServerPlayer entity, int containerId, List<EnchantmentSkeleton> enchantmentSkeletons) {
        MessageHandler.DEFAULT_CHANNEL.send(PacketDistributor.PLAYER.with(() -> entity),