From 0509e018823bc68eed261619cfc9cb3a8685bb5e Mon Sep 17 00:00:00 2001 From: Jakub <53441451+kuba6000@users.noreply.github.com> Date: Sun, 2 Jul 2023 00:07:16 +0200 Subject: Clean up and fixes (#84) * Remove unused mixins * Unused * Unused * Update MobHandlerLoader.java * Fix EEC * Spotless * Update zh_CN.lang * Update dependencies.gradle --- src/main/java/kubatech/api/LoaderReference.java | 2 - .../kubatech/api/helpers/ProgressBarWrapper.java | 75 ------------------- src/main/java/kubatech/api/utils/FastRandom.java | 47 ------------ src/main/java/kubatech/api/utils/GSONUtils.java | 83 ---------------------- 4 files changed, 207 deletions(-) delete mode 100644 src/main/java/kubatech/api/helpers/ProgressBarWrapper.java delete mode 100644 src/main/java/kubatech/api/utils/FastRandom.java delete mode 100644 src/main/java/kubatech/api/utils/GSONUtils.java (limited to 'src/main/java/kubatech/api') diff --git a/src/main/java/kubatech/api/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java index fc736536bc..7bbb1db1ac 100644 --- a/src/main/java/kubatech/api/LoaderReference.java +++ b/src/main/java/kubatech/api/LoaderReference.java @@ -14,11 +14,9 @@ public class LoaderReference { public static final boolean GTNHCoreMod = Loader.isModLoaded("dreamcraft"); public static final boolean GTPlusPlus = Loader.isModLoaded("miscutils"); public static final boolean HarvestCraft = Loader.isModLoaded("harvestcraft"); - public static final boolean TwilightForest = Loader.isModLoaded("TwilightForest"); public static final boolean Forestry = Loader.isModLoaded("Forestry"); public static final boolean DraconicEvolution = Loader.isModLoaded("DraconicEvolution"); public static final boolean Avaritia = Loader.isModLoaded("Avaritia"); public static final boolean ProjRedIllumination = Loader.isModLoaded("ProjRed|Illumination"); public static final boolean RandomThings = Loader.isModLoaded("RandomThings"); - public static final boolean BetterLoadingScreen = Loader.isModLoaded("betterloadingscreen"); } diff --git a/src/main/java/kubatech/api/helpers/ProgressBarWrapper.java b/src/main/java/kubatech/api/helpers/ProgressBarWrapper.java deleted file mode 100644 index 24758565e3..0000000000 --- a/src/main/java/kubatech/api/helpers/ProgressBarWrapper.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * spotless:off - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - * spotless:on - */ - -package kubatech.api.helpers; - -import static kubatech.api.utils.ModUtils.isClientSided; - -import java.io.IOException; - -import alexiil.mods.load.ProgressDisplayer; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.ProgressManager; -import kubatech.Tags; -import kubatech.api.LoaderReference; - -@SuppressWarnings("deprecation") -public class ProgressBarWrapper { - - ProgressManager.ProgressBar internalFMLBar; - boolean isFMLBar; - String name; - int maxSteps; - int steps = 0; - - public ProgressBarWrapper(String name, int steps) { - if (!isClientSided) return; - maxSteps = steps; - this.name = name; - if (!LoaderReference.BetterLoadingScreen) { - internalFMLBar = ProgressManager.push(name, steps); - isFMLBar = true; - return; - } - isFMLBar = false; - } - - public void step(String message) { - if (!isClientSided) return; - if (isFMLBar) internalFMLBar.step(message); - else { - steps++; - try { - ProgressDisplayer - .displayProgress(Tags.MODNAME + ": " + name + " -> " + message, (float) steps / (float) maxSteps); - } catch (IOException e) { - throw new RuntimeException(e); - } - // Prevent game freeze - FMLCommonHandler.instance() - .processWindowMessages(); - } - } - - public void end() { - if (!isClientSided) return; - if (isFMLBar) ProgressManager.pop(internalFMLBar); - } -} diff --git a/src/main/java/kubatech/api/utils/FastRandom.java b/src/main/java/kubatech/api/utils/FastRandom.java deleted file mode 100644 index dd40e92b55..0000000000 --- a/src/main/java/kubatech/api/utils/FastRandom.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * spotless:off - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - * spotless:on - */ - -package kubatech.api.utils; - -import java.util.Random; -import java.util.SplittableRandom; - -public class FastRandom extends Random { - - private SplittableRandom realRandom; - - public FastRandom() { - realRandom = new SplittableRandom(); - } - - public FastRandom(long seed) { - realRandom = new SplittableRandom(seed); - } - - @Override - public synchronized void setSeed(long seed) { - realRandom = new SplittableRandom(seed); - } - - @Override - protected int next(int bits) { - return (realRandom.nextInt() >>> (32 - bits)); - } -} diff --git a/src/main/java/kubatech/api/utils/GSONUtils.java b/src/main/java/kubatech/api/utils/GSONUtils.java deleted file mode 100644 index 01c186a44b..0000000000 --- a/src/main/java/kubatech/api/utils/GSONUtils.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * spotless:off - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2023 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - * spotless:on - */ - -package kubatech.api.utils; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTException; -import net.minecraft.nbt.NBTTagCompound; - -import com.google.gson.ExclusionStrategy; -import com.google.gson.FieldAttributes; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonDeserializer; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializer; - -public class GSONUtils { - - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.FIELD) - public @interface SkipGSON {} - - private static final ExclusionStrategy GSONStrategy = new ExclusionStrategy() { - - @Override - public boolean shouldSkipField(FieldAttributes f) { - return f.getAnnotation(SkipGSON.class) != null; - } - - @Override - public boolean shouldSkipClass(Class clazz) { - return false; - } - }; - - private static final JsonSerializer NBTTagCompoundSerializer = (src, typeOfSrc, - context) -> new JsonPrimitive(src.toString()); - - private static final JsonDeserializer NBTTagCompoundDeserializer = (json, typeOfT, context) -> { - try { - if (!(json instanceof JsonPrimitive)) return null; - if (!((JsonPrimitive) json).isString()) return null; - return (NBTTagCompound) JsonToNBT.func_150315_a(json.getAsString()); - } catch (NBTException e) { - throw new RuntimeException(e); - } - }; - - public static final GsonBuilder GSON_BUILDER = new GsonBuilder().addSerializationExclusionStrategy(GSONStrategy) - .addDeserializationExclusionStrategy(GSONStrategy) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) - .serializeNulls(); - public static final GsonBuilder GSON_BUILDER_PRETTY = new GsonBuilder() - .addSerializationExclusionStrategy(GSONStrategy) - .addDeserializationExclusionStrategy(GSONStrategy) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) - .serializeNulls() - .setPrettyPrinting(); -} -- cgit