Search in sources :

Example 1 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class CommandRaidAll method build.

@Override
public LiteralArgumentBuilder<CommandSource> build() {
    final List<String> raidTypes = new ArrayList<>();
    for (final ColonyEventTypeRegistryEntry type : IMinecoloniesAPI.getInstance().getColonyEventRegistry().getValues()) {
        if (!type.getRegistryName().getPath().equals(PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID.getPath()) && !type.getRegistryName().getPath().equals(NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID.getPath())) {
            raidTypes.add(type.getRegistryName().getPath());
        }
    }
    String[] opt = new String[2];
    opt[0] = RAID_NOW;
    opt[1] = RAID_TONIGHT;
    return IMCCommand.newLiteral(getName()).then(IMCCommand.newArgument(RAID_TIME_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(opt, builder)).then(IMCCommand.newArgument(RAID_TYPE_ARG, StringArgumentType.string()).suggests((ctx, builder) -> ISuggestionProvider.suggest(raidTypes, builder)).executes(this::onSpecificExecute)).executes(this::checkPreConditionAndExecute));
}
Also used : IMCCommand(com.minecolonies.coremod.commands.commandTypes.IMCCommand) CommandArgumentNames(com.minecolonies.coremod.commands.CommandArgumentNames) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) PirateGroundRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent) CommandContext(com.mojang.brigadier.context.CommandContext) ISuggestionProvider(net.minecraft.command.ISuggestionProvider) IColonyManager(com.minecolonies.api.colony.IColonyManager) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) ArrayList(java.util.ArrayList) CommandSource(net.minecraft.command.CommandSource) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) List(java.util.List) IMinecoloniesAPI(com.minecolonies.api.IMinecoloniesAPI) IColony(com.minecolonies.api.colony.IColony) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) IMCOPCommand(com.minecolonies.coremod.commands.commandTypes.IMCOPCommand) NorsemenShipRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent) ArrayList(java.util.ArrayList) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 2 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class CommonMinecoloniesAPIImpl method onRegistryNewRegistry.

public void onRegistryNewRegistry(final RegistryEvent.NewRegistry event) {
    buildingRegistry = new RegistryBuilder<BuildingEntry>().setName(new ResourceLocation(Constants.MOD_ID, "buildings")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(BuildingEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    jobRegistry = new RegistryBuilder<JobEntry>().setName(new ResourceLocation(Constants.MOD_ID, "jobs")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(JobEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    guardTypeRegistry = new RegistryBuilder<GuardType>().setName(new ResourceLocation(Constants.MOD_ID, "guardtypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setDefaultKey(ModGuardTypes.KNIGHT_ID).setType(GuardType.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    interactionHandlerRegistry = new RegistryBuilder<InteractionResponseHandlerEntry>().setName(new ResourceLocation(Constants.MOD_ID, "interactionresponsehandlers")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(InteractionResponseHandlerEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    colonyEventRegistry = new RegistryBuilder<ColonyEventTypeRegistryEntry>().setName(new ResourceLocation(Constants.MOD_ID, "colonyeventtypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(ColonyEventTypeRegistryEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    colonyEventDescriptionRegistry = new RegistryBuilder<ColonyEventDescriptionTypeRegistryEntry>().setName(new ResourceLocation(Constants.MOD_ID, "colonyeventdesctypes")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "null")).disableSaving().allowModification().setType(ColonyEventDescriptionTypeRegistryEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    recipeTypeEntryRegistry = new RegistryBuilder<RecipeTypeEntry>().setName(new ResourceLocation(Constants.MOD_ID, "recipetypeentries")).setDefaultKey(new ResourceLocation(Constants.MOD_ID, "classic")).disableSaving().allowModification().setType(RecipeTypeEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    researchRequirementRegistry = new RegistryBuilder<ResearchRequirementEntry>().setName(new ResourceLocation(Constants.MOD_ID, "researchrequirementtypes")).setDefaultKey(RESEARCH_RESEARCH_REQ_ID).disableSaving().allowModification().setType(ResearchRequirementEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
    researchEffectRegistry = new RegistryBuilder<ResearchEffectEntry>().setName(new ResourceLocation(Constants.MOD_ID, "researcheffecttypes")).setDefaultKey(GLOBAL_EFFECT_ID).disableSaving().allowModification().setType(ResearchEffectEntry.class).setIDRange(0, Integer.MAX_VALUE - 1).create();
}
Also used : JobEntry(com.minecolonies.api.colony.jobs.registry.JobEntry) ColonyEventDescriptionTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventDescriptionTypeRegistryEntry) ResearchEffectEntry(com.minecolonies.api.research.effects.registry.ResearchEffectEntry) InteractionResponseHandlerEntry(com.minecolonies.api.colony.interactionhandling.registry.InteractionResponseHandlerEntry) RecipeTypeEntry(com.minecolonies.api.crafting.registry.RecipeTypeEntry) BuildingEntry(com.minecolonies.api.colony.buildings.registry.BuildingEntry) ResourceLocation(net.minecraft.util.ResourceLocation) RegistryBuilder(net.minecraftforge.registries.RegistryBuilder) GuardType(com.minecolonies.api.colony.guardtype.GuardType) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry) ResearchRequirementEntry(com.minecolonies.api.research.registry.ResearchRequirementEntry)

Example 3 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by Minecolonies.

the class EventManager method readFromNBT.

@Override
public void readFromNBT(@NotNull final CompoundNBT compound) {
    if (compound.contains(TAG_EVENT_MANAGER)) {
        final CompoundNBT eventManagerNBT = compound.getCompound(TAG_EVENT_MANAGER);
        final ListNBT eventListNBT = eventManagerNBT.getList(TAG_EVENT_LIST, Constants.NBT.TAG_COMPOUND);
        for (final INBT base : eventListNBT) {
            final CompoundNBT tagCompound = (CompoundNBT) base;
            final ResourceLocation eventTypeID = new ResourceLocation(MOD_ID, tagCompound.getString(TAG_NAME));
            final ColonyEventTypeRegistryEntry registryEntry = MinecoloniesAPIProxy.getInstance().getColonyEventRegistry().getValue(eventTypeID);
            if (registryEntry == null) {
                Log.getLogger().warn("Event is missing registryEntry!:" + eventTypeID.getPath());
                continue;
            }
            final IColonyEvent colonyEvent = registryEntry.deserializeEvent(colony, tagCompound);
            events.put(colonyEvent.getID(), colonyEvent);
        }
        currentEventID = eventManagerNBT.getInt(TAG_EVENT_ID);
        structureManager.readFromNBT(compound);
    }
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) INBT(net.minecraft.nbt.INBT) ResourceLocation(net.minecraft.util.ResourceLocation) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 4 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by ldtteam.

the class EventManager method readFromNBT.

@Override
public void readFromNBT(@NotNull final CompoundNBT compound) {
    if (compound.contains(TAG_EVENT_MANAGER)) {
        final CompoundNBT eventManagerNBT = compound.getCompound(TAG_EVENT_MANAGER);
        final ListNBT eventListNBT = eventManagerNBT.getList(TAG_EVENT_LIST, Constants.NBT.TAG_COMPOUND);
        for (final INBT base : eventListNBT) {
            final CompoundNBT tagCompound = (CompoundNBT) base;
            final ResourceLocation eventTypeID = new ResourceLocation(MOD_ID, tagCompound.getString(TAG_NAME));
            final ColonyEventTypeRegistryEntry registryEntry = MinecoloniesAPIProxy.getInstance().getColonyEventRegistry().getValue(eventTypeID);
            if (registryEntry == null) {
                Log.getLogger().warn("Event is missing registryEntry!:" + eventTypeID.getPath());
                continue;
            }
            final IColonyEvent colonyEvent = registryEntry.deserializeEvent(colony, tagCompound);
            events.put(colonyEvent.getID(), colonyEvent);
        }
        currentEventID = eventManagerNBT.getInt(TAG_EVENT_ID);
        structureManager.readFromNBT(compound);
    }
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) ListNBT(net.minecraft.nbt.ListNBT) CompoundNBT(net.minecraft.nbt.CompoundNBT) INBT(net.minecraft.nbt.INBT) ResourceLocation(net.minecraft.util.ResourceLocation) ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Example 5 with ColonyEventTypeRegistryEntry

use of com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry in project minecolonies by ldtteam.

the class ModColonyEventTypeInitializer method init.

public static void init(final RegistryEvent.Register<ColonyEventTypeRegistryEntry> event) {
    final IForgeRegistry<ColonyEventTypeRegistryEntry> reg = event.getRegistry();
    reg.register(new ColonyEventTypeRegistryEntry(PirateRaidEvent::loadFromNBT, PirateRaidEvent.PIRATE_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(BarbarianRaidEvent::loadFromNBT, BarbarianRaidEvent.BARBARIAN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(EgyptianRaidEvent::loadFromNBT, EgyptianRaidEvent.EGYPTIAN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(AmazonRaidEvent::loadFromNBT, AmazonRaidEvent.AMAZON_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(NorsemenRaidEvent::loadFromNBT, NorsemenRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(NorsemenShipRaidEvent::loadFromNBT, NorsemenShipRaidEvent.NORSEMEN_RAID_EVENT_TYPE_ID));
    reg.register(new ColonyEventTypeRegistryEntry(PirateGroundRaidEvent::loadFromNBT, PirateGroundRaidEvent.PIRATE_GROUND_RAID_EVENT_TYPE_ID));
}
Also used : ColonyEventTypeRegistryEntry(com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)

Aggregations

ColonyEventTypeRegistryEntry (com.minecolonies.api.colony.colonyEvents.registry.ColonyEventTypeRegistryEntry)10 LanguageHandler (com.ldtteam.structurize.util.LanguageHandler)4 IMinecoloniesAPI (com.minecolonies.api.IMinecoloniesAPI)4 IColony (com.minecolonies.api.colony.IColony)4 IColonyManager (com.minecolonies.api.colony.IColonyManager)4 NorsemenShipRaidEvent (com.minecolonies.coremod.colony.colonyEvents.raidEvents.norsemenevent.NorsemenShipRaidEvent)4 PirateGroundRaidEvent (com.minecolonies.coremod.colony.colonyEvents.raidEvents.pirateEvent.PirateGroundRaidEvent)4 CommandArgumentNames (com.minecolonies.coremod.commands.CommandArgumentNames)4 IMCCommand (com.minecolonies.coremod.commands.commandTypes.IMCCommand)4 IMCOPCommand (com.minecolonies.coremod.commands.commandTypes.IMCOPCommand)4 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)4 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)4 CommandContext (com.mojang.brigadier.context.CommandContext)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 CommandSource (net.minecraft.command.CommandSource)4 ISuggestionProvider (net.minecraft.command.ISuggestionProvider)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 BuildingEntry (com.minecolonies.api.colony.buildings.registry.BuildingEntry)2 IColonyEvent (com.minecolonies.api.colony.colonyEvents.IColonyEvent)2