Buckets & entity enhancements, cleanup

This commit is contained in:
paulevsGitch 2021-04-19 21:22:11 +03:00
parent 00fd2b6199
commit 3ec2edd6d5
234 changed files with 1988 additions and 1643 deletions

View file

@ -4,13 +4,15 @@ import java.lang.reflect.Type;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Supplier;
import net.minecraft.util.GsonHelper;
import org.jetbrains.annotations.Nullable;
import com.google.common.collect.Maps;
import com.google.common.reflect.TypeToken;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.util.GsonHelper;
import ru.betterend.util.JsonFactory;
public final class ConfigKeeper {

View file

@ -1,91 +1,93 @@
package ru.betterend.config;
import java.util.function.BiFunction;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.Nullable;
import ru.betterend.config.ConfigKeeper.Entry;
import ru.betterend.config.ConfigKeeper.FloatRange;
import ru.betterend.config.ConfigKeeper.IntegerRange;
public class IdConfig extends Config {
protected final BiFunction<ResourceLocation, String, ConfigKey> keyFactory;
public IdConfig(String group, BiFunction<ResourceLocation, String, ConfigKey> keyFactory) {
super(group);
this.keyFactory = keyFactory;
}
@Override
protected void registerEntries() {}
protected ConfigKey createKey(ResourceLocation id, String key) {
return this.keyFactory.apply(id, key);
}
@Nullable
public <T, E extends Entry<T>> E getEntry(ResourceLocation id, String key, Class<E> type) {
return this.getEntry(createKey(id, key), type);
}
@Nullable
public <T, E extends Entry<T>> T getDefault(ResourceLocation id, String key, Class<E> type) {
return this.getDefault(createKey(id, key), type);
}
public String getString(ResourceLocation id, String key, String defaultValue) {
return this.getString(createKey(id, key), defaultValue);
}
public String getString(ResourceLocation id, String key) {
return this.getString(createKey(id, key));
}
public boolean setString(ResourceLocation id, String key, String value) {
return this.setString(createKey(id, key), value);
}
public int getInt(ResourceLocation id, String key, int defaultValue) {
return this.getInt(createKey(id, key), defaultValue);
}
public int getInt(ResourceLocation id, String key) {
return this.getInt(createKey(id, key));
}
public boolean setInt(ResourceLocation id, String key, int value) {
return this.setInt(createKey(id, key), value);
}
public boolean setRangedInt(ResourceLocation id, String key, int value) {
return this.setRanged(createKey(id, key), value, IntegerRange.class);
}
public boolean setRangedFloat(ResourceLocation id, String key, float value) {
return this.setRanged(createKey(id, key), value, FloatRange.class);
}
public float getFloat(ResourceLocation id, String key, float defaultValue) {
return this.getFloat(createKey(id, key), defaultValue);
}
public float getFloat(ResourceLocation id, String key) {
return this.getFloat(createKey(id, key));
}
public boolean setFloat(ResourceLocation id, String key, float value) {
return this.setFloat(createKey(id, key), value);
}
public boolean getBoolean(ResourceLocation id, String key, boolean defaultValue) {
return this.getBoolean(createKey(id, key), defaultValue);
}
public boolean getBoolean(ResourceLocation id, String key) {
return this.getBoolean(createKey(id, key));
}
public boolean setBoolean(ResourceLocation id, String key, boolean value) {
return this.setBoolean(createKey(id, key), value);
}
}
package ru.betterend.config;
import java.util.function.BiFunction;
import org.jetbrains.annotations.Nullable;
import net.minecraft.resources.ResourceLocation;
import ru.betterend.config.ConfigKeeper.Entry;
import ru.betterend.config.ConfigKeeper.FloatRange;
import ru.betterend.config.ConfigKeeper.IntegerRange;
public class IdConfig extends Config {
protected final BiFunction<ResourceLocation, String, ConfigKey> keyFactory;
public IdConfig(String group, BiFunction<ResourceLocation, String, ConfigKey> keyFactory) {
super(group);
this.keyFactory = keyFactory;
}
@Override
protected void registerEntries() {}
protected ConfigKey createKey(ResourceLocation id, String key) {
return this.keyFactory.apply(id, key);
}
@Nullable
public <T, E extends Entry<T>> E getEntry(ResourceLocation id, String key, Class<E> type) {
return this.getEntry(createKey(id, key), type);
}
@Nullable
public <T, E extends Entry<T>> T getDefault(ResourceLocation id, String key, Class<E> type) {
return this.getDefault(createKey(id, key), type);
}
public String getString(ResourceLocation id, String key, String defaultValue) {
return this.getString(createKey(id, key), defaultValue);
}
public String getString(ResourceLocation id, String key) {
return this.getString(createKey(id, key));
}
public boolean setString(ResourceLocation id, String key, String value) {
return this.setString(createKey(id, key), value);
}
public int getInt(ResourceLocation id, String key, int defaultValue) {
return this.getInt(createKey(id, key), defaultValue);
}
public int getInt(ResourceLocation id, String key) {
return this.getInt(createKey(id, key));
}
public boolean setInt(ResourceLocation id, String key, int value) {
return this.setInt(createKey(id, key), value);
}
public boolean setRangedInt(ResourceLocation id, String key, int value) {
return this.setRanged(createKey(id, key), value, IntegerRange.class);
}
public boolean setRangedFloat(ResourceLocation id, String key, float value) {
return this.setRanged(createKey(id, key), value, FloatRange.class);
}
public float getFloat(ResourceLocation id, String key, float defaultValue) {
return this.getFloat(createKey(id, key), defaultValue);
}
public float getFloat(ResourceLocation id, String key) {
return this.getFloat(createKey(id, key));
}
public boolean setFloat(ResourceLocation id, String key, float value) {
return this.setFloat(createKey(id, key), value);
}
public boolean getBoolean(ResourceLocation id, String key, boolean defaultValue) {
return this.getBoolean(createKey(id, key), defaultValue);
}
public boolean getBoolean(ResourceLocation id, String key) {
return this.getBoolean(createKey(id, key));
}
public boolean setBoolean(ResourceLocation id, String key, boolean value) {
return this.setBoolean(createKey(id, key), value);
}
}