Skip to content

Commit

Permalink
customVillagerProfession
Browse files Browse the repository at this point in the history
  • Loading branch information
BeiShanair committed Feb 15, 2024
1 parent ab6b2e7 commit 076ff07
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20 2024-02-09T14:06:21.8457476 Tutorial Mod/Block Loot Tables
// 1.20 2024-02-15T10:28:20.6385214 Tutorial Mod/Block Loot Tables
f856acdc24b7ee23232ef53a2730f89be45a6fb0 data\tutorialmod\loot_tables\blocks\ice_ether_pressure_plate.json
104db78bc21c049f01d0a45256b364a5c46b4247 data\tutorialmod\loot_tables\blocks\ice_ether_slab.json
9d5c7704d9983f142c40a90636e96cdbc2e01eb2 data\tutorialmod\loot_tables\blocks\ice_ether_block.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20 2024-02-09T14:06:21.8502537 Tutorial Mod/Tags for minecraft:block
// 1.20 2024-02-15T10:28:20.6405258 Tutorial Mod/Tags for minecraft:block
6594795e343a0735ffeed65007f8302fe6eefc6b data\minecraft\tags\blocks\walls.json
7d2d23a1205b470cb0bf371376bb0bd61747008d data\tutorialmod\tags\blocks\prospector_list.json
da0c8afadbc3b0594ff3355cbf4785e7c875b347 data\minecraft\tags\blocks\mineable\pickaxe.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20 2024-02-09T14:06:21.8477469 Tutorial Mod/Model Definitions
// 1.20 2024-02-15T10:28:20.6395263 Tutorial Mod/Model Definitions
8f322c19ddc2db4ce7e171d77ebb9db5603f651d assets\tutorialmod\models\item\raw_ice_ether.json
bffb482765941ed0f5d1ebdc91deead34197b921 assets\tutorialmod\blockstates\ice_ether_fence_gate.json
20c838e70833de9004bf47ea5feb56f6f22df8eb assets\tutorialmod\models\item\ice_ether_helmet_emerald_trim.json
Expand Down Expand Up @@ -102,13 +102,13 @@ e86928fc298ae8233af1334db7a05d0d107a8d88 assets\tutorialmod\models\item\ice_ethe
117bdfb166c0ab5a79ad8afff7a2f5ff4e03e282 assets\tutorialmod\models\item\ice_ether_helmet_lapis_trim.json
8eade5a16345adf9e7f0a58013045790b4548667 assets\tutorialmod\blockstates\ice_ether_button.json
cd160627f85d92d55b07917069b28f1e8f111e7f assets\tutorialmod\models\block\ice_ether_door_top_right_open.json
d9e8248ad63df2c5836001045d7bf89b7fb983e5 assets\tutorialmod\models\item\ice_ether_boots_copper_trim.json
8444238f04261c56864325fc5edb2ff814c1ea77 assets\tutorialmod\models\block\corn_crop_stage8.json
d9e8248ad63df2c5836001045d7bf89b7fb983e5 assets\tutorialmod\models\item\ice_ether_boots_copper_trim.json
a832b3ff2faf4a07f22f2b4a2995c9fd0c64d6a3 assets\tutorialmod\models\block\ice_ether_wall_post.json
50af97203db0d0c9f30b379e0e29a578119864f0 assets\tutorialmod\models\item\ice_ether_leggings_emerald_trim.json
e024658bdd9c8a84697fcfaef33db16e707dac7b assets\tutorialmod\models\item\ice_ether_boots_iron_trim.json
64a5a838af7489a0950ad11d0a78b409ad15ca87 assets\tutorialmod\models\block\raw_ice_ether_block.json
bcf47915c2fae223f4aef462a621fda8daab9830 assets\tutorialmod\models\block\corn_crop_stage4.json
64a5a838af7489a0950ad11d0a78b409ad15ca87 assets\tutorialmod\models\block\raw_ice_ether_block.json
44ca70b97774caa10b7b6e73e9f854cc8b0606ac assets\tutorialmod\models\block\ice_ether_trapdoor_bottom.json
ef86c5cb2ad2b0df0d264651756b98ad7af9b3c7 assets\tutorialmod\models\item\ice_ether_boots_lapis_trim.json
c10c0faa2c229ecbc53f068e6bd266580a90c331 assets\tutorialmod\models\block\ice_ether_button_pressed.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 1.20 2024-02-09T14:06:21.8467468 Tutorial Mod/Recipes
// 1.20 2024-02-15T10:28:20.6385214 Tutorial Mod/Recipes
0446d0bd45e65c672637f3c6c4be6bfa8bd90c57 data\tutorialmod\advancements\recipes\misc\ice_ether.json
18aab3737a6b952a7883838edaa01e69c5a83600 data\tutorialmod\recipes\ice_ether_from_smelting_raw_ice_ether.json
a7a52623ff3f32e9f526354c6a1c278326e79d6c data\tutorialmod\recipes\ice_ether.json
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.20 2024-02-15T10:28:20.6395263 Tutorial Mod/Tags for minecraft:point_of_interest_type
78962891c373229b4fe870a6579bd271c66c239e data\minecraft\tags\point_of_interest_type\acquirable_job_site.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// 1.20 2024-02-09T14:06:21.8447463 Tutorial Mod/Tags for minecraft:item
// 1.20 2024-02-15T10:28:20.6370176 Tutorial Mod/Tags for minecraft:item
ce010d2466a35ec6f527d2d2cfd45bb119c1b373 data\minecraft\tags\items\trimmable_armor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"replace": false,
"values": [
{
"id": "tutorialmod:ice_ether_poi",
"required": false
}
]
}
3 changes: 3 additions & 0 deletions src/main/java/com/besson/tutorialmod/TutorialMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.besson.tutorialmod.item.ModItems;
import com.besson.tutorialmod.util.ModLootTableModifiers;
import com.besson.tutorialmod.util.ModTrades;
import com.besson.tutorialmod.villager.ModVillagers;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.registry.FuelRegistry;
import org.slf4j.Logger;
Expand All @@ -24,6 +25,8 @@ public void onInitialize() {
ModLootTableModifiers.modifierLootTables();
ModTrades.registerTrades();

ModVillagers.registerVillagers();

FuelRegistry.INSTANCE.add(ModItems.ANTHRACITE,2000);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
pack.addProvider(ModModelsProvider::new);
pack.addProvider(ModLootTablesProvider::new);
pack.addProvider(ModRecipesProvider::new);
pack.addProvider(ModPoiTagsProvider::new);

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.besson.tutorialmod.datagen;

import com.besson.tutorialmod.TutorialMod;
import net.minecraft.data.DataOutput;
import net.minecraft.data.server.tag.TagProvider;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.PointOfInterestTypeTags;
import net.minecraft.util.Identifier;
import net.minecraft.world.poi.PointOfInterestType;

import java.util.concurrent.CompletableFuture;

public class ModPoiTagsProvider extends TagProvider<PointOfInterestType> {
public ModPoiTagsProvider(DataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookupFuture) {
super(output, RegistryKeys.POINT_OF_INTEREST_TYPE, registryLookupFuture);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup lookup) {
getOrCreateTagBuilder(PointOfInterestTypeTags.ACQUIRABLE_JOB_SITE)
.addOptional(new Identifier(TutorialMod.MOD_ID,"ice_ether_poi"));
}
}
18 changes: 18 additions & 0 deletions src/main/java/com/besson/tutorialmod/util/ModTrades.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.besson.tutorialmod.util;

import com.besson.tutorialmod.block.ModBlocks;
import com.besson.tutorialmod.item.ModItems;
import com.besson.tutorialmod.villager.ModVillagers;
import net.fabricmc.fabric.api.object.builder.v1.trade.TradeOfferHelper;
import net.minecraft.enchantment.EnchantmentLevelEntry;
import net.minecraft.enchantment.Enchantments;
Expand Down Expand Up @@ -33,5 +35,21 @@ public static void registerTrades(){
3,12,0.05f
));
});
TradeOfferHelper.registerVillagerOffers(ModVillagers.ICE_ETHER_MASTER,1,
factories -> {
factories.add((entity, random) -> new TradeOffer(
new ItemStack(ModItems.ICE_ETHER,16),
new ItemStack(ModBlocks.ICE_ETHER_BLOCK,2),
3,12,0.05f
));
});
TradeOfferHelper.registerVillagerOffers(ModVillagers.ICE_ETHER_MASTER,2,
factories -> {
factories.add((entity, random) -> new TradeOffer(
new ItemStack(ModItems.RAW_ICE_ETHER,32),
new ItemStack(ModItems.PROSPECTOR,1),
3,24,0.05f
));
});
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/besson/tutorialmod/villager/ModVillagers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.besson.tutorialmod.villager;

import com.besson.tutorialmod.TutorialMod;
import com.besson.tutorialmod.block.ModBlocks;
import com.google.common.collect.ImmutableSet;
import net.fabricmc.fabric.api.object.builder.v1.world.poi.PointOfInterestHelper;
import net.minecraft.block.Block;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.sound.SoundEvents;
import net.minecraft.util.Identifier;
import net.minecraft.village.VillagerProfession;
import net.minecraft.world.poi.PointOfInterestType;

public class ModVillagers {
public static final RegistryKey<PointOfInterestType> ICE_ETHER_POI_KEY = point("ice_ether_poi");
public static final PointOfInterestType ICE_ETHER_POI = registerPointOfInterestType("ice_ether_poi", ModBlocks.ICE_ETHER_BLOCK);
public static final VillagerProfession ICE_ETHER_MASTER = registerVillagerProfession("ice_ether_master",ICE_ETHER_POI_KEY);
private static VillagerProfession registerVillagerProfession(String name,RegistryKey<PointOfInterestType> type){
return Registry.register(Registries.VILLAGER_PROFESSION,new Identifier(TutorialMod.MOD_ID,name),
new VillagerProfession(name,entry -> entry.matchesKey(type),entry -> entry.matchesKey(type),
ImmutableSet.of(),ImmutableSet.of(), SoundEvents.ENTITY_VILLAGER_WORK_LIBRARIAN));
}
private static PointOfInterestType registerPointOfInterestType(String name, Block block){
return PointOfInterestHelper.register(new Identifier(TutorialMod.MOD_ID,name),1,1,block);
}
private static RegistryKey<PointOfInterestType> point(String name){
return RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE,new Identifier(TutorialMod.MOD_ID,name));
}
public static void registerVillagers(){

}
}
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 @@ -35,5 +35,7 @@

"itemGroup.tutorial_group": "Tutorial Group",

"entity.minecraft.villager.ice_ether_master": "Ice Ether Master",

"item.tutorialmod.fire_ether.tooltip": "It may make you on fire!"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 076ff07

Please sign in to comment.