Search in sources :

Example 1 with Pack

use of org.blockartistry.DynSurround.packs.ResourcePacks.Pack in project DynamicSurroundings by OreCruncher.

the class FootstepsRegistry method init.

@Override
public void init() {
    this.acousticsManager = new AcousticsManager();
    this.primitiveMap = new PrimitiveMap(this.acousticsManager);
    this.blockMap = new BlockMap(this.acousticsManager);
    this.FOOTPRINT_MATERIAL = new IdentityHashSet<>();
    this.FOOTPRINT_STATES = new IdentityHashSet<>();
    this.ARMOR_SOUND = new EnumMap<>(ArmorClass.class);
    this.ARMOR_SOUND_FOOT = new EnumMap<>(ArmorClass.class);
    this.variators = new HashMap<>();
    // Initialize the known materials that leave footprints
    this.FOOTPRINT_MATERIAL.add(Material.CLAY);
    this.FOOTPRINT_MATERIAL.add(Material.GRASS);
    this.FOOTPRINT_MATERIAL.add(Material.GROUND);
    this.FOOTPRINT_MATERIAL.add(Material.ICE);
    this.FOOTPRINT_MATERIAL.add(Material.PACKED_ICE);
    this.FOOTPRINT_MATERIAL.add(Material.SAND);
    this.FOOTPRINT_MATERIAL.add(Material.CRAFTED_SNOW);
    this.FOOTPRINT_MATERIAL.add(Material.SNOW);
    // It's a hack - needs refactor
    AcousticsManager.SWIM = null;
    AcousticsManager.JUMP = null;
    AcousticsManager.SPLASH = null;
    final List<Pack> repo = ResourcePacks.findResourcePacks();
    reloadAcoustics(repo);
    reloadPrimitiveMap(repo);
    seedMap();
}
Also used : AcousticsManager(org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager) BlockMap(org.blockartistry.DynSurround.client.footsteps.implem.BlockMap) PrimitiveMap(org.blockartistry.DynSurround.client.footsteps.implem.PrimitiveMap) Pack(org.blockartistry.DynSurround.packs.ResourcePacks.Pack)

Example 2 with Pack

use of org.blockartistry.DynSurround.packs.ResourcePacks.Pack in project DynamicSurroundings by OreCruncher.

the class RegistryManager method reload.

public void reload() {
    // Collect the locations where DS data is configured
    final List<Pack> packs = ResourcePacks.findResourcePacks();
    final List<ModContainer> activeMods = Loader.instance().getActiveModList();
    DSurround.log().info("Identified the following resource pack locations");
    packs.stream().map(Pack::toString).forEach(DSurround.log()::info);
    // Do the preinit
    this.initOrder.forEach(Registry::init);
    // Process the mod config from each of our packs
    activeMods.stream().map(mod -> {
        return new ResourceLocation(DSurround.MOD_ID, "data/" + mod.getModId().toLowerCase() + ".json");
    }).forEach(rl -> {
        packs.forEach(p -> {
            final String loadingText = "[" + rl.toString() + "] <- [" + p.getModName() + "]";
            process(p, rl, loadingText);
        });
    });
    // Process general config files from our packs
    final ResourceLocation rl = ResourcePacks.CONFIGURE_RESOURCE;
    packs.stream().forEach(p -> process(p, rl, "[" + rl.toString() + "] <- [" + p.getModName() + "]"));
    // Apply built-in profiles
    final List<ProfileScript> resources = Profiles.getProfileStreams();
    for (final ProfileScript script : resources) {
        try (final InputStreamReader reader = new InputStreamReader(script.stream)) {
            final ModConfigurationFile cfg = DataScripts.loadFromStream(reader);
            final String loadingText = "[" + DSurround.MOD_ID + "] <- [" + script.packName + "]";
            configRegistries(cfg, loadingText);
        } catch (@Nonnull final Throwable ex) {
            final String temp = String.format("Unable to load profile [%s]", script.packName);
            DSurround.log().error(temp, ex);
        }
    }
    // Load scripts specified in the configuration
    Arrays.stream(ModOptions.general.externalScriptFiles).forEach(cfg -> configRegistries(DataScripts.loadFromDirectory(cfg), "[" + cfg + "]"));
    // Have the registries finalize their settings
    this.initOrder.forEach(Registry::initComplete);
    // Let everyone know a reload happened
    MinecraftForge.EVENT_BUS.post(new ReloadEvent.Registry(this.side));
}
Also used : Arrays(java.util.Arrays) ModConfigurationFile(org.blockartistry.DynSurround.data.xface.ModConfigurationFile) Loader(net.minecraftforge.fml.common.Loader) Scheduler(org.blockartistry.lib.task.Scheduler) ProfileScript(org.blockartistry.DynSurround.data.Profiles.ProfileScript) SideLocal(org.blockartistry.lib.SideLocal) ArrayList(java.util.ArrayList) DSurround(org.blockartistry.DynSurround.DSurround) Side(net.minecraftforge.fml.relauncher.Side) Map(java.util.Map) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) ReloadEvent(org.blockartistry.DynSurround.event.ReloadEvent) Pack(org.blockartistry.DynSurround.packs.ResourcePacks.Pack) IdentityHashMap(java.util.IdentityHashMap) ResourcePacks(org.blockartistry.DynSurround.packs.ResourcePacks) InputStreamReader(java.io.InputStreamReader) List(java.util.List) MinecraftForge(net.minecraftforge.common.MinecraftForge) DataScripts(org.blockartistry.DynSurround.data.xface.DataScripts) ModOptions(org.blockartistry.DynSurround.ModOptions) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ModContainer(net.minecraftforge.fml.common.ModContainer) Profiles(org.blockartistry.DynSurround.data.Profiles) InputStream(java.io.InputStream) ReloadEvent(org.blockartistry.DynSurround.event.ReloadEvent) ModConfigurationFile(org.blockartistry.DynSurround.data.xface.ModConfigurationFile) ModContainer(net.minecraftforge.fml.common.ModContainer) InputStreamReader(java.io.InputStreamReader) ResourceLocation(net.minecraft.util.ResourceLocation) Pack(org.blockartistry.DynSurround.packs.ResourcePacks.Pack) ProfileScript(org.blockartistry.DynSurround.data.Profiles.ProfileScript)

Aggregations

Pack (org.blockartistry.DynSurround.packs.ResourcePacks.Pack)2 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 IdentityHashMap (java.util.IdentityHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 MinecraftForge (net.minecraftforge.common.MinecraftForge)1 Loader (net.minecraftforge.fml.common.Loader)1 ModContainer (net.minecraftforge.fml.common.ModContainer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 Side (net.minecraftforge.fml.relauncher.Side)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1 DSurround (org.blockartistry.DynSurround.DSurround)1 ModOptions (org.blockartistry.DynSurround.ModOptions)1 AcousticsManager (org.blockartistry.DynSurround.client.footsteps.implem.AcousticsManager)1 BlockMap (org.blockartistry.DynSurround.client.footsteps.implem.BlockMap)1