mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-16 11:54:52 +00:00
code cleanup
This commit is contained in:
76 files changed
+691
-622
No files matched your search
+23
-15
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2022 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
@@ -73,7 +73,7 @@ import java.util.function.BiConsumer;
|
||||
/**
|
||||
* The actual implementation of ConfigurationManager. Migrated stuff here so that we don't unnecessarily expose
|
||||
* internal-use functionality.
|
||||
*
|
||||
* <p>
|
||||
* Do not read if you value your sanity.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@@ -116,7 +116,8 @@ public class ConfigurationManagerImpl {
|
||||
parsedConfigMap.get(configClass).save();
|
||||
}
|
||||
|
||||
public static boolean validateFields(BiConsumer<Class<?>, Field> invalidFieldHandler, Class<?> configClass, boolean resetInvalid) throws ConfigException {
|
||||
public static boolean validateFields(BiConsumer<Class<?>, Field> invalidFieldHandler, Class<?> configClass, boolean resetInvalid)
|
||||
throws ConfigException {
|
||||
if (!parsedConfigMap.containsKey(configClass)) {
|
||||
throw new ConfigException("Class " + configClass.getName() + " is not a registered configuration!");
|
||||
}
|
||||
@@ -133,13 +134,13 @@ public class ConfigurationManagerImpl {
|
||||
|
||||
public static void sendRequest(DataOutput output) throws IOException {
|
||||
val synced = new ArrayList<Class<?>>();
|
||||
for (val entry: parsedConfigMap.entrySet()) {
|
||||
for (val entry : parsedConfigMap.entrySet()) {
|
||||
if (entry.getValue().sync) {
|
||||
synced.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
output.writeInt(synced.size());
|
||||
for (val clazz: synced) {
|
||||
for (val clazz : synced) {
|
||||
output.writeUTF(clazz.getName());
|
||||
}
|
||||
}
|
||||
@@ -151,7 +152,7 @@ public class ConfigurationManagerImpl {
|
||||
for (int i = 0; i < count; i++) {
|
||||
classNames.add(input.readUTF());
|
||||
}
|
||||
for (val entry: parsedConfigMap.keySet()) {
|
||||
for (val entry : parsedConfigMap.keySet()) {
|
||||
if (classNames.contains(entry.getName())) {
|
||||
result.add(entry);
|
||||
}
|
||||
@@ -161,13 +162,13 @@ public class ConfigurationManagerImpl {
|
||||
|
||||
public static void sendReply(DataOutput output, List<Class<?>> requestedClasses) throws IOException {
|
||||
val syncEntries = new HashMap<>(parsedConfigMap);
|
||||
for (val entry: parsedConfigMap.entrySet()) {
|
||||
for (val entry : parsedConfigMap.entrySet()) {
|
||||
if (!entry.getValue().sync || !requestedClasses.contains(entry.getKey())) {
|
||||
syncEntries.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
output.writeInt(syncEntries.size());
|
||||
for (val entry: syncEntries.entrySet()) {
|
||||
for (val entry : syncEntries.entrySet()) {
|
||||
output.writeUTF(entry.getKey().getName());
|
||||
val b = new ByteArrayOutputStream();
|
||||
val bo = new DataOutputStream(b);
|
||||
@@ -187,7 +188,8 @@ public class ConfigurationManagerImpl {
|
||||
for (int i = 0; i < count; i++) {
|
||||
String className = input.readUTF();
|
||||
int dataSize = input.readInt();
|
||||
val opt = parsedConfigMap.keySet().stream().filter((clazz) -> clazz.getName().equals(className)).findFirst();
|
||||
val opt =
|
||||
parsedConfigMap.keySet().stream().filter((clazz) -> clazz.getName().equals(className)).findFirst();
|
||||
if (!opt.isPresent()) {
|
||||
input.skipBytes(dataSize);
|
||||
FalsePatternLib.getLog().warn("Server tried to sync config not registered on our side: " + className);
|
||||
@@ -197,7 +199,9 @@ public class ConfigurationManagerImpl {
|
||||
val config = parsedConfigMap.get(clazz);
|
||||
if (!config.sync) {
|
||||
input.skipBytes(dataSize);
|
||||
FalsePatternLib.getLog().warn("Server tried to sync config without @Synchronize annotation on our side: " + className);
|
||||
FalsePatternLib.getLog()
|
||||
.warn("Server tried to sync config without @Synchronize annotation on our side: " +
|
||||
className);
|
||||
continue;
|
||||
}
|
||||
if (!ConfigSyncEvent.postStart(clazz)) {
|
||||
@@ -223,11 +227,11 @@ public class ConfigurationManagerImpl {
|
||||
|
||||
public static void loadRawConfig(Configuration rawConfig) throws ConfigException {
|
||||
rawConfig.load();
|
||||
for (val configClass: configToClassMap.get(rawConfig)) {
|
||||
for (val configClass : configToClassMap.get(rawConfig)) {
|
||||
val config = parsedConfigMap.get(configClass);
|
||||
try {
|
||||
config.reloadFields();
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ConfigException(e);
|
||||
}
|
||||
}
|
||||
@@ -296,7 +300,7 @@ public class ConfigurationManagerImpl {
|
||||
return;
|
||||
}
|
||||
val configClasses = configToClassMap.get(rawConfig);
|
||||
for (val clazz: configClasses) {
|
||||
for (val clazz : configClasses) {
|
||||
val config = parsedConfigMap.get(clazz);
|
||||
config.configChanged();
|
||||
}
|
||||
@@ -323,12 +327,16 @@ public class ConfigurationManagerImpl {
|
||||
val cfg = e.configClass.getAnnotation(Config.class);
|
||||
if (e.successful) {
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
FormattedText.parse(EnumChatFormatting.GREEN + "Synced config").toChatText().get(0),
|
||||
FormattedText.parse(EnumChatFormatting.GREEN + "Synced config")
|
||||
.toChatText()
|
||||
.get(0),
|
||||
FormattedText.parse(cfg.modid() + ":" + cfg.category()).toChatText().get(0),
|
||||
false, 5000));
|
||||
} else {
|
||||
GuiToast.add(new SimpleToast(ToastBG.TOAST_DARK, null,
|
||||
FormattedText.parse(EnumChatFormatting.RED + "Failed to sync config").toChatText().get(0),
|
||||
FormattedText.parse(EnumChatFormatting.RED + "Failed to sync config")
|
||||
.toChatText()
|
||||
.get(0),
|
||||
FormattedText.parse(cfg.modid() + ":" + cfg.category()).toChatText().get(0),
|
||||
false, 5000));
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2022 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
@@ -38,7 +38,6 @@ import lombok.val;
|
||||
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
import java.io.DataInput;
|
||||
@@ -57,15 +56,6 @@ import java.util.function.BiConsumer;
|
||||
public class ParsedConfiguration {
|
||||
private static final Field propField;
|
||||
|
||||
public final Class<?> configClass;
|
||||
public final String modid;
|
||||
public final String category;
|
||||
public final Configuration rawConfig;
|
||||
public final boolean sync;
|
||||
private final Map<String, AConfigField<?>> fields = new HashMap<>();
|
||||
private final Map<String, ConfigElement<?>> elements = new HashMap<>();
|
||||
private int maxFieldNameLength;
|
||||
|
||||
static {
|
||||
try {
|
||||
propField = ConfigElement.class.getDeclaredField("prop");
|
||||
@@ -75,6 +65,15 @@ public class ParsedConfiguration {
|
||||
ReflectionUtil.jailBreak(propField);
|
||||
}
|
||||
|
||||
public final Class<?> configClass;
|
||||
public final String modid;
|
||||
public final String category;
|
||||
public final Configuration rawConfig;
|
||||
public final boolean sync;
|
||||
private final Map<String, AConfigField<?>> fields = new HashMap<>();
|
||||
private final Map<String, ConfigElement<?>> elements = new HashMap<>();
|
||||
private int maxFieldNameLength;
|
||||
|
||||
public static ParsedConfiguration parseConfig(Class<?> configClass) throws ConfigException {
|
||||
val cfg = Optional.ofNullable(configClass.getAnnotation(Config.class))
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
@@ -84,10 +83,11 @@ public class ParsedConfiguration {
|
||||
.orElseThrow(() -> new ConfigException(
|
||||
"Config class " + configClass.getName() + " has an empty category!"));
|
||||
val rawConfig = ConfigurationManagerImpl.getForgeConfig(cfg.modid());
|
||||
val parsedConfig = new ParsedConfiguration(configClass, cfg.modid(), category, rawConfig, configClass.isAnnotationPresent(Config.Synchronize.class));
|
||||
val parsedConfig = new ParsedConfiguration(configClass, cfg.modid(), category, rawConfig,
|
||||
configClass.isAnnotationPresent(Config.Synchronize.class));
|
||||
try {
|
||||
parsedConfig.reloadFields();
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new ConfigException(e);
|
||||
}
|
||||
return parsedConfig;
|
||||
@@ -102,7 +102,7 @@ public class ParsedConfiguration {
|
||||
|
||||
//Happens when changed through the gui
|
||||
public void configChanged() {
|
||||
for (val field: fields.values()) {
|
||||
for (val field : fields.values()) {
|
||||
field.load();
|
||||
}
|
||||
rawConfig.save();
|
||||
@@ -110,7 +110,7 @@ public class ParsedConfiguration {
|
||||
|
||||
public void load() throws ConfigException {
|
||||
ConfigurationManagerImpl.loadRawConfig(rawConfig);
|
||||
for (val field: fields.values()) {
|
||||
for (val field : fields.values()) {
|
||||
field.load();
|
||||
}
|
||||
}
|
||||
@@ -118,15 +118,17 @@ public class ParsedConfiguration {
|
||||
public void receive(DataInput input) throws IOException {
|
||||
if (sync) {
|
||||
val syncFields = new HashMap<>(fields);
|
||||
for (val key: fields.keySet()) {
|
||||
for (val key : fields.keySet()) {
|
||||
if (syncFields.get(key).noSync) {
|
||||
syncFields.remove(key);
|
||||
}
|
||||
}
|
||||
while (syncFields.size() > 0) {
|
||||
val fieldName = StringConfigField.receiveString(input, maxFieldNameLength, "field name", configClass.getName());
|
||||
val fieldName =
|
||||
StringConfigField.receiveString(input, maxFieldNameLength, "field name", configClass.getName());
|
||||
if (!syncFields.containsKey(fieldName)) {
|
||||
throw new IOException("Invalid sync field name received: " + fieldName + " for config class " + configClass.getName());
|
||||
throw new IOException("Invalid sync field name received: " + fieldName + " for config class " +
|
||||
configClass.getName());
|
||||
}
|
||||
syncFields.remove(fieldName).receive(input);
|
||||
}
|
||||
@@ -136,19 +138,19 @@ public class ParsedConfiguration {
|
||||
public void transmit(DataOutput output) throws IOException {
|
||||
if (sync) {
|
||||
val syncFields = new HashMap<>(fields);
|
||||
for (val key: fields.keySet()) {
|
||||
for (val key : fields.keySet()) {
|
||||
if (syncFields.get(key).noSync) {
|
||||
syncFields.remove(key);
|
||||
}
|
||||
}
|
||||
for (val field: syncFields.entrySet()) {
|
||||
for (val field : syncFields.entrySet()) {
|
||||
StringConfigField.transmitString(output, field.getKey());
|
||||
field.getValue().transmit(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadFields() throws ConfigException, NoSuchFieldException, IllegalAccessException {
|
||||
public void reloadFields() throws ConfigException, IllegalAccessException {
|
||||
fields.clear();
|
||||
maxFieldNameLength = 0;
|
||||
val cat = rawConfig.getCategory(category);
|
||||
@@ -209,7 +211,7 @@ public class ParsedConfiguration {
|
||||
|
||||
public boolean validate(BiConsumer<Class<?>, Field> invalidFieldHandler, boolean resetInvalid) {
|
||||
boolean valid = true;
|
||||
for (val field: fields.values()) {
|
||||
for (val field : fields.values()) {
|
||||
if (!field.validateField()) {
|
||||
if (resetInvalid) {
|
||||
field.setToDefault();
|
||||
|
||||
@@ -102,6 +102,7 @@ public abstract class AConfigField<T> {
|
||||
return property;
|
||||
}
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public abstract boolean validateField();
|
||||
|
||||
public abstract void transmit(DataOutput output) throws IOException;
|
||||
|
||||
+2
-1
@@ -112,7 +112,8 @@ public class DoubleConfigField extends AConfigField<Double> {
|
||||
if (value >= min && value <= max) {
|
||||
return true;
|
||||
}
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Double.toString(value), Double.toString(min), Double.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Double.toString(value),
|
||||
Double.toString(min), Double.toString(max));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -107,7 +107,8 @@ public class DoubleListConfigField extends AListConfigField<double[]> {
|
||||
for (int j = 0; j < doubles.length; j++) {
|
||||
double d = doubles[j];
|
||||
if (d < min || d > max) {
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Double.toString(d), Double.toString(min), Double.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Double.toString(d),
|
||||
Double.toString(min), Double.toString(max));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,9 @@ public class EnumConfigField<T extends Enum<T>> extends AConfigField<T> {
|
||||
.stream()
|
||||
.filter((e) -> e.name().equals(defName))
|
||||
.findAny()
|
||||
.orElseThrow(() -> new IllegalArgumentException("Default value \"" + defName + "\" was not found in enum " + enumClass.getName())))
|
||||
.orElseThrow(() -> new IllegalArgumentException(
|
||||
"Default value \"" + defName +
|
||||
"\" was not found in enum " + enumClass.getName())))
|
||||
.orElseGet(() -> {
|
||||
FalsePatternLib.getLog()
|
||||
.warn("The field " + field.getName() + " in class " +
|
||||
|
||||
+2
-1
@@ -118,7 +118,8 @@ public class FloatConfigField extends AConfigField<Float> {
|
||||
if (value >= min && value <= max) {
|
||||
return true;
|
||||
}
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Float.toString(value), Float.toString(min), Float.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Float.toString(value),
|
||||
Float.toString(min), Float.toString(max));
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
|
||||
@@ -112,7 +112,8 @@ public class IntConfigField extends AConfigField<Integer> {
|
||||
if (value >= min && value <= max) {
|
||||
return true;
|
||||
}
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Integer.toString(value), Integer.toString(min), Integer.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, -1, Integer.toString(value),
|
||||
Integer.toString(min), Integer.toString(max));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -107,7 +107,8 @@ public class IntListConfigField extends AListConfigField<int[]> {
|
||||
for (int j = 0; j < ints.length; j++) {
|
||||
int i = ints[j];
|
||||
if (i < min || i > max) {
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Integer.toString(i), Integer.toString(min), Integer.toString(max));
|
||||
ConfigValidationFailureEvent.postNumericRangeOutOfBounds(field, j, Integer.toString(i),
|
||||
Integer.toString(min), Integer.toString(max));
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
+32
-30
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/*
|
||||
* Copyright (C) 2022 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
@@ -24,8 +24,8 @@ import com.falsepattern.lib.dependencies.DependencyLoader;
|
||||
import com.falsepattern.lib.dependencies.Version;
|
||||
import com.falsepattern.lib.internal.FalsePatternLib;
|
||||
import com.falsepattern.lib.internal.Internet;
|
||||
import com.falsepattern.lib.internal.config.LibraryConfig;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.config.LibraryConfig;
|
||||
import com.falsepattern.lib.util.FileUtil;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -66,11 +66,9 @@ public class DependencyLoaderImpl {
|
||||
mavenRepositories.add(url);
|
||||
}
|
||||
|
||||
public static void loadLibrary(@NonNull String loadingModId, @NonNull String groupId, @NonNull String artifactId,
|
||||
@NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion,
|
||||
String regularSuffix, String devSuffix) {
|
||||
new DependencyLoadTask(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion, regularSuffix, devSuffix)
|
||||
.load();
|
||||
public static void loadLibrary(@NonNull String loadingModId, @NonNull String groupId, @NonNull String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String regularSuffix, String devSuffix) {
|
||||
new DependencyLoadTask(loadingModId, groupId, artifactId, minVersion, maxVersion, preferredVersion,
|
||||
regularSuffix, devSuffix).load();
|
||||
}
|
||||
|
||||
private static String bytesToHex(byte[] hash) {
|
||||
@@ -188,8 +186,8 @@ public class DependencyLoaderImpl {
|
||||
|
||||
private void setupLibraryNames() {
|
||||
suffix = FalsePatternLib.isDeveloperEnvironment() ? devSuffix : regularSuffix;
|
||||
artifactLogName =
|
||||
String.format("%s:%s:%s%s", groupId, artifactId, preferredVersion, suffix != null ? "-" + suffix : "");
|
||||
artifactLogName = String.format("%s:%s:%s%s", groupId, artifactId, preferredVersion,
|
||||
suffix != null ? "-" + suffix : "");
|
||||
log.info("Adding library {}, requested by mod {}", artifactLogName, loadingModId);
|
||||
artifact = groupId + ":" + artifactId + ":" + suffix;
|
||||
}
|
||||
@@ -230,8 +228,8 @@ public class DependencyLoaderImpl {
|
||||
}
|
||||
}
|
||||
val modsDir = Paths.get(homeDir, "mods").toFile();
|
||||
mavenJarName = String.format("%s-%s%s.jar", artifactId, preferredVersion,
|
||||
(suffix != null) ? ("-" + suffix) : "");
|
||||
mavenJarName =
|
||||
String.format("%s-%s%s.jar", artifactId, preferredVersion, (suffix != null) ? ("-" + suffix) : "");
|
||||
jarName = groupId + "-" + mavenJarName;
|
||||
libDir = new File(modsDir, "falsepattern");
|
||||
if (!libDir.exists()) {
|
||||
@@ -244,7 +242,9 @@ public class DependencyLoaderImpl {
|
||||
}
|
||||
|
||||
private boolean tryLoadingExistingFile() {
|
||||
if (!file.exists()) return false;
|
||||
if (!file.exists()) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
addToClasspath(file);
|
||||
loadedLibraries.put(artifact, preferredVersion);
|
||||
@@ -273,8 +273,8 @@ public class DependencyLoaderImpl {
|
||||
if (!repo.endsWith("/")) {
|
||||
repo = repo + "/";
|
||||
}
|
||||
val url = String.format("%s%s/%s/%s/%s", repo, groupId.replace('.', '/'), artifactId,
|
||||
preferredVersion, mavenJarName);
|
||||
val url = String.format("%s%s/%s/%s/%s", repo, groupId.replace('.', '/'), artifactId, preferredVersion,
|
||||
mavenJarName);
|
||||
String finalRepo = repo;
|
||||
int retryCount = 0;
|
||||
while (true) {
|
||||
@@ -283,14 +283,14 @@ public class DependencyLoaderImpl {
|
||||
break;
|
||||
}
|
||||
val success = new AtomicBoolean(false);
|
||||
Internet.connect(new URL(url), (ex) -> log.debug("Artifact {} could not be downloaded from repo {}: {}",
|
||||
artifactLogName, finalRepo, ex.getMessage()),
|
||||
(input) -> {
|
||||
log.debug("Downloading {} from {}", artifactLogName, finalRepo);
|
||||
download(input, file);
|
||||
log.debug("Downloaded {} from {}", artifactLogName, finalRepo);
|
||||
success.set(true);
|
||||
});
|
||||
Internet.connect(new URL(url),
|
||||
(ex) -> log.debug("Artifact {} could not be downloaded from repo {}: {}",
|
||||
artifactLogName, finalRepo, ex.getMessage()), (input) -> {
|
||||
log.debug("Downloading {} from {}", artifactLogName, finalRepo);
|
||||
download(input, file);
|
||||
log.debug("Downloaded {} from {}", artifactLogName, finalRepo);
|
||||
success.set(true);
|
||||
});
|
||||
if (success.get()) {
|
||||
log.debug("Validating checksum for {}", artifactLogName);
|
||||
val hadChecksum = validateChecksum(url);
|
||||
@@ -322,13 +322,13 @@ public class DependencyLoaderImpl {
|
||||
log.debug("Attempting to get {} checksum...", checksumType);
|
||||
val success = new AtomicBoolean(false);
|
||||
Internet.connect(new URL(checksumURL),
|
||||
(ex) -> log.debug("Could not get {} checksum for {}: {}", checksumType, artifactLogName, ex.getMessage()),
|
||||
(input) -> {
|
||||
log.debug("Downloading {} checksum for {}", checksumType, artifactLogName);
|
||||
download(input, checksumFile);
|
||||
log.debug("Downloaded {} checksum for {}", checksumType, artifactLogName);
|
||||
success.set(true);
|
||||
});
|
||||
(ex) -> log.debug("Could not get {} checksum for {}: {}", checksumType,
|
||||
artifactLogName, ex.getMessage()), (input) -> {
|
||||
log.debug("Downloading {} checksum for {}", checksumType, artifactLogName);
|
||||
download(input, checksumFile);
|
||||
log.debug("Downloaded {} checksum for {}", checksumType, artifactLogName);
|
||||
success.set(true);
|
||||
});
|
||||
if (success.get()) {
|
||||
val fileHash = hash(checksumType, file);
|
||||
val referenceHash = new String(Files.readAllBytes(checksumFile.toPath()));
|
||||
@@ -347,7 +347,9 @@ public class DependencyLoaderImpl {
|
||||
}
|
||||
|
||||
private enum ChecksumStatus {
|
||||
OK, FAILED, MISSING
|
||||
OK,
|
||||
FAILED,
|
||||
MISSING
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.impl.toast;
|
||||
|
||||
import com.falsepattern.lib.internal.config.LibraryConfig;
|
||||
import com.falsepattern.lib.internal.config.ToastConfig;
|
||||
import com.falsepattern.lib.toasts.IToast;
|
||||
import com.falsepattern.lib.util.MathUtil;
|
||||
@@ -45,10 +44,14 @@ import java.util.Deque;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiToastImpl extends Gui {
|
||||
private static GuiToastImpl instance;
|
||||
private final Minecraft mc;
|
||||
private final Deque<IToast> toastsQueue = Queues.newArrayDeque();
|
||||
private ToastInstance<?>[] visible = new ToastInstance[0];
|
||||
private static GuiToastImpl instance;
|
||||
|
||||
public GuiToastImpl(Minecraft mcIn) {
|
||||
this.mc = mcIn;
|
||||
}
|
||||
|
||||
public static void initialize(Minecraft mc) {
|
||||
if (instance != null) {
|
||||
@@ -64,7 +67,7 @@ public class GuiToastImpl extends Gui {
|
||||
|
||||
@SubscribeEvent
|
||||
public void updateToasts(TickEvent.RenderTickEvent event) {
|
||||
if ( event.phase != TickEvent.Phase.END) {
|
||||
if (event.phase != TickEvent.Phase.END) {
|
||||
return;
|
||||
}
|
||||
mc.mcProfiler.startSection("toasts");
|
||||
@@ -72,11 +75,6 @@ public class GuiToastImpl extends Gui {
|
||||
mc.mcProfiler.endSection();
|
||||
}
|
||||
|
||||
|
||||
public GuiToastImpl(Minecraft mcIn) {
|
||||
this.mc = mcIn;
|
||||
}
|
||||
|
||||
public void drawToast(ScaledResolution resolution) {
|
||||
if (!this.mc.gameSettings.hideGUI) {
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
@@ -168,9 +166,7 @@ public class GuiToastImpl extends Gui {
|
||||
GL11.glPushMatrix();
|
||||
val shift = toast.width() * getVisibility(sysTime);
|
||||
val X = ToastConfig.leftAlign() ? shift - toast.width() : x - shift;
|
||||
GL11.glTranslatef(X,
|
||||
(float) (y * 32) + ToastConfig.Y_OFFSET,
|
||||
(float) (500 + y));
|
||||
GL11.glTranslatef(X, (float) (y * 32) + ToastConfig.Y_OFFSET, (float) (500 + y));
|
||||
val visibility = this.toast.draw(GuiToastImpl.this, sysTime - this.visibleTime);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
Reference in new issue
Block a user