diff options
author | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
---|---|---|
committer | Jason Mitchell <mitchej@gmail.com> | 2023-01-28 19:03:53 -0800 |
commit | f51616bda220887fdd45c4bc951ff59e3398213a (patch) | |
tree | 35fdbb15b4c7ea0282773a388eff517a1d09d941 /src/main/java/kubatech/api | |
parent | 11216d666cbc30fc1e1dfc84e1e0c2f4252b1fc2 (diff) | |
download | GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.gz GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.tar.bz2 GT5-Unofficial-f51616bda220887fdd45c4bc951ff59e3398213a.zip |
[ci skip] spotlessApply with the new settings
Diffstat (limited to 'src/main/java/kubatech/api')
19 files changed, 254 insertions, 373 deletions
diff --git a/src/main/java/kubatech/api/ConstructableItemStack.java b/src/main/java/kubatech/api/ConstructableItemStack.java index 0d03fc5fd2..0d80076760 100644 --- a/src/main/java/kubatech/api/ConstructableItemStack.java +++ b/src/main/java/kubatech/api/ConstructableItemStack.java @@ -1,42 +1,36 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api; -import cpw.mods.fml.common.registry.GameRegistry; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import java.nio.charset.StandardCharsets; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTSizeTracker; import net.minecraft.nbt.NBTTagCompound; +import cpw.mods.fml.common.registry.GameRegistry; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + public class ConstructableItemStack { + public final GameRegistry.UniqueIdentifier itemIdentifier; public final int meta; public final int size; public final NBTTagCompound tagCompound; - private ConstructableItemStack( - GameRegistry.UniqueIdentifier itemIdentifier, int meta, int size, NBTTagCompound tagCompound) { + private ConstructableItemStack(GameRegistry.UniqueIdentifier itemIdentifier, int meta, int size, + NBTTagCompound tagCompound) { this.itemIdentifier = itemIdentifier; this.meta = meta; this.size = size; @@ -107,10 +101,12 @@ public class ConstructableItemStack { byteBuf.readBytes(bytes); try { nbtTagCompound = CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L)); - } catch (Exception ignored) { - } + } catch (Exception ignored) {} } return new ConstructableItemStack( - new GameRegistry.UniqueIdentifier(modid + ":" + name), meta, stacksize, nbtTagCompound); + new GameRegistry.UniqueIdentifier(modid + ":" + name), + meta, + stacksize, + nbtTagCompound); } } diff --git a/src/main/java/kubatech/api/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java index 3215fa1b21..5ae387ed63 100644 --- a/src/main/java/kubatech/api/LoaderReference.java +++ b/src/main/java/kubatech/api/LoaderReference.java @@ -3,6 +3,7 @@ package kubatech.api; import cpw.mods.fml.common.Loader; public class LoaderReference { + public static final boolean BloodMagic = Loader.isModLoaded("AWWayofTime"); public static final boolean EnderIO = Loader.isModLoaded("EnderIO"); public static final boolean ExtraUtilities = Loader.isModLoaded("ExtraUtilities"); diff --git a/src/main/java/kubatech/api/Variables.java b/src/main/java/kubatech/api/Variables.java index 0f07c48324..bc67003a68 100644 --- a/src/main/java/kubatech/api/Variables.java +++ b/src/main/java/kubatech/api/Variables.java @@ -1,30 +1,23 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api; import kubatech.api.utils.StringUtils; + import net.minecraft.util.EnumChatFormatting; public class Variables { - public static final String Author = - "Author: " + StringUtils.applyRainbow("kuba6000", 0, EnumChatFormatting.BOLD.toString()); + + public static final String Author = "Author: " + + StringUtils.applyRainbow("kuba6000", 0, EnumChatFormatting.BOLD.toString()); public static String buildAuthorList(String... authors) { if (authors.length == 0) return "Author: Unknown"; @@ -32,17 +25,19 @@ public class Variables { .append(StringUtils.applyRainbow(authors[0], 0, EnumChatFormatting.BOLD.toString())); for (int i = 1; i < authors.length; i++) { String author = authors[i]; - b.append(EnumChatFormatting.RESET) - .append(" & ") - .append(EnumChatFormatting.GOLD) - .append(author); + b.append(EnumChatFormatting.RESET).append(" & ").append(EnumChatFormatting.GOLD).append(author); } return b.toString(); } - public static final String StructureHologram = - "To see the structure, use a " + EnumChatFormatting.BLUE + "Tec" + EnumChatFormatting.DARK_BLUE + "Tech" - + EnumChatFormatting.RESET + "" + EnumChatFormatting.GRAY + " Blueprint on the Controller!"; + public static final String StructureHologram = "To see the structure, use a " + EnumChatFormatting.BLUE + + "Tec" + + EnumChatFormatting.DARK_BLUE + + "Tech" + + EnumChatFormatting.RESET + + "" + + EnumChatFormatting.GRAY + + " Blueprint on the Controller!"; public static final double ln4 = Math.log(4d); public static final double ln2 = Math.log(2d); diff --git a/src/main/java/kubatech/api/enums/ItemList.java b/src/main/java/kubatech/api/enums/ItemList.java index b92dead10e..426cac0df5 100644 --- a/src/main/java/kubatech/api/enums/ItemList.java +++ b/src/main/java/kubatech/api/enums/ItemList.java @@ -3,17 +3,20 @@ package kubatech.api.enums; import static gregtech.api.enums.GT_Values.NI; import static gregtech.api.enums.GT_Values.W; +import java.util.Locale; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; + import gregtech.api.interfaces.IItemContainer; import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import java.util.Locale; -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; public enum ItemList implements IItemContainer { + ExtremeExterminationChamber, ExtremeIndustrialApiary, LegendaryBlackTea, @@ -147,10 +150,8 @@ public enum ItemList implements IItemContainer { StringBuilder tCamelCasedDisplayNameBuilder = new StringBuilder(); final String[] tDisplayNameWords = aDisplayName.split("\\W"); for (String tWord : tDisplayNameWords) { - if (tWord.length() > 0) - tCamelCasedDisplayNameBuilder.append(tWord.substring(0, 1).toUpperCase(Locale.US)); - if (tWord.length() > 1) - tCamelCasedDisplayNameBuilder.append(tWord.substring(1).toLowerCase(Locale.US)); + if (tWord.length() > 0) tCamelCasedDisplayNameBuilder.append(tWord.substring(0, 1).toUpperCase(Locale.US)); + if (tWord.length() > 1) tCamelCasedDisplayNameBuilder.append(tWord.substring(1).toLowerCase(Locale.US)); } if (tCamelCasedDisplayNameBuilder.length() == 0) { // CamelCased DisplayName is empty, so use hash of aDisplayName @@ -197,9 +198,8 @@ public enum ItemList implements IItemContainer { } /** - * Returns the internal stack. - * This method is unsafe. It's here only for quick operations. - * DON'T CHANGE THE RETURNED VALUE! + * Returns the internal stack. This method is unsafe. It's here only for quick operations. DON'T CHANGE THE RETURNED + * VALUE! */ public ItemStack getInternalStack_unsafe() { return mStack; diff --git a/src/main/java/kubatech/api/helpers/EnderIOHelper.java b/src/main/java/kubatech/api/helpers/EnderIOHelper.java index c5bb281b7e..30158500c7 100644 --- a/src/main/java/kubatech/api/helpers/EnderIOHelper.java +++ b/src/main/java/kubatech/api/helpers/EnderIOHelper.java @@ -1,31 +1,25 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.helpers; -import crazypants.enderio.EnderIO; import kubatech.api.LoaderReference; + import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.boss.IBossDisplayData; +import crazypants.enderio.EnderIO; + public class EnderIOHelper { + public static boolean canEntityBeCapturedWithSoulVial(Entity entity, String entityID) { if (!LoaderReference.EnderIO) return true; if (ReflectionHelper.<Boolean>callMethod(EnderIO.itemSoulVessel, "isBlackListed", false, entityID)) diff --git a/src/main/java/kubatech/api/helpers/GTHelper.java b/src/main/java/kubatech/api/helpers/GTHelper.java index 782c697232..16abbe348c 100644 --- a/src/main/java/kubatech/api/helpers/GTHelper.java +++ b/src/main/java/kubatech/api/helpers/GTHelper.java @@ -3,9 +3,9 @@ package kubatech.api.helpers; import static gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase.isValidMetaTileEntity; import static kubatech.api.Variables.ln4; +import kubatech.api.implementations.KubaTechGTMultiBlockBase; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Energy; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase; -import kubatech.api.implementations.KubaTechGTMultiBlockBase; public class GTHelper { diff --git a/src/main/java/kubatech/api/helpers/InfernalHelper.java b/src/main/java/kubatech/api/helpers/InfernalHelper.java index dcfd87daad..a2842d66a7 100644 --- a/src/main/java/kubatech/api/helpers/InfernalHelper.java +++ b/src/main/java/kubatech/api/helpers/InfernalHelper.java @@ -1,34 +1,28 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.helpers; -import atomicstryker.infernalmobs.common.InfernalMobsCore; -import atomicstryker.infernalmobs.common.mods.api.ModifierLoader; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; + import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; +import atomicstryker.infernalmobs.common.InfernalMobsCore; +import atomicstryker.infernalmobs.common.mods.api.ModifierLoader; + @SuppressWarnings("unchecked") public class InfernalHelper { + private static Method isClassAllowed = null; public static boolean isClassAllowed(EntityLivingBase e) { @@ -49,8 +43,8 @@ public class InfernalHelper { public static boolean checkEntityClassForced(EntityLivingBase e) { try { if (checkEntityClassForced == null) { - checkEntityClassForced = - InfernalMobsCore.class.getDeclaredMethod("checkEntityClassForced", EntityLivingBase.class); + checkEntityClassForced = InfernalMobsCore.class + .getDeclaredMethod("checkEntityClassForced", EntityLivingBase.class); checkEntityClassForced.setAccessible(true); } return (boolean) checkEntityClassForced.invoke(InfernalMobsCore.instance(), e); diff --git a/src/main/java/kubatech/api/helpers/ReflectionHelper.java b/src/main/java/kubatech/api/helpers/ReflectionHelper.java index 03fc9f45d9..404d1de5f9 100644 --- a/src/main/java/kubatech/api/helpers/ReflectionHelper.java +++ b/src/main/java/kubatech/api/helpers/ReflectionHelper.java @@ -1,20 +1,11 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.helpers; @@ -24,7 +15,9 @@ import java.lang.reflect.Method; import java.util.HashMap; public class ReflectionHelper { + private static class _FieldsMethods { + HashMap<String, Field> fields = new HashMap<>(); HashMap<String, Method> methods = new HashMap<>(); } diff --git a/src/main/java/kubatech/api/implementations/KubaTechGTMultiBlockBase.java b/src/main/java/kubatech/api/implementations/KubaTechGTMultiBlockBase.java index aa51834a10..0b31c27011 100644 --- a/src/main/java/kubatech/api/implementations/KubaTechGTMultiBlockBase.java +++ b/src/main/java/kubatech/api/implementations/KubaTechGTMultiBlockBase.java @@ -3,16 +3,19 @@ package kubatech.api.implementations; import static kubatech.api.Variables.ln2; import static kubatech.api.Variables.ln4; -import com.gtnewhorizons.modularui.api.drawable.IDrawable; -import com.gtnewhorizons.modularui.api.widget.Widget; -import gregtech.api.gui.modularui.GT_UITextures; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; import java.util.ArrayList; import java.util.Arrays; import java.util.function.Function; + import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; +import com.gtnewhorizons.modularui.api.drawable.IDrawable; +import com.gtnewhorizons.modularui.api.widget.Widget; + +import gregtech.api.gui.modularui.GT_UITextures; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_ExtendedPowerMultiBlockBase; + public abstract class KubaTechGTMultiBlockBase<T extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<T>> extends GT_MetaTileEntity_ExtendedPowerMultiBlockBase<T> { @@ -25,8 +28,9 @@ public abstract class KubaTechGTMultiBlockBase<T extends GT_MetaTileEntity_Exten } /** - * Enables infinite overclocking (will give more outputs with more energy past 1 tick) - * Currently doesn't support recipe inputs + * Enables infinite overclocking (will give more outputs with more energy past 1 tick) Currently doesn't support + * recipe inputs + * * @return If this supports infinite overclock */ protected boolean isOverclockingInfinite() { @@ -41,16 +45,16 @@ public abstract class KubaTechGTMultiBlockBase<T extends GT_MetaTileEntity_Exten } @Override - protected void calculateOverclockedNessMultiInternal( - long aEUt, int aDuration, int mAmperage, long maxInputVoltage, boolean perfectOC) { + protected void calculateOverclockedNessMultiInternal(long aEUt, int aDuration, int mAmperage, long maxInputVoltage, + boolean perfectOC) { calculateOverclock(aEUt, aDuration, getMaxInputEu(), perfectOC); } /** - * @param aEUt Recipe EU/t - * @param aDuration Recipe duration (in ticks) + * @param aEUt Recipe EU/t + * @param aDuration Recipe duration (in ticks) * @param maxInputEU The amount of energy we want to overclock to - * @param isPerfect Is this overclock perfect ? + * @param isPerfect Is this overclock perfect ? * @return The amount of overclocks */ protected int calculateOverclock(long aEUt, int aDuration, final long maxInputEU, final boolean isPerfect) { @@ -61,8 +65,8 @@ public abstract class KubaTechGTMultiBlockBase<T extends GT_MetaTileEntity_Exten this.mMaxProgresstime = aDuration; return 0; } - int durationTiers = - (int) Math.ceil(Math.log((double) aDuration / (double) minDuration) / (isPerfect ? ln4 : ln2)); + int durationTiers = (int) Math + .ceil(Math.log((double) aDuration / (double) minDuration) / (isPerfect ? ln4 : ln2)); if (durationTiers < 0) durationTiers = 0; // We do not support downclocks (yet) if (durationTiers > tiers) durationTiers = tiers; if (!isOverclockingInfinite()) { @@ -135,7 +139,7 @@ public abstract class KubaTechGTMultiBlockBase<T extends GT_MetaTileEntity_Exten protected final Function<Widget, Boolean> isFixed = widget -> getIdealStatus() == getRepairStatus() && mMachine; protected static final Function<Integer, IDrawable[]> toggleButtonBackgroundGetter = val -> { - if (val == 0) return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS}; - else return new IDrawable[] {GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK}; + if (val == 0) return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CROSS }; + else return new IDrawable[] { GT_UITextures.BUTTON_STANDARD, GT_UITextures.OVERLAY_BUTTON_CHECKMARK }; }; } diff --git a/src/main/java/kubatech/api/mobhandler/MobDrop.java b/src/main/java/kubatech/api/mobhandler/MobDrop.java index 1a5f73ae49..554e36bd6a 100644 --- a/src/main/java/kubatech/api/mobhandler/MobDrop.java +++ b/src/main/java/kubatech/api/mobhandler/MobDrop.java @@ -1,37 +1,34 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.mobhandler; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import java.util.HashMap; + import kubatech.api.ConstructableItemStack; import kubatech.api.utils.GSONUtils; + import net.minecraft.item.ItemStack; +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; + public class MobDrop { + public enum DropType { + Normal, Rare, Additional, Infernal; + private static final DropType[] values = values(); public static DropType get(int ordinal) { @@ -52,14 +49,8 @@ public class MobDrop { private MobDrop() {} - public MobDrop( - ItemStack stack, - DropType type, - int chance, - Integer enchantable, - HashMap<Integer, Integer> damages, - boolean lootable, - boolean playerOnly) { + public MobDrop(ItemStack stack, DropType type, int chance, Integer enchantable, HashMap<Integer, Integer> damages, + boolean lootable, boolean playerOnly) { this.stack = stack; this.reconstructableStack = new ConstructableItemStack(stack); this.type = type; diff --git a/src/main/java/kubatech/api/network/CustomTileEntityPacket.java b/src/main/java/kubatech/api/network/CustomTileEntityPacket.java index 334ff091aa..551110a107 100644 --- a/src/main/java/kubatech/api/network/CustomTileEntityPacket.java +++ b/src/main/java/kubatech/api/network/CustomTileEntityPacket.java @@ -1,24 +1,25 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.network; +import java.nio.charset.StandardCharsets; + +import kubatech.api.tileentity.CustomTileEntityPacketHandler; +import kubatech.api.utils.ModUtils; +import kubatech.kubatech; + +import net.minecraft.client.Minecraft; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; + import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.simpleimpl.IMessage; import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; @@ -27,15 +28,9 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; -import java.nio.charset.StandardCharsets; -import kubatech.api.tileentity.CustomTileEntityPacketHandler; -import kubatech.api.utils.ModUtils; -import kubatech.kubatech; -import net.minecraft.client.Minecraft; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; public class CustomTileEntityPacket implements IMessage { + public int w, x, y, z; public final ByteBuf customdata = Unpooled.buffer(); @@ -125,6 +120,7 @@ public class CustomTileEntityPacket implements IMessage { } public static class Handler implements IMessageHandler<CustomTileEntityPacket, IMessage> { + @Override public IMessage onMessage(CustomTileEntityPacket message, MessageContext ctx) { if (!ModUtils.isClientSided) return null; diff --git a/src/main/java/kubatech/api/network/LoadConfigPacket.java b/src/main/java/kubatech/api/network/LoadConfigPacket.java index 0c9015de12..04a8f68770 100644 --- a/src/main/java/kubatech/api/network/LoadConfigPacket.java +++ b/src/main/java/kubatech/api/network/LoadConfigPacket.java @@ -1,35 +1,27 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.network; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import io.netty.buffer.ByteBuf; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.HashSet; + import kubatech.config.Config; import kubatech.config.OverridesConfig; import kubatech.kubatech; import kubatech.loaders.MobRecipeLoader; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; public class LoadConfigPacket implements IMessage { @@ -54,7 +46,8 @@ public class LoadConfigPacket implements IMessage { byte[] sbytes = new byte[buf.readInt()]; buf.readBytes(sbytes); mobsOverrides.put( - new String(sbytes, StandardCharsets.UTF_8), OverridesConfig.MobOverride.readFromByteBuf(buf)); + new String(sbytes, StandardCharsets.UTF_8), + OverridesConfig.MobOverride.readFromByteBuf(buf)); } } } @@ -81,6 +74,7 @@ public class LoadConfigPacket implements IMessage { } public static class Handler implements IMessageHandler<LoadConfigPacket, IMessage> { + @Override public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) { kubatech.info("Received Mob Handler config, parsing"); diff --git a/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java index 3a1fa78d15..039b545890 100644 --- a/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java +++ b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java @@ -1,20 +1,11 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.tileentity; @@ -22,5 +13,6 @@ package kubatech.api.tileentity; import kubatech.api.network.CustomTileEntityPacket; public interface CustomTileEntityPacketHandler { + void HandleCustomPacket(CustomTileEntityPacket customdata); } diff --git a/src/main/java/kubatech/api/utils/FastRandom.java b/src/main/java/kubatech/api/utils/FastRandom.java index 03699d2b62..33d157a1aa 100644 --- a/src/main/java/kubatech/api/utils/FastRandom.java +++ b/src/main/java/kubatech/api/utils/FastRandom.java @@ -1,20 +1,11 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; diff --git a/src/main/java/kubatech/api/utils/GSONUtils.java b/src/main/java/kubatech/api/utils/GSONUtils.java index 1882a1e346..99580ad803 100644 --- a/src/main/java/kubatech/api/utils/GSONUtils.java +++ b/src/main/java/kubatech/api/utils/GSONUtils.java @@ -1,40 +1,35 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; -import com.google.gson.*; import java.io.IOException; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; + import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTSizeTracker; import net.minecraft.nbt.NBTTagCompound; +import com.google.gson.*; + 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; @@ -62,25 +57,19 @@ public class GSONUtils { try { if (!(json instanceof JsonArray)) return null; byte[] bytes = new byte[((JsonArray) json).size()]; - for (int i = 0; i < bytes.length; i++) - bytes[i] = ((JsonArray) json).get(i).getAsByte(); + for (int i = 0; i < bytes.length; i++) bytes[i] = ((JsonArray) json).get(i).getAsByte(); return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L)); } catch (IOException e) { throw new RuntimeException(e); } }; - public static final GsonBuilder GSON_BUILDER = new GsonBuilder() - .addSerializationExclusionStrategy(GSONStrategy) + public static final GsonBuilder GSON_BUILDER = new GsonBuilder().addSerializationExclusionStrategy(GSONStrategy) .addDeserializationExclusionStrategy(GSONStrategy) .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) - .serializeNulls(); + .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer).serializeNulls(); public static final GsonBuilder GSON_BUILDER_PRETTY = new GsonBuilder() - .addSerializationExclusionStrategy(GSONStrategy) - .addDeserializationExclusionStrategy(GSONStrategy) + .addSerializationExclusionStrategy(GSONStrategy).addDeserializationExclusionStrategy(GSONStrategy) .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer) - .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer) - .serializeNulls() - .setPrettyPrinting(); + .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer).serializeNulls().setPrettyPrinting(); } diff --git a/src/main/java/kubatech/api/utils/ItemID.java b/src/main/java/kubatech/api/utils/ItemID.java index d296c7d80d..c2060e59bc 100644 --- a/src/main/java/kubatech/api/utils/ItemID.java +++ b/src/main/java/kubatech/api/utils/ItemID.java @@ -1,30 +1,23 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; import java.util.Objects; + import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; public class ItemID { + private final Item item; private final int count; private final int meta; diff --git a/src/main/java/kubatech/api/utils/MobUtils.java b/src/main/java/kubatech/api/utils/MobUtils.java index 76bec7b988..0a6881edeb 100644 --- a/src/main/java/kubatech/api/utils/MobUtils.java +++ b/src/main/java/kubatech/api/utils/MobUtils.java @@ -1,27 +1,17 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import java.lang.reflect.Field; + import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelBox; import net.minecraft.client.model.ModelRenderer; @@ -30,6 +20,9 @@ import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.client.renderer.entity.RendererLivingEntity; import net.minecraft.entity.EntityLiving; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + public class MobUtils { private static Field mainmodelfield = null; @@ -48,8 +41,8 @@ public class MobUtils { public static float getMobHeight(EntityLiving e) { try { if (mainmodelfield == null) { - mainmodelfield = RendererLivingEntity.class.getDeclaredField( - ModUtils.isDeobfuscatedEnvironment ? "mainModel" : "field_77045_g"); + mainmodelfield = RendererLivingEntity.class + .getDeclaredField(ModUtils.isDeobfuscatedEnvironment ? "mainModel" : "field_77045_g"); mainmodelfield.setAccessible(true); } float eheight = e.height; diff --git a/src/main/java/kubatech/api/utils/ModUtils.java b/src/main/java/kubatech/api/utils/ModUtils.java index 6870a8801d..a09b3b68ee 100644 --- a/src/main/java/kubatech/api/utils/ModUtils.java +++ b/src/main/java/kubatech/api/utils/ModUtils.java @@ -1,35 +1,30 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.ModContainer; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; import java.util.*; + import javax.xml.bind.DatatypeConverter; + import net.minecraft.launchwrapper.Launch; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.ModContainer; + public class ModUtils { - public static final boolean isDeobfuscatedEnvironment = - (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment"); + + public static final boolean isDeobfuscatedEnvironment = (boolean) Launch.blackboard + .get("fml.deobfuscatedEnvironment"); public static boolean isClientSided = false; private static final HashMap<String, String> classNamesToModIDs = new HashMap<>(); private static final Map.Entry<String, String> emptyEntry = new AbstractMap.SimpleEntry<>("", ""); @@ -39,15 +34,11 @@ public class ModUtils { classNamesToModIDs.put("net.minecraft", "Minecraft"); Loader.instance().getActiveModList().forEach(m -> { Object Mod = m.getMod(); - if (Mod != null) - classNamesToModIDs.put(Mod.getClass().getPackage().getName(), m.getName()); + if (Mod != null) classNamesToModIDs.put(Mod.getClass().getPackage().getName(), m.getName()); }); } - return classNamesToModIDs.entrySet().stream() - .filter(e -> classname.startsWith(e.getKey())) - .findAny() - .orElse(emptyEntry) - .getValue(); + return classNamesToModIDs.entrySet().stream().filter(e -> classname.startsWith(e.getKey())).findAny() + .orElse(emptyEntry).getValue(); } private static String modListVersion = null; @@ -55,10 +46,9 @@ public class ModUtils { public static String getModListVersion() { if (modListVersion != null) return modListVersion; @SuppressWarnings("unchecked") - ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) - ((ArrayList<ModContainer>) Loader.instance().getActiveModList()).clone(); - String sortedList = modlist.stream() - .filter(m -> m.getMod() != null) + ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) ((ArrayList<ModContainer>) Loader.instance() + .getActiveModList()).clone(); + String sortedList = modlist.stream().filter(m -> m.getMod() != null) .sorted(Comparator.comparing(ModContainer::getModId)) .collect( StringBuilder::new, @@ -81,19 +71,16 @@ public class ModUtils { public static String getModListVersionIgnoringModVersions() { if (modListVersionIgnoringModVersions != null) return modListVersionIgnoringModVersions; @SuppressWarnings("unchecked") - ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) - ((ArrayList<ModContainer>) Loader.instance().getActiveModList()).clone(); - String sortedList = modlist.stream() - .filter(m -> m.getMod() != null) + ArrayList<ModContainer> modlist = (ArrayList<ModContainer>) ((ArrayList<ModContainer>) Loader.instance() + .getActiveModList()).clone(); + String sortedList = modlist.stream().filter(m -> m.getMod() != null) .sorted(Comparator.comparing(ModContainer::getModId)) - .collect(StringBuilder::new, (a, b) -> a.append(b.getModId()), (a, b) -> a.append(", ") - .append(b)) + .collect(StringBuilder::new, (a, b) -> a.append(b.getModId()), (a, b) -> a.append(", ").append(b)) .toString(); try { MessageDigest md = MessageDigest.getInstance("MD5"); - modListVersionIgnoringModVersions = DatatypeConverter.printHexBinary( - md.digest(sortedList.getBytes(StandardCharsets.UTF_8))) - .toUpperCase(); + modListVersionIgnoringModVersions = DatatypeConverter + .printHexBinary(md.digest(sortedList.getBytes(StandardCharsets.UTF_8))).toUpperCase(); return modListVersionIgnoringModVersions; } catch (Exception e) { modListVersionIgnoringModVersions = sortedList; diff --git a/src/main/java/kubatech/api/utils/StringUtils.java b/src/main/java/kubatech/api/utils/StringUtils.java index f7bbdcf9b7..066fa69d4f 100644 --- a/src/main/java/kubatech/api/utils/StringUtils.java +++ b/src/main/java/kubatech/api/utils/StringUtils.java @@ -1,20 +1,11 @@ /* - * 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 <https://www.gnu.org/licenses/>. - * + * 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 + * <https://www.gnu.org/licenses/>. */ package kubatech.api.utils; @@ -23,33 +14,20 @@ import net.minecraft.util.EnumChatFormatting; public class StringUtils { - private static final String[] rainbow = new String[] { - EnumChatFormatting.DARK_RED.toString(), - EnumChatFormatting.RED.toString(), - EnumChatFormatting.GOLD.toString(), - EnumChatFormatting.YELLOW.toString(), - EnumChatFormatting.DARK_GREEN.toString(), - EnumChatFormatting.GREEN.toString(), - EnumChatFormatting.AQUA.toString(), - EnumChatFormatting.DARK_AQUA.toString(), - EnumChatFormatting.DARK_BLUE.toString(), - EnumChatFormatting.BLUE.toString(), - EnumChatFormatting.LIGHT_PURPLE.toString(), - EnumChatFormatting.DARK_PURPLE.toString(), - EnumChatFormatting.WHITE.toString(), - EnumChatFormatting.GRAY.toString(), - EnumChatFormatting.DARK_GRAY.toString(), - EnumChatFormatting.BLACK.toString(), - }; + private static final String[] rainbow = new String[] { EnumChatFormatting.DARK_RED.toString(), + EnumChatFormatting.RED.toString(), EnumChatFormatting.GOLD.toString(), EnumChatFormatting.YELLOW.toString(), + EnumChatFormatting.DARK_GREEN.toString(), EnumChatFormatting.GREEN.toString(), + EnumChatFormatting.AQUA.toString(), EnumChatFormatting.DARK_AQUA.toString(), + EnumChatFormatting.DARK_BLUE.toString(), EnumChatFormatting.BLUE.toString(), + EnumChatFormatting.LIGHT_PURPLE.toString(), EnumChatFormatting.DARK_PURPLE.toString(), + EnumChatFormatting.WHITE.toString(), EnumChatFormatting.GRAY.toString(), + EnumChatFormatting.DARK_GRAY.toString(), EnumChatFormatting.BLACK.toString(), }; public static String applyRainbow(String str, int offset, String additional) { StringBuilder final_string = new StringBuilder(); int i = offset; for (char c : str.toCharArray()) - final_string - .append(rainbow[i++ % rainbow.length]) - .append(additional) - .append(c); + final_string.append(rainbow[i++ % rainbow.length]).append(additional).append(c); return final_string.toString(); } |