diff --git a/src/main/java/de/teamlapen/vampirism/core/ModAi.java b/src/main/java/de/teamlapen/vampirism/core/ModAi.java new file mode 100644 index 0000000000..9336789f3d --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/core/ModAi.java @@ -0,0 +1,19 @@ +package de.teamlapen.vampirism.core; + +import de.teamlapen.vampirism.REFERENCE; +import de.teamlapen.vampirism.entity.ai.sensing.VampireVillagerHostilesSensor; +import net.minecraft.world.entity.ai.sensing.SensorType; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +public class ModAi { + public static final DeferredRegister> SENSOR_TYPES = DeferredRegister.create(ForgeRegistries.SENSOR_TYPES, REFERENCE.MODID); + + public static final RegistryObject> VAMPIRE_VILLAGER_HOSTILES = SENSOR_TYPES.register("vampire_villager_hostiles", () -> new SensorType<>(VampireVillagerHostilesSensor::new)); + + static void register(IEventBus bus) { + SENSOR_TYPES.register(bus); + } +} diff --git a/src/main/java/de/teamlapen/vampirism/core/ModVillage.java b/src/main/java/de/teamlapen/vampirism/core/ModVillage.java index 878c5e1bf0..fcbfaed0bb 100644 --- a/src/main/java/de/teamlapen/vampirism/core/ModVillage.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModVillage.java @@ -30,7 +30,6 @@ public class ModVillage { public static final DeferredRegister PROFESSIONS = DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, REFERENCE.MODID); public static final DeferredRegister POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, REFERENCE.MODID); - public static final DeferredRegister> SENSOR_TYPES = DeferredRegister.create(ForgeRegistries.SENSOR_TYPES, REFERENCE.MODID); public static final DeferredRegister SCHEDULES = DeferredRegister.create(ForgeRegistries.SCHEDULES, REFERENCE.MODID); public static final RegistryObject HUNTER_TOTEM = POI_TYPES.register("hunter_totem", () -> new PoiType(getAllStates(ModBlocks.TOTEM_TOP_VAMPIRISM_HUNTER.get(), ModBlocks.TOTEM_TOP_VAMPIRISM_HUNTER_CRAFTED.get()), 1, 1)); @@ -38,7 +37,11 @@ public class ModVillage { public static final RegistryObject NO_FACTION_TOTEM = POI_TYPES.register("no_faction_totem", () -> new PoiType(getAllStates(ModBlocks.TOTEM_TOP.get(), ModBlocks.TOTEM_TOP_CRAFTED.get()), 1, 1)); public static final RegistryObject ALTAR_CLEANSING = POI_TYPES.register("church_altar", () -> new PoiType(getAllStates(ModBlocks.ALTAR_CLEANSING.get()), 1, 1)); - public static final RegistryObject> VAMPIRE_VILLAGER_HOSTILES = SENSOR_TYPES.register("vampire_villager_hostiles", () -> new SensorType<>(VampireVillagerHostilesSensor::new)); + /** + * @deprecated use {@link ModAi#VAMPIRE_VILLAGER_HOSTILES} instead + */ + @Deprecated(forRemoval = true) + public static final RegistryObject> VAMPIRE_VILLAGER_HOSTILES = ModAi.VAMPIRE_VILLAGER_HOSTILES; public static final RegistryObject CONVERTED_DEFAULT = SCHEDULES.register("converted_default", () -> new ScheduleBuilder(new Schedule()).changeActivityAt(12000, Activity.IDLE).changeActivityAt(10, Activity.REST).changeActivityAt(14000, Activity.WORK).changeActivityAt(21000, Activity.MEET).changeActivityAt(23000, Activity.IDLE).build()); @@ -51,7 +54,6 @@ public class ModVillage { static void register(IEventBus bus) { POI_TYPES.register(bus); PROFESSIONS.register(bus); - SENSOR_TYPES.register(bus); SCHEDULES.register(bus); } diff --git a/src/main/java/de/teamlapen/vampirism/core/RegistryManager.java b/src/main/java/de/teamlapen/vampirism/core/RegistryManager.java index 211e6a2d4b..6337482787 100644 --- a/src/main/java/de/teamlapen/vampirism/core/RegistryManager.java +++ b/src/main/java/de/teamlapen/vampirism/core/RegistryManager.java @@ -56,6 +56,7 @@ public static void setupRegistries(@NotNull IEventBus modbus) { ModSounds.register(modbus); ModTasks.register(modbus); ModTiles.register(modbus); + ModAi.register(modbus); ModVillage.register(modbus); VampireActions.register(modbus); HunterActions.register(modbus); diff --git a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java index 713df99413..103c1c2dfd 100644 --- a/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java +++ b/src/main/java/de/teamlapen/vampirism/entity/converted/ConvertedVillagerEntity.java @@ -9,6 +9,7 @@ import de.teamlapen.vampirism.api.entity.player.vampire.IBloodStats; import de.teamlapen.vampirism.blockentity.TotemBlockEntity; import de.teamlapen.vampirism.core.ModAdvancements; +import de.teamlapen.vampirism.core.ModAi; import de.teamlapen.vampirism.core.ModVillage; import de.teamlapen.vampirism.entity.VampirismVillagerEntity; import de.teamlapen.vampirism.entity.player.vampire.VampirePlayer; @@ -64,7 +65,7 @@ public class ConvertedVillagerEntity extends VampirismVillagerEntity implements static { SENSOR_TYPES = Lists.newArrayList(Villager.SENSOR_TYPES); SENSOR_TYPES.remove(SensorType.VILLAGER_HOSTILES); - SENSOR_TYPES.add(ModVillage.VAMPIRE_VILLAGER_HOSTILES.get()); + SENSOR_TYPES.add(ModAi.VAMPIRE_VILLAGER_HOSTILES.get()); } private @NotNull EnumStrength garlicCache = EnumStrength.NONE;