Skip to content

Commit

Permalink
custom villager type
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaupenjoe committed Jan 19, 2025
1 parent 907a749 commit 0a0907e
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ minecraft_version=1.21.1
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21,1.21.2)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.1.68
neo_version=21.1.93
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.0.0-beta,)
# The loader version range can only use the major version of FML as bounds
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/kaupenjoe/tutorialmod/TutorialMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.kaupenjoe.tutorialmod.potion.ModPotions;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.kaupenjoe.tutorialmod.util.ModItemProperties;
import net.kaupenjoe.tutorialmod.villager.ModVillagers;
import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.world.item.CreativeModeTabs;
import org.slf4j.Logger;
Expand Down Expand Up @@ -63,6 +64,8 @@ public TutorialMod(IEventBus modEventBus, ModContainer modContainer) {
ModEnchantmentEffects.register(modEventBus);
ModEntities.register(modEventBus);

ModVillagers.register(modEventBus);

// Register the item to a creative tab
modEventBus.addListener(this::addCreative);
// Register our mod's ModConfigSpec so that FML can create and load the config file for us
Expand Down
33 changes: 33 additions & 0 deletions src/main/java/net/kaupenjoe/tutorialmod/villager/ModVillagers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package net.kaupenjoe.tutorialmod.villager;

import com.google.common.collect.ImmutableSet;
import net.kaupenjoe.tutorialmod.TutorialMod;
import net.kaupenjoe.tutorialmod.block.ModBlocks;
import net.kaupenjoe.tutorialmod.sound.ModSounds;
import net.minecraft.core.Holder;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.entity.ai.village.poi.PoiType;
import net.minecraft.world.entity.npc.VillagerProfession;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.neoforge.registries.DeferredRegister;

public class ModVillagers {
public static final DeferredRegister<PoiType> POI_TYPES =
DeferredRegister.create(BuiltInRegistries.POINT_OF_INTEREST_TYPE, TutorialMod.MOD_ID);
public static final DeferredRegister<VillagerProfession> VILLAGER_PROFESSIONS =
DeferredRegister.create(BuiltInRegistries.VILLAGER_PROFESSION, TutorialMod.MOD_ID);

public static final Holder<PoiType> KAUPEN_POI = POI_TYPES.register("kaupen_poi",
() -> new PoiType(ImmutableSet.copyOf(ModBlocks.CHAIR.get().getStateDefinition().getPossibleStates()), 1, 1));

public static final Holder<VillagerProfession> KAUPENGER = VILLAGER_PROFESSIONS.register("kaupenger",
() -> new VillagerProfession("kaupenger", holder -> holder.value() == KAUPEN_POI.value(),
poiTypeHolder -> poiTypeHolder.value() == KAUPEN_POI.value(), ImmutableSet.of(), ImmutableSet.of(),
ModSounds.MAGIC_BLOCK_HIT.get()));


public static void register(IEventBus eventBus) {
POI_TYPES.register(eventBus);
VILLAGER_PROFESSIONS.register(eventBus);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/assets/tutorialmod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@
"block.tutorialmod.chair": "Chair",


"entity.minecraft.villager.tutorialmod.kaupenger": "Kaupenger",

"creativetab.tutorialmod.bismuth_items": "Bismuth Items",
"creativetab.tutorialmod.bismuth_blocks": "Bismuth Blocks",

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"replace": false,
"values": [
{
"id": "tutorialmod:kaupen_poi",
"required": false
}
]
}

0 comments on commit 0a0907e

Please sign in to comment.