From 076ff07365970347ed9b5113541de9d9338c1841 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E5=B1=B1=5FBesson?= <137259636+BeiShanair@users.noreply.github.com> Date: Thu, 15 Feb 2024 10:34:21 +0800 Subject: [PATCH] customVillagerProfession --- .../378f9509398ea584ca54616156177f9ec588f984 | 2 +- .../80beaa027efbcf9e17d04d48300d7784fb0cb57f | 2 +- .../bf8b55c7a3e1253642a8b1063c0b39ff5689945b | 6 +-- .../dfb0a8ea05a472c697eb35080aef6b0f1497af5b | 2 +- .../e4e32e775410155fd5b39910e36714f200d58a95 | 2 + .../f3f56cafc2cbe41709406bb540eb1fca38a90f18 | 2 +- .../acquirable_job_site.json | 9 +++++ .../com/besson/tutorialmod/TutorialMod.java | 3 ++ .../tutorialmod/TutorialModDataGenerator.java | 1 + .../datagen/ModPoiTagsProvider.java | 24 ++++++++++++ .../besson/tutorialmod/util/ModTrades.java | 18 +++++++++ .../tutorialmod/villager/ModVillagers.java | 35 ++++++++++++++++++ .../assets/tutorialmod/lang/en_us.json | 2 + .../villager/profession/ice_ether_master.png | Bin 0 -> 1696 bytes 14 files changed, 101 insertions(+), 7 deletions(-) create mode 100644 src/main/generated/.cache/e4e32e775410155fd5b39910e36714f200d58a95 create mode 100644 src/main/generated/data/minecraft/tags/point_of_interest_type/acquirable_job_site.json create mode 100644 src/main/java/com/besson/tutorialmod/datagen/ModPoiTagsProvider.java create mode 100644 src/main/java/com/besson/tutorialmod/villager/ModVillagers.java create mode 100644 src/main/resources/assets/tutorialmod/textures/entity/villager/profession/ice_ether_master.png diff --git a/src/main/generated/.cache/378f9509398ea584ca54616156177f9ec588f984 b/src/main/generated/.cache/378f9509398ea584ca54616156177f9ec588f984 index 1071ddb..fe17a4e 100644 --- a/src/main/generated/.cache/378f9509398ea584ca54616156177f9ec588f984 +++ b/src/main/generated/.cache/378f9509398ea584ca54616156177f9ec588f984 @@ -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 diff --git a/src/main/generated/.cache/80beaa027efbcf9e17d04d48300d7784fb0cb57f b/src/main/generated/.cache/80beaa027efbcf9e17d04d48300d7784fb0cb57f index 51793f9..ca60f93 100644 --- a/src/main/generated/.cache/80beaa027efbcf9e17d04d48300d7784fb0cb57f +++ b/src/main/generated/.cache/80beaa027efbcf9e17d04d48300d7784fb0cb57f @@ -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 diff --git a/src/main/generated/.cache/bf8b55c7a3e1253642a8b1063c0b39ff5689945b b/src/main/generated/.cache/bf8b55c7a3e1253642a8b1063c0b39ff5689945b index 3e0bede..8e7f3ac 100644 --- a/src/main/generated/.cache/bf8b55c7a3e1253642a8b1063c0b39ff5689945b +++ b/src/main/generated/.cache/bf8b55c7a3e1253642a8b1063c0b39ff5689945b @@ -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 @@ -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 diff --git a/src/main/generated/.cache/dfb0a8ea05a472c697eb35080aef6b0f1497af5b b/src/main/generated/.cache/dfb0a8ea05a472c697eb35080aef6b0f1497af5b index e24be9f..145b66d 100644 --- a/src/main/generated/.cache/dfb0a8ea05a472c697eb35080aef6b0f1497af5b +++ b/src/main/generated/.cache/dfb0a8ea05a472c697eb35080aef6b0f1497af5b @@ -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 diff --git a/src/main/generated/.cache/e4e32e775410155fd5b39910e36714f200d58a95 b/src/main/generated/.cache/e4e32e775410155fd5b39910e36714f200d58a95 new file mode 100644 index 0000000..0416f05 --- /dev/null +++ b/src/main/generated/.cache/e4e32e775410155fd5b39910e36714f200d58a95 @@ -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 diff --git a/src/main/generated/.cache/f3f56cafc2cbe41709406bb540eb1fca38a90f18 b/src/main/generated/.cache/f3f56cafc2cbe41709406bb540eb1fca38a90f18 index 7ed5134..a1c4e43 100644 --- a/src/main/generated/.cache/f3f56cafc2cbe41709406bb540eb1fca38a90f18 +++ b/src/main/generated/.cache/f3f56cafc2cbe41709406bb540eb1fca38a90f18 @@ -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 diff --git a/src/main/generated/data/minecraft/tags/point_of_interest_type/acquirable_job_site.json b/src/main/generated/data/minecraft/tags/point_of_interest_type/acquirable_job_site.json new file mode 100644 index 0000000..7c453f8 --- /dev/null +++ b/src/main/generated/data/minecraft/tags/point_of_interest_type/acquirable_job_site.json @@ -0,0 +1,9 @@ +{ + "replace": false, + "values": [ + { + "id": "tutorialmod:ice_ether_poi", + "required": false + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/besson/tutorialmod/TutorialMod.java b/src/main/java/com/besson/tutorialmod/TutorialMod.java index 1084970..5d5bf9c 100644 --- a/src/main/java/com/besson/tutorialmod/TutorialMod.java +++ b/src/main/java/com/besson/tutorialmod/TutorialMod.java @@ -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; @@ -24,6 +25,8 @@ public void onInitialize() { ModLootTableModifiers.modifierLootTables(); ModTrades.registerTrades(); + ModVillagers.registerVillagers(); + FuelRegistry.INSTANCE.add(ModItems.ANTHRACITE,2000); } } \ No newline at end of file diff --git a/src/main/java/com/besson/tutorialmod/TutorialModDataGenerator.java b/src/main/java/com/besson/tutorialmod/TutorialModDataGenerator.java index a2a2a39..1503093 100644 --- a/src/main/java/com/besson/tutorialmod/TutorialModDataGenerator.java +++ b/src/main/java/com/besson/tutorialmod/TutorialModDataGenerator.java @@ -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); } } diff --git a/src/main/java/com/besson/tutorialmod/datagen/ModPoiTagsProvider.java b/src/main/java/com/besson/tutorialmod/datagen/ModPoiTagsProvider.java new file mode 100644 index 0000000..9737104 --- /dev/null +++ b/src/main/java/com/besson/tutorialmod/datagen/ModPoiTagsProvider.java @@ -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 { + public ModPoiTagsProvider(DataOutput output, CompletableFuture 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")); + } +} diff --git a/src/main/java/com/besson/tutorialmod/util/ModTrades.java b/src/main/java/com/besson/tutorialmod/util/ModTrades.java index 7f1b213..e7037cd 100644 --- a/src/main/java/com/besson/tutorialmod/util/ModTrades.java +++ b/src/main/java/com/besson/tutorialmod/util/ModTrades.java @@ -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; @@ -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 + )); + }); } } diff --git a/src/main/java/com/besson/tutorialmod/villager/ModVillagers.java b/src/main/java/com/besson/tutorialmod/villager/ModVillagers.java new file mode 100644 index 0000000..1e239d6 --- /dev/null +++ b/src/main/java/com/besson/tutorialmod/villager/ModVillagers.java @@ -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 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 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 point(String name){ + return RegistryKey.of(RegistryKeys.POINT_OF_INTEREST_TYPE,new Identifier(TutorialMod.MOD_ID,name)); + } + public static void registerVillagers(){ + + } +} diff --git a/src/main/resources/assets/tutorialmod/lang/en_us.json b/src/main/resources/assets/tutorialmod/lang/en_us.json index 9196102..d2562d8 100644 --- a/src/main/resources/assets/tutorialmod/lang/en_us.json +++ b/src/main/resources/assets/tutorialmod/lang/en_us.json @@ -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!" } \ No newline at end of file diff --git a/src/main/resources/assets/tutorialmod/textures/entity/villager/profession/ice_ether_master.png b/src/main/resources/assets/tutorialmod/textures/entity/villager/profession/ice_ether_master.png new file mode 100644 index 0000000000000000000000000000000000000000..d11a51ccf8fa1308459e0936102c954b4529ceaa GIT binary patch literal 1696 zcmV;R24DG!P)i6K$sMSW9WG{Im9>4Qkr7;hofc;UfI5F&*1LIs6FyR^H@0JFnVdr{yV zAEq;%-R|ymx0fyL{$9Fs&d$vF{^vX2`OeqYr<7tYBMLo$LQ@o=&;uwmMF9#ufI>6p z1@L)&VgHFl)_ro*L*<^&mX&hpY`VbClc!K zE}iK4p0xd;70Xz&QkyancJFCc>()QOs+IQ;s92QLXT+~^w(A@nZS8E|wk7ZPmw0_4 zlks-nnw46$6?wJfGo(rvPhKY7=(ze2GS5M58e}+S&n} zwZ3~#^Yk2G_Mb?oY`cJ0e~}_ZiWDhQq)3q|q^l>Yx_Y8&__|cX*JV;tR=?HzkTh!w zB7KpI3=R$FeBZ1Q03aT}nslAe!=CrdDgp9gO3PVOL03;SXc%C&GBP@0F0>~-4X>6Hh3J{IPsH(o3M;?7F?elIq z0qmI!g@Q!-E;#McXpHUKw)j$O1>3i6@qPKtcXQ*&{zOAl&W6tUAULZ8DA#IpzGqem zkPov;fbk?gMT!(D;wIx+prP?yB_*`%Oa8S}{nodYsrPdD;D-e{N7OYmDZgvGGxad` zwV4tG2aH}y12su)spHO=3Sa0v%mRPan06rq14eHiL!UluK?aOoQpHLo>ozFF*zU`b z?um|XQc0Z*x525ipN_1Dp>*n`6J@4RyLug3NaNTqhj{eKr_rN2klq8b3UEWp3_Y3J zC!e~M1CHM#-8J=alA%9--t64t*J_huh^dEjUjkP9%sEB7-P}u@bY!%o`rZv`+r3_5 zRbnMA`*!)pwvXLa@}+k5x}?wHGaci)FEub`6hH`p84IVBmL;YhCJ^*edTQf@ZM+uJ z2%oWj!uUmSlU9Jbh9)H?yu9gIKK|jft4Hw4=I7b}eJ4*eG^yXxk zjaV4JR)Y|Nr|u6B3|8Xv%|of1#A26#vA>uoG$jausarEzB7|c&BcF{}wQCN!=L3W&K}yL2 ze-*+diY?NB8F7qx0PpX55v3IE?Hvr65&FysWg|JZU1_yv+;(CC&ffOk>o4H*L2GL( z0Ol1P^Gb}t{(k_8aVg47EkHZ&xS_sL31GmCu)tr%zlj)Noe5HxZbA>!KXMK)4b&i| zBy~Hq*|G1K>OA%y{$ph>eEeq7p?7+oi+bmQ(aE)>5Sb4XH)}9f#Kl&`M zflU`lL9qPx8vykGS3>!G$@O8AJAx0pO3#u&We6$Z{K=z~jeH;A`>&d3WRUYBY0wYW q)#vq>6s?C_Zb{<-d~^NZ=l=&c-ln&N7}(eV0000