From b67f9f3f73b8b64a14edc5cf94afa199d9609e9c Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Fri, 18 Oct 2024 15:44:30 +0200 Subject: [PATCH 1/2] Rework recruitment items to be datapack driven --- .../compatibility/CompatibilityManager.java | 51 ------- .../compatibility/ICompatibilityManager.java | 7 - .../configuration/ServerConfiguration.java | 17 --- .../modules/TavernBuildingModule.java | 90 ++++++------ .../RecruitmentItemsListener.java | 130 ++++++++++++++++++ .../minecolonies/core/event/EventHandler.java | 44 ++---- .../core/event/FMLEventHandler.java | 1 + .../recruitment_items/baked_potato.json | 4 + .../minecolonies/recruitment_items/book.json | 4 + .../minecolonies/recruitment_items/cake.json | 4 + .../recruitment_items/diamond.json | 4 + .../recruitment_items/emerald.json | 4 + .../recruitment_items/enchanted_book.json | 4 + .../recruitment_items/gold_ingot.json | 4 + .../recruitment_items/hay_block.json | 4 + .../recruitment_items/honeycomb.json | 4 + .../recruitment_items/lapis_lazuli.json | 4 + .../recruitment_items/quartz.json | 4 + .../recruitment_items/redstone.json | 4 + .../recruitment_items/sunflower.json | 4 + 20 files changed, 240 insertions(+), 152 deletions(-) create mode 100644 src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java create mode 100644 src/main/resources/data/minecolonies/recruitment_items/baked_potato.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/book.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/cake.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/diamond.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/emerald.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/enchanted_book.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/gold_ingot.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/hay_block.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/honeycomb.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/lapis_lazuli.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/quartz.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/redstone.json create mode 100644 src/main/resources/data/minecolonies/recruitment_items/sunflower.json diff --git a/src/main/java/com/minecolonies/api/compatibility/CompatibilityManager.java b/src/main/java/com/minecolonies/api/compatibility/CompatibilityManager.java index 145dd38e535..3f025ba2ff6 100755 --- a/src/main/java/com/minecolonies/api/compatibility/CompatibilityManager.java +++ b/src/main/java/com/minecolonies/api/compatibility/CompatibilityManager.java @@ -129,11 +129,6 @@ public class CompatibilityManager implements ICompatibilityManager */ private final Map> luckyOres = new HashMap<>(); - /** - * The items and weights of the recruitment. - */ - private final List> recruitmentCostsWeights = new ArrayList<>(); - /** * Random obj. */ @@ -188,7 +183,6 @@ private void clear() compostRecipes.clear(); luckyOres.clear(); - recruitmentCostsWeights.clear(); diseases.clear(); diseaseList.clear(); freeBlocks.clear(); @@ -209,7 +203,6 @@ public void discover(@NotNull final RecipeManager recipeManager, final Level lev discoverAllItems(level); discoverLuckyOres(); - discoverRecruitCosts(); discoverDiseases(); discoverFreeBlocksAndPos(); discoverModCompat(); @@ -266,7 +259,6 @@ public void deserialize(@NotNull final FriendlyByteBuf buf, final ClientLevel le // the below are loaded from config files, which have been synched already by this point discoverLuckyOres(); - discoverRecruitCosts(); discoverDiseases(); discoverFreeBlocksAndPos(); discoverModCompat(); @@ -503,12 +495,6 @@ public List getDiseases() return new ArrayList<>(diseases.values()); } - @Override - public List> getRecruitmentCostsWeights() - { - return Collections.unmodifiableList(recruitmentCostsWeights); - } - @Override public boolean isOre(final BlockState block) { @@ -888,43 +874,6 @@ private void discoverLuckyOres() Log.getLogger().info("Finished discovering lucky oreBlocks " + luckyOres.size()); } - /** - * Parses recruitment costs from config - */ - private void discoverRecruitCosts() - { - if (recruitmentCostsWeights.isEmpty()) - { - for (final String itemString : MinecoloniesAPIProxy.getInstance().getConfig().getServer().configListRecruitmentItems.get()) - { - final String[] split = itemString.split(";"); - if (split.length < 2) - { - Log.getLogger().warn("Wrong configured recruitment cost: " + itemString); - continue; - } - - final Item item = ForgeRegistries.ITEMS.getValue(new ResourceLocation(split[0])); - if (item == null || item == Items.AIR) - { - Log.getLogger().warn("Invalid recruitment item: " + item); - continue; - } - - try - { - final int rarity = Integer.parseInt(split[split.length - 1]); - recruitmentCostsWeights.add(new Tuple<>(item, rarity)); - } - catch (final NumberFormatException ex) - { - Log.getLogger().warn("Invalid recruitment weight for: " + item); - } - } - } - Log.getLogger().info("Finished discovering recruitment costs"); - } - /** * Go through the disease config and setup all possible diseases. */ diff --git a/src/main/java/com/minecolonies/api/compatibility/ICompatibilityManager.java b/src/main/java/com/minecolonies/api/compatibility/ICompatibilityManager.java index 09cc1b0461f..e02a8ac4fdc 100755 --- a/src/main/java/com/minecolonies/api/compatibility/ICompatibilityManager.java +++ b/src/main/java/com/minecolonies/api/compatibility/ICompatibilityManager.java @@ -162,13 +162,6 @@ public interface ICompatibilityManager */ List getDiseases(); - /** - * Gets the list of recruitment costs with weights - * - * @return list of costs - */ - List> getRecruitmentCostsWeights(); - /** * Checks if a certain Block is an ore. * diff --git a/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java b/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java index ec3bb5fabb7..410044df73c 100755 --- a/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java +++ b/src/main/java/com/minecolonies/api/configuration/ServerConfiguration.java @@ -98,7 +98,6 @@ public class ServerConfiguration extends AbstractConfiguration * -------------------------------------------------------------------------------- */ public final ForgeConfigSpec.ConfigValue> configListStudyItems; - public final ForgeConfigSpec.ConfigValue> configListRecruitmentItems; public final ForgeConfigSpec.ConfigValue> luckyOres; public final ForgeConfigSpec.ConfigValue> diseases; public final ForgeConfigSpec.BooleanValue auditCraftingTags; @@ -205,22 +204,6 @@ protected ServerConfiguration(final ForgeConfigSpec.Builder builder) ("minecraft:paper;400;100", "minecraft:book;600;10"), s -> s instanceof String); - configListRecruitmentItems = defineList(builder, "configlistrecruitmentitems", - Arrays.asList - ("minecraft:hay_block;3", - "minecraft:book;2", - "minecraft:enchanted_book;9", - "minecraft:diamond;9", - "minecraft:emerald;8", - "minecraft:baked_potato;1", - "minecraft:gold_ingot;2", - "minecraft:redstone;2", - "minecraft:lapis_lazuli;2", - "minecraft:cake;11", - "minecraft:sunflower;5", - "minecraft:honeycomb;6", - "minecraft:quartz;3"), - s -> s instanceof String); luckyOres = defineList(builder, "luckyores", Arrays.asList ("minecraft:coal_ore!64", diff --git a/src/main/java/com/minecolonies/core/colony/buildings/modules/TavernBuildingModule.java b/src/main/java/com/minecolonies/core/colony/buildings/modules/TavernBuildingModule.java index 31ef96b4282..7fa90744e9c 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/modules/TavernBuildingModule.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/modules/TavernBuildingModule.java @@ -8,18 +8,18 @@ import com.minecolonies.api.colony.interactionhandling.ChatPriority; import com.minecolonies.api.sounds.TavernSounds; import com.minecolonies.api.util.BlockPosUtil; -import com.minecolonies.api.util.Tuple; import com.minecolonies.core.Network; import com.minecolonies.core.client.gui.huts.WindowHutLiving; import com.minecolonies.core.colony.buildings.views.LivingBuildingView; import com.minecolonies.core.colony.eventhooks.citizenEvents.VisitorSpawnedEvent; import com.minecolonies.core.colony.interactionhandling.RecruitmentInteraction; import com.minecolonies.core.datalistener.CustomVisitorListener; +import com.minecolonies.core.datalistener.RecruitmentItemsListener; +import com.minecolonies.core.datalistener.RecruitmentItemsListener.RecruitCost; import com.minecolonies.core.network.messages.client.colony.PlayMusicAtPosMessage; import net.minecraft.world.entity.player.Player; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EquipmentSlot; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.nbt.CompoundTag; @@ -53,10 +53,10 @@ public class TavernBuildingModule extends AbstractBuildingModule implements IDef /** * Skill levels */ - private static final int LEATHER_SKILL_LEVEL = 20; - private static final int GOLD_SKILL_LEVEL = 25; - private static final int IRON_SKILL_LEVEL = 30; - private static final int DIAMOND_SKILL_LEVEL = 35; + public static final int LEATHER_SKILL_LEVEL = 20; + public static final int GOLD_SKILL_LEVEL = 25; + public static final int IRON_SKILL_LEVEL = 30; + public static final int DIAMOND_SKILL_LEVEL = 35; /** * Music interval @@ -154,7 +154,7 @@ public void onColonyTick(@NotNull final IColony colony) if (building.getBuildingLevel() > 0 && externalCitizens.size() < 3 * building.getBuildingLevel() && noVisitorTime <= 0) { - spawnVisitor(); + spawnVisitorInternal(); noVisitorTime = colony.getWorld().getRandom().nextInt(3000) + (6000 / building.getBuildingLevel()) * colony.getCitizenManager().getCurrentCitizenCount() / colony.getCitizenManager() .getMaxCitizens(); @@ -168,25 +168,33 @@ public void onUpgradeComplete(final int newlevel) } /** - * Spawns a recruitable visitor citizen. + * Spawns a visitor specifically for the tavern logic. */ - private void spawnVisitor() + private void spawnVisitorInternal() { - IVisitorData newCitizen = (IVisitorData) building.getColony().getVisitorManager().createAndRegisterCivilianData(); - externalCitizens.add(newCitizen.getId()); - - newCitizen.setBedPos(building.getPosition()); - newCitizen.setHomeBuilding(building); - - int recruitLevel = building.getColony().getWorld().random.nextInt(10 * building.getBuildingLevel()) + 15; - List> recruitCosts = IColonyManager.getInstance().getCompatibilityManager().getRecruitmentCostsWeights(); + final IVisitorData visitorData = spawnVisitor(); - if (newCitizen.getName().contains("Ray")) + if (!CustomVisitorListener.chanceCustomVisitors(visitorData)) { - newCitizen.setRecruitCosts(new ItemStack(Items.BAKED_POTATO, 64)); + visitorData.triggerInteraction(new RecruitmentInteraction(Component.translatable( + "com.minecolonies.coremod.gui.chat.recruitstory" + (building.getColony().getWorld().random.nextInt(MAX_STORY) + 1), visitorData.getName().split(" ")[0]), + ChatPriority.IMPORTANT)); } + } + + /** + * Spawns a visitor citizen that can be recruited. + */ + public IVisitorData spawnVisitor() + { + final int recruitLevel = building.getColony().getWorld().random.nextInt(10 * building.getBuildingLevel()) + 15; + final RecruitCost cost = RecruitmentItemsListener.getRandomRecruitCost(building.getColony().getWorld().getRandom(), recruitLevel); + final IVisitorData newCitizen = (IVisitorData) building.getColony().getVisitorManager().createAndRegisterCivilianData(); + newCitizen.setBedPos(building.getPosition()); + newCitizen.setHomeBuilding(building); newCitizen.getCitizenSkillHandler().init(recruitLevel); + newCitizen.setRecruitCosts(cost.toItemStack(recruitLevel)); BlockPos spawnPos = BlockPosUtil.findSpawnPosAround(building.getColony().getWorld(), building.getPosition()); if (spawnPos == null) @@ -194,8 +202,25 @@ private void spawnVisitor() spawnPos = building.getPosition(); } - Tuple cost = recruitCosts.get(building.getColony().getWorld().random.nextInt(recruitCosts.size())); + building.getColony().getVisitorManager().spawnOrCreateCivilian(newCitizen, building.getColony().getWorld(), spawnPos, true); + if (newCitizen.getEntity().isPresent()) + { + newCitizen.getEntity().get().setItemSlot(EquipmentSlot.FEET, getBoots(recruitLevel)); + } + building.getColony().getEventDescriptionManager().addEventDescription(new VisitorSpawnedEvent(spawnPos, newCitizen.getName())); + + externalCitizens.add(newCitizen.getId()); + return newCitizen; + } + /** + * Get the boots for the given recruit level. + * + * @param recruitLevel the input recruit level. + * @return the itemstack for the boots. + */ + private ItemStack getBoots(final int recruitLevel) + { ItemStack boots = ItemStack.EMPTY; if (recruitLevel > LEATHER_SKILL_LEVEL) { @@ -209,38 +234,15 @@ private void spawnVisitor() } if (recruitLevel > IRON_SKILL_LEVEL) { - if (cost.getB() <= 2) - { - cost = recruitCosts.get(building.getColony().getWorld().random.nextInt(recruitCosts.size())); - } // Iron boots = new ItemStack(Items.IRON_BOOTS); } if (recruitLevel > DIAMOND_SKILL_LEVEL) { - if (cost.getB() <= 3) - { - cost = recruitCosts.get(building.getColony().getWorld().random.nextInt(recruitCosts.size())); - } // Diamond boots = new ItemStack(Items.DIAMOND_BOOTS); } - - newCitizen.setRecruitCosts(new ItemStack(cost.getA(), (int) (recruitLevel * 3.0 / cost.getB()))); - - if (!CustomVisitorListener.chanceCustomVisitors(newCitizen)) - { - newCitizen.triggerInteraction(new RecruitmentInteraction(Component.translatable( - "com.minecolonies.coremod.gui.chat.recruitstory" + (building.getColony().getWorld().random.nextInt(MAX_STORY) + 1), newCitizen.getName().split(" ")[0]), - ChatPriority.IMPORTANT)); - } - - building.getColony().getVisitorManager().spawnOrCreateCivilian(newCitizen, building.getColony().getWorld(), spawnPos, true); - if (newCitizen.getEntity().isPresent()) - { - newCitizen.getEntity().get().setItemSlot(EquipmentSlot.FEET, boots); - } - building.getColony().getEventDescriptionManager().addEventDescription(new VisitorSpawnedEvent(spawnPos, newCitizen.getName())); + return boots; } @Override diff --git a/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java b/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java new file mode 100644 index 00000000000..433903aac15 --- /dev/null +++ b/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java @@ -0,0 +1,130 @@ +package com.minecolonies.core.datalistener; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener; +import net.minecraft.util.GsonHelper; +import net.minecraft.util.RandomSource; +import net.minecraft.util.profiling.ProfilerFiller; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static com.minecolonies.core.colony.buildings.modules.TavernBuildingModule.DIAMOND_SKILL_LEVEL; +import static com.minecolonies.core.colony.buildings.modules.TavernBuildingModule.IRON_SKILL_LEVEL; + +/** + * Loads and listens to free block data. + */ +public class RecruitmentItemsListener extends SimpleJsonResourceReloadListener +{ + /** + * Gson instance + */ + private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); + + /** + * Json constants + */ + private static final String KEY_ITEM = "item"; + private static final String KEY_RARITY = "rarity"; + + /** + * The current list of free to interact blocks. + */ + private static List RECRUIT_COSTS = new ArrayList<>(); + + /** + * A possible recruit cost item. + * + * @param item the item to recruit with. + * @param rarity the rarity of the given item. + */ + public record RecruitCost(Item item, int rarity) + { + /** + * Generate an itemstack for the given recruit cost. + * + * @param level the recruitment level. + * @return the newly generated itemstack. + */ + public ItemStack toItemStack(final int level) + { + return new ItemStack(item, (int) Math.round(level * 3.0 / rarity)); + } + } + + /** + * Default constructor. + */ + public RecruitmentItemsListener() + { + super(GSON, "recruitment_items"); + } + + /** + * Get a random recruit cost using the input random source. + * + * @param source the random source. + * @param level the recruitment level. + * @return a random recruit cost. + */ + public static RecruitCost getRandomRecruitCost(final RandomSource source, final int level) + { + int minimumRarity; + if (level > DIAMOND_SKILL_LEVEL) + { + minimumRarity = 3; + } + else if (level > IRON_SKILL_LEVEL) + { + minimumRarity = 2; + } + else + { + minimumRarity = 0; + } + final List recruitCostStream = RECRUIT_COSTS.stream().filter(f -> f.rarity <= minimumRarity).toList(); + return recruitCostStream.get(source.nextInt(recruitCostStream.size())); + } + + @Override + protected void apply( + final @NotNull Map jsonElementMap, + final @NotNull ResourceManager resourceManager, + final @NotNull ProfilerFiller profiler) + { + final List recruitCosts = new ArrayList<>(); + for (final Map.Entry entry : jsonElementMap.entrySet()) + { + if (!entry.getValue().isJsonObject()) + { + return; + } + + final JsonObject object = entry.getValue().getAsJsonObject(); + final Item item = BuiltInRegistries.ITEM.get(new ResourceLocation(GsonHelper.getAsString(object, KEY_ITEM))); + final int rarity = GsonHelper.getAsInt(object, KEY_RARITY); + + if (item == Items.AIR) + { + throw new IllegalArgumentException("Recruit cost '" + entry.getKey() + "' item not allowed to be air"); + } + + recruitCosts.add(new RecruitCost(item, rarity)); + } + + RECRUIT_COSTS = Collections.unmodifiableList(recruitCosts); + } +} \ No newline at end of file diff --git a/src/main/java/com/minecolonies/core/event/EventHandler.java b/src/main/java/com/minecolonies/core/event/EventHandler.java index 5158718e53e..5b1aa9a31db 100755 --- a/src/main/java/com/minecolonies/core/event/EventHandler.java +++ b/src/main/java/com/minecolonies/core/event/EventHandler.java @@ -26,7 +26,6 @@ import com.minecolonies.core.client.render.RenderBipedCitizen; import com.minecolonies.core.colony.ColonyManager; import com.minecolonies.core.colony.buildings.modules.TavernBuildingModule; -import com.minecolonies.core.colony.eventhooks.citizenEvents.VisitorSpawnedEvent; import com.minecolonies.core.colony.interactionhandling.RecruitmentInteraction; import com.minecolonies.core.colony.jobs.AbstractJobGuard; import com.minecolonies.core.colony.jobs.JobFarmer; @@ -58,7 +57,6 @@ import net.minecraft.world.entity.monster.ZombieVillager; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.BlockItem; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; @@ -112,7 +110,7 @@ public class EventHandler /** * Player position map for watching chunk entries */ - private static Map playerPositions = new HashMap<>(); + private static final Map playerPositions = new HashMap<>(); @SubscribeEvent public static void onCommandsRegister(final RegisterCommandsEvent event) @@ -872,44 +870,24 @@ public static void onEntityConverted(@NotNull final LivingConversionEvent.Pre ev event.setCanceled(true); if (ForgeEventFactory.canLivingConvert(entity, ModEntities.VISITOR, null)) { - IVisitorData visitorData = (IVisitorData) colony.getVisitorManager().createAndRegisterCivilianData(); - BlockPos tavernPos = colony.getBuildingManager().getRandomBuilding(b -> !b.getModulesByType(TavernBuildingModule.class).isEmpty()); - IBuilding tavern = colony.getBuildingManager().getBuilding(tavernPos); - - visitorData.setHomeBuilding(tavern); - visitorData.setBedPos(tavernPos); - tavern.getModulesByType(TavernBuildingModule.class).forEach(mod -> mod.getExternalCitizens().add(visitorData.getId())); - - int recruitLevel = world.random.nextInt(10 * tavern.getBuildingLevel()) + 15; - List> recruitCosts = IColonyManager.getInstance().getCompatibilityManager().getRecruitmentCostsWeights(); - - visitorData.getCitizenSkillHandler().init(recruitLevel); - colony.getVisitorManager().spawnOrCreateCivilian(visitorData, world, entity.blockPosition(), false); - colony.getEventDescriptionManager().addEventDescription(new VisitorSpawnedEvent(entity.blockPosition(), visitorData.getName())); - - if (visitorData.getEntity().isPresent()) + final BlockPos tavernPos = colony.getBuildingManager().getRandomBuilding(b -> !b.getModulesByType(TavernBuildingModule.class).isEmpty()); + if (tavernPos == null) { - AbstractEntityCitizen visitorEntity = visitorData.getEntity().get(); - for (EquipmentSlot slotType : EquipmentSlot.values()) - { - ItemStack itemstack = entity.getItemBySlot(slotType); - if (slotType.getType() == EquipmentSlot.Type.ARMOR && !itemstack.isEmpty()) - { - visitorEntity.setItemSlot(slotType, itemstack); - } - } + return; } + final IBuilding tavern = colony.getBuildingManager().getBuilding(tavernPos); + final TavernBuildingModule module = tavern.getFirstModuleOccurance(TavernBuildingModule.class); + final IVisitorData visitorData = module.spawnVisitor(); + visitorData.triggerInteraction(new RecruitmentInteraction(Component.translatable( + "com.minecolonies.coremod.gui.chat.recruitstorycured", visitorData.getName().split(" ")[0]), ChatPriority.IMPORTANT)); + if (!entity.isSilent()) { - world.levelEvent((Player) null, 1027, entity.blockPosition(), 0); + world.levelEvent(null, 1027, entity.blockPosition(), 0); } entity.remove(Entity.RemovalReason.DISCARDED); - Tuple cost = recruitCosts.get(world.random.nextInt(recruitCosts.size())); - visitorData.setRecruitCosts(new ItemStack(cost.getA(), (int)(recruitLevel * 3.0 / cost.getB()))); - visitorData.triggerInteraction(new RecruitmentInteraction(Component.translatable( - "com.minecolonies.coremod.gui.chat.recruitstorycured", visitorData.getName().split(" ")[0]), ChatPriority.IMPORTANT)); } } } diff --git a/src/main/java/com/minecolonies/core/event/FMLEventHandler.java b/src/main/java/com/minecolonies/core/event/FMLEventHandler.java index ecc742de3e1..2dea18e8124 100755 --- a/src/main/java/com/minecolonies/core/event/FMLEventHandler.java +++ b/src/main/java/com/minecolonies/core/event/FMLEventHandler.java @@ -51,6 +51,7 @@ public static void onAddReloadListenerEvent(@NotNull final AddReloadListenerEven event.addListener(new CitizenNameListener()); event.addListener(new QuestJsonListener()); event.addListener(new ItemNbtListener()); + event.addListener(new RecruitmentItemsListener()); } @SubscribeEvent diff --git a/src/main/resources/data/minecolonies/recruitment_items/baked_potato.json b/src/main/resources/data/minecolonies/recruitment_items/baked_potato.json new file mode 100644 index 00000000000..df0fb3855a6 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/baked_potato.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:baked_potato", + "rarity": 1 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/book.json b/src/main/resources/data/minecolonies/recruitment_items/book.json new file mode 100644 index 00000000000..bc6f66bc970 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/book.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:book", + "rarity": 2 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/cake.json b/src/main/resources/data/minecolonies/recruitment_items/cake.json new file mode 100644 index 00000000000..6f6fa9f1ead --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/cake.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:cake", + "rarity": 11 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/diamond.json b/src/main/resources/data/minecolonies/recruitment_items/diamond.json new file mode 100644 index 00000000000..f2ae0525087 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/diamond.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:diamond", + "rarity": 9 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/emerald.json b/src/main/resources/data/minecolonies/recruitment_items/emerald.json new file mode 100644 index 00000000000..d3ab46046b2 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/emerald.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:emerald", + "rarity": 8 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/enchanted_book.json b/src/main/resources/data/minecolonies/recruitment_items/enchanted_book.json new file mode 100644 index 00000000000..4de1f5b2bf3 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/enchanted_book.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:enchanted_book", + "rarity": 9 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/gold_ingot.json b/src/main/resources/data/minecolonies/recruitment_items/gold_ingot.json new file mode 100644 index 00000000000..d585e7704e3 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/gold_ingot.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:gold_ingot", + "rarity": 2 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/hay_block.json b/src/main/resources/data/minecolonies/recruitment_items/hay_block.json new file mode 100644 index 00000000000..2ae3941c7a2 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/hay_block.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:hay_block", + "rarity": 3 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/honeycomb.json b/src/main/resources/data/minecolonies/recruitment_items/honeycomb.json new file mode 100644 index 00000000000..bbbea16c38b --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/honeycomb.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:honeycomb", + "rarity": 6 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/lapis_lazuli.json b/src/main/resources/data/minecolonies/recruitment_items/lapis_lazuli.json new file mode 100644 index 00000000000..e79ce562404 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/lapis_lazuli.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:lapis_lazuli", + "rarity": 2 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/quartz.json b/src/main/resources/data/minecolonies/recruitment_items/quartz.json new file mode 100644 index 00000000000..76a2dc9af15 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/quartz.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:quartz", + "rarity": 3 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/redstone.json b/src/main/resources/data/minecolonies/recruitment_items/redstone.json new file mode 100644 index 00000000000..557c0e481a1 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/redstone.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:redstone", + "rarity": 2 +} \ No newline at end of file diff --git a/src/main/resources/data/minecolonies/recruitment_items/sunflower.json b/src/main/resources/data/minecolonies/recruitment_items/sunflower.json new file mode 100644 index 00000000000..bd8f3f583c1 --- /dev/null +++ b/src/main/resources/data/minecolonies/recruitment_items/sunflower.json @@ -0,0 +1,4 @@ +{ + "item": "minecraft:sunflower", + "rarity": 5 +} \ No newline at end of file From 54c3afd7e4d710fe8a9945ef2586fc5d11fcc85c Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Fri, 18 Oct 2024 16:01:06 +0200 Subject: [PATCH 2/2] Javadoc --- .../core/datalistener/RecruitmentItemsListener.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java b/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java index 433903aac15..67eac25b9d8 100644 --- a/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java +++ b/src/main/java/com/minecolonies/core/datalistener/RecruitmentItemsListener.java @@ -25,7 +25,7 @@ import static com.minecolonies.core.colony.buildings.modules.TavernBuildingModule.IRON_SKILL_LEVEL; /** - * Loads and listens to free block data. + * Loads and listens to recruitment costs data. */ public class RecruitmentItemsListener extends SimpleJsonResourceReloadListener { @@ -41,7 +41,7 @@ public class RecruitmentItemsListener extends SimpleJsonResourceReloadListener private static final String KEY_RARITY = "rarity"; /** - * The current list of free to interact blocks. + * The current list of recruitment costs. */ private static List RECRUIT_COSTS = new ArrayList<>(); @@ -127,4 +127,4 @@ protected void apply( RECRUIT_COSTS = Collections.unmodifiableList(recruitCosts); } -} \ No newline at end of file +}