aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kubatech/api/utils
diff options
context:
space:
mode:
authorJakub <53441451+kuba6000@users.noreply.github.com>2023-06-22 23:48:40 +0200
committerGitHub <noreply@github.com>2023-06-22 23:48:40 +0200
commit705dec10c37a7f878f11aad11ea4615a7c08ec00 (patch)
tree96d8f4eaa486eed2cb9bb3b469007354a48743b2 /src/main/java/kubatech/api/utils
parent4f7ebceca5992e3d81f86b264460f38db27eb28b (diff)
downloadGT5-Unofficial-705dec10c37a7f878f11aad11ea4615a7c08ec00.tar.gz
GT5-Unofficial-705dec10c37a7f878f11aad11ea4615a7c08ec00.tar.bz2
GT5-Unofficial-705dec10c37a7f878f11aad11ea4615a7c08ec00.zip
Remove Mobs Info NEI page from KubaTech (#82)
* Add Mobs Info * Use MobsInfo * Update dependencies.gradle * Update repositories.gradle * Update GT_MetaTileEntity_ExtremeExterminationChamber.java * Update dependencies.gradle
Diffstat (limited to 'src/main/java/kubatech/api/utils')
-rw-r--r--src/main/java/kubatech/api/utils/ItemID.java104
-rw-r--r--src/main/java/kubatech/api/utils/MobUtils.java81
-rw-r--r--src/main/java/kubatech/api/utils/ModUtils.java103
3 files changed, 0 insertions, 288 deletions
diff --git a/src/main/java/kubatech/api/utils/ItemID.java b/src/main/java/kubatech/api/utils/ItemID.java
deleted file mode 100644
index 819b08e572..0000000000
--- a/src/main/java/kubatech/api/utils/ItemID.java
+++ /dev/null
@@ -1,104 +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 <https://www.gnu.org/licenses/>.
- * spotless:on
- */
-
-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;
- private final NBTTagCompound tag;
- private final boolean ignorecount;
- private final boolean ignoremeta;
- private final boolean ignorenbt;
-
- public static ItemID create(ItemStack stack) {
- return new ItemID(stack, true, true, true, true); // ignore count by default
- }
-
- public static ItemID create(ItemStack stack, boolean ignorecount) {
- return new ItemID(stack, ignorecount, false, false, true);
- }
-
- public static ItemID create(ItemStack stack, boolean ignorecount, boolean ignoremeta) {
- return new ItemID(stack, ignorecount, ignoremeta, false, true);
- }
-
- public static ItemID create(ItemStack stack, boolean ignorecount, boolean ignoremeta, boolean ignorenbt) {
- return new ItemID(stack, ignorecount, ignoremeta, ignorenbt, true);
- }
-
- public static ItemID create_NoCopy(ItemStack stack) {
- return new ItemID(stack, true, false, false, false); // ignore count by default
- }
-
- public static ItemID create_NoCopy(ItemStack stack, boolean ignorecount) {
- return new ItemID(stack, ignorecount, false, false, false);
- }
-
- public static ItemID create_NoCopy(ItemStack stack, boolean ignorecount, boolean ignoremeta) {
- return new ItemID(stack, ignorecount, ignoremeta, false, false);
- }
-
- public static ItemID create_NoCopy(ItemStack stack, boolean ignorecount, boolean ignoremeta, boolean ignorenbt) {
- return new ItemID(stack, ignorecount, ignoremeta, ignorenbt, false);
- }
-
- private ItemID(ItemStack stack, boolean ignorecount, boolean ignoremeta, boolean ignorenbt, boolean createcopy) {
- this.ignorecount = ignorecount;
- this.ignoremeta = ignoremeta;
- this.ignorenbt = ignorenbt;
- item = stack.getItem();
- count = ignorecount ? 0 : stack.stackSize;
- meta = ignoremeta ? 0 : stack.getItemDamage();
- tag = ignorenbt ? null : (createcopy ? (NBTTagCompound) stack.stackTagCompound.copy() : stack.stackTagCompound);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(item, count, meta, tag);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) return false;
- if (obj == this) return true;
- if (obj instanceof ItemID) return obj.hashCode() == this.hashCode();
- if (obj instanceof ItemStack) {
- if (!item.equals(((ItemStack) obj).getItem())) return false;
- if (!ignorecount) if (count != ((ItemStack) obj).stackSize) return false;
- if (!ignoremeta) if (meta != ((ItemStack) obj).getItemDamage()) return false;
- if (!ignorenbt) {
- if (tag == null)
- return ((ItemStack) obj).stackTagCompound == null || ((ItemStack) obj).stackTagCompound.hasNoTags();
- return tag.equals(((ItemStack) obj).stackTagCompound);
- }
- return true;
- }
- return false;
- }
-}
diff --git a/src/main/java/kubatech/api/utils/MobUtils.java b/src/main/java/kubatech/api/utils/MobUtils.java
deleted file mode 100644
index d3ec59757a..0000000000
--- a/src/main/java/kubatech/api/utils/MobUtils.java
+++ /dev/null
@@ -1,81 +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 <https://www.gnu.org/licenses/>.
- * spotless:on
- */
-
-package kubatech.api.utils;
-
-import net.minecraft.client.model.ModelBase;
-import net.minecraft.client.model.ModelBox;
-import net.minecraft.client.model.ModelRenderer;
-import net.minecraft.client.renderer.entity.Render;
-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;
-import kubatech.mixin.mixins.minecraft.RendererLivingEntityAccessor;
-
-public class MobUtils {
-
- @SideOnly(Side.CLIENT)
- public static float getDesiredScale(EntityLiving e, float desiredHeight) {
- return getDesiredScale(getMobHeight(e), desiredHeight);
- }
-
- @SideOnly(Side.CLIENT)
- public static float getDesiredScale(float entityHeight, float desiredHeight) {
- return desiredHeight / entityHeight;
- }
-
- @SideOnly(Side.CLIENT)
- public static float getMobHeight(EntityLiving e) {
- try {
- float eheight = e.height;
- float ewidth = e.width;
- Render r = RenderManager.instance.getEntityRenderObject(e);
- if (r instanceof RendererLivingEntity) {
- ModelBase mainModel = ((RendererLivingEntityAccessor) r).getMainModel();
- for (Object box : mainModel.boxList) {
- if (box instanceof ModelRenderer) {
- float minY = 999f;
- float minX = 999f;
- float maxY = -999f;
- float maxX = -999f;
- for (Object cube : ((ModelRenderer) box).cubeList) {
- if (cube instanceof ModelBox) {
- if (minY > ((ModelBox) cube).posY1) minY = ((ModelBox) cube).posY1;
- if (minX > ((ModelBox) cube).posX1) minX = ((ModelBox) cube).posX1;
- if (maxY < ((ModelBox) cube).posY2) maxY = ((ModelBox) cube).posY2;
- if (maxX < ((ModelBox) cube).posX2) maxX = ((ModelBox) cube).posX2;
- }
- }
- float cubeheight = (maxY - minY) / 10f;
- float cubewidth = (maxX - minX) / 10f;
- if (eheight < cubeheight) eheight = cubeheight;
- if (ewidth < cubewidth) ewidth = cubewidth;
- }
- }
- }
- return eheight;
- } catch (Exception ex) {
- return 1f;
- }
- }
-}
diff --git a/src/main/java/kubatech/api/utils/ModUtils.java b/src/main/java/kubatech/api/utils/ModUtils.java
index 61352cce9d..28165adacf 100644
--- a/src/main/java/kubatech/api/utils/ModUtils.java
+++ b/src/main/java/kubatech/api/utils/ModUtils.java
@@ -20,21 +20,9 @@
package kubatech.api.utils;
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.util.AbstractMap;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.bind.DatatypeConverter;
-
import net.minecraft.launchwrapper.Launch;
import cpw.mods.fml.common.FMLCommonHandler;
-import cpw.mods.fml.common.Loader;
-import cpw.mods.fml.common.ModContainer;
import kubatech.kubatech;
public class ModUtils {
@@ -48,95 +36,4 @@ public class ModUtils {
.getEffectiveSide()
.isClient();
}
-
- @FunctionalInterface
- public interface TriConsumer<T, U, V> {
-
- void accept(T t, U u, V v);
- }
-
- private static final HashMap<String, String> classNamesToModIDs = new HashMap<>();
- private static final Map.Entry<String, String> emptyEntry = new AbstractMap.SimpleEntry<>("", "");
-
- public static String getModNameFromClassName(String classname) {
- if (classNamesToModIDs.size() == 0) {
- classNamesToModIDs.put("net.minecraft", "Minecraft");
- Loader.instance()
- .getActiveModList()
- .forEach(m -> {
- Object Mod = m.getMod();
- if (Mod != null) {
- Package modPackage = Mod.getClass()
- .getPackage();
- if (modPackage == null) { // HOW CAN THIS EVEN HAPPEN ?!
- kubatech.warn("Mod " + m.getModId() + " package is not loaded yet!");
- return;
- }
- classNamesToModIDs.put(modPackage.getName(), m.getName());
- }
- });
- }
- return classNamesToModIDs.entrySet()
- .stream()
- .filter(e -> classname.startsWith(e.getKey()))
- .findAny()
- .orElse(emptyEntry)
- .getValue();
- }
-
- private static String modListVersion = null;
-
- 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)
- .sorted(Comparator.comparing(ModContainer::getModId))
- .collect(
- StringBuilder::new,
- (a, b) -> a.append(b.getModId())
- .append(b.getVersion()),
- (a, b) -> a.append(", ")
- .append(b))
- .toString();
- try {
- MessageDigest md = MessageDigest.getInstance("MD5");
- modListVersion = DatatypeConverter.printHexBinary(md.digest(sortedList.getBytes(StandardCharsets.UTF_8)))
- .toUpperCase();
- return modListVersion;
- } catch (Exception e) {
- modListVersion = sortedList;
- return sortedList;
- }
- }
-
- private static String modListVersionIgnoringModVersions = null;
-
- 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)
- .sorted(Comparator.comparing(ModContainer::getModId))
- .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();
- return modListVersionIgnoringModVersions;
- } catch (Exception e) {
- modListVersionIgnoringModVersions = sortedList;
- return sortedList;
- }
- }
}