Skip to content

Instantly share code, notes, and snippets.

@tubbynl
Last active November 16, 2024 13:43
Show Gist options
  • Select an option

  • Save tubbynl/d35db722502d04a500d15544bd2bf99c to your computer and use it in GitHub Desktop.

Select an option

Save tubbynl/d35db722502d04a500d15544bd2bf99c to your computer and use it in GitHub Desktop.

Forge steps

Gebaseerd op devoxx4kids Minecraft workshop

Installatie

  • JDK 21
  • Forge MDK (downloaded 50.1 in this repository)
  • ./gradlew --refresh-dependencies
  • Eclipse: ./gradlew genEclipseRuns, IntelliJ: ./gradlew genIntellijRuns of VSCode: ./gradlew genVSCodeRuns
  • daarna in je ide zou de runClient moeten werken (Minecraft start)

Eerste code

  • in src/main/java package com.example.examplemod
  • Create new class -> ChatItems
  • vervang de inhoud van ChatItems.java met onderstaande code
package com.example.examplemod;

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraftforge.event.ServerChatEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber(modid = ExampleMod.MODID)
public class ChatItems {
    @SubscribeEvent
    public static void giveItems(ServerChatEvent event) {
        if (event.getMessage().getString().contains("aardappel")) {
            event.getPlayer().getInventory().add(new ItemStack(Items.POTATO, 64));
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment