Skip to content

Commit

Permalink
Check to see if a sound file path exists within the resourcepack befo…
Browse files Browse the repository at this point in the history
…re caching it. Now dumps a list of sounds that cannot be found to the console when refreshing resources. Won't attempt to play the missing sounds at-all, avoiding repeating error messages.
  • Loading branch information
dagswell committed Jun 6, 2015
1 parent fddad02 commit 0d57ee5
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 54 deletions.
2 changes: 1 addition & 1 deletion ant/build_matmos.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<project name="MAtmos" basedir="." default="main">

<!-- The version of your mod, can be any string as long as it's valid as part of a file name -->
<property name="version" value="29" />
<property name="version" value="29ub4" />

<!-- The Minecraft version the mod is for, appended to the output file name for reference -->
<property name="mcversion" value="1.7.10" />
Expand Down
4 changes: 2 additions & 2 deletions ant/buildnumber.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Sat May 23 13:39:36 BST 2015
build.number=18
#Sat Jun 06 15:50:24 BST 2015
build.number=24
2 changes: 1 addition & 1 deletion ant/litemod.template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eu.ha3.mc.matmos",
"mcversion": "1.7.10",
"version": "r29unOfficialBeta2",
"version": "r29UnofficialBeta4",
"revision": "29",
"author": "Hurricaaane (Ha3)",
"url": "http://matmos.ha3.eu",
Expand Down
30 changes: 21 additions & 9 deletions main-src/eu/ha3/matmos/engine/core/implem/Event.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package eu.ha3.matmos.engine.core.implem;

import java.util.List;
import java.util.Random;

import eu.ha3.matmos.engine.core.implem.abstractions.Component;
import eu.ha3.matmos.engine.core.interfaces.EventInterface;
import eu.ha3.matmos.engine.core.interfaces.SoundRelay;
import eu.ha3.matmos.log.MAtLog;
import net.minecraft.client.resources.IResourcePack;
import net.minecraft.util.ResourceLocation;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/* x-placeholder */

Expand Down Expand Up @@ -38,14 +42,22 @@ public Event(
this.pitchMax = pitchMax;
this.distance = distance;
}

@Override
public void cacheSounds()
public void cacheSounds(IResourcePack resourcePack)
{
for (String path : this.paths)
{
this.relay.cacheSound(path);
}
List<String> toRemove = new ArrayList<String>();
for (String path : this.paths)
{
if (resourcePack.resourceExists(new ResourceLocation("minecraft", "sounds/" + path)))
this.relay.cacheSound(path);
else
{
MAtLog.warning("File: " + path + " appears to be missing from: " + resourcePack.getPackName() + " [This sound will not be cached or played in-game]");
toRemove.add(path);
}
}
paths.removeAll(toRemove);
}

@Override
Expand Down
29 changes: 8 additions & 21 deletions main-src/eu/ha3/matmos/engine/core/implem/Knowledge.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
package eu.ha3.matmos.engine.core.implem;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;

import eu.ha3.matmos.engine.core.implem.abstractions.Provider;
import eu.ha3.matmos.engine.core.interfaces.Data;
import eu.ha3.matmos.engine.core.interfaces.Dependable;
import eu.ha3.matmos.engine.core.interfaces.Evaluated;
import eu.ha3.matmos.engine.core.interfaces.EventInterface;
import eu.ha3.matmos.engine.core.interfaces.Named;
import eu.ha3.matmos.engine.core.interfaces.PossibilityList;
import eu.ha3.matmos.engine.core.interfaces.ReferenceTime;
import eu.ha3.matmos.engine.core.interfaces.Sheet;
import eu.ha3.matmos.engine.core.interfaces.SheetCommander;
import eu.ha3.matmos.engine.core.interfaces.SheetIndex;
import eu.ha3.matmos.engine.core.interfaces.Simulated;
import eu.ha3.matmos.engine.core.interfaces.SoundRelay;
import eu.ha3.matmos.engine.core.interfaces.*;
import eu.ha3.matmos.expansions.ExpansionIdentity;
import eu.ha3.matmos.log.MAtLog;
import net.minecraft.client.resources.IResourcePack;

import java.util.*;

/* x-placeholder */

Expand Down Expand Up @@ -200,11 +186,12 @@ private void purge(
}
}

public void cacheSounds()
public void cacheSounds(ExpansionIdentity identity)
{
IResourcePack resourcePack = identity.getPack();
for (EventInterface event : this.eventMapped.values())
{
event.cacheSounds();
event.cacheSounds(resourcePack);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
--filenotes-placeholder
*/

import net.minecraft.client.resources.IResourcePack;

public interface EventInterface
{

public abstract void cacheSounds();
public abstract void cacheSounds(IResourcePack resourcePack);

public abstract void playSound(float volMod, float pitchMod);

Expand Down
28 changes: 9 additions & 19 deletions main-src/eu/ha3/matmos/expansions/Expansion.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
package eu.ha3.matmos.expansions;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;
import java.util.Set;

import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.util.ResourceLocation;
import eu.ha3.easy.TimeStatistic;
import eu.ha3.matmos.engine.core.implem.Knowledge;
import eu.ha3.matmos.engine.core.implem.ProviderCollection;
import eu.ha3.matmos.engine.core.implem.SystemClock;
import eu.ha3.matmos.engine.core.interfaces.Data;
import eu.ha3.matmos.engine.core.interfaces.Evaluated;
import eu.ha3.matmos.engine.core.interfaces.EventInterface;
import eu.ha3.matmos.engine.core.interfaces.ReferenceTime;
import eu.ha3.matmos.engine.core.interfaces.Simulated;
import eu.ha3.matmos.engine.core.interfaces.*;
import eu.ha3.matmos.expansions.agents.LoadingAgent;
import eu.ha3.matmos.expansions.agents.RawJasonLoadingAgent;
import eu.ha3.matmos.expansions.debugunit.ExpansionDebugUnit;
Expand All @@ -36,6 +19,13 @@
import eu.ha3.matmos.log.MAtLog;
import eu.ha3.matmos.pluggable.PluggableIntoMinecraft;
import eu.ha3.util.property.simple.ConfigProperty;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.FolderResourcePack;
import net.minecraft.util.ResourceLocation;

import java.io.File;
import java.io.IOException;
import java.util.*;

/* x-placeholder */

Expand Down Expand Up @@ -145,7 +135,7 @@ private void buildKnowledge()
newKnowledge();
}

this.knowledge.cacheSounds();
this.knowledge.cacheSounds(this.identity);
}

public void playSample()
Expand Down

0 comments on commit 0d57ee5

Please sign in to comment.