Skip to content

Commit

Permalink
add ModAi class for storing ai brain related objects
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 21, 2023
1 parent 12ec10f commit ba23dbe
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/main/java/de/teamlapen/vampirism/core/ModAi.java
Original file line number Diff line number Diff line change
@@ -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<SensorType<?>> SENSOR_TYPES = DeferredRegister.create(ForgeRegistries.SENSOR_TYPES, REFERENCE.MODID);

public static final RegistryObject<SensorType<VampireVillagerHostilesSensor>> VAMPIRE_VILLAGER_HOSTILES = SENSOR_TYPES.register("vampire_villager_hostiles", () -> new SensorType<>(VampireVillagerHostilesSensor::new));

static void register(IEventBus bus) {
SENSOR_TYPES.register(bus);
}
}
8 changes: 5 additions & 3 deletions src/main/java/de/teamlapen/vampirism/core/ModVillage.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,18 @@
public class ModVillage {
public static final DeferredRegister<VillagerProfession> PROFESSIONS = DeferredRegister.create(ForgeRegistries.VILLAGER_PROFESSIONS, REFERENCE.MODID);
public static final DeferredRegister<PoiType> POI_TYPES = DeferredRegister.create(ForgeRegistries.POI_TYPES, REFERENCE.MODID);
public static final DeferredRegister<SensorType<?>> SENSOR_TYPES = DeferredRegister.create(ForgeRegistries.SENSOR_TYPES, REFERENCE.MODID);
public static final DeferredRegister<Schedule> SCHEDULES = DeferredRegister.create(ForgeRegistries.SCHEDULES, REFERENCE.MODID);

public static final RegistryObject<PoiType> 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));
public static final RegistryObject<PoiType> VAMPIRE_TOTEM = POI_TYPES.register("vampire_totem", () -> new PoiType(getAllStates(ModBlocks.TOTEM_TOP_VAMPIRISM_VAMPIRE.get(), ModBlocks.TOTEM_TOP_VAMPIRISM_VAMPIRE_CRAFTED.get()), 1, 1));
public static final RegistryObject<PoiType> 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<PoiType> ALTAR_CLEANSING = POI_TYPES.register("church_altar", () -> new PoiType(getAllStates(ModBlocks.ALTAR_CLEANSING.get()), 1, 1));

public static final RegistryObject<SensorType<VampireVillagerHostilesSensor>> 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<SensorType<VampireVillagerHostilesSensor>> VAMPIRE_VILLAGER_HOSTILES = ModAi.VAMPIRE_VILLAGER_HOSTILES;

public static final RegistryObject<Schedule> 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());
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ba23dbe

Please sign in to comment.