Removed deprecated Methods/Classes
This commit is contained in:
parent
907785f2f5
commit
22ae922439
81 changed files with 61 additions and 6277 deletions
|
@ -7,7 +7,6 @@ import net.minecraft.core.BlockPos.MutableBlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.level.ClipContext.Fluid;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -326,17 +325,6 @@ public class BlocksHelper {
|
|||
return state.getFluidState().getType() instanceof LavaFluid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if block is {@link Fluid} or not.
|
||||
*
|
||||
* @param state - {@link BlockState} to check.
|
||||
* @return {@code true} if block is fluid and {@code false} if not.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean isFluidOld(BlockState state) {
|
||||
return !state.getFluidState().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isFluid(BlockState state) {
|
||||
return state.getMaterial().isLiquid();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.ui.ColorUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,165 +0,0 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import com.mojang.blaze3d.platform.NativeImage;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.item.Item;
|
||||
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.impl.client.indigo.renderer.helper.ColorHelper;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class ColorUtil {
|
||||
private static final float[] FLOAT_BUFFER = new float[4];
|
||||
private static final int ALPHA = 255 << 24;
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#color(int, int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int color(int r, int g, int b) {
|
||||
return ALPHA | (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#color(String)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int color(String hex) {
|
||||
int r = Integer.parseInt(hex.substring(0, 2), 16);
|
||||
int g = Integer.parseInt(hex.substring(2, 4), 16);
|
||||
int b = Integer.parseInt(hex.substring(4, 6), 16);
|
||||
return color(r, g, b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toIntArray(int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int[] toIntArray(int color) {
|
||||
return new int[]{(color >> 24) & 255, (color >> 16) & 255, (color >> 8) & 255, color & 255};
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toFloatArray(int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static float[] toFloatArray(int color) {
|
||||
FLOAT_BUFFER[0] = ((color >> 16 & 255) / 255.0F);
|
||||
FLOAT_BUFFER[1] = ((color >> 8 & 255) / 255.0F);
|
||||
FLOAT_BUFFER[2] = ((color & 255) / 255.0F);
|
||||
FLOAT_BUFFER[3] = ((color >> 24 & 255) / 255.0F);
|
||||
|
||||
return FLOAT_BUFFER;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#RGBtoHSB(int, int, int, float[])} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static float[] RGBtoHSB(int r, int g, int b, float[] hsbvals) {
|
||||
return org.betterx.ui.ColorUtil.RGBtoHSB(r, g, b, hsbvals);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#HSBtoRGB(float, float, float)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int HSBtoRGB(float hue, float saturation, float brightness) {
|
||||
return org.betterx.ui.ColorUtil.HSBtoRGB(hue, saturation, brightness);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#parseHex(String)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int parseHex(String hexColor) {
|
||||
return org.betterx.ui.ColorUtil.parseHex(hexColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#toABGR(int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int toABGR(int color) {
|
||||
int r = (color >> 16) & 255;
|
||||
int g = (color >> 8) & 255;
|
||||
int b = color & 255;
|
||||
return 0xFF000000 | b << 16 | g << 8 | r;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#ABGRtoARGB(int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int ABGRtoARGB(int color) {
|
||||
int a = (color >> 24) & 255;
|
||||
int b = (color >> 16) & 255;
|
||||
int g = (color >> 8) & 255;
|
||||
int r = color & 255;
|
||||
return a << 24 | r << 16 | g << 8 | b;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#colorBrigtness(int, float)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int colorBrigtness(int color, float val) {
|
||||
RGBtoHSB((color >> 16) & 255, (color >> 8) & 255, color & 255, FLOAT_BUFFER);
|
||||
FLOAT_BUFFER[2] += val / 10.0F;
|
||||
FLOAT_BUFFER[2] = Mth.clamp(FLOAT_BUFFER[2], 0.0F, 1.0F);
|
||||
return HSBtoRGB(FLOAT_BUFFER[0], FLOAT_BUFFER[1], FLOAT_BUFFER[2]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#applyTint(int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int applyTint(int color, int tint) {
|
||||
return colorBrigtness(ColorHelper.multiplyColor(color, tint), 1.5F);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#colorDistance(int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int colorDistance(int color1, int color2) {
|
||||
int r1 = (color1 >> 16) & 255;
|
||||
int g1 = (color1 >> 8) & 255;
|
||||
int b1 = color1 & 255;
|
||||
int r2 = (color2 >> 16) & 255;
|
||||
int g2 = (color2 >> 8) & 255;
|
||||
int b2 = color2 & 255;
|
||||
return MHelper.sqr(r1 - r2) + MHelper.sqr(g1 - g2) + MHelper.sqr(b1 - b2);
|
||||
}
|
||||
|
||||
private static final Map<ResourceLocation, Integer> colorPalette = Maps.newHashMap();
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#extractColor(Item)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static int extractColor(Item item) {
|
||||
return org.betterx.ui.ColorUtil.extractColor(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.ui.ColorUtil#loadImage(ResourceLocation, int, int)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
@Environment(EnvType.CLIENT)
|
||||
public static NativeImage loadImage(ResourceLocation image, int w, int h) {
|
||||
return org.betterx.ui.ColorUtil.loadImage(image, w, h);
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final class Logger {
|
||||
private static final org.apache.logging.log4j.Logger LOGGER = LogManager.getLogger();
|
||||
private final String modPref;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link org.betterx.worlds.together.util.Logger#Logger(String)} instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public Logger(String modID) {
|
||||
this.modPref = "[" + modID + "] ";
|
||||
}
|
||||
|
||||
public void log(Level level, String message) {
|
||||
LOGGER.log(level, modPref + message);
|
||||
}
|
||||
|
||||
public void log(Level level, String message, Object... params) {
|
||||
LOGGER.log(level, modPref + message, params);
|
||||
}
|
||||
|
||||
public void debug(Object message) {
|
||||
this.log(Level.DEBUG, message.toString());
|
||||
}
|
||||
|
||||
public void debug(Object message, Object... params) {
|
||||
this.log(Level.DEBUG, message.toString(), params);
|
||||
}
|
||||
|
||||
public void catching(Throwable ex) {
|
||||
this.error(ex.getLocalizedMessage());
|
||||
LOGGER.catching(ex);
|
||||
}
|
||||
|
||||
public void info(String message) {
|
||||
this.log(Level.INFO, message);
|
||||
}
|
||||
|
||||
public void info(String message, Object... params) {
|
||||
this.log(Level.INFO, message, params);
|
||||
}
|
||||
|
||||
public void warning(String message, Object... params) {
|
||||
this.log(Level.WARN, message, params);
|
||||
}
|
||||
|
||||
public void warning(String message, Object obj, Exception ex) {
|
||||
LOGGER.warn(modPref + message, obj, ex);
|
||||
}
|
||||
|
||||
public void error(String message) {
|
||||
this.log(Level.ERROR, message);
|
||||
}
|
||||
|
||||
public void error(String message, Object obj, Exception ex) {
|
||||
LOGGER.error(modPref + message, obj, ex);
|
||||
}
|
||||
|
||||
public void error(String message, Exception ex) {
|
||||
LOGGER.error(modPref + message, ex);
|
||||
}
|
||||
}
|
|
@ -19,12 +19,6 @@ public class MethodReplace {
|
|||
MethodReplace.item = item;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void addBlockReplace(Block block, Function<BlockStateBase, Boolean> blockReplace) {
|
||||
MethodReplace.blockReplace = blockReplace;
|
||||
MethodReplace.block = block;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Function<ItemStack, Boolean> getItemReplace(Item item) {
|
||||
if (MethodReplace.item != item) {
|
||||
|
@ -34,15 +28,4 @@ public class MethodReplace {
|
|||
itemReplace = null;
|
||||
return replace;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Deprecated(forRemoval = true)
|
||||
public static Function<BlockStateBase, Boolean> getBlockReplace(Block block) {
|
||||
if (MethodReplace.block != block) {
|
||||
return null;
|
||||
}
|
||||
Function<BlockStateBase, Boolean> replace = blockReplace;
|
||||
blockReplace = null;
|
||||
return replace;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,439 +0,0 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import org.betterx.bclib.BCLib;
|
||||
import org.betterx.worlds.together.WorldsTogether;
|
||||
import org.betterx.worlds.together.util.PathUtil;
|
||||
|
||||
import net.fabricmc.loader.api.*;
|
||||
import net.fabricmc.loader.api.metadata.*;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class ModUtil {
|
||||
private static Map<String, ModInfo> mods;
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#invalidateCachedMods()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void invalidateCachedMods() {
|
||||
mods = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getMods()} ()}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static Map<String, ModInfo> getMods() {
|
||||
if (mods != null) return mods;
|
||||
|
||||
mods = new HashMap<>();
|
||||
PathUtil.fileWalker(PathUtil.MOD_FOLDER.toFile(), false, (ModUtil::accept));
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
||||
private static ModMetadata readJSON(InputStream is, String sourceFile) throws IOException {
|
||||
try (com.google.gson.stream.JsonReader reader = new JsonReader(new InputStreamReader(
|
||||
is,
|
||||
StandardCharsets.UTF_8
|
||||
))) {
|
||||
JsonObject data = JsonParser.parseReader(reader)
|
||||
.getAsJsonObject();
|
||||
Version ver;
|
||||
try {
|
||||
ver = SemanticVersion.parse(data.get("version").getAsString());
|
||||
} catch (VersionParsingException e) {
|
||||
BCLib.LOGGER.error("Unable to parse Version in " + sourceFile);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.get("id") == null) {
|
||||
BCLib.LOGGER.error("Unable to read ID in " + sourceFile);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (data.get("name") == null) {
|
||||
BCLib.LOGGER.error("Unable to read name in " + sourceFile);
|
||||
return null;
|
||||
}
|
||||
|
||||
return new ModMetadata() {
|
||||
@Override
|
||||
public Version getVersion() {
|
||||
return ver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "fabric";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return data.get("id")
|
||||
.getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getProvides() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModEnvironment getEnvironment() {
|
||||
JsonElement env = data.get("environment");
|
||||
if (env == null) {
|
||||
BCLib.LOGGER.warning("No environment specified in " + sourceFile);
|
||||
//return ModEnvironment.UNIVERSAL;
|
||||
}
|
||||
final String environment = env == null ? "" : env.getAsString()
|
||||
.toLowerCase(Locale.ROOT);
|
||||
|
||||
if (environment.isEmpty() || environment.equals("*") || environment.equals("\"*\"") || environment.equals(
|
||||
"common")) {
|
||||
JsonElement entrypoints = data.get("entrypoints");
|
||||
boolean hasClient = true;
|
||||
|
||||
//check if there is an actual client entrypoint
|
||||
if (entrypoints != null && entrypoints.isJsonObject()) {
|
||||
JsonElement client = entrypoints.getAsJsonObject()
|
||||
.get("client");
|
||||
if (client != null && client.isJsonArray()) {
|
||||
hasClient = client.getAsJsonArray()
|
||||
.size() > 0;
|
||||
} else if (client == null || !client.isJsonPrimitive()) {
|
||||
hasClient = false;
|
||||
} else if (!client.getAsJsonPrimitive()
|
||||
.isString()) {
|
||||
hasClient = false;
|
||||
}
|
||||
}
|
||||
|
||||
//if (hasClient == false) return ModEnvironment.SERVER;
|
||||
return ModEnvironment.UNIVERSAL;
|
||||
} else if (environment.equals("client")) {
|
||||
return ModEnvironment.CLIENT;
|
||||
} else if (environment.equals("server")) {
|
||||
return ModEnvironment.SERVER;
|
||||
} else {
|
||||
BCLib.LOGGER.error("Unable to read environment in " + sourceFile);
|
||||
return ModEnvironment.UNIVERSAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ModDependency> getDepends() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ModDependency> getRecommends() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ModDependency> getSuggests() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ModDependency> getConflicts() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ModDependency> getBreaks() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
public Collection<ModDependency> getDependencies() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return data.get("name")
|
||||
.getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Person> getAuthors() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Person> getContributors() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContactInformation getContact() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getLicense() {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> getIconPath(int size) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsCustomValue(String key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomValue getCustomValue(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, CustomValue> getCustomValues() {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsCustomElement(String key) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public JsonElement getCustomElement(String key) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModInfo(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static ModInfo getModInfo(String modID) {
|
||||
return getModInfo(modID, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModInfo(String, boolean)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static ModInfo getModInfo(String modID, boolean matchVersion) {
|
||||
getMods();
|
||||
final ModInfo mi = mods.get(modID);
|
||||
if (mi == null || (matchVersion && !org.betterx.worlds.together.util.ModUtil.getModVersion(modID)
|
||||
.equals(mi.getVersion())))
|
||||
return null;
|
||||
return mi;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModVersion(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String getModVersion(String modID) {
|
||||
if (modID == WorldsTogether.MOD_ID) modID = BCLib.MOD_ID;
|
||||
|
||||
Optional<ModContainer> optional = FabricLoader.getInstance()
|
||||
.getModContainer(modID);
|
||||
if (optional.isPresent()) {
|
||||
ModContainer modContainer = optional.get();
|
||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString(modContainer.getMetadata()
|
||||
.getVersion());
|
||||
|
||||
}
|
||||
|
||||
return org.betterx.worlds.together.util.ModUtil.getModVersionFromJar(modID);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#getModVersionFromJar(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String getModVersionFromJar(String modID) {
|
||||
final ModInfo mi = getModInfo(modID, false);
|
||||
if (mi != null) return mi.getVersion();
|
||||
|
||||
return "0.0.0";
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#convertModVersion(String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static int convertModVersion(String version) {
|
||||
if (version.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
int res = 0;
|
||||
final String semanticVersionPattern = "(\\d+)\\.(\\d+)(\\.(\\d+))?\\D*";
|
||||
final Matcher matcher = Pattern.compile(semanticVersionPattern)
|
||||
.matcher(version);
|
||||
if (matcher.find()) {
|
||||
if (matcher.groupCount() > 0)
|
||||
res = matcher.group(1) == null ? 0 : ((Integer.parseInt(matcher.group(1)) & 0xFF) << 22);
|
||||
if (matcher.groupCount() > 1)
|
||||
res |= matcher.group(2) == null ? 0 : ((Integer.parseInt(matcher.group(2)) & 0xFF) << 14);
|
||||
if (matcher.groupCount() > 3)
|
||||
res |= matcher.group(4) == null ? 0 : Integer.parseInt(matcher.group(4)) & 0x3FFF;
|
||||
}
|
||||
|
||||
return res;
|
||||
} catch (Exception e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#convertModVersion(int)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String convertModVersion(int version) {
|
||||
int a = (version >> 22) & 0xFF;
|
||||
int b = (version >> 14) & 0xFF;
|
||||
int c = version & 0x3FFF;
|
||||
return String.format(Locale.ROOT, "%d.%d.%d", a, b, c);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#isLargerVersion(String, String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean isLargerVersion(String v1, String v2) {
|
||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(v1) > org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
||||
v2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil#isLargerOrEqualVersion(String, String)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean isLargerOrEqualVersion(String v1, String v2) {
|
||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(v1) >= org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
||||
v2);
|
||||
}
|
||||
|
||||
private static void accept(Path file) {
|
||||
try {
|
||||
URI uri = URI.create("jar:" + file.toUri());
|
||||
|
||||
FileSystem fs;
|
||||
// boolean doClose = false;
|
||||
try {
|
||||
fs = FileSystems.getFileSystem(uri);
|
||||
} catch (Exception e) {
|
||||
// doClose = true;
|
||||
fs = FileSystems.newFileSystem(file);
|
||||
}
|
||||
if (fs != null) {
|
||||
try {
|
||||
Path modMetaFile = fs.getPath("fabric.mod.json");
|
||||
if (modMetaFile != null) {
|
||||
try (InputStream is = Files.newInputStream(modMetaFile)) {
|
||||
//ModMetadata mc = ModMetadataParser.parseMetadata(is, uri.toString(), new LinkedList<String>());
|
||||
ModMetadata mc = readJSON(is, uri.toString());
|
||||
if (mc != null) {
|
||||
mods.put(mc.getId(), new ModInfo(mc, file));
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Error for " + uri + ": " + e);
|
||||
}
|
||||
//if (doClose) fs.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
BCLib.LOGGER.error("Error for " + file.toUri() + ": " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static class ModInfo {
|
||||
public final ModMetadata metadata;
|
||||
public final Path jarPath;
|
||||
|
||||
ModInfo(ModMetadata metadata, Path jarPath) {
|
||||
this.metadata = metadata;
|
||||
this.jarPath = jarPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo#versionToString(Version)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String versionToString(Version v) {
|
||||
if (v instanceof SemanticVersion) {
|
||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString((SemanticVersion) v);
|
||||
}
|
||||
return org.betterx.worlds.together.util.ModUtil.convertModVersion(
|
||||
org.betterx.worlds.together.util.ModUtil.convertModVersion(v.toString())
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link org.betterx.worlds.together.util.ModUtil.ModInfo#versionToString(SemanticVersion)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String versionToString(SemanticVersion v) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
boolean first = true;
|
||||
final int cCount = Math.min(v.getVersionComponentCount(), 3);
|
||||
for (int i = 0; i < cCount; i++) {
|
||||
if (first) {
|
||||
first = false;
|
||||
} else {
|
||||
stringBuilder.append('.');
|
||||
}
|
||||
|
||||
stringBuilder.append(v.getVersionComponent(i));
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ModInfo{" + "id=" + metadata.getId() + ", version=" + metadata.getVersion() + ", jarPath=" + jarPath + '}';
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
if (metadata == null) {
|
||||
return "0.0.0";
|
||||
}
|
||||
return org.betterx.worlds.together.util.ModUtil.ModInfo.versionToString(metadata.getVersion());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package org.betterx.bclib.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public class PathUtil {
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#GAME_FOLDER}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final static Path GAME_FOLDER = org.betterx.worlds.together.util.PathUtil.GAME_FOLDER;
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#MOD_FOLDER}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final static Path MOD_FOLDER = org.betterx.worlds.together.util.PathUtil.MOD_FOLDER;
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#MOD_BAK_FOLDER}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public final static Path MOD_BAK_FOLDER = org.betterx.worlds.together.util.PathUtil.MOD_BAK_FOLDER;
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#isChildOf(Path, Path)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static boolean isChildOf(Path parent, Path child) {
|
||||
return org.betterx.worlds.together.util.PathUtil.isChildOf(parent, child);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#fileWalker(File, Consumer)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void fileWalker(File path, Consumer<Path> pathConsumer) {
|
||||
org.betterx.worlds.together.util.PathUtil.fileWalker(path, pathConsumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#fileWalker(File, boolean, Consumer)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static void fileWalker(File path, boolean recursive, Consumer<Path> pathConsumer) {
|
||||
org.betterx.worlds.together.util.PathUtil.fileWalker(path, recursive, pathConsumer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated replaced by {@link org.betterx.worlds.together.util.PathUtil#humanReadableFileSize(long)}
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String humanReadableFileSize(long size) {
|
||||
return org.betterx.worlds.together.util.PathUtil.humanReadableFileSize(size);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue