Skip to content

Commit 457d404

Browse files
committed
Added VillagerProfession ME
1 parent fde24d2 commit 457d404

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<#--
2+
# MCreator (https://mcreator.net/)
3+
# Copyright (C) 2012-2020, Pylo
4+
# Copyright (C) 2020-2025, Pylo, opensource contributors
5+
#
6+
# This program is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# This program is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
#
19+
# Additional permission for code generator templates (*.ftl files)
20+
#
21+
# As a special exception, you may create a larger work that contains part or
22+
# all of the MCreator code generator templates (*.ftl files) and distribute
23+
# that work under terms of your choice, so long as that work isn't itself a
24+
# template for code generation. Alternatively, if you modify or redistribute
25+
# the template itself, you may (at your option) remove this special exception,
26+
# which will cause the template and the resulting code generator output files
27+
# to be licensed under the GNU General Public License without this special
28+
# exception.
29+
-->
30+
31+
<#-- @formatter:off -->
32+
<#include "../mcitems.ftl">
33+
/*
34+
* MCreator note: This file will be REGENERATED on each build.
35+
*/
36+
package ${package}.init;
37+
38+
@Mod.EventBusSubscriber public class ${JavaModName}VillagerProfessions {
39+
private static final List<VillagerProfession> REGISTRY = new ArrayList<>();
40+
41+
<#list villagerprofessions as villagerprofession>
42+
public static final VillagerRegistry.VillagerProfession ${villagerprofession.getModElement().getRegistryNameUpper()} = register("${villagerprofession.getModElement().getRegistryName()}", () -> new VillagerProfession(
43+
"${villagerprofession.getModElement().getRegistryName()}",
44+
"${modid}:textures/entities/${villagerprofession.professionTextureFile}",
45+
"${modid}:textures/entities/${villagerprofession.zombifiedProfessionTextureFile}"));
46+
public static final VillagerRegistry.VillagerCareer ${villagerprofession.getModElement().getRegistryNameUpper()}_CAREER = new VillagerRegistry.VillagerCareer(${villagerprofession.getModElement().getRegistryNameUpper()}, "${villagerprofession.getModElement().getRegistryName()}");
47+
</#list>
48+
49+
private static VillagerProfession register(String registryname, Supplier<VillagerProfession> profession) {
50+
VillagerProfession instance = profession.get().setRegistryName(registryname);
51+
REGISTRY.add(instance);
52+
return instance;
53+
}
54+
55+
@SubscribeEvent public static void registerVillagerProfessions(RegistryEvent.Register<VillagerProfession> event) {
56+
event.getRegistry().registerAll(REGISTRY.toArray(new VillagerProfession[0]));
57+
}
58+
}
59+
<#-- @formatter:on -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
global_templates:
2+
- template: elementinits/villagerprofessions.java.ftl
3+
name: "@SRCROOT/@BASEPACKAGEPATH/init/@JavaModNameVillagerProfessions.java"
4+
5+
localizationkeys:
6+
- key: entity.minecraft.villager.@modid.@registryname
7+
mapto: displayName
8+
9+
field_exclusions: [pointOfInterest, actionSound, hat]

0 commit comments

Comments
 (0)