Skip to content

Commit dbf94fb

Browse files
committed
1.5.4.
1 parent 7ae39b8 commit dbf94fb

7 files changed

Lines changed: 74 additions & 18 deletions

File tree

build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ mc_version=1.12.2
22
forge_version=14.23.0.2544
33
mcp_mappings=snapshot_20171120
44

5-
mod_version=1.5.3
5+
mod_version=1.5.4

src/main/java/alexiil/mc/mod/load/ClsManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ public class ClsManager {
9797
FUNC_CTX.put_l("memory_used", () -> {
9898
return (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()) / 1024 / 1024;
9999
});
100+
101+
FUNC_CTX.put_s_s("translate", Translation::translate);
100102
}
101103

102104
public static boolean load() throws InvalidExpressionException {

src/main/java/alexiil/mc/mod/load/Translation.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ static boolean scanLangRoot(final Path langRoot) {
5757
try {
5858
for (Path child : Files.list(langRoot).collect(Collectors.toList())) {
5959
String fn = child.getFileName().toString();
60+
if (fn.endsWith(".lang.txt")) {
61+
fn = fn.substring(0, fn.length() - 4);
62+
CLSLog.warn("Found .lang.txt file in lang root, treating as .lang: " + child);
63+
}
6064
if (!fn.endsWith(".lang") || !Files.isRegularFile(child)) {
65+
CLSLog.warn("Encountered unknown file in lang root " + child);
6166
continue;
6267
}
6368
String locale = fn.substring(0, fn.lastIndexOf('.'));
@@ -118,7 +123,16 @@ public static void scanFileForTranslations(File modLocation) {
118123

119124
public static void setTranslator() {
120125
// Scan config dir for langs
121-
scanLangRoot(Paths.get("config", "customloadingscreen", "lang"));
126+
Path cfgLangFolder = Paths.get("config", "customloadingscreen", "lang");
127+
if (Files.exists(cfgLangFolder)) {
128+
scanLangRoot(cfgLangFolder);
129+
} else {
130+
try {
131+
Files.createDirectories(cfgLangFolder);
132+
} catch (IOException ignored) {
133+
// Ignore
134+
}
135+
}
122136

123137
// Lastly, set the current locale
124138
File options = new File("./options.txt");

src/main/java/alexiil/mc/mod/load/baked/insn/BakedColourSimple.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package alexiil.mc.mod.load.baked.insn;
22

3-
import net.minecraft.client.renderer.GlStateManager;
3+
import org.lwjgl.opengl.GL11;
44

55
public class BakedColourSimple extends BakedInsn {
66
private final float a, r, g, b;
@@ -14,6 +14,6 @@ public BakedColourSimple(float a, float r, float g, float b) {
1414

1515
@Override
1616
public void render() {
17-
GlStateManager.color(r, g, b, a);
17+
GL11.glColor4f(r, g, b, a);
1818
}
1919
}

src/main/java/alexiil/mc/mod/load/json/ConfigManager.java

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ private static String getTextResource(ResourceLocation identifier) {
184184
static <T extends JsonConfigurable<T, ?>> T getAsT(EType type, String location) throws InvalidExpressionException {
185185
if (StringUtils.isEmpty(location)) {
186186
CLSLog.warn("Location was given as null!", new Throwable());
187-
return null;
187+
throw new JsonSyntaxException("Invalid location '" + location + "'");
188188
}
189189
CLSLog.info("Getting " + location + " as " + type);
190190
ResourceLocation loc = getLocation(type, location);
@@ -196,7 +196,7 @@ private static String getTextResource(ResourceLocation identifier) {
196196
return (T) failed;
197197
}
198198
CLSLog.warn("The text inside of \"" + loc + "\" was null!");
199-
return null;
199+
throw new JsonSyntaxException("Invalid location '" + location + "': the text inside it was null!");
200200
}
201201
try {
202202
T t = (T) GSON_ADAPTORS.fromJson(text, type.clazz);
@@ -241,22 +241,55 @@ public static void getAsScript(String location) {
241241
}
242242

243243
public static ResourceLocation getLocation(EType type, String base) {
244+
245+
/* Namespace rules: */
246+
247+
// If the location starts contains a colon before a slash then it's a namespace,
248+
// and we don't do anything special other that use it instead of the default.
249+
250+
// If the location starts with "config/" then we use "config" as the namespace
251+
// and we *don't* add the type prefix if the type is EType.CONFIG.
252+
253+
/* Path rules: */
254+
255+
// We always append ".json" to the path, no exceptions
256+
// The other rules are a bit more complicated:
257+
258+
// If it starts with "builtin/" or "sample/" then we bring that to the front.
259+
260+
// Then we add "type"
261+
262+
String namespace = "customloadingscreen";
244263
String path;
245-
if (base.startsWith("builtin/")) {
246-
path = "builtin/" + type.resourceBase + "/" + base.substring("builtin/".length()) + ".json";
247-
} else if (base.startsWith("sample/")) {
248-
path = "sample/" + type.resourceBase + "/" + base.substring("sample/".length()) + ".json";
249-
} else if (base.startsWith("config/")) {
250-
if (type == EType.CONFIG) {
251-
path = base.substring("config/".length()) + ".json";
264+
int colon = base.indexOf(':');
265+
int slash = base.indexOf('/');
266+
267+
if (colon > 0 && (colon < slash || slash < 0)) {
268+
namespace = base.substring(0, colon);
269+
base = base.substring(colon + 1);
270+
271+
if ("config".equals(namespace) && type == EType.CONFIG) {
272+
path = base;
252273
} else {
253-
path = type.resourceBase + "/" + base.substring("config/".length()) + ".json";
274+
path = type.resourceBase + "/" + base;
254275
}
255-
return new ResourceLocation("config", path);
256276
} else {
257-
path = type.resourceBase + "/" + base + ".json";
277+
if (base.startsWith("builtin/")) {
278+
path = "builtin/" + type.resourceBase + base.substring(slash);
279+
} else if (base.startsWith("sample/")) {
280+
path = "sample/" + type.resourceBase + base.substring(slash);
281+
} else if (base.startsWith("config/")) {
282+
if (type == EType.CONFIG) {
283+
path = base.substring(slash + 1);
284+
} else {
285+
path = type.resourceBase + base.substring(slash);
286+
}
287+
namespace = "config";
288+
} else {
289+
path = type.resourceBase + "/" + base;
290+
}
258291
}
259292

260-
return new ResourceLocation("customloadingscreen", path);
293+
return new ResourceLocation(namespace, path + ".json");
261294
}
262295
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Bug Fixes:
22

3-
* Fix colour handling for non-constant colours.
3+
* Fix non-constant colour handling treating components as either fully bright or off, rather than values ranging from 255 (100% brightness) to 0 (dark).
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Bug Fixes:
2+
3+
* Fix constant colours sometimes not applying properly.
4+
* Add a new function: "translate". This takes 1 string argument, and can be used to localize custom language strings (in addition to tghe built-in ones).
5+
* Print debug information about language paths when loading them.
6+
* Fix a NullPointerException being thrown when json resources aren't found.
7+
* Improve namespace handling for json resources.

0 commit comments

Comments
 (0)