diff options
author | Jakub <53441451+kuba6000@users.noreply.github.com> | 2023-06-22 23:48:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-22 23:48:40 +0200 |
commit | 705dec10c37a7f878f11aad11ea4615a7c08ec00 (patch) | |
tree | 96d8f4eaa486eed2cb9bb3b469007354a48743b2 /src | |
parent | 4f7ebceca5992e3d81f86b264460f38db27eb28b (diff) | |
download | GT5-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')
33 files changed, 363 insertions, 3086 deletions
diff --git a/src/main/java/kubatech/ClientProxy.java b/src/main/java/kubatech/ClientProxy.java index 99e9661e33..4d53d945e4 100644 --- a/src/main/java/kubatech/ClientProxy.java +++ b/src/main/java/kubatech/ClientProxy.java @@ -30,7 +30,6 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppedEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import kubatech.api.utils.ModUtils; -import kubatech.loaders.MobRecipeLoader; import kubatech.nei.IMCForNEI; @SuppressWarnings("unused") @@ -72,6 +71,5 @@ public class ClientProxy extends CommonProxy { public void loadComplete(FMLLoadCompleteEvent event) { super.loadComplete(event); - MobRecipeLoader.generateMobRecipeMap(); } } diff --git a/src/main/java/kubatech/CommonProxy.java b/src/main/java/kubatech/CommonProxy.java index 267efdab21..6d54bbf326 100644 --- a/src/main/java/kubatech/CommonProxy.java +++ b/src/main/java/kubatech/CommonProxy.java @@ -39,6 +39,7 @@ import kubatech.api.LoaderReference; import kubatech.commands.CommandHandler; import kubatech.config.Config; import kubatech.loaders.MTLoader; +import kubatech.loaders.MobHandlerLoader; import kubatech.loaders.RecipeLoader; import kubatech.loaders.TCLoader; import kubatech.savedata.PlayerDataManager; @@ -56,6 +57,7 @@ public class CommonProxy { MinecraftForge.EVENT_BUS.register(new PlayerDataManager()); registerItems(); registerBlocks(); + MobHandlerLoader.init(); } public void init(FMLInitializationEvent event) { diff --git a/src/main/java/kubatech/FMLEventHandler.java b/src/main/java/kubatech/FMLEventHandler.java index 27ff42615c..e4d216bde9 100644 --- a/src/main/java/kubatech/FMLEventHandler.java +++ b/src/main/java/kubatech/FMLEventHandler.java @@ -25,7 +25,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent; import kubatech.api.helpers.UUIDFinder; -import kubatech.api.network.LoadConfigPacket; +import kubatech.network.LoadConfigPacket; import kubatech.savedata.PlayerDataManager; public class FMLEventHandler { diff --git a/src/main/java/kubatech/api/ConstructableItemStack.java b/src/main/java/kubatech/api/ConstructableItemStack.java deleted file mode 100644 index 3e82f64958..0000000000 --- a/src/main/java/kubatech/api/ConstructableItemStack.java +++ /dev/null @@ -1,122 +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; - -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) { - this.itemIdentifier = itemIdentifier; - this.meta = meta; - this.size = size; - this.tagCompound = tagCompound; - } - - public ConstructableItemStack(ItemStack stack) { - itemIdentifier = GameRegistry.findUniqueIdentifierFor(stack.getItem()); - meta = stack.getItemDamage(); - size = stack.stackSize; - tagCompound = stack.stackTagCompound; - } - - public ItemStack construct() { - if (itemIdentifier == null) return null; - Item it = GameRegistry.findItem(itemIdentifier.modId, itemIdentifier.name); - if (it == null) return null; - ItemStack stack = new ItemStack(it, size, meta); - stack.stackTagCompound = tagCompound; - return stack; - } - - public boolean isSame(ConstructableItemStack stack, boolean ignoreSize) { - if (!stack.itemIdentifier.modId.equals(itemIdentifier.modId)) return false; - if (!stack.itemIdentifier.name.equals(itemIdentifier.name)) return false; - return ignoreSize || stack.size == size; - } - - private static final ByteBuf BufHelper = Unpooled.buffer(); - - public void writeToByteBuf(ByteBuf byteBuf) { - BufHelper.clear(); - byte[] bytes = itemIdentifier.modId.getBytes(StandardCharsets.UTF_8); - BufHelper.writeInt(bytes.length); - BufHelper.writeBytes(bytes); - bytes = itemIdentifier.name.getBytes(StandardCharsets.UTF_8); - BufHelper.writeInt(bytes.length); - BufHelper.writeBytes(bytes); - BufHelper.writeInt(meta); - BufHelper.writeInt(size); - BufHelper.writeBoolean(tagCompound != null); - if (tagCompound != null) { - try { - bytes = CompressedStreamTools.compress(tagCompound); - } catch (Exception ignored) { - bytes = new byte[0]; - } - BufHelper.writeInt(bytes.length); - BufHelper.writeBytes(bytes); - } - byteBuf.writeInt(BufHelper.readableBytes()); - byteBuf.writeBytes(BufHelper); - } - - public static ConstructableItemStack readFromByteBuf(ByteBuf byteBuf) { - int size = byteBuf.readInt(); - byte[] bytes = new byte[byteBuf.readInt()]; - byteBuf.readBytes(bytes); - String modid = new String(bytes, StandardCharsets.UTF_8); - bytes = new byte[byteBuf.readInt()]; - byteBuf.readBytes(bytes); - String name = new String(bytes, StandardCharsets.UTF_8); - int meta = byteBuf.readInt(); - int stacksize = byteBuf.readInt(); - NBTTagCompound nbtTagCompound = null; - if (byteBuf.readBoolean()) { - bytes = new byte[byteBuf.readInt()]; - byteBuf.readBytes(bytes); - try { - nbtTagCompound = CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L)); - } catch (Exception ignored) {} - } - return new ConstructableItemStack( - new GameRegistry.UniqueIdentifier(modid + ":" + name), - meta, - stacksize, - nbtTagCompound); - } -} diff --git a/src/main/java/kubatech/api/helpers/EnderIOHelper.java b/src/main/java/kubatech/api/helpers/EnderIOHelper.java deleted file mode 100644 index 63da31e76e..0000000000 --- a/src/main/java/kubatech/api/helpers/EnderIOHelper.java +++ /dev/null @@ -1,42 +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.helpers; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.boss.IBossDisplayData; - -import crazypants.enderio.EnderIO; -import kubatech.api.LoaderReference; - -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)) - return false; - return crazypants.enderio.config.Config.soulVesselCapturesBosses || !(entity instanceof IBossDisplayData); - } - - public static boolean canEntityBeCapturedWithSoulVial(Entity entity) { - return canEntityBeCapturedWithSoulVial(entity, EntityList.getEntityString(entity)); - } -} diff --git a/src/main/java/kubatech/api/mobhandler/MobDrop.java b/src/main/java/kubatech/api/mobhandler/MobDrop.java deleted file mode 100644 index 9b8b9cd51c..0000000000 --- a/src/main/java/kubatech/api/mobhandler/MobDrop.java +++ /dev/null @@ -1,118 +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.mobhandler; - -import java.util.HashMap; - -import net.minecraft.item.ItemStack; - -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import kubatech.api.ConstructableItemStack; -import kubatech.api.utils.GSONUtils; - -public class MobDrop { - - public enum DropType { - - Normal, - Rare, - Additional, - Infernal; - - private static final DropType[] values = values(); - - public static DropType get(int ordinal) { - return values[ordinal]; - } - } - - @GSONUtils.SkipGSON - public ItemStack stack; - - public ConstructableItemStack reconstructableStack; - public DropType type; - public int chance; - public Integer enchantable; - public HashMap<Integer, Integer> damages; - public boolean lootable = false; - public boolean playerOnly = false; - - private MobDrop() {} - - 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; - this.chance = chance; - this.enchantable = enchantable; - this.damages = damages; - this.lootable = lootable; - this.playerOnly = playerOnly; - } - - public void reconstructStack() { - this.stack = reconstructableStack.construct(); - } - - private static final ByteBuf BufHelper = Unpooled.buffer(); - - public void writeToByteBuf(ByteBuf byteBuf) { - BufHelper.clear(); - reconstructableStack.writeToByteBuf(BufHelper); - BufHelper.writeInt(type.ordinal()); - BufHelper.writeInt(chance); - BufHelper.writeBoolean(enchantable != null); - if (enchantable != null) BufHelper.writeInt(enchantable); - BufHelper.writeBoolean(damages != null); - if (damages != null) { - BufHelper.writeInt(damages.size()); - damages.forEach((k, v) -> { - BufHelper.writeInt(k); - BufHelper.writeInt(v); - }); - } - BufHelper.writeBoolean(lootable); - BufHelper.writeBoolean(playerOnly); - byteBuf.writeInt(BufHelper.readableBytes()); - byteBuf.writeBytes(BufHelper); - } - - public static MobDrop readFromByteBuf(ByteBuf byteBuf) { - MobDrop mobDrop = new MobDrop(); - int size = byteBuf.readInt(); - mobDrop.reconstructableStack = ConstructableItemStack.readFromByteBuf(byteBuf); - mobDrop.type = DropType.get(byteBuf.readInt()); - mobDrop.chance = byteBuf.readInt(); - if (byteBuf.readBoolean()) mobDrop.enchantable = byteBuf.readInt(); - else mobDrop.enchantable = null; - if (byteBuf.readBoolean()) { - mobDrop.damages = new HashMap<>(); - int damagessize = byteBuf.readInt(); - for (int i = 0; i < damagessize; i++) mobDrop.damages.put(byteBuf.readInt(), byteBuf.readInt()); - } else mobDrop.damages = null; - mobDrop.lootable = byteBuf.readBoolean(); - mobDrop.playerOnly = byteBuf.readBoolean(); - mobDrop.reconstructStack(); - return mobDrop; - } -} diff --git a/src/main/java/kubatech/api/network/LoadConfigPacket.java b/src/main/java/kubatech/api/network/LoadConfigPacket.java deleted file mode 100644 index be3d0b803c..0000000000 --- a/src/main/java/kubatech/api/network/LoadConfigPacket.java +++ /dev/null @@ -1,94 +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.network; - -import java.nio.charset.StandardCharsets; -import java.util.HashMap; -import java.util.HashSet; - -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 kubatech.config.Config; -import kubatech.config.OverridesConfig; -import kubatech.kubatech; -import kubatech.loaders.MobRecipeLoader; - -public class LoadConfigPacket implements IMessage { - - public static final LoadConfigPacket instance = new LoadConfigPacket(); - - public final HashSet<String> mobsToLoad = new HashSet<>(); - public final HashMap<String, OverridesConfig.MobOverride> mobsOverrides = new HashMap<>(); - - @Override - public void fromBytes(ByteBuf buf) { - if (!buf.readBoolean()) mobsToLoad.clear(); - else { - mobsToLoad.clear(); - int mobssize = buf.readInt(); - for (int i = 0; i < mobssize; i++) { - byte[] sbytes = new byte[buf.readInt()]; - buf.readBytes(sbytes); - mobsToLoad.add(new String(sbytes, StandardCharsets.UTF_8)); - } - int overridessize = buf.readInt(); - for (int i = 0; i < overridessize; i++) { - byte[] sbytes = new byte[buf.readInt()]; - buf.readBytes(sbytes); - mobsOverrides - .put(new String(sbytes, StandardCharsets.UTF_8), OverridesConfig.MobOverride.readFromByteBuf(buf)); - } - } - } - - @Override - public void toBytes(ByteBuf buf) { - if (!Config.MobHandler.mobHandlerEnabled) buf.writeBoolean(false); - else { - buf.writeBoolean(true); - buf.writeInt(mobsToLoad.size()); - mobsToLoad.forEach(s -> { - byte[] sbytes = s.getBytes(StandardCharsets.UTF_8); - buf.writeInt(sbytes.length); - buf.writeBytes(sbytes); - }); - buf.writeInt(mobsOverrides.size()); - mobsOverrides.forEach((k, v) -> { - byte[] sbytes = k.getBytes(StandardCharsets.UTF_8); - buf.writeInt(sbytes.length); - buf.writeBytes(sbytes); - v.writeToByteBuf(buf); - }); - } - } - - public static class Handler implements IMessageHandler<LoadConfigPacket, IMessage> { - - @Override - public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) { - kubatech.info("Received Mob Handler config, parsing"); - MobRecipeLoader.processMobRecipeMap(message.mobsToLoad, message.mobsOverrides); - return null; - } - } -} diff --git a/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java index 82343dd4ea..98de36150f 100644 --- a/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java +++ b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java @@ -20,7 +20,7 @@ package kubatech.api.tileentity; -import kubatech.api.network.CustomTileEntityPacket; +import kubatech.network.CustomTileEntityPacket; public interface CustomTileEntityPacketHandler { 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; - } - } } diff --git a/src/main/java/kubatech/client/effect/EntityRenderer.java b/src/main/java/kubatech/client/effect/EntityRenderer.java index 0691dc07ce..247b6ba788 100644 --- a/src/main/java/kubatech/client/effect/EntityRenderer.java +++ b/src/main/java/kubatech/client/effect/EntityRenderer.java @@ -41,10 +41,11 @@ import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import org.lwjgl.util.glu.GLU; +import com.kuba6000.mobsinfo.api.utils.MobUtils; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import kubatech.Tags; -import kubatech.api.utils.MobUtils; import kubatech.config.Config; @SideOnly(Side.CLIENT) diff --git a/src/main/java/kubatech/commands/CommandConfig.java b/src/main/java/kubatech/commands/CommandConfig.java index cf43bc88ba..04d4420314 100644 --- a/src/main/java/kubatech/commands/CommandConfig.java +++ b/src/main/java/kubatech/commands/CommandConfig.java @@ -31,10 +31,9 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.StatCollector; -import kubatech.api.network.LoadConfigPacket; import kubatech.config.Config; import kubatech.kubatech; -import kubatech.loaders.MobRecipeLoader; +import kubatech.network.LoadConfigPacket; @CommandHandler.ChildCommand public class CommandConfig extends CommandBase { @@ -48,7 +47,7 @@ public class CommandConfig extends CommandBase { final String key; Translations() { - key = "command.config." + this.name() + key = "kubatech.command.config." + this.name() .toLowerCase(); } @@ -93,7 +92,6 @@ public class CommandConfig extends CommandBase { return; } Config.synchronizeConfiguration(); - MobRecipeLoader.processMobRecipeMap(); MinecraftServer.getServer() .getConfigurationManager().playerEntityList.forEach(p -> { if (!(p instanceof EntityPlayerMP)) return; diff --git a/src/main/java/kubatech/commands/CommandCustomDrops.java b/src/main/java/kubatech/commands/CommandCustomDrops.java deleted file mode 100644 index 80148eb796..0000000000 --- a/src/main/java/kubatech/commands/CommandCustomDrops.java +++ /dev/null @@ -1,67 +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.commands; - -import java.io.File; - -import net.minecraft.command.CommandBase; -import net.minecraft.command.ICommandSender; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.EnumChatFormatting; - -import kubatech.api.utils.ModUtils; -import kubatech.loaders.MobRecipeLoader; - -@CommandHandler.ChildCommand -public class CommandCustomDrops extends CommandBase { - - @Override - public String getCommandName() { - return "customdrops"; - } - - @Override - public String getCommandUsage(ICommandSender p_71518_1_) { - return "customdrops"; - } - - @Override - public int getRequiredPermissionLevel() { - return 4; - } - - @Override - public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) { - - if (!ModUtils.isClientSided) { - p_71515_1_ - .addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "This command is single-player only!")); - return; - } - - File f = MobRecipeLoader.makeCustomDrops(); - - if (f == null) { - p_71515_1_.addChatMessage( - new ChatComponentText(EnumChatFormatting.RED + "There was an error! Look in the console")); - } else p_71515_1_.addChatMessage(new ChatComponentText(f.getAbsolutePath())); - } -} diff --git a/src/main/java/kubatech/commands/CommandHandler.java b/src/main/java/kubatech/commands/CommandHandler.java index 89f1db7429..599d690f21 100644 --- a/src/main/java/kubatech/commands/CommandHandler.java +++ b/src/main/java/kubatech/commands/CommandHandler.java @@ -56,7 +56,7 @@ public class CommandHandler extends CommandBase { final String key; Translations() { - key = "commandhandler." + this.name() + key = "kubatech.commandhandler." + this.name() .toLowerCase(); } diff --git a/src/main/java/kubatech/commands/CommandHelp.java b/src/main/java/kubatech/commands/CommandHelp.java index d7e9fbee59..49a31bc829 100644 --- a/src/main/java/kubatech/commands/CommandHelp.java +++ b/src/main/java/kubatech/commands/CommandHelp.java @@ -39,7 +39,7 @@ public class CommandHelp extends CommandBase { final String key; Translations() { - key = "command.help." + this.name() + key = "kubatech.command.help." + this.name() .toLowerCase(); } diff --git a/src/main/java/kubatech/commands/CommandTea.java b/src/main/java/kubatech/commands/CommandTea.java index 64412f8ef3..c37fabab81 100644 --- a/src/main/java/kubatech/commands/CommandTea.java +++ b/src/main/java/kubatech/commands/CommandTea.java @@ -53,7 +53,7 @@ public class CommandTea extends CommandBase { final String key; Translations() { - key = "command.tea." + this.name() + key = "kubatech.command.tea." + this.name() .toLowerCase(); } diff --git a/src/main/java/kubatech/config/Config.java b/src/main/java/kubatech/config/Config.java index 6508063faf..1976e76949 100644 --- a/src/main/java/kubatech/config/Config.java +++ b/src/main/java/kubatech/config/Config.java @@ -51,59 +51,10 @@ public class Config { public static class MobHandler { - public static boolean mobHandlerEnabled = true; - - public enum _CacheRegenerationTrigger { - - Never, - ModAdditionRemoval, - ModAdditionRemovalChange, - Always; - - public static _CacheRegenerationTrigger get(int oridinal) { - return values()[oridinal]; - } - } - - public static _CacheRegenerationTrigger regenerationTrigger = _CacheRegenerationTrigger.ModAdditionRemovalChange; - public static boolean includeEmptyMobs = true; - public static String[] mobBlacklist; public static double playerOnlyDropsModifier = .1d; private static void load(Configuration configuration) { Category category = Category.MOB_HANDLER; - mobHandlerEnabled = configuration - .get(category.get(), "Enabled", true, "Enable \"Mob Drops\" NEI page and Extreme Extermination Chamber") - .getBoolean(); - StringBuilder c = new StringBuilder("When will cache regeneration trigger? "); - for (_CacheRegenerationTrigger value : _CacheRegenerationTrigger.values()) c.append(value.ordinal()) - .append(" - ") - .append(value.name()) - .append(", "); - regenerationTrigger = _CacheRegenerationTrigger.get( - configuration - .get( - category.get(), - "CacheRegenerationTrigger", - _CacheRegenerationTrigger.ModAdditionRemovalChange.ordinal(), - c.toString()) - .getInt()); - includeEmptyMobs = configuration - .get(category.get(), "IncludeEmptyMobs", true, "Include mobs that have no drops in NEI") - .getBoolean(); - mobBlacklist = configuration - .get( - category.get(), - "MobBlacklist", - new String[] { "Giant", "Thaumcraft.TravelingTrunk", "chisel.snowman", "OpenBlocks.Luggage", - "OpenBlocks.MiniMe", "SpecialMobs.SpecialCreeper", "SpecialMobs.SpecialZombie", - "SpecialMobs.SpecialPigZombie", "SpecialMobs.SpecialSlime", "SpecialMobs.SpecialSkeleton", - "SpecialMobs.SpecialEnderman", "SpecialMobs.SpecialCaveSpider", "SpecialMobs.SpecialGhast", - "SpecialMobs.SpecialWitch", "SpecialMobs.SpecialSpider", "TwilightForest.HydraHead", - "TwilightForest.RovingCube", "TwilightForest.Harbinger Cube", "TwilightForest.Adherent", - "SpecialMobs.SpecialSilverfish", }, - "These mobs will be skipped when generating recipe map") - .getStringList(); playerOnlyDropsModifier = configuration .get( category.get(), diff --git a/src/main/java/kubatech/config/OverridesConfig.java b/src/main/java/kubatech/config/OverridesConfig.java deleted file mode 100644 index 6547854557..0000000000 --- a/src/main/java/kubatech/config/OverridesConfig.java +++ /dev/null @@ -1,246 +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.config; - -import java.io.File; -import java.io.Reader; -import java.io.Writer; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.JsonToNBT; -import net.minecraft.nbt.NBTTagCompound; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.dreammaster.main.MainRegistry; -import com.dreammaster.modcustomdrops.CustomDrops; -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import cpw.mods.fml.common.registry.GameRegistry; -import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; -import kubatech.Tags; -import kubatech.api.ConstructableItemStack; -import kubatech.api.LoaderReference; -import kubatech.api.helpers.ReflectionHelper; -import kubatech.api.mobhandler.MobDrop; -import kubatech.api.utils.GSONUtils; - -public class OverridesConfig { - - private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Config-Overrides]"); - - public static class MobDropSimplified { - - @GSONUtils.SkipGSON - ItemStack stack; - - ConstructableItemStack reconstructableStack; - MobDrop.DropType type; - - private MobDropSimplified() {} - - public MobDropSimplified(ItemStack stack, MobDrop.DropType type) { - reconstructableStack = new ConstructableItemStack(stack); - this.type = type; - } - - public void reconstructStack() { - stack = reconstructableStack.construct(); - } - - public boolean isMatching(MobDrop drop) { - return reconstructableStack.isSame(drop.reconstructableStack, true); - } - - private static final ByteBuf BufHelper = Unpooled.buffer(); - - public void writeToByteBuf(ByteBuf byteBuf) { - BufHelper.clear(); - reconstructableStack.writeToByteBuf(BufHelper); - BufHelper.writeInt(type.ordinal()); - byteBuf.writeInt(BufHelper.readableBytes()); - byteBuf.writeBytes(BufHelper); - } - - public static MobDropSimplified readFromByteBuf(ByteBuf byteBuf) { - MobDropSimplified mobDropSimplified = new MobDropSimplified(); - int size = byteBuf.readInt(); - mobDropSimplified.reconstructableStack = ConstructableItemStack.readFromByteBuf(byteBuf); - mobDropSimplified.type = MobDrop.DropType.get(byteBuf.readInt()); - mobDropSimplified.reconstructStack(); - return mobDropSimplified; - } - } - - public static class MobOverride { - - public boolean removeAll = false; - public final List<MobDrop> additions = new ArrayList<>(); - public final List<MobDropSimplified> removals = new ArrayList<>(); - - private static final ByteBuf BufHelper = Unpooled.buffer(); - - public void writeToByteBuf(ByteBuf byteBuf) { - BufHelper.clear(); - BufHelper.writeBoolean(removeAll); - BufHelper.writeInt(additions.size()); - additions.forEach(drop -> drop.writeToByteBuf(BufHelper)); - BufHelper.writeInt(removals.size()); - removals.forEach(drop -> drop.writeToByteBuf(BufHelper)); - byteBuf.writeInt(BufHelper.readableBytes()); - byteBuf.writeBytes(BufHelper); - } - - public static MobOverride readFromByteBuf(ByteBuf byteBuf) { - int size = byteBuf.readInt(); - MobOverride mobOverride = new MobOverride(); - mobOverride.removeAll = byteBuf.readBoolean(); - int additionssize = byteBuf.readInt(); - for (int i = 0; i < additionssize; i++) mobOverride.additions.add(MobDrop.readFromByteBuf(byteBuf)); - int removalssize = byteBuf.readInt(); - for (int i = 0; i < removalssize; i++) mobOverride.removals.add(MobDropSimplified.readFromByteBuf(byteBuf)); - return mobOverride; - } - } - - public static Map<String, MobOverride> overrides = new HashMap<>(); - private static File overrideFile = null; - - private static final Gson gson = GSONUtils.GSON_BUILDER_PRETTY.create(); - - @SuppressWarnings("UnstableApiUsage") - public static void LoadConfig() { - LOG.info("Loading Config"); - if (overrideFile == null) overrideFile = Config.getConfigFile("MobOverrides.json"); - if (!overrideFile.exists()) writeExampleFile(); - Reader reader = null; - try { - reader = Files.newReader(overrideFile, StandardCharsets.UTF_8); - overrides = gson.fromJson(reader, new TypeToken<Map<String, MobOverride>>() {}.getType()); - overrides.remove("ExampleMob"); - overrides.values() - .forEach(o -> o.additions.forEach(MobDrop::reconstructStack)); - if (LoaderReference.GTNHCoreMod) { - LOG.info("Detected GTNH Core Mod, parsing custom drops from there."); - CustomDrops coredrops = ReflectionHelper - .getField(MainRegistry.Module_CustomDrops, "_mCustomDrops", null); - if (coredrops != null) { - @SuppressWarnings("unchecked") - ArrayList<CustomDrops.CustomDrop> customdrops = (ArrayList<CustomDrops.CustomDrop>) ((ArrayList<CustomDrops.CustomDrop>) coredrops - .getCustomDrops()).clone(); - for (CustomDrops.CustomDrop customdrop : customdrops) { - try { - Class<?> eclass = Class.forName(customdrop.getEntityName()); - if (!EntityLiving.class.isAssignableFrom(eclass)) continue; - String ename = (String) EntityList.classToStringMapping.get(eclass); - if (ename == null) continue; - MobOverride override = overrides.computeIfAbsent(ename, k -> new MobOverride()); - for (CustomDrops.CustomDrop.Drop drop : customdrop.getDrops()) { - String[] parts = drop.getItemName() - .split(":"); - ItemStack stack = GameRegistry.findItemStack(parts[0], parts[1], 1); - if (stack == null) continue; - if (parts.length > 2) stack.setItemDamage(Integer.parseInt(parts[2])); - String pNBT = ReflectionHelper.getField(drop, "mTag", null); - if (pNBT != null && !pNBT.isEmpty()) { - try { - stack.stackTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(pNBT); - } catch (Exception ignored) {} - } - int chance = drop.getChance() * 100; - int amount = drop.getAmount(); - if (drop.getIsRandomAmount()) { - // average chance formula - // chance *= ((((amount * (amount + 1d)) / 2d)) + 1d) / (amount + 1d); - chance *= (2d + (amount * amount) + amount) / (2d * (amount + 1d)); - amount = 1; - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - amount *= div; - chance /= div; - } - } - stack.stackSize = amount; - // Drops from coremod are player only - override.additions - .add(new MobDrop(stack, MobDrop.DropType.Normal, chance, null, null, false, true)); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - if (reader != null) try { - reader.close(); - } catch (Exception ignored) {} - } - } - - @SuppressWarnings("UnstableApiUsage") - private static void writeExampleFile() { - LOG.info("No config has been detected, writing an example one"); - Writer writer = null; - try { - writer = Files.newWriter(overrideFile, StandardCharsets.UTF_8); - Map<String, MobOverride> example = new HashMap<>(1); - MobOverride ex1 = new MobOverride(); - ex1.removals.add(new MobDropSimplified(new ItemStack(Items.rotten_flesh, 1), MobDrop.DropType.Normal)); - HashMap<Integer, Integer> exdamages = new HashMap<>(3); - exdamages.put(1, 1); - exdamages.put(2, 5); - exdamages.put(3, 10); - ex1.additions.add( - new MobDrop( - new ItemStack(Items.diamond_sword), - MobDrop.DropType.Rare, - 500, - 20, - exdamages, - true, - false)); - example.put("ExampleMob", ex1); - gson.toJson(example, writer); - writer.flush(); - } catch (Exception ex) { - ex.printStackTrace(); - } finally { - if (writer != null) try { - writer.close(); - } catch (Exception ignored) {} - } - } -} diff --git a/src/main/java/kubatech/kubatech.java b/src/main/java/kubatech/kubatech.java index 6cb6bd299c..5bc38d189e 100644 --- a/src/main/java/kubatech/kubatech.java +++ b/src/main/java/kubatech/kubatech.java @@ -49,8 +49,8 @@ import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; import cpw.mods.fml.relauncher.Side; import kubatech.api.enums.ItemList; import kubatech.api.helpers.ReflectionHelper; -import kubatech.api.network.CustomTileEntityPacket; -import kubatech.api.network.LoadConfigPacket; +import kubatech.network.CustomTileEntityPacket; +import kubatech.network.LoadConfigPacket; @SuppressWarnings("unused") @Mod( @@ -60,6 +60,7 @@ import kubatech.api.network.LoadConfigPacket; acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after: gregtech; " + "required-after: gtnhmixins@[2.0.1,); " + "required-after: modularui; " + + "required-after: mobsinfo; " + "after: EnderIO; " + "after: AWWayofTime; " + "after: ExtraUtilities; " diff --git a/src/main/java/kubatech/loaders/MobHandlerLoader.java b/src/main/java/kubatech/loaders/MobHandlerLoader.java new file mode 100644 index 0000000000..2ebff9afaf --- /dev/null +++ b/src/main/java/kubatech/loaders/MobHandlerLoader.java @@ -0,0 +1,258 @@ +package kubatech.loaders; + +import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.DIAMOND_SPIKES_DAMAGE; +import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MOB_SPAWN_INTERVAL; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Random; + +import net.minecraft.enchantment.EnchantmentHelper; +import net.minecraft.entity.EntityList; +import net.minecraft.entity.EntityLiving; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.JsonToNBT; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.StatCollector; +import net.minecraftforge.common.MinecraftForge; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.dreammaster.main.MainRegistry; +import com.dreammaster.modcustomdrops.CustomDrops; +import com.kuba6000.mobsinfo.api.MobDrop; +import com.kuba6000.mobsinfo.api.MobOverride; +import com.kuba6000.mobsinfo.api.MobRecipe; +import com.kuba6000.mobsinfo.api.event.MobNEIRegistrationEvent; +import com.kuba6000.mobsinfo.api.event.PostMobRegistrationEvent; +import com.kuba6000.mobsinfo.api.event.PostMobsOverridesLoadEvent; +import com.kuba6000.mobsinfo.api.event.PreMobsRegistrationEvent; + +import atomicstryker.infernalmobs.common.InfernalMobsCore; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.registry.GameRegistry; +import gregtech.api.util.GT_Utility; +import kubatech.Tags; +import kubatech.api.LoaderReference; +import kubatech.api.helpers.ReflectionHelper; +import kubatech.config.Config; +import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber; + +public class MobHandlerLoader { + + private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler Loader]"); + + private static MobHandlerLoader instance = null; + + public static void init() { + instance = new MobHandlerLoader(); + MinecraftForge.EVENT_BUS.register(instance); + } + + public static Map<String, MobEECRecipe> recipeMap = new HashMap<>(); + + public static class MobEECRecipe { + + public final List<MobDrop> mOutputs; + + public final MobRecipe recipe; + + public final int mEUt = 2000; + public final int mDuration; + + public MobEECRecipe(List<MobDrop> transformedDrops, MobRecipe recipe) { + this.mOutputs = transformedDrops; + this.recipe = recipe; + mDuration = Math.max(MOB_SPAWN_INTERVAL, (int) ((recipe.maxEntityHealth / DIAMOND_SPIKES_DAMAGE) * 10d)); + } + + public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeExterminationChamber MTE, + double attackDamage, int lootinglevel, boolean preferInfernalDrops) { + MTE.lEUt = mEUt; + MTE.mMaxProgresstime = Math.max(MOB_SPAWN_INTERVAL, (int) ((recipe.maxEntityHealth / attackDamage) * 10d)); + ArrayList<ItemStack> stacks = new ArrayList<>(this.mOutputs.size()); + for (MobDrop o : this.mOutputs) { + int chance = o.chance; + if (o.playerOnly) { + chance = (int) ((double) chance * Config.MobHandler.playerOnlyDropsModifier); + if (chance < 1) chance = 1; + } + int amount = o.stack.stackSize; + if (o.lootable && lootinglevel > 0) { + chance += lootinglevel * 5000; + if (chance > 10000) { + int div = (int) Math.ceil(chance / 10000d); + amount *= div; + chance /= div; + } + } + if (chance == 10000 || rnd.nextInt(10000) < chance) { + ItemStack s = o.stack.copy(); + s.stackSize = amount; + if (o.enchantable != null) EnchantmentHelper.addRandomEnchantment(rnd, s, o.enchantable); + if (o.damages != null) { + int rChance = rnd.nextInt(recipe.mMaxDamageChance); + int cChance = 0; + for (Map.Entry<Integer, Integer> damage : o.damages.entrySet()) { + cChance += damage.getValue(); + if (rChance <= cChance) { + s.setItemDamage(damage.getKey()); + break; + } + } + } + stacks.add(s); + } + } + + if (LoaderReference.InfernalMobs) { + InfernalMobsCore infernalMobsCore = InfernalMobsCore.instance(); + if (recipe.infernalityAllowed && mEUt * 8 < MTE.getMaxInputVoltage() + && !infernalMobsCore.getDimensionBlackList() + .contains( + MTE.getBaseMetaTileEntity() + .getWorld().provider.dimensionId)) { + int p = 0; + int mods = 0; + if (recipe.alwaysinfernal + || (preferInfernalDrops && rnd.nextInt(infernalMobsCore.getEliteRarity()) == 0)) { + p = 1; + if (rnd.nextInt(infernalMobsCore.getUltraRarity()) == 0) { + p = 2; + if (rnd.nextInt(infernalMobsCore.getInfernoRarity()) == 0) p = 3; + } + } + ArrayList<ItemStack> infernalstacks = null; + if (p > 0) if (p == 1) { + infernalstacks = infernalMobsCore.getDropIdListElite(); + mods = infernalMobsCore.getMinEliteModifiers(); + } else if (p == 2) { + infernalstacks = infernalMobsCore.getDropIdListUltra(); + mods = infernalMobsCore.getMinUltraModifiers(); + } else { + infernalstacks = infernalMobsCore.getDropIdListInfernal(); + mods = infernalMobsCore.getMinInfernoModifiers(); + } + if (infernalstacks != null) { + ItemStack infernalstack = infernalstacks.get(rnd.nextInt(infernalstacks.size())) + .copy(); + // noinspection ConstantConditions + EnchantmentHelper.addRandomEnchantment( + rnd, + infernalstack, + infernalstack.getItem() + .getItemEnchantability()); + stacks.add(infernalstack); + MTE.lEUt *= 8L; + MTE.mMaxProgresstime *= mods * InfernalMobsCore.instance() + .getMobModHealthFactor(); + } + } + } + + return stacks.toArray(new ItemStack[0]); + } + + } + + @SubscribeEvent + public void onPreMobsRegistration(PreMobsRegistrationEvent event) { + recipeMap.clear(); + } + + @SubscribeEvent + public void onPostMobRegistration(PostMobRegistrationEvent event) { + if (!event.drops.isEmpty() && event.recipe.isUsableInVial) { + ArrayList<MobDrop> drops = (ArrayList<MobDrop>) event.drops.clone(); + drops.removeIf(d -> d.chance == 0); + if (!drops.isEmpty()) { + recipeMap.put(event.currentMob, new MobEECRecipe(drops, event.recipe)); + event.drops.stream() + .filter(d -> d.chance == 0) + .forEach( + d -> d.additionalInfo.add(StatCollector.translateToLocal("kubatech.mobhandler.eec_disabled"))); + } + } + } + + @SubscribeEvent + public void onPostOverridesConfigLoad(PostMobsOverridesLoadEvent event) { + if (LoaderReference.GTNHCoreMod) { + LOG.info("Detected GTNH Core Mod, parsing custom drops from there."); + CustomDrops coredrops = ReflectionHelper.getField(MainRegistry.Module_CustomDrops, "_mCustomDrops", null); + if (coredrops != null) { + @SuppressWarnings("unchecked") + ArrayList<CustomDrops.CustomDrop> customdrops = (ArrayList<CustomDrops.CustomDrop>) ((ArrayList<CustomDrops.CustomDrop>) coredrops + .getCustomDrops()).clone(); + for (CustomDrops.CustomDrop customdrop : customdrops) { + try { + Class<?> eclass = Class.forName(customdrop.getEntityName()); + if (!EntityLiving.class.isAssignableFrom(eclass)) continue; + String ename = (String) EntityList.classToStringMapping.get(eclass); + if (ename == null) continue; + MobOverride override = event.overrides.computeIfAbsent(ename, k -> new MobOverride()); + for (CustomDrops.CustomDrop.Drop drop : customdrop.getDrops()) { + String[] parts = drop.getItemName() + .split(":"); + ItemStack stack = GameRegistry.findItemStack(parts[0], parts[1], 1); + if (stack == null) continue; + if (parts.length > 2) stack.setItemDamage(Integer.parseInt(parts[2])); + String pNBT = ReflectionHelper.getField(drop, "mTag", null); + if (pNBT != null && !pNBT.isEmpty()) { + try { + stack.stackTagCompound = (NBTTagCompound) JsonToNBT.func_150315_a(pNBT); + } catch (Exception ignored) {} + } + int chance = drop.getChance() * 100; + int amount = drop.getAmount(); + if (drop.getIsRandomAmount()) { + // average chance formula + // chance *= ((((amount * (amount + 1d)) / 2d)) + 1d) / (amount + 1d); + chance *= (2d + (amount * amount) + amount) / (2d * (amount + 1d)); + amount = 1; + if (chance > 10000) { + int div = (int) Math.ceil(chance / 10000d); + amount *= div; + chance /= div; + } + } + stack.stackSize = amount; + // Drops from coremod are player only + MobDrop mobDrop = new MobDrop( + stack, + MobDrop.DropType.Normal, + chance, + null, + null, + false, + true); + mobDrop.additionalInfo.add( + StatCollector.translateToLocalFormatted( + "kubatech.mobhandler.eec_chance", + (((double) chance / 100d) * Config.MobHandler.playerOnlyDropsModifier))); + override.additions.add(mobDrop); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + + } + + @SubscribeEvent + public void onMobNEIRegistration(MobNEIRegistrationEvent event) { + MobEECRecipe recipe = recipeMap.get(event.mobName); + if (recipe != null) { + event.additionalInformation.addAll( + Arrays.asList( + GT_Utility.trans("153", "Usage: ") + GT_Utility.formatNumbers(recipe.mEUt) + " EU/t", + GT_Utility.trans("158", "Time: ") + GT_Utility.formatNumbers(recipe.mDuration / 20d) + " secs")); + } + } +} diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java deleted file mode 100644 index da54d44117..0000000000 --- a/src/main/java/kubatech/loaders/MobRecipeLoader.java +++ /dev/null @@ -1,1326 +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.loaders; - -import static kubatech.api.utils.ModUtils.isClientSided; -import static kubatech.api.utils.ModUtils.isDeobfuscatedEnvironment; -import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.DIAMOND_SPIKES_DAMAGE; -import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MOB_SPAWN_INTERVAL; -import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MobNameToRecipeMap; - -import java.io.File; -import java.io.Reader; -import java.io.Writer; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.UUID; -import java.util.function.Supplier; -import java.util.stream.Collectors; - -import net.minecraft.block.Block; -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.item.EntityItem; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.entity.monster.EntitySlime; -import net.minecraft.entity.monster.IMob; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.DamageSource; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; -import net.minecraftforge.common.ForgeHooks; -import net.minecraftforge.common.util.FakePlayer; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import com.google.common.io.Files; -import com.google.gson.Gson; -import com.mojang.authlib.GameProfile; - -import atomicstryker.infernalmobs.common.InfernalMobsCore; -import atomicstryker.infernalmobs.common.MobModifier; -import atomicstryker.infernalmobs.common.mods.api.ModifierLoader; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.util.GT_Utility; -import gregtech.common.GT_DummyWorld; -import kubatech.Tags; -import kubatech.api.LoaderReference; -import kubatech.api.helpers.EnderIOHelper; -import kubatech.api.helpers.ProgressBarWrapper; -import kubatech.api.mobhandler.MobDrop; -import kubatech.api.network.LoadConfigPacket; -import kubatech.api.utils.FastRandom; -import kubatech.api.utils.GSONUtils; -import kubatech.api.utils.ModUtils; -import kubatech.api.utils.ModUtils.TriConsumer; -import kubatech.config.Config; -import kubatech.config.OverridesConfig; -import kubatech.mixin.mixins.minecraft.EntityAccessor; -import kubatech.mixin.mixins.minecraft.EntityLivingAccessor; -import kubatech.mixin.mixins.minecraft.EntityLivingBaseAccessor; -import kubatech.mixin.mixins.minecraft.EntitySlimeAccessor; -import kubatech.nei.Mob_Handler; -import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber; -import minetweaker.MineTweakerAPI; -import minetweaker.api.entity.IEntityDefinition; -import minetweaker.api.item.IItemStack; -import minetweaker.mc1710.item.MCItemStack; -import stanhebben.zenscript.value.IntRange; -import thaumcraft.common.items.wands.ItemWandCasting; - -public class MobRecipeLoader { - - private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Recipe Loader]"); - - private static final String addRandomArmorName = isDeobfuscatedEnvironment ? "addRandomArmor" : "func_82164_bB"; - private static final String enchantEquipmentName = isDeobfuscatedEnvironment ? "enchantEquipment" : "func_82162_bC"; - - private static boolean alreadyGenerated = false; - public static boolean isInGenerationProcess = false; - public static final String randomEnchantmentDetectedString = "RandomEnchantmentDetected"; - - public static class MobRecipe { - - public final ArrayList<MobDrop> mOutputs; - public final int mEUt = 2000; - public final int mDuration; - public int mMaxDamageChance; - public final boolean infernalityAllowed; - public final boolean alwaysinfernal; - public static droplist infernaldrops; - public final boolean isPeacefulAllowed; - public final EntityLiving entity; - public final float maxEntityHealth; - public final boolean isUsable; - - @SuppressWarnings("unchecked") - public MobRecipe copy() { - return new MobRecipe( - (ArrayList<MobDrop>) mOutputs.clone(), - mDuration, - mMaxDamageChance, - infernalityAllowed, - alwaysinfernal, - isPeacefulAllowed, - entity, - maxEntityHealth, - isUsable); - } - - private MobRecipe(ArrayList<MobDrop> mOutputs, int mDuration, int mMaxDamageChance, boolean infernalityAllowed, - boolean alwaysinfernal, boolean isPeacefulAllowed, EntityLiving entity, float maxEntityHealth, - boolean isUsable) { - this.mOutputs = mOutputs; - this.mDuration = mDuration; - this.mMaxDamageChance = mMaxDamageChance; - this.infernalityAllowed = infernalityAllowed; - this.alwaysinfernal = alwaysinfernal; - this.isPeacefulAllowed = isPeacefulAllowed; - this.entity = entity; - this.maxEntityHealth = maxEntityHealth; - this.isUsable = isUsable; - } - - public static MobRecipe generateMobRecipe(EntityLiving e, String entityID, ArrayList<MobDrop> outputs) { - return new MobRecipe(e, entityID, outputs); - } - - @SuppressWarnings("unchecked") - private MobRecipe(EntityLiving e, String entityID, ArrayList<MobDrop> outputs) { - if (LoaderReference.InfernalMobs) { - InfernalMobsCore infernalMobsCore = InfernalMobsCore.instance(); - if (infernaldrops == null) { - infernaldrops = new droplist(); - LOG.info("Generating Infernal drops"); - ArrayList<ModifierLoader<?>> modifierLoaders = (ArrayList<ModifierLoader<?>>) infernalMobsCore - .getModifierLoaders() - .clone(); - int i = 0; - for (ModifierLoader<?> modifierLoader : modifierLoaders) { - MobModifier nextMod = modifierLoader.make(null); - if (nextMod.getBlackListMobClasses() != null) - for (Class<?> cl : nextMod.getBlackListMobClasses()) if (e.getClass() - .isAssignableFrom(cl)) break; - i++; - } - if (i > 0) { - double chance = infernalMobsCore.checkEntityClassForced(e) ? 1d - : (1d / infernalMobsCore.getEliteRarity()); - ArrayList<ItemStack> elitelist = infernalMobsCore.getDropIdListElite(); - for (ItemStack stack : elitelist) { - dropinstance instance = infernaldrops - .add(new dropinstance(stack.copy(), infernaldrops), chance / elitelist.size()); - instance.isEnchatmentRandomized = true; - // noinspection ConstantConditions - instance.enchantmentLevel = stack.getItem() - .getItemEnchantability(); - } - ArrayList<ItemStack> ultralist = infernalMobsCore.getDropIdListUltra(); - chance *= 1d / infernalMobsCore.getUltraRarity(); - for (ItemStack stack : ultralist) { - dropinstance instance = infernaldrops - .add(new dropinstance(stack.copy(), infernaldrops), chance / ultralist.size()); - instance.isEnchatmentRandomized = true; - // noinspection ConstantConditions - instance.enchantmentLevel = stack.getItem() - .getItemEnchantability(); - } - ArrayList<ItemStack> infernallist = infernalMobsCore.getDropIdListInfernal(); - chance *= 1d / infernalMobsCore.getInfernoRarity(); - for (ItemStack stack : infernallist) { - dropinstance instance = infernaldrops - .add(new dropinstance(stack.copy(), infernaldrops), chance / infernallist.size()); - instance.isEnchatmentRandomized = true; - // noinspection ConstantConditions - instance.enchantmentLevel = stack.getItem() - .getItemEnchantability(); - } - } - } - infernalityAllowed = infernalMobsCore.isClassAllowed(e); - alwaysinfernal = infernalMobsCore.checkEntityClassForced(e); - } else { - infernalityAllowed = false; - alwaysinfernal = false; - } - - if (infernaldrops == null) infernaldrops = new droplist(); - - isPeacefulAllowed = !(e instanceof IMob); - - mOutputs = (ArrayList<MobDrop>) outputs.clone(); - int maxdamagechance = 0; - for (MobDrop o : mOutputs) if (o.damages != null) for (int v : o.damages.values()) maxdamagechance += v; - mMaxDamageChance = maxdamagechance; - maxEntityHealth = e.getMaxHealth(); - mDuration = Math.max(MOB_SPAWN_INTERVAL, (int) ((maxEntityHealth / DIAMOND_SPIKES_DAMAGE) * 10d)); - entity = e; - isUsable = EnderIOHelper.canEntityBeCapturedWithSoulVial(e, entityID); - } - - public void refresh() { - int maxdamagechance = 0; - for (MobDrop o : mOutputs) if (o.damages != null) for (int v : o.damages.values()) maxdamagechance += v; - mMaxDamageChance = maxdamagechance; - } - - public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeExterminationChamber MTE, - double attackDamage, int lootinglevel, boolean preferInfernalDrops) { - MTE.lEUt = mEUt; - MTE.mMaxProgresstime = Math.max(MOB_SPAWN_INTERVAL, (int) ((maxEntityHealth / attackDamage) * 10d)); - ArrayList<ItemStack> stacks = new ArrayList<>(mOutputs.size()); - for (MobDrop o : mOutputs) { - int chance = o.chance; - if (o.playerOnly) { - chance = (int) ((double) chance * Config.MobHandler.playerOnlyDropsModifier); - if (chance < 1) chance = 1; - } - int amount = o.stack.stackSize; - if (o.lootable && lootinglevel > 0) { - chance += lootinglevel * 5000; - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - amount *= div; - chance /= div; - } - } - if (chance == 10000 || rnd.nextInt(10000) < chance) { - ItemStack s = o.stack.copy(); - s.stackSize = amount; - if (o.enchantable != null) EnchantmentHelper.addRandomEnchantment(rnd, s, o.enchantable); - if (o.damages != null) { - int rChance = rnd.nextInt(mMaxDamageChance); - int cChance = 0; - for (Map.Entry<Integer, Integer> damage : o.damages.entrySet()) { - cChance += damage.getValue(); - if (rChance <= cChance) { - s.setItemDamage(damage.getKey()); - break; - } - } - } - stacks.add(s); - } - } - - if (LoaderReference.InfernalMobs) { - InfernalMobsCore infernalMobsCore = InfernalMobsCore.instance(); - if (infernalityAllowed && mEUt * 8 < MTE.getMaxInputVoltage() - && !infernalMobsCore.getDimensionBlackList() - .contains( - MTE.getBaseMetaTileEntity() - .getWorld().provider.dimensionId)) { - int p = 0; - int mods = 0; - if (alwaysinfernal - || (preferInfernalDrops && rnd.nextInt(infernalMobsCore.getEliteRarity()) == 0)) { - p = 1; - if (rnd.nextInt(infernalMobsCore.getUltraRarity()) == 0) { - p = 2; - if (rnd.nextInt(infernalMobsCore.getInfernoRarity()) == 0) p = 3; - } - } - ArrayList<ItemStack> infernalstacks = null; - if (p > 0) if (p == 1) { - infernalstacks = infernalMobsCore.getDropIdListElite(); - mods = infernalMobsCore.getMinEliteModifiers(); - } else if (p == 2) { - infernalstacks = infernalMobsCore.getDropIdListUltra(); - mods = infernalMobsCore.getMinUltraModifiers(); - } else { - infernalstacks = infernalMobsCore.getDropIdListInfernal(); - mods = infernalMobsCore.getMinInfernoModifiers(); - } - if (infernalstacks != null) { - ItemStack infernalstack = infernalstacks.get(rnd.nextInt(infernalstacks.size())) - .copy(); - // noinspection ConstantConditions - EnchantmentHelper.addRandomEnchantment( - rnd, - infernalstack, - infernalstack.getItem() - .getItemEnchantability()); - stacks.add(infernalstack); - MTE.lEUt *= 8L; - MTE.mMaxProgresstime *= mods * InfernalMobsCore.instance() - .getMobModHealthFactor(); - } - } - } - - return stacks.toArray(new ItemStack[0]); - } - } - - public static class fakeRand extends Random { - - private static class nexter { - - private final int type; - private final int bound; - private int next; - - public nexter(int type, int bound) { - this.next = 0; - this.bound = bound; - this.type = type; - } - - private int getType() { - return type; - } - - private boolean getBoolean() { - return next == 1; - } - - private int getInt() { - return next; - } - - private float getFloat() { - return next * 0.1f; - } - - private boolean next() { - next++; - return next >= bound; - } - } - - private final ArrayList<nexter> nexts = new ArrayList<>(); - private int walkCounter = 0; - private double chance; - private boolean exceptionOnEnchantTry = false; - private int maxWalkCount = -1; - private float forceFloatValue = -1.f; - - @Override - public int nextInt(int bound) { - if (exceptionOnEnchantTry && bound == Enchantment.enchantmentsBookList.length) return -1; - if (nexts.size() <= walkCounter) { // new call - if (maxWalkCount == walkCounter) { - return 0; - } - nexts.add(new nexter(0, bound)); - walkCounter++; - chance /= bound; - return 0; - } - chance /= bound; - return nexts.get(walkCounter++) - .getInt(); - } - - @Override - public float nextFloat() { - if (forceFloatValue != -1f) return forceFloatValue; - if (nexts.size() <= walkCounter) { // new call - if (maxWalkCount == walkCounter) { - return 0f; - } - nexts.add(new nexter(2, 10)); - walkCounter++; - chance /= 10; - return 0f; - } - chance /= 10; - return nexts.get(walkCounter++) - .getFloat(); - } - - @Override - public boolean nextBoolean() { - if (nexts.size() <= walkCounter) { // new call - if (maxWalkCount == walkCounter) { - return false; - } - nexts.add(new nexter(1, 2)); - walkCounter++; - chance /= 2; - return false; - } - chance /= 2; - return nexts.get(walkCounter++) - .getBoolean(); - } - - public void newRound() { - walkCounter = 0; - nexts.clear(); - chance = 1d; - maxWalkCount = -1; - exceptionOnEnchantTry = false; - forceFloatValue = -1f; - } - - public boolean nextRound() { - walkCounter = 0; - chance = 1d; - while (nexts.size() > 0 && nexts.get(nexts.size() - 1) - .next()) nexts.remove(nexts.size() - 1); - return nexts.size() > 0; - } - } - - private static class dropinstance { - - public boolean isDamageRandomized = false; - public HashMap<Integer, Integer> damagesPossible = new HashMap<>(); - public boolean isEnchatmentRandomized = false; - public int enchantmentLevel = 0; - public final ItemStack stack; - public final GT_Utility.ItemId itemId; - private double dropchance = 0d; - private int dropcount = 1; - private final droplist owner; - - public dropinstance(ItemStack s, droplist owner) { - this.owner = owner; - stack = s; - itemId = GT_Utility.ItemId.createNoCopy(stack); - } - - public int getchance(int chancemodifier) { - dropchance = (double) Math.round(dropchance * 100000) / 100000d; - return (int) (dropchance * chancemodifier); - } - - @Override - public int hashCode() { - return itemId.hashCode(); - } - } - - public static class droplist { - - private final ArrayList<dropinstance> drops = new ArrayList<>(); - private final HashMap<GT_Utility.ItemId, Integer> dropschecker = new HashMap<>(); - - public dropinstance add(dropinstance i, double chance) { - if (contains(i)) { - int ssize = i.stack.stackSize; - i = get(dropschecker.get(i.itemId)); - i.dropchance += chance * ssize; - i.dropcount += ssize; - return i; - } - drops.add(i); - i.dropchance += chance * i.stack.stackSize; - i.dropcount += i.stack.stackSize - 1; - i.stack.stackSize = 1; - dropschecker.put(i.itemId, drops.size() - 1); - return i; - } - - public dropinstance get(int index) { - return drops.get(index); - } - - public dropinstance get(dropinstance i) { - if (!contains(i)) return null; - return get(dropschecker.get(i.itemId)); - } - - public boolean contains(dropinstance i) { - return dropschecker.containsKey(i.itemId); - } - - public boolean contains(ItemStack stack) { - return dropschecker.containsKey(GT_Utility.ItemId.createNoCopy(stack)); - } - - public boolean isEmpty() { - return drops.isEmpty(); - } - - public int size() { - return drops.size(); - } - - public int indexOf(dropinstance i) { - if (!contains(i)) return -1; - return dropschecker.get(i.itemId); - } - } - - private static class dropCollector { - - final HashMap<GT_Utility.ItemId, Integer> damagableChecker = new HashMap<>(); - private boolean booksAlwaysRandomlyEnchanted = false; - - public void addDrop(droplist fdrops, ArrayList<EntityItem> listToParse, double chance) { - for (EntityItem entityItem : listToParse) { - ItemStack ostack = entityItem.getEntityItem(); - if (ostack == null) continue; - dropinstance drop; - boolean randomchomenchantdetected = ostack.hasTagCompound() - && ostack.stackTagCompound.hasKey(randomEnchantmentDetectedString); - int randomenchantmentlevel = 0; - if (randomchomenchantdetected) { - randomenchantmentlevel = ostack.stackTagCompound.getInteger(randomEnchantmentDetectedString); - ostack.stackTagCompound.removeTag("ench"); - ostack.stackTagCompound.setInteger(randomEnchantmentDetectedString, 0); - } - if ((booksAlwaysRandomlyEnchanted || randomchomenchantdetected) - && Items.enchanted_book == ostack.getItem()) { - NBTTagCompound tagCompound = (NBTTagCompound) ostack.stackTagCompound.copy(); - tagCompound.removeTag("StoredEnchantments"); - ostack = new ItemStack(Items.book, ostack.stackSize, 0); - if (!tagCompound.hasNoTags()) ostack.stackTagCompound = tagCompound; - if (randomenchantmentlevel == 0) randomenchantmentlevel = 1; - randomchomenchantdetected = true; - } - boolean randomdamagedetected = false; - int newdamage = -1; - if (ostack.isItemStackDamageable()) { - int odamage = ostack.getItemDamage(); - ostack.setItemDamage(1); - GT_Utility.ItemId id = GT_Utility.ItemId.createNoCopy(ostack); - damagableChecker.putIfAbsent(id, odamage); - int check = damagableChecker.get(id); - if (check != odamage) { - randomdamagedetected = true; - newdamage = odamage; - ostack.setItemDamage(check); - } else ostack.setItemDamage(odamage); - } - drop = fdrops.add(new dropinstance(ostack.copy(), fdrops), chance); - if (!drop.isEnchatmentRandomized && randomchomenchantdetected) { - drop.isEnchatmentRandomized = true; - drop.enchantmentLevel = randomenchantmentlevel; - } - if (drop.isDamageRandomized && !randomdamagedetected) { - drop.damagesPossible.merge(drop.stack.getItemDamage(), 1, Integer::sum); - } - if (randomdamagedetected) { - if (!drop.isDamageRandomized) { - drop.isDamageRandomized = true; - drop.damagesPossible.merge(drop.stack.getItemDamage(), drop.dropcount - 1, Integer::sum); - } - if (newdamage == -1) newdamage = drop.stack.getItemDamage(); - drop.damagesPossible.merge(newdamage, 1, Integer::sum); - } - } - - listToParse.clear(); - } - - public void newRound() { - damagableChecker.clear(); - booksAlwaysRandomlyEnchanted = false; - } - } - - public static class GeneralMappedMob { - - public final EntityLiving mob; - public final MobRecipe recipe; - public final ArrayList<MobDrop> drops; - - public GeneralMappedMob(EntityLiving mob, MobRecipe recipe, ArrayList<MobDrop> drops) { - this.mob = mob; - this.recipe = recipe; - this.drops = drops; - } - } - - public static final HashMap<String, GeneralMappedMob> GeneralMobList = new HashMap<>(); - - private static class MobRecipeLoaderCacheStructure { - - String version; - Map<String, ArrayList<MobDrop>> moblist; - } - - @SuppressWarnings({ "unchecked", "UnstableApiUsage" }) - public static void generateMobRecipeMap() { - - if (alreadyGenerated) return; - alreadyGenerated = true; - if (!Config.MobHandler.mobHandlerEnabled) return; - - World f = new GT_DummyWorld() { - - @Override - public boolean blockExists(int p_72899_1_, int p_72899_2_, int p_72899_3_) { - return false; - } - - @SuppressWarnings("rawtypes") - @Override - public List getEntitiesWithinAABB(Class p_72872_1_, AxisAlignedBB p_72872_2_) { - return new ArrayList(); - } - - @Override - public Block getBlock(int aX, int aY, int aZ) { - if (LoaderReference.TwilightForest && new Throwable().getStackTrace()[1].getClassName() - .equals("twilightforest.client.renderer.entity.RenderTFSnowQueenIceShield")) - return Blocks.packed_ice; - return super.getBlock(aX, aY, aZ); - } - }; - f.isRemote = true; // quick hack to get around achievements - - fakeRand frand = new fakeRand(); - f.rand = frand; - - File cache = Config.getConfigFile("MobRecipeLoader.cache"); - Gson gson = GSONUtils.GSON_BUILDER.create(); - - String modlistversion; - if (Config.MobHandler.regenerationTrigger == Config.MobHandler._CacheRegenerationTrigger.ModAdditionRemoval) - modlistversion = ModUtils.getModListVersionIgnoringModVersions(); - else modlistversion = ModUtils.getModListVersion(); - - if (Config.MobHandler.regenerationTrigger != Config.MobHandler._CacheRegenerationTrigger.Always - && cache.exists()) { - LOG.info("Parsing Cached map"); - Reader reader = null; - try { - reader = Files.newReader(cache, StandardCharsets.UTF_8); - MobRecipeLoaderCacheStructure s = gson.fromJson(reader, MobRecipeLoaderCacheStructure.class); - if (Config.MobHandler.regenerationTrigger == Config.MobHandler._CacheRegenerationTrigger.Never - || s.version.equals(modlistversion)) { - ProgressBarWrapper bar = new ProgressBarWrapper("Parsing cached Mob Recipe Map", s.moblist.size()); - for (Map.Entry<String, ArrayList<MobDrop>> entry : s.moblist.entrySet()) { - bar.step(entry.getKey()); - try { - EntityLiving e; - String mobName = entry.getKey(); - if (mobName.equals("witherSkeleton") - && !EntityList.stringToClassMapping.containsKey("witherSkeleton")) { - e = new EntitySkeleton(f); - ((EntitySkeleton) e).setSkeletonType(1); - } else e = (EntityLiving) ((Class<?>) EntityList.stringToClassMapping.get(mobName)) - .getConstructor(new Class[] { World.class }) - .newInstance(new Object[] { f }); - ArrayList<MobDrop> drops = entry.getValue(); - drops.forEach(MobDrop::reconstructStack); - GeneralMobList.put( - mobName, - new GeneralMappedMob(e, MobRecipe.generateMobRecipe(e, mobName, drops), drops)); - } catch (Exception ignored) {} - } - bar.end(); - LOG.info("Parsed cached map, skipping generation"); - return; - } else { - LOG.info("Cached map version mismatch, generating a new one"); - } - } catch (Exception ignored) { - LOG.warn("There was an exception while parsing cached map, generating a new one"); - } finally { - if (reader != null) try { - reader.close(); - } catch (Exception ignored) {} - } - } else { - LOG.info("Cached map doesn't exist or config option forced, generating a new one"); - } - - isInGenerationProcess = true; - - LOG.info("Generating Recipe Map for Mob Handler and EEC"); - - long time = System.currentTimeMillis(); - - dropCollector collector = new dropCollector(); - - // Stupid MC code, I need to cast myself - Map<String, Class<? extends Entity>> stringToClassMapping = (Map<String, Class<? extends Entity>>) EntityList.stringToClassMapping; - boolean registeringWitherSkeleton = !stringToClassMapping.containsKey("witherSkeleton"); - if (registeringWitherSkeleton) stringToClassMapping.put("witherSkeleton", EntitySkeleton.class); - ProgressBarWrapper bar = new ProgressBarWrapper("Generating Mob Recipe Map", stringToClassMapping.size()); - stringToClassMapping.forEach((k, v) -> { - bar.step(k); - if (v == null) return; - - if (Modifier.isAbstract(v.getModifiers())) { - LOG.info("Entity " + k + " is abstract, skipping"); - return; - } - - EntityLiving e; - try { - e = (EntityLiving) v.getConstructor(new Class[] { World.class }) - .newInstance(new Object[] { f }); - } catch (ClassCastException ex) { - // not a EntityLiving - LOG.info("Entity " + k + " is not a LivingEntity, skipping"); - return; - } catch (NoSuchMethodException ex) { - // No constructor ? - LOG.info("Entity " + k + " doesn't have constructor, skipping"); - return; - } catch (NoClassDefFoundError ex) { - // Its using classes from Client ? Then it's not important to include - LOG.info("Entity " + k + " is using undefined classes, skipping"); - return; - } catch (Throwable ex) { - ex.printStackTrace(); - return; - } - - if (registeringWitherSkeleton && e instanceof EntitySkeleton && k.equals("witherSkeleton")) - ((EntitySkeleton) e).setSkeletonType(1); - else if (StatCollector.translateToLocal("entity." + k + ".name") - .equals("entity." + k + ".name")) { - LOG.info("Entity " + k + " does't have localized name, skipping"); - return; - } - - // POWERFULL GENERATION - - try { - - e.captureDrops = true; - - if (e instanceof EntitySlime) ((EntitySlimeAccessor) e).callSetSlimeSize(1); - - ((EntityAccessor) e).setRand(frand); - - droplist drops = new droplist(); - droplist raredrops = new droplist(); - droplist superraredrops = new droplist(); - droplist additionaldrops = new droplist(); - droplist dropslooting = new droplist(); - droplist dropscustom = new droplist(); - - frand.newRound(); - collector.newRound(); - - Runnable checkForWitchery = () -> { - if (v.getName() - .startsWith("com.emoniph.witchery")) { - ((EntityLivingBaseAccessor) e).callDropFewItems(true, 0); - frand.newRound(); - frand.exceptionOnEnchantTry = true; - boolean enchantmentDetected = false; - try { - ((EntityLivingBaseAccessor) e).callDropFewItems(true, 0); - } catch (Exception ex) { - enchantmentDetected = true; - } - int w = frand.walkCounter; - frand.newRound(); - if (enchantmentDetected) { - frand.maxWalkCount = w; - collector.booksAlwaysRandomlyEnchanted = true; - } - e.capturedDrops.clear(); - } - }; - - TriConsumer<Supplier<Boolean>, droplist, String> doTheDrop = (callerCanceller, dList, dListName) -> { - boolean second = false; - do { - if (!callerCanceller.get()) break; - - collector.addDrop(dList, e.capturedDrops, frand.chance); - - if (second && frand.chance < 0.0000001d) { - LOG.warn("Skipping " + k + " " + dListName + " dropmap because it's too randomized"); - break; - } - second = true; - - } while (frand.nextRound()); - - frand.newRound(); - collector.newRound(); - }; - - checkForWitchery.run(); - - doTheDrop.accept(() -> { - ((EntityLivingBaseAccessor) e).callDropFewItems(true, 0); - return true; - }, drops, "normal"); - - checkForWitchery.run(); - - doTheDrop.accept(() -> { - ((EntityLivingBaseAccessor) e).callDropFewItems(true, 1); - return true; - }, dropslooting, "normal"); - - doTheDrop.accept(() -> { - ((EntityLivingBaseAccessor) e).callDropRareDrop(0); - return true; - }, raredrops, "rare"); - - doTheDrop.accept(() -> { - ((EntityLivingBaseAccessor) e).callDropRareDrop(1); - return true; - }, superraredrops, "rare"); - - if (registeringWitherSkeleton && e instanceof EntitySkeleton && k.equals("witherSkeleton")) { - dropinstance i = new dropinstance(new ItemStack(Items.stone_sword), additionaldrops); - i.isDamageRandomized = true; - int maxdamage = i.stack.getMaxDamage(); - int max = Math.max(maxdamage - 25, 1); - for (int d = Math.min(max, 25); d <= max; d++) i.damagesPossible.put(d, 1); - additionaldrops.add(i, 1d); - } else try { - Class<?> cl = e.getClass(); - boolean detectedException; - do { - detectedException = false; - try { - cl.getDeclaredMethod(addRandomArmorName); - } catch (Exception ex) { - detectedException = true; - cl = cl.getSuperclass(); - } - } while (detectedException && !cl.equals(Entity.class)); - if (cl.equals(EntityLiving.class) || cl.equals(Entity.class)) throw new Exception(); - cl = e.getClass(); - do { - detectedException = false; - try { - cl.getDeclaredMethod(enchantEquipmentName); - } catch (Exception ex) { - detectedException = true; - cl = cl.getSuperclass(); - } - } while (detectedException && !cl.equals(EntityLiving.class)); - boolean usingVanillaEnchantingMethod = cl.equals(EntityLiving.class); - double chanceModifierLocal = 1f; - if (v.getName() - .startsWith("twilightforest.entity")) { - frand.forceFloatValue = 0f; - chanceModifierLocal = 0.25f; - } - boolean second = false; - do { - ((EntityLivingAccessor) e).callAddRandomArmor(); - if (!usingVanillaEnchantingMethod) ((EntityLivingAccessor) e).callEnchantEquipment(); - ItemStack[] lastActiveItems = e.getLastActiveItems(); - for (int j = 0, lastActiveItemsLength = lastActiveItems.length; j - < lastActiveItemsLength; j++) { - ItemStack stack = lastActiveItems[j]; - if (stack != null) { - if (LoaderReference.Thaumcraft) - if (stack.getItem() instanceof ItemWandCasting) continue; // crashes the game when - // rendering in GUI - - int randomenchant = -1; - if (stack.hasTagCompound() - && stack.stackTagCompound.hasKey(randomEnchantmentDetectedString)) { - randomenchant = stack.stackTagCompound.getInteger(randomEnchantmentDetectedString); - stack.stackTagCompound.removeTag("ench"); - } - dropinstance i = additionaldrops.add( - new dropinstance(stack.copy(), additionaldrops), - frand.chance * chanceModifierLocal - * (usingVanillaEnchantingMethod ? (j == 0 ? 0.75d : 0.5d) : 1d)); - if (!i.isDamageRandomized && i.stack.isItemStackDamageable()) { - i.isDamageRandomized = true; - int maxdamage = i.stack.getMaxDamage(); - int max = Math.max(maxdamage - 25, 1); - for (int d = Math.min(max, 25); d <= max; d++) i.damagesPossible.put(d, 1); - } - if (!i.isEnchatmentRandomized && randomenchant != -1) { - i.isEnchatmentRandomized = true; - i.enchantmentLevel = randomenchant; - } - if (usingVanillaEnchantingMethod) { - if (!stack.hasTagCompound()) stack.stackTagCompound = new NBTTagCompound(); - stack.stackTagCompound.setInteger(randomEnchantmentDetectedString, 14); - dropinstance newdrop = additionaldrops.add( - new dropinstance(stack.copy(), additionaldrops), - frand.chance * chanceModifierLocal * (j == 0 ? 0.25d : 0.5d)); - newdrop.isEnchatmentRandomized = true; - newdrop.enchantmentLevel = 14; - newdrop.isDamageRandomized = i.isDamageRandomized; - newdrop.damagesPossible = (HashMap<Integer, Integer>) i.damagesPossible.clone(); - } - } - } - Arrays.fill(e.getLastActiveItems(), null); - - if (second && frand.chance < 0.0000001d) { - LOG.warn("Skipping " + k + " additional dropmap because it's too randomized"); - break; - } - second = true; - - } while (frand.nextRound()); - } catch (Exception ignored) {} - - frand.newRound(); - collector.newRound(); - - if (drops.isEmpty() && raredrops.isEmpty() && additionaldrops.isEmpty()) { - ArrayList<MobDrop> arr = new ArrayList<>(); - GeneralMobList.put(k, new GeneralMappedMob(e, MobRecipe.generateMobRecipe(e, k, arr), arr)); - LOG.info("Mapped " + k); - return; - } - - ArrayList<MobDrop> moboutputs = new ArrayList<>( - drops.size() + raredrops.size() + additionaldrops.size()); - - for (dropinstance drop : drops.drops) { - ItemStack stack = drop.stack; - if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString); - int chance = drop.getchance(10000); - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - stack.stackSize *= div; - chance /= div; - } - if (chance == 0) { - LOG.warn("Detected 0% loot, setting to 0.01%"); - chance = 1; - } - dropinstance dlooting = dropslooting.get(drop); - moboutputs.add( - new MobDrop( - stack, - MobDrop.DropType.Normal, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - dlooting != null && dlooting.dropcount > drop.dropcount, - false)); - } - for (dropinstance drop : raredrops.drops) { - ItemStack stack = drop.stack; - if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString); - int chance = drop.getchance(250); - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - stack.stackSize *= div; - chance /= div; - } - if (chance == 0) { - LOG.warn("Detected 0% loot, setting to 0.01%"); - chance = 1; - } - moboutputs.add( - new MobDrop( - stack, - MobDrop.DropType.Rare, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); - } - for (dropinstance drop : superraredrops.drops) { - if (raredrops.contains(drop)) continue; - ItemStack stack = drop.stack; - if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString); - int chance = drop.getchance(50); - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - stack.stackSize *= div; - chance /= div; - } - if (chance == 0) { - LOG.warn("Detected 0% loot, setting to 0.01%"); - chance = 1; - } - moboutputs.add( - new MobDrop( - stack, - MobDrop.DropType.Rare, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); - } - for (dropinstance drop : additionaldrops.drops) { - ItemStack stack = drop.stack; - if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString); - int chance = drop.getchance(850); - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - stack.stackSize *= div; - chance /= div; - } - if (chance == 0) { - LOG.warn("Detected 0% loot, setting to 0.01%"); - chance = 1; - } - moboutputs.add( - new MobDrop( - stack, - MobDrop.DropType.Additional, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); - } - - GeneralMobList - .put(k, new GeneralMappedMob(e, MobRecipe.generateMobRecipe(e, k, moboutputs), moboutputs)); - - LOG.info("Mapped " + k); - } catch (Exception ex) { - LOG.error("Something went wrong while generating recipes for " + k + ", stacktrace: "); - ex.printStackTrace(); - } - }); - - if (registeringWitherSkeleton) stringToClassMapping.remove("witherSkeleton"); - - time -= System.currentTimeMillis(); - time = -time; - - LOG.info("Recipe map generated ! It took " + time + "ms"); - - bar.end(); - - isInGenerationProcess = false; - - LOG.info("Saving generated map to file"); - MobRecipeLoaderCacheStructure s = new MobRecipeLoaderCacheStructure(); - s.version = modlistversion; - s.moblist = new HashMap<>(); - GeneralMobList.forEach((k, v) -> s.moblist.put(k, v.drops)); - Writer writer = null; - try { - writer = Files.newWriter(cache, StandardCharsets.UTF_8); - gson.toJson(s, writer); - writer.flush(); - writer.close(); - } catch (Exception e) { - e.printStackTrace(); - } finally { - if (writer != null) try { - writer.close(); - } catch (Exception ignored) {} - } - } - - @SuppressWarnings("UnstableApiUsage") - public static File makeCustomDrops() { - - dropCollector collector = new dropCollector(); - Map<String, OverridesConfig.MobOverride> customDropsMap = new HashMap<>(); - isInGenerationProcess = true; - - for (Map.Entry<String, GeneralMappedMob> mob : GeneralMobList.entrySet()) { - EntityLiving e = mob.getValue().mob; - String k = mob.getKey(); - - // There is high probability that the hooks are using custom random class - // so we are just going to do approximation by calling it 10k times :LoL: - ((EntityAccessor) e).setRand(new FastRandom()); - e.worldObj.isRemote = false; - - FakePlayer fp = new FakePlayer( - FMLCommonHandler.instance() - .getMinecraftServerInstance().worldServers[0], - new GameProfile( - UUID.nameUUIDFromBytes("[MobRecipeLoader]".getBytes(StandardCharsets.UTF_8)), - "[MobRecipeLoader]")); - - droplist dropscustom = new droplist(); - - try { - - for (int i = 0; i < 10000; i++) { - if (ForgeHooks - .onLivingDrops(e, DamageSource.causePlayerDamage(fp), e.capturedDrops, 0, true, 100)) { - LOG.warn("Event onLivingDrops for " + k + " has been cancelled, I am gonna ignore that!"); - break; - } - collector.addDrop(dropscustom, e.capturedDrops, 1.d / 10000.d); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - - e.worldObj.isRemote = true; - - collector.newRound(); - - if (!dropscustom.isEmpty()) { - OverridesConfig.MobOverride override = new OverridesConfig.MobOverride(); - for (dropinstance drop : dropscustom.drops) { - ItemStack stack = drop.stack; - if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString); - int chance = drop.getchance(10000); - if (chance > 10000) { - int div = (int) Math.ceil(chance / 10000d); - stack.stackSize *= div; - chance /= div; - } - override.additions.add( - new MobDrop( - drop.stack, - MobDrop.DropType.Normal, - chance, - drop.isEnchatmentRandomized ? drop.enchantmentLevel : null, - drop.isDamageRandomized ? drop.damagesPossible : null, - false, - false)); - customDropsMap.put(k, override); - } - } - - } - - Writer writer = null; - Gson gson = GSONUtils.GSON_BUILDER_PRETTY.create(); - File f = new File("CustomDropsMap.json"); - try { - writer = Files.newWriter(f, StandardCharsets.UTF_8); - gson.toJson(customDropsMap, writer); - writer.flush(); - } catch (Exception ex) { - ex.printStackTrace(); - f = null; - } finally { - if (writer != null) try { - writer.close(); - } catch (Exception ignored) {} - } - - isInGenerationProcess = false; - - return f; - } - - public static void processMobRecipeMap() { - LOG.info("Loading config"); - - OverridesConfig.LoadConfig(); - - if (isClientSided) Mob_Handler.clearRecipes(); - MobNameToRecipeMap.clear(); - LoadConfigPacket.instance.mobsToLoad.clear(); - LoadConfigPacket.instance.mobsOverrides.clear(); - for (Map.Entry<String, GeneralMappedMob> entry : GeneralMobList.entrySet()) { - String k = entry.getKey(); - GeneralMappedMob v = entry.getValue(); - if (Arrays.asList(Config.MobHandler.mobBlacklist) - .contains(k)) { - LOG.info("Entity " + k + " is blacklisted, skipping"); - continue; - } - - MobRecipe recipe = v.recipe; - recipe = recipe.copy(); - @SuppressWarnings("unchecked") - ArrayList<MobDrop> drops = (ArrayList<MobDrop>) v.drops.clone(); - - // MT Scripts should already be loaded here - if (LoaderReference.MineTweaker) { - Optionals.parseMTAdditions(k, drops, recipe); - } - - OverridesConfig.MobOverride override; - if ((override = OverridesConfig.overrides.get(k)) != null) { - if (override.removeAll) { - drops.clear(); - recipe.mOutputs.clear(); - } else for (OverridesConfig.MobDropSimplified removal : override.removals) { - drops.removeIf(removal::isMatching); - recipe.mOutputs.removeIf(removal::isMatching); - } - drops.addAll(override.additions); - recipe.mOutputs.addAll(override.additions); - LoadConfigPacket.instance.mobsOverrides.put(k, override); - } - recipe.refresh(); - - if (drops.isEmpty()) { - LOG.info("Entity " + k + " doesn't drop any items, skipping EEC map"); - if (!Config.MobHandler.includeEmptyMobs) continue; - LoadConfigPacket.instance.mobsToLoad.add(k); - LOG.info("Registered " + k); - continue; - } - if (v.recipe.mOutputs.size() > 0) MobNameToRecipeMap.put(k, recipe); - LoadConfigPacket.instance.mobsToLoad.add(k); - LOG.info("Registered " + k); - } - } - - @SideOnly(Side.CLIENT) - public static void processMobRecipeMap(HashSet<String> mobs, - HashMap<String, OverridesConfig.MobOverride> overrides) { - Mob_Handler.clearRecipes(); - MobNameToRecipeMap.clear(); - mobs.forEach(k -> { - GeneralMappedMob v = GeneralMobList.get(k); - MobRecipe recipe = v.recipe; - recipe = recipe.copy(); - @SuppressWarnings("unchecked") - ArrayList<MobDrop> drops = (ArrayList<MobDrop>) v.drops.clone(); - - // MT Scripts should already be loaded here - if (LoaderReference.MineTweaker) { - Optionals.parseMTAdditions(k, drops, recipe); - } - - OverridesConfig.MobOverride override; - if ((override = overrides.get(k)) != null) { - if (override.removeAll) { - drops.clear(); - recipe.mOutputs.clear(); - } else for (OverridesConfig.MobDropSimplified removal : override.removals) { - drops.removeIf(removal::isMatching); - recipe.mOutputs.removeIf(removal::isMatching); - } - drops.addAll(override.additions); - recipe.mOutputs.addAll(override.additions); - drops.sort(Comparator.comparing(d -> d.type)); // Fix GUI - } - recipe.refresh(); - - Mob_Handler.addRecipe(v.mob, drops); - if (recipe.mOutputs.size() > 0) MobNameToRecipeMap.put(k, recipe); - LOG.info("Registered " + k); - }); - LOG.info("Sorting NEI map"); - Mob_Handler.sortCachedRecipes(); - } - - private static class Optionals { - - private static void parseMTAdditions(String k, ArrayList<MobDrop> drops, MobRecipe recipe) { - IEntityDefinition ie = MineTweakerAPI.game.getEntity(k); - if (ie != null) { - for (Map.Entry<IItemStack, IntRange> entry : ie.getDropsToAdd() - .entrySet()) { - IntRange r = entry.getValue(); - // Get average chance - double chance; - if (r.getFrom() == 0 && r.getTo() == 0) chance = 1d; - else { - double a = r.getFrom(); - double b = r.getTo(); - chance = ((b * b) + b - (a * a) + a) / (2 * (b - a + 1)); - } - ItemStack stack = ((ItemStack) entry.getKey() - .getInternal()).copy(); - MobDrop drop = new MobDrop( - stack, - MobDrop.DropType.Normal, - (int) (chance * 10000), - null, - null, - false, - false); - drops.add(drop); - recipe.mOutputs.add(drop); - } - for (Map.Entry<IItemStack, IntRange> entry : ie.getDropsToAddPlayerOnly() - .entrySet()) { - IntRange r = entry.getValue(); - // Get average chance - double chance; - if (r.getFrom() == 0 && r.getTo() == 0) chance = 1d; - else { - double a = r.getFrom(); - double b = r.getTo(); - chance = ((b * b) + b - (a * a) + a) / (2 * (b - a + 1)); - } - ItemStack stack = ((ItemStack) entry.getKey() - .getInternal()).copy(); - MobDrop drop = new MobDrop( - stack, - MobDrop.DropType.Normal, - (int) (chance * 10000), - null, - null, - false, - true); - drops.add(drop); - } - for (IItemStack istack : ie.getDropsToRemove()) { - List<MobDrop> toRemove = drops.stream() - .filter(d -> istack.matches(new MCItemStack(d.stack))) - .collect(Collectors.toList()); - drops.removeAll(toRemove); - recipe.mOutputs.removeAll(toRemove); - } - } - } - } -} diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java index acc2f89b1b..eccab9fd7b 100644 --- a/src/main/java/kubatech/loaders/RecipeLoader.java +++ b/src/main/java/kubatech/loaders/RecipeLoader.java @@ -195,9 +195,6 @@ public class RecipeLoader { // Runs on server start if (lateRecipesInitialized) return; lateRecipesInitialized = true; - - MobRecipeLoader.generateMobRecipeMap(); - MobRecipeLoader.processMobRecipeMap(); } private static void RegisterTeaLine() { diff --git a/src/main/java/kubatech/loaders/TCLoader.java b/src/main/java/kubatech/loaders/TCLoader.java index 3b9fdc392a..ae30b87988 100644 --- a/src/main/java/kubatech/loaders/TCLoader.java +++ b/src/main/java/kubatech/loaders/TCLoader.java @@ -29,10 +29,11 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.world.World; +import com.kuba6000.mobsinfo.api.utils.ItemID; + import cpw.mods.fml.common.registry.GameRegistry; import kubatech.api.LoaderReference; import kubatech.api.enums.ItemList; -import kubatech.api.utils.ItemID; import kubatech.loaders.item.items.TeaUltimate; import thaumcraft.api.ThaumcraftApi; import thaumcraft.api.ThaumcraftApiHelper; @@ -81,7 +82,7 @@ public class TCLoader { ItemList.WhiteTea.get(1), ItemList.YellowTea.get(1) }; final HashSet<ItemID> componentsHashed = Arrays.stream(components) - .map(stack -> ItemID.create_NoCopy(stack, true, false, true)) + .map(stack -> ItemID.createNoCopy(stack, true, false, true)) .collect(Collectors.toCollection(HashSet::new)); // noinspection unchecked @@ -106,7 +107,7 @@ public class TCLoader { return false; if (componentsHashed.size() > input.size()) return false; HashSet<ItemID> hashedInputs = input.stream() - .map(stack -> ItemID.create_NoCopy(stack, true, false, true)) + .map(stack -> ItemID.createNoCopy(stack, true, false, true)) .collect(Collectors.toCollection(HashSet::new)); return hashedInputs.containsAll(componentsHashed); } diff --git a/src/main/java/kubatech/mixin/Mixin.java b/src/main/java/kubatech/mixin/Mixin.java index 19e3b32610..e94eca69bb 100644 --- a/src/main/java/kubatech/mixin/Mixin.java +++ b/src/main/java/kubatech/mixin/Mixin.java @@ -11,7 +11,6 @@ import cpw.mods.fml.relauncher.FMLLaunchHandler; public enum Mixin { // Minecraft - EnchantmentHelperMixin("minecraft.EnchantmentHelperMixin", VANILLA), WorldMixin("minecraft.WorldMixin", VANILLA), EntityAccessor("minecraft.EntityAccessor", VANILLA), EntityLivingAccessor("minecraft.EntityLivingAccessor", VANILLA), @@ -47,10 +46,10 @@ public enum Mixin { .isClient()) && new HashSet<>(loadedMods).containsAll(targetedMods); } -} -enum Side { - BOTH, - CLIENT, - SERVER + enum Side { + BOTH, + CLIENT, + SERVER + } } diff --git a/src/main/java/kubatech/mixin/mixins/minecraft/EnchantmentHelperMixin.java b/src/main/java/kubatech/mixin/mixins/minecraft/EnchantmentHelperMixin.java deleted file mode 100644 index 9df946b6aa..0000000000 --- a/src/main/java/kubatech/mixin/mixins/minecraft/EnchantmentHelperMixin.java +++ /dev/null @@ -1,40 +0,0 @@ -package kubatech.mixin.mixins.minecraft; - -import static kubatech.loaders.MobRecipeLoader.randomEnchantmentDetectedString; - -import java.util.Random; - -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagInt; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import kubatech.api.utils.FastRandom; -import kubatech.loaders.MobRecipeLoader; - -@SuppressWarnings("unused") -@Mixin(value = EnchantmentHelper.class) -public class EnchantmentHelperMixin { - - private static final Random rnd = new FastRandom(); - - @Inject(method = "addRandomEnchantment", at = @At("HEAD"), require = 1) - private static void addRandomEnchantmentDetector(Random random, ItemStack itemStack, int enchantabilityLevel, - CallbackInfoReturnable<ItemStack> callbackInfoReturnable) { - if (MobRecipeLoader.isInGenerationProcess && random instanceof MobRecipeLoader.fakeRand) { - itemStack.setTagInfo(randomEnchantmentDetectedString, new NBTTagInt(enchantabilityLevel)); - } - } - - @ModifyVariable(method = "addRandomEnchantment", at = @At("HEAD"), ordinal = 0, argsOnly = true, require = 1) - private static Random addRandomEnchantmentModifier(Random random) { - if (!MobRecipeLoader.isInGenerationProcess) return random; - if (random instanceof MobRecipeLoader.fakeRand) return rnd; - return random; - } -} diff --git a/src/main/java/kubatech/nei/IMCForNEI.java b/src/main/java/kubatech/nei/IMCForNEI.java index 2ad10225ec..6a4419e9a0 100644 --- a/src/main/java/kubatech/nei/IMCForNEI.java +++ b/src/main/java/kubatech/nei/IMCForNEI.java @@ -29,10 +29,7 @@ import kubatech.api.LoaderReference; public class IMCForNEI { public static void IMCSender() { - - sendHandler("kubatech.mobhandler", "minecraft:diamond_sword", 168, 192, 1, 6); - sendCatalyst("kubatech.mobhandler", "minecraft:diamond_sword"); - if (LoaderReference.EnderIO) sendCatalyst("kubatech.mobhandler", "gregtech:gt.blockmachines:14201"); + if (LoaderReference.EnderIO) sendCatalyst("mobsinfo.mobhandler", "gregtech:gt.blockmachines:14201"); } private static void sendHandler(String aName, String aBlock, int width, int height, int maxrecipesperpage, diff --git a/src/main/java/kubatech/nei/Mob_Handler.java b/src/main/java/kubatech/nei/Mob_Handler.java deleted file mode 100644 index 10f932ec71..0000000000 --- a/src/main/java/kubatech/nei/Mob_Handler.java +++ /dev/null @@ -1,615 +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.nei; - -import static kubatech.nei.Mob_Handler.Translations.ADDITIONAL_DROPS; -import static kubatech.nei.Mob_Handler.Translations.AVERAGE_REMINDER; -import static kubatech.nei.Mob_Handler.Translations.BOSS; -import static kubatech.nei.Mob_Handler.Translations.CANNOT_USE_VIAL; -import static kubatech.nei.Mob_Handler.Translations.CHANCE; -import static kubatech.nei.Mob_Handler.Translations.EEC_CHANCE; -import static kubatech.nei.Mob_Handler.Translations.INFERNAL_ALWAYS; -import static kubatech.nei.Mob_Handler.Translations.INFERNAL_CAN; -import static kubatech.nei.Mob_Handler.Translations.INFERNAL_CANNOT; -import static kubatech.nei.Mob_Handler.Translations.INFERNAL_DROPS; -import static kubatech.nei.Mob_Handler.Translations.LOOTABLE; -import static kubatech.nei.Mob_Handler.Translations.MAX_HEALTH; -import static kubatech.nei.Mob_Handler.Translations.MOD; -import static kubatech.nei.Mob_Handler.Translations.NORMAL_DROPS; -import static kubatech.nei.Mob_Handler.Translations.PLAYER_ONLY; -import static kubatech.nei.Mob_Handler.Translations.RARE_DROPS; - -import java.awt.*; -import java.nio.FloatBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Random; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.gui.inventory.GuiInventory; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.entity.EntityList; -import net.minecraft.entity.EntityLiving; -import net.minecraft.entity.boss.BossStatus; -import net.minecraft.entity.monster.EntitySkeleton; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.lwjgl.BufferUtils; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.util.glu.GLU; - -import atomicstryker.infernalmobs.common.InfernalMobsCore; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiCraftingRecipe; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.GuiUsageRecipe; -import codechicken.nei.recipe.IUsageHandler; -import codechicken.nei.recipe.RecipeCatalysts; -import codechicken.nei.recipe.TemplateRecipeHandler; -import cpw.mods.fml.common.event.FMLInterModComms; -import crazypants.enderio.EnderIO; -import crazypants.enderio.machine.spawner.BlockPoweredSpawner; -import gregtech.api.util.GT_Utility; -import kubatech.Tags; -import kubatech.api.LoaderReference; -import kubatech.api.mobhandler.MobDrop; -import kubatech.api.utils.FastRandom; -import kubatech.api.utils.MobUtils; -import kubatech.api.utils.ModUtils; -import kubatech.config.Config; -import kubatech.kubatech; -import kubatech.loaders.MobRecipeLoader; -import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber; - -public class Mob_Handler extends TemplateRecipeHandler { - - enum Translations { - - NORMAL_DROPS, - RARE_DROPS, - ADDITIONAL_DROPS, - INFERNAL_DROPS, - INFERNAL_CANNOT, - INFERNAL_CAN, - INFERNAL_ALWAYS, - CANNOT_USE_VIAL, - CHANCE, - AVERAGE_REMINDER, - MOD, - MAX_HEALTH, - BOSS, - LOOTABLE, - PLAYER_ONLY, - EEC_CHANCE,; - - final String key; - - Translations() { - key = "mobhandler." + this.name() - .toLowerCase(); - } - - public String get() { - return StatCollector.translateToLocal(key); - } - - public String get(Object... args) { - return StatCollector.translateToLocalFormatted(key, args); - } - - public String getKey() { - return key; - } - - @Override - public String toString() { - return get(); - } - } - - private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler]"); - private static final Mob_Handler instance = new Mob_Handler(); - private static final List<MobCachedRecipe> cachedRecipes = new ArrayList<>(); - public static int cycleTicksStatic = Math.abs((int) System.currentTimeMillis()); - private static final int itemsPerRow = 8, itemXShift = 18, itemYShift = 18, nextRowYShift = 35; - - public static void addRecipe(EntityLiving e, List<MobDrop> drop) { - List<MobPositionedStack> positionedStacks = new ArrayList<>(); - int xorigin = 7, xoffset = xorigin, yoffset = 95, normaldrops = 0, raredrops = 0, additionaldrops = 0, - infernaldrops = 0; - MobDrop.DropType i = null; - for (MobDrop d : drop) { - if (i == d.type) { - xoffset += itemXShift; - if (xoffset >= xorigin + (itemXShift * itemsPerRow)) { - xoffset = xorigin; - yoffset += itemYShift; - } - } - if (i != null && i != d.type) { - xoffset = xorigin; - yoffset += nextRowYShift; - } - i = d.type; - if (d.type == MobDrop.DropType.Normal) normaldrops++; - else if (d.type == MobDrop.DropType.Rare) raredrops++; - else if (d.type == MobDrop.DropType.Additional) additionaldrops++; - else if (d.type == MobDrop.DropType.Infernal) break; // dont render infernal drops - positionedStacks.add( - new MobPositionedStack( - d.stack.copy(), - xoffset, - yoffset, - d.type, - d.chance, - d.enchantable, - d.damages != null ? new ArrayList<>(d.damages.keySet()) : null, - d.lootable, - d.playerOnly)); - } - instance.addRecipeInt(e, positionedStacks, normaldrops, raredrops, additionaldrops, infernaldrops); - } - - private void addRecipeInt(EntityLiving e, List<Mob_Handler.MobPositionedStack> l, int normaldrops, int raredrops, - int additionaldrops, int infernalDrops) { - cachedRecipes.add(new MobCachedRecipe(e, l, normaldrops, raredrops, additionaldrops, infernalDrops)); - } - - public static void clearRecipes() { - cachedRecipes.clear(); - } - - public static void sortCachedRecipes() { - cachedRecipes.sort((o1, o2) -> { - boolean m1 = o1.mod.equals("Minecraft"); - boolean m2 = o2.mod.equals("Minecraft"); - if (m1 && !m2) return -1; - else if (!m1 && m2) return 1; - if (!o1.mod.equals(o2.mod)) return o1.mod.compareTo(o2.mod); - else return o1.localizedName.compareTo(o2.localizedName); - }); - } - - public Mob_Handler() { - this.transferRects.add(new RecipeTransferRect(new Rectangle(7, 62, 16, 16), getOverlayIdentifier())); - if (!NEI_Config.isAdded) { - FMLInterModComms.sendRuntimeMessage( - kubatech.instance, - "NEIPlugins", - "register-crafting-handler", - "kubatech@" + getRecipeName() + "@" + getOverlayIdentifier()); - GuiCraftingRecipe.craftinghandlers.add(this); - GuiUsageRecipe.usagehandlers.add(this); - } - } - - @Override - public TemplateRecipeHandler newInstance() { - return new Mob_Handler(); - } - - @Override - public String getOverlayIdentifier() { - return "kubatech.mobhandler"; - } - - @Override - public String getGuiTexture() { - return "kubatech:textures/gui/MobHandler.png"; - } - - @Override - public void drawBackground(int recipe) { - GL11.glColor4f(1f, 1f, 1f, 1f); - GuiDraw.changeTexture(getGuiTexture()); - GuiDraw.drawTexturedModalRect(0, 0, 0, 0, 168, 192); - - MobCachedRecipe currentrecipe = ((MobCachedRecipe) arecipes.get(recipe)); - - { - int x = 6, y = 94, yshift = nextRowYShift; - if (currentrecipe.normalOutputsCount > 0) { - for (int i = 0; i < ((currentrecipe.normalOutputsCount - 1) / itemsPerRow) + 1; i++) { - GuiDraw.drawTexturedModalRect(x, y + (18 * i), 0, 192, 144, 18); - if (i > 0) GuiDraw.drawTexturedModalRect(x, y + ((18 * i) - 1), 0, 193, 144, 2); - } - y += yshift + ((currentrecipe.normalOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.rareOutputsCount > 0) { - for (int i = 0; i < ((currentrecipe.rareOutputsCount - 1) / itemsPerRow) + 1; i++) { - GuiDraw.drawTexturedModalRect(x, y + (18 * i), 0, 192, 144, 18); - if (i > 0) GuiDraw.drawTexturedModalRect(x, y + ((18 * i) - 1), 0, 193, 144, 2); - } - y += yshift + ((currentrecipe.rareOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.additionalOutputsCount > 0) { - for (int i = 0; i < ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) + 1; i++) { - GuiDraw.drawTexturedModalRect(x, y + (18 * i), 0, 192, 144, 18); - if (i > 0) GuiDraw.drawTexturedModalRect(x, y + ((18 * i) - 1), 0, 193, 144, 2); - } - y += yshift + ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.infernalOutputsCount > 0) { - for (int i = 0; i < ((currentrecipe.infernalOutputsCount - 1) / itemsPerRow) + 1; i++) { - GuiDraw.drawTexturedModalRect(x, y + (18 * i), 0, 192, 144, 18); - if (i > 0) GuiDraw.drawTexturedModalRect(x, y + ((18 * i) - 1), 0, 193, 144, 2); - } - } - } - - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glColor4f(1f, 1f, 1f, 1f); - - Minecraft mc = Minecraft.getMinecraft(); - - ScaledResolution scale = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - - int width = scale.getScaledWidth(); - int height = scale.getScaledHeight(); - int mouseX = Mouse.getX() * width / mc.displayWidth; - int mouseZ = height - Mouse.getY() * height / mc.displayHeight - 1; - - // Get current x,y from matrix - FloatBuffer buf = BufferUtils.createFloatBuffer(16); - GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, buf); - float x = buf.get(12); - float y = buf.get(13); - - int stackdepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); - - GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS); - - GL11.glPushMatrix(); - - float healthScale = BossStatus.healthScale; - int statusBarTime = BossStatus.statusBarTime; - String bossName = BossStatus.bossName; - boolean hasColorModifier = BossStatus.hasColorModifier; - - BossStatus.statusBarTime = 0; - - try { - EntityLiving e = currentrecipe.mob; - - float eheight = MobUtils.getMobHeight(e); - float scaled = MobUtils.getDesiredScale(eheight, 27); - // - // int maxwidth = 15; - // scaled = (int) Math.min(scaled, maxwidth / ewidth); - - int mobx = 30, moby = 50; - e.setPosition(mc.thePlayer.posX + 5, mc.thePlayer.posY, mc.thePlayer.posZ); - - // ARGS: x, y, scale, rot, rot, entity - GuiInventory.func_147046_a( - mobx, - moby, - Math.round(scaled), - (x + mobx) - mouseX, - y + moby - eheight * scaled - mouseZ, - e); - } catch (Throwable ex) { - Tessellator tes = Tessellator.instance; - try { - tes.draw(); - } catch (Exception ignored) {} - } - - if (BossStatus.statusBarTime > 0 && currentrecipe.isBoss.isEmpty()) currentrecipe.isBoss = BossStatus.bossName; - - BossStatus.healthScale = healthScale; - BossStatus.statusBarTime = statusBarTime; - BossStatus.bossName = bossName; - BossStatus.hasColorModifier = hasColorModifier; - - GL11.glMatrixMode(GL11.GL_MODELVIEW_MATRIX); - stackdepth -= GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); - if (stackdepth < 0) for (; stackdepth < 0; stackdepth++) GL11.glPopMatrix(); - if (stackdepth > 0) for (; stackdepth > 0; stackdepth--) GL11.glPushMatrix(); - - GL11.glPopAttrib(); - - int err; - while ((err = GL11.glGetError()) != GL11.GL_NO_ERROR) if (Config.Debug.showRenderErrors) - LOG.error(currentrecipe.mobname + " | GL ERROR: " + err + " / " + GLU.gluErrorString(err)); - - GL11.glDisable(GL11.GL_DEPTH_TEST); - } - - @Override - public void drawForeground(int recipe) { - MobCachedRecipe currentrecipe = ((MobCachedRecipe) arecipes.get(recipe)); - int y = 7, yshift = 10, x = 57; - GuiDraw.drawString(currentrecipe.localizedName, x, y, 0xFF555555, false); - if (Minecraft.getMinecraft().gameSettings.advancedItemTooltips && NEIClientUtils.shiftKey()) - GuiDraw.drawString(currentrecipe.mobname, x, y += yshift, 0xFF555555, false); - GuiDraw.drawString(MOD.get() + currentrecipe.mod, x, y += yshift, 0xFF555555, false); - GuiDraw.drawString(MAX_HEALTH.get() + currentrecipe.maxHealth, x, y += yshift, 0xFF555555, false); - switch (currentrecipe.infernaltype) { - case -1: - break; - case 0: - GuiDraw.drawString(INFERNAL_CANNOT.get(), x, y += yshift, 0xFF555555, false); - break; - case 1: - GuiDraw.drawString(INFERNAL_CAN.get(), x, y += yshift, 0xFFFF0000, false); - break; - case 2: - GuiDraw.drawString(INFERNAL_ALWAYS.get(), x, y += yshift, 0xFFFF0000, false); - break; - } - - if (!currentrecipe.isBoss.isEmpty()) - GuiDraw.drawString(EnumChatFormatting.BOLD + "" + BOSS.get(), x, y += yshift, 0xFFD68F00, false); - - MobRecipeLoader.MobRecipe MBRecipe = GT_MetaTileEntity_ExtremeExterminationChamber.MobNameToRecipeMap - .get(currentrecipe.mobname); - if (MBRecipe != null) { - if (MBRecipe.isUsable) { - GuiDraw.drawString( - GT_Utility.trans("153", "Usage: ") + GT_Utility.formatNumbers(MBRecipe.mEUt) + " EU/t", - x, - y += yshift, - 0xFF555555, - false); - GuiDraw.drawString( - GT_Utility.trans("158", "Time: ") + GT_Utility.formatNumbers(MBRecipe.mDuration / 20d) + " secs", - x, - y += yshift, - 0xFF555555, - false); - } else { - GuiDraw.drawString(CANNOT_USE_VIAL.get(), x, y += yshift, 0xFF555555, false); - } - } - - x = 6; - y = 83; - yshift = nextRowYShift; - if (currentrecipe.normalOutputsCount > 0) { - GuiDraw.drawString(NORMAL_DROPS.get(), x, y, 0xFF555555, false); - y += yshift + ((currentrecipe.normalOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.rareOutputsCount > 0) { - GuiDraw.drawString(RARE_DROPS.get(), x, y, 0xFF555555, false); - y += yshift + ((currentrecipe.rareOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.additionalOutputsCount > 0) { - GuiDraw.drawString(ADDITIONAL_DROPS.get(), x, y, 0xFF555555, false); - y += yshift + ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) * 18; - } - if (currentrecipe.infernalOutputsCount > 0) { - GuiDraw.drawString(INFERNAL_DROPS.get(), x, y, 0xFF555555, false); - y += yshift + ((currentrecipe.additionalOutputsCount - 1) / itemsPerRow) * 18; - } - yshift = 10; - } - - @Override - public String getRecipeName() { - return "Mob Drops"; - } - - @Override - public IUsageHandler getUsageAndCatalystHandler(String inputId, Object... ingredients) { - if (inputId.equals("item")) { - TemplateRecipeHandler handler = newInstance(); - ItemStack candidate = (ItemStack) ingredients[0]; - if (RecipeCatalysts.containsCatalyst(handler, candidate)) { - handler.loadCraftingRecipes(getOverlayIdentifier(), (Object) null); - return handler; - } - } - return this.getUsageHandler(inputId, ingredients); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) { - if (outputId.equals(getOverlayIdentifier())) { - arecipes.addAll(cachedRecipes); - return; - } - super.loadCraftingRecipes(outputId, results); - } - - @Override - public void loadCraftingRecipes(ItemStack result) { - for (MobCachedRecipe r : cachedRecipes) if (r.contains(r.mOutputs, result)) arecipes.add(r); - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) { - if (LoaderReference.EnderIO && ingredient.getItem() == Item.getItemFromBlock(EnderIO.blockPoweredSpawner)) { - if (!ingredient.hasTagCompound() || !ingredient.getTagCompound() - .hasKey("mobType")) { - loadCraftingRecipes(getOverlayIdentifier(), (Object) null); - return; - } - for (MobCachedRecipe r : cachedRecipes) if (r.mInput.stream() - .anyMatch( - s -> s.getItem() == ingredient.getItem() && Objects.equals( - s.getTagCompound() - .getString("mobType"), - ingredient.getTagCompound() - .getString("mobType")))) - arecipes.add(r); - } else for (MobCachedRecipe r : cachedRecipes) if (r.mInput.stream() - .anyMatch(ingredient::isItemEqual)) arecipes.add(r); - } - - @Override - public void onUpdate() { - cycleTicksStatic++; - } - - @Override - public List<String> handleItemTooltip(GuiRecipe<?> gui, ItemStack stack, List<String> currenttip, int recipe) { - MobCachedRecipe currentrecipe = ((MobCachedRecipe) arecipes.get(recipe)); - PositionedStack positionedStack = currentrecipe.mOutputs.stream() - .filter(ps -> ps.item == stack) - .findFirst() - .orElse(null); - if (positionedStack instanceof MobPositionedStack) - currenttip.addAll(((MobPositionedStack) positionedStack).extraTooltip); - return currenttip; - } - - public static class MobPositionedStack extends PositionedStack { - - public final MobDrop.DropType type; - public final int chance; - public final boolean enchantable; - public final boolean randomdamage; - public final List<Integer> damages; - public final int enchantmentLevel; - private final Random rand; - public final List<String> extraTooltip; - - public MobPositionedStack(Object object, int x, int y, MobDrop.DropType type, int chance, Integer enchantable, - List<Integer> damages, boolean lootable, boolean isPlayerOnly) { - super(object, x, y, false); - rand = new FastRandom(); - this.type = type; - this.chance = chance; - this.enchantable = enchantable != null; - if (this.enchantable) enchantmentLevel = enchantable; - else enchantmentLevel = 0; - this.randomdamage = damages != null; - if (this.randomdamage) this.damages = damages; - else this.damages = null; - extraTooltip = new ArrayList<>(); - - if (chance != 10000) extraTooltip.add(EnumChatFormatting.RESET + CHANCE.get((double) chance / 100d)); - if (lootable) extraTooltip.add(EnumChatFormatting.RESET + LOOTABLE.get()); - if (isPlayerOnly) { - extraTooltip.add(EnumChatFormatting.RESET + PLAYER_ONLY.get()); - extraTooltip.add( - EnumChatFormatting.RESET + EEC_CHANCE - .get(((double) ((int) ((double) chance * Config.MobHandler.playerOnlyDropsModifier)) / 100d))); - } - extraTooltip.add(EnumChatFormatting.RESET + AVERAGE_REMINDER.get()); - - setPermutationToRender(0); - } - - @Override - public void setPermutationToRender(int index) { - if (this.item == null) this.item = this.items[0].copy(); - if (enchantable) { - if (this.item.getItem() == Items.enchanted_book) this.item = this.items[0].copy(); - if (this.item.hasTagCompound()) this.item.getTagCompound() - .removeTag("ench"); - EnchantmentHelper.addRandomEnchantment(rand, this.item, enchantmentLevel); - } - if (randomdamage) this.item.setItemDamage(damages.get(rand.nextInt(damages.size()))); - } - } - - private class MobCachedRecipe extends TemplateRecipeHandler.CachedRecipe { - - public final EntityLiving mob; - public final List<PositionedStack> mOutputs; - public final List<ItemStack> mInput; - public final String mobname; - public final int infernaltype; - public final PositionedStack ingredient; - public final String localizedName; - public final String mod; - public final float maxHealth; - public final int normalOutputsCount; - public final int rareOutputsCount; - public final int additionalOutputsCount; - public final int infernalOutputsCount; - public String isBoss = ""; - - public MobCachedRecipe(EntityLiving mob, List<MobPositionedStack> mOutputs, int normalOutputsCount, - int rareOutputsCount, int additionalOutputsCount, int infernalOutputsCount) { - super(); - String classname = mob.getClass() - .getName(); - this.mod = ModUtils.getModNameFromClassName(classname); - this.mob = mob; - this.maxHealth = mob.getMaxHealth(); - this.mOutputs = new ArrayList<>(mOutputs.size()); - this.mOutputs.addAll(mOutputs); - this.normalOutputsCount = normalOutputsCount; - this.rareOutputsCount = rareOutputsCount; - this.additionalOutputsCount = additionalOutputsCount; - this.infernalOutputsCount = infernalOutputsCount; - this.mInput = new ArrayList<>(); - int id = EntityList.getEntityID(mob); - mobname = EntityList.getEntityString(mob); - localizedName = mobname.equals("Skeleton") && ((EntitySkeleton) mob).getSkeletonType() == 1 - ? "Wither Skeleton" - : StatCollector.translateToLocal("entity." + mobname + ".name"); - if (id != 0) { - this.mInput.add(new ItemStack(Items.spawn_egg, 1, id)); - this.mInput.add(new ItemStack(Blocks.mob_spawner, 1, id)); - } - if (LoaderReference.EnderIO) { - ItemStack s = new ItemStack(EnderIO.blockPoweredSpawner, 1); - NBTTagCompound nbt = new NBTTagCompound(); - BlockPoweredSpawner.writeMobTypeToNBT(nbt, mobname); - s.setTagCompound(nbt); - this.mInput.add(0, s); - } else if (id == 0) this.mInput.add(new ItemStack(Items.spawn_egg, 1, 0)); // ??? - ingredient = new PositionedStack(this.mInput.get(0), 38, 44, false); - - if (!LoaderReference.InfernalMobs) infernaltype = -1; // not supported - else { - InfernalMobsCore infernalMobsCore = InfernalMobsCore.instance(); - if (!infernalMobsCore.isClassAllowed(mob)) infernaltype = 0; // not allowed - else if (infernalMobsCore.checkEntityClassForced(mob)) infernaltype = 2; // forced - else infernaltype = 1; // normal - } - } - - @Override - public PositionedStack getIngredient() { - return ingredient; - } - - @Override - public PositionedStack getResult() { - return null; - } - - @Override - public List<PositionedStack> getOtherStacks() { - if (cycleTicksStatic % 10 == 0) mOutputs.forEach(p -> p.setPermutationToRender(0)); - return mOutputs; - } - } -} diff --git a/src/main/java/kubatech/nei/NEI_Config.java b/src/main/java/kubatech/nei/NEI_Config.java index 3836c05461..74ff128a9e 100644 --- a/src/main/java/kubatech/nei/NEI_Config.java +++ b/src/main/java/kubatech/nei/NEI_Config.java @@ -40,13 +40,8 @@ import kubatech.Tags; public class NEI_Config implements IConfigureNEI { - public static boolean isAdded = true; - @Override public void loadConfig() { - isAdded = false; - new Mob_Handler(); - isAdded = true; API.hideItem(LegendaryBlackTea.get(1)); API.hideItem(LegendaryButterflyTea.get(1)); API.hideItem(LegendaryEarlGrayTea.get(1)); diff --git a/src/main/java/kubatech/api/network/CustomTileEntityPacket.java b/src/main/java/kubatech/network/CustomTileEntityPacket.java index 67a310ecf5..b080349a8b 100644 --- a/src/main/java/kubatech/api/network/CustomTileEntityPacket.java +++ b/src/main/java/kubatech/network/CustomTileEntityPacket.java @@ -18,7 +18,7 @@ * spotless:on */ -package kubatech.api.network; +package kubatech.network; import java.nio.charset.StandardCharsets; diff --git a/src/main/java/kubatech/network/LoadConfigPacket.java b/src/main/java/kubatech/network/LoadConfigPacket.java new file mode 100644 index 0000000000..ecde7d6abe --- /dev/null +++ b/src/main/java/kubatech/network/LoadConfigPacket.java @@ -0,0 +1,52 @@ +/* + * 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.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 kubatech.config.Config; +import kubatech.kubatech; + +public class LoadConfigPacket implements IMessage { + + public static final LoadConfigPacket instance = new LoadConfigPacket(); + + @Override + public void fromBytes(ByteBuf buf) { + Config.MobHandler.playerOnlyDropsModifier = buf.readDouble(); + } + + @Override + public void toBytes(ByteBuf buf) { + buf.writeDouble(Config.MobHandler.playerOnlyDropsModifier); + } + + public static class Handler implements IMessageHandler<LoadConfigPacket, IMessage> { + + @Override + public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) { + kubatech.info("Received KubaTech config, parsing"); + return null; + } + } +} diff --git a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java index 7f2c12ca1a..6d27461e7d 100644 --- a/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java +++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java @@ -24,6 +24,7 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.isAir; import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock; import static com.gtnewhorizon.structurelib.structure.StructureUtility.onElementPass; import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose; +import static com.kuba6000.mobsinfo.api.MobRecipe.MobNameToRecipeMap; import static gregtech.api.enums.GT_HatchElement.Energy; import static gregtech.api.enums.GT_HatchElement.InputBus; import static gregtech.api.enums.GT_HatchElement.Maintenance; @@ -41,7 +42,6 @@ import static kubatech.api.Variables.StructureHologram; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; -import java.util.HashMap; import java.util.Random; import java.util.UUID; @@ -92,6 +92,7 @@ import com.gtnewhorizons.modularui.common.widget.DynamicTextWidget; import com.gtnewhorizons.modularui.common.widget.FakeSyncWidget; import com.gtnewhorizons.modularui.common.widget.SlotWidget; import com.gtnewhorizons.modularui.common.widget.TextWidget; +import com.kuba6000.mobsinfo.api.utils.ItemID; import com.mojang.authlib.GameProfile; import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry; @@ -122,18 +123,16 @@ import kubatech.Tags; import kubatech.api.LoaderReference; import kubatech.api.helpers.ReflectionHelper; import kubatech.api.implementations.KubaTechGTMultiBlockBase; -import kubatech.api.network.CustomTileEntityPacket; import kubatech.api.tileentity.CustomTileEntityPacketHandler; import kubatech.api.utils.FastRandom; -import kubatech.api.utils.ItemID; import kubatech.client.effect.EntityRenderer; -import kubatech.loaders.MobRecipeLoader; +import kubatech.loaders.MobHandlerLoader; +import kubatech.network.CustomTileEntityPacket; public class GT_MetaTileEntity_ExtremeExterminationChamber extends KubaTechGTMultiBlockBase<GT_MetaTileEntity_ExtremeExterminationChamber> implements CustomTileEntityPacketHandler, ISurvivalConstructable { - public static final HashMap<String, MobRecipeLoader.MobRecipe> MobNameToRecipeMap = new HashMap<>(); public static final double DIAMOND_SPIKES_DAMAGE = 9d; // Powered spawner with octadic capacitor spawns ~22/min ~= 0.366/sec ~= 2.72s/spawn ~= 54.54t/spawn public static final int MOB_SPAWN_INTERVAL = 55; @@ -369,10 +368,10 @@ public class GT_MetaTileEntity_ExtremeExterminationChamber if (message.getDataBoolean()) { renderEntity = true; String mobType = message.getDataString(); - MobRecipeLoader.MobRecipe r = MobNameToRecipeMap.get(mobType); + MobHandlerLoader.MobEECRecipe r = MobHandlerLoader.recipeMap.get(mobType); if (r != null) { if (entityRenderer == null) setupEntityRenderer(getBaseMetaTileEntity(), 40); - entityRenderer.setEntity(r.entity); + entityRenderer.setEntity(r.recipe.entity); } else entityRenderer.setEntity(null); } else { renderEntity = false; @@ -496,10 +495,10 @@ public class GT_MetaTileEntity_ExtremeExterminationChamber if (mobType.equals("Skeleton") && getBaseMetaTileEntity().getWorld().provider instanceof WorldProviderHell && rand.nextInt(5) > 0) mobType = "witherSkeleton"; - MobRecipeLoader.MobRecipe recipe = MobNameToRecipeMap.get(mobType); + MobHandlerLoader.MobEECRecipe recipe = MobHandlerLoader.recipeMap.get(mobType); if (recipe == null) return false; - if (!recipe.isPeacefulAllowed && this.getBaseMetaTileEntity() + if (!recipe.recipe.isPeacefulAllowed && this.getBaseMetaTileEntity() .getWorld().difficultySetting == EnumDifficulty.PEACEFUL) return false; if (isInRitualMode && isRitualValid()) { @@ -510,7 +509,7 @@ public class GT_MetaTileEntity_ExtremeExterminationChamber this.mMaxProgresstime = 400; } else { if (getMaxInputEu() < recipe.mEUt) return false; - if (recipe.alwaysinfernal && getMaxInputEu() < recipe.mEUt * 8) return false; + if (recipe.recipe.alwaysinfernal && getMaxInputEu() < recipe.mEUt * 8) return false; double attackDamage = DIAMOND_SPIKES_DAMAGE; // damage from spikes GT_MetaTileEntity_Hatch_InputBus inputbus = this.mInputBusses.size() == 0 ? null : this.mInputBusses.get(0); @@ -539,7 +538,7 @@ public class GT_MetaTileEntity_ExtremeExterminationChamber weaponCache.isValid = true; weaponCache.looting = Math .min(4, EnchantmentHelper.getEnchantmentLevel(Enchantment.looting.effectId, lootingHolder)); - weaponCache.id = ItemID.create_NoCopy(lootingHolder, true, true); + weaponCache.id = ItemID.createNoCopy(lootingHolder, true, true); } if (weaponCache.isValid) attackDamage += weaponCache.attackDamage; @@ -558,7 +557,7 @@ public class GT_MetaTileEntity_ExtremeExterminationChamber Item lootingHolderItem = lootingHolder.getItem(); for (int i = 0; i < times + 1; i++) { // noinspection ConstantConditions - if (!lootingHolderItem.hitEntity(lootingHolder, recipe.entity, EECPlayer)) break; + if (!lootingHolderItem.hitEntity(lootingHolder, recipe.recipe.entity, EECPlayer)) break; if (lootingHolder.stackSize == 0) { // noinspection ConstantConditions inputbus.setInventorySlotContents(0, null); diff --git a/src/main/resources/assets/kubatech/lang/en_US.lang b/src/main/resources/assets/kubatech/lang/en_US.lang index b830d3611e..3d39bb8e4a 100644 --- a/src/main/resources/assets/kubatech/lang/en_US.lang +++ b/src/main/resources/assets/kubatech/lang/en_US.lang @@ -1,40 +1,26 @@ #This file is a translation file for KubaTech #NEI -mobhandler.normal_drops=Normal drops -mobhandler.rare_drops=Rare drops -mobhandler.additional_drops=Additional drops -mobhandler.infernal_drops=Infernal drops -mobhandler.infernal_cannot=Cannot spawn infernal -mobhandler.infernal_can=Can spawn infernal -mobhandler.infernal_always=Always spawns infernal -mobhandler.mod=Mod: -mobhandler.max_health=Max health: -mobhandler.boss=BOSS -mobhandler.cannot_use_vial=Can't be in soul vial -mobhandler.chance=Chance: %.2f%% -mobhandler.average_reminder=§7§oPlease remember that these are average drops. -mobhandler.lootable=Looting is applied -mobhandler.player_only=§7Hard player-only -mobhandler.eec_chance=§5Chance to drop in EEC: %.2f%% +kubatech.mobhandler.eec_chance=§5Chance to drop in EEC: %.2f%% +kubatech.mobhandler.eec_disabled=§5Does not drop in EEC #Commands -commandhandler.invalid=§cInvalid use ! The proper use of this command is /%s -commandhandler.cant_find=§cCan't find command option %s -commandhandler.generic_help=§cYou can also use "/kubatech help" to get possible commands -commandhandler.usage=<option> -command.help.possible_commands=Possible commands: -command.help.usage=- Shows all possible commands -command.config.invalid_option=§cInvalid option ! Possible options: reload -command.config.success=§aConfig reloaded successfully ! -command.config.usage=<option> +kubatech.commandhandler.invalid=§cInvalid use ! The proper use of this command is /%s +kubatech.commandhandler.cant_find=§cCan't find command option %s +kubatech.commandhandler.generic_help=§cYou can also use "/kubatech help" to get possible commands +kubatech.commandhandler.usage=<option> +kubatech.command.help.possible_commands=Possible commands: +kubatech.command.help.usage=- Shows all possible commands +kubatech.command.config.invalid_option=§cInvalid option ! Possible options: reload +kubatech.command.config.success=§aConfig reloaded successfully ! +kubatech.command.config.usage=<option> -command.tea.invalid_option=§cInvalid usage ! -command.tea.player_not_found=§cPlayer not found ! -command.tea.success_get=Player %s has %d Tea -command.tea.success_set=Player %s now has %d Tea -command.tea.success_add=Player %s now has %d Tea -command.tea.usage=<username> get/set/add (<amount>) +kubatech.command.tea.invalid_option=§cInvalid usage ! +kubatech.command.tea.player_not_found=§cPlayer not found ! +kubatech.command.tea.success_get=Player %s has %d Tea +kubatech.command.tea.success_set=Player %s now has %d Tea +kubatech.command.tea.success_add=Player %s now has %d Tea +kubatech.command.tea.usage=<username> get/set/add (<amount>) #Blocks |