From 6d436a2c6a5d9b51070b8399c4fdb196603a8e82 Mon Sep 17 00:00:00 2001
From: Jakub <53441451+kuba6000@users.noreply.github.com>
Date: Sun, 14 Aug 2022 15:19:13 +0200
Subject: Add "Mob Drops" NEI page + Extreme Extermination Chamber (#1)
* First commit
* Mixins
* Merge the same items with diffrent damage
* Faster random in NEI
* More accuracy ?
* Update ClientProxy.java
* Renaming
* Update buildscript
* Use reserved MTE ID's
* EEC work
* Rework NEI page
* Fix inaccurate chances
* Basic equipment spawn
* Add config options
* Translations
* Add infernal drops
* Witchery fix
* Forestry fixes
* More fixes
* Default blacklist
* NEI sorting
* Comment out testing deps
* Clientsided check
* Blood Magic support
* LoaderReference
* Check if peacefull is allowed
* Add some XP output
* Add recipe
* Send Server config to Client
* Add command to reload config
* Translations
* Process MT additions
---
.../java/kubatech/loaders/MobRecipeLoader.java | 973 +++++++++++++++++++++
src/main/java/kubatech/loaders/RecipeLoader.java | 77 ++
2 files changed, 1050 insertions(+)
create mode 100644 src/main/java/kubatech/loaders/MobRecipeLoader.java
create mode 100644 src/main/java/kubatech/loaders/RecipeLoader.java
(limited to 'src/main/java/kubatech/loaders')
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
new file mode 100644
index 0000000000..033beb49fd
--- /dev/null
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -0,0 +1,973 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 kuba6000
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package kubatech.loaders;
+
+import static kubatech.api.utils.ModUtils.isClientSided;
+import static kubatech.api.utils.ModUtils.isDeobfuscatedEnvironment;
+import static kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MobNameToRecipeMap;
+
+import atomicstryker.infernalmobs.common.InfernalMobsCore;
+import atomicstryker.infernalmobs.common.MobModifier;
+import atomicstryker.infernalmobs.common.mods.api.ModifierLoader;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import gregtech.api.util.GT_Utility;
+import gregtech.common.GT_DummyWorld;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.*;
+import java.util.stream.Collectors;
+import kubatech.Config;
+import kubatech.Tags;
+import kubatech.api.LoaderReference;
+import kubatech.api.utils.InfernalHelper;
+import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
+import kubatech.nei.Mob_Handler;
+import kubatech.network.LoadConfigPacket;
+import minetweaker.MineTweakerAPI;
+import minetweaker.api.entity.IEntityDefinition;
+import minetweaker.api.item.IItemStack;
+import minetweaker.mc1710.item.MCItemStack;
+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.EntityLivingBase;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.monster.EntitySlime;
+import net.minecraft.entity.monster.IMob;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.StatCollector;
+import net.minecraft.world.World;
+import net.minecraftforge.client.event.GuiOpenEvent;
+import net.minecraftforge.common.MinecraftForge;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import stanhebben.zenscript.value.IntRange;
+import thaumcraft.common.items.wands.ItemWandCasting;
+
+public class MobRecipeLoader {
+
+ private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Mob Handler]");
+
+ public static final MobRecipeLoader instance = new MobRecipeLoader();
+
+ @SuppressWarnings("unused")
+ @SubscribeEvent
+ public void onOpenGui(GuiOpenEvent event) {
+ MobRecipeLoader.generateMobRecipeMap();
+ MinecraftForge.EVENT_BUS.unregister(instance);
+ }
+
+ private static final String dropFewItemsName = isDeobfuscatedEnvironment ? "dropFewItems" : "func_70628_a";
+ private static final String dropRareDropName = isDeobfuscatedEnvironment ? "dropRareDrop" : "func_70600_l";
+ private static final String setSlimeSizeName = isDeobfuscatedEnvironment ? "setSlimeSize" : "func_70799_a";
+ private static final String addRandomArmorName = isDeobfuscatedEnvironment ? "addRandomArmor" : "func_82164_bB";
+ private static final String enchantEquipmentName = isDeobfuscatedEnvironment ? "enchantEquipment" : "func_82162_bC";
+ private static final String randName = isDeobfuscatedEnvironment ? "rand" : "field_70146_Z";
+
+ private static boolean alreadyGenerated = false;
+ public static boolean isInGenerationProcess = false;
+ public static final String randomEnchantmentDetectedString = "RandomEnchantmentDetected";
+
+ public static class MobRecipe {
+ public final ArrayList mOutputs;
+ public final int mEUt = 2000;
+ public final int mDuration;
+ public final int mMaxDamageChance;
+ public final boolean infernalityAllowed;
+ public final boolean alwaysinfernal;
+ public static droplist infernaldrops;
+ public final boolean isPeacefulAllowed;
+
+ @SuppressWarnings("unchecked")
+ public MobRecipe copy() {
+ return new MobRecipe(
+ (ArrayList) mOutputs.clone(),
+ mDuration,
+ mMaxDamageChance,
+ infernalityAllowed,
+ alwaysinfernal,
+ isPeacefulAllowed);
+ }
+
+ private MobRecipe(
+ ArrayList mOutputs,
+ int mDuration,
+ int mMaxDamageChance,
+ boolean infernalityAllowed,
+ boolean alwaysinfernal,
+ boolean isPeacefulAllowed) {
+ this.mOutputs = mOutputs;
+ this.mDuration = mDuration;
+ this.mMaxDamageChance = mMaxDamageChance;
+ this.infernalityAllowed = infernalityAllowed;
+ this.alwaysinfernal = alwaysinfernal;
+ this.isPeacefulAllowed = isPeacefulAllowed;
+ }
+
+ @SuppressWarnings("unchecked")
+ public MobRecipe(EntityLiving e, ArrayList outputs) {
+ if (infernaldrops == null && LoaderReference.InfernalMobs) {
+ infernaldrops = new droplist();
+ LOG.info("Generating Infernal drops");
+ ArrayList> modifierLoaders = (ArrayList>)
+ InfernalHelper.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 =
+ InfernalHelper.checkEntityClassForced(e) ? 1d : (1d / InfernalHelper.getEliteRarity());
+ ArrayList elitelist = InfernalHelper.getDropIdListElite();
+ for (ItemStack stack : elitelist) {
+ dropinstance instance = infernaldrops.add(
+ new dropinstance(stack.copy(), infernaldrops), chance / elitelist.size());
+ instance.isEnchatmentRandomized = true;
+ instance.enchantmentLevel = stack.getItem().getItemEnchantability();
+ }
+ ArrayList ultralist = InfernalHelper.getDropIdListUltra();
+ chance *= 1d / InfernalHelper.getUltraRarity();
+ for (ItemStack stack : ultralist) {
+ dropinstance instance = infernaldrops.add(
+ new dropinstance(stack.copy(), infernaldrops), chance / ultralist.size());
+ instance.isEnchatmentRandomized = true;
+ instance.enchantmentLevel = stack.getItem().getItemEnchantability();
+ }
+ ArrayList infernallist = InfernalHelper.getDropIdListInfernal();
+ chance *= 1d / InfernalHelper.getInfernoRarity();
+ for (ItemStack stack : infernallist) {
+ dropinstance instance = infernaldrops.add(
+ new dropinstance(stack.copy(), infernaldrops), chance / infernallist.size());
+ instance.isEnchatmentRandomized = true;
+ instance.enchantmentLevel = stack.getItem().getItemEnchantability();
+ }
+ }
+ } else if (infernaldrops == null) infernaldrops = new droplist();
+
+ infernalityAllowed = InfernalHelper.isClassAllowed(e);
+ alwaysinfernal = InfernalHelper.checkEntityClassForced(e);
+ isPeacefulAllowed = !(e instanceof IMob);
+
+ mOutputs = outputs;
+ int maxdamagechance = 0;
+ for (MobDrop o : mOutputs) {
+ if (o.damages != null) for (int v : o.damages.values()) maxdamagechance += v;
+ }
+ mMaxDamageChance = maxdamagechance;
+ // Powered spawner with octadic capacitor spawns ~22/min ~= 0.366/sec ~= 2.72s/spawn ~= 54.54t/spawn
+ mDuration = 55 + 10 + (((int) e.getMaxHealth() / 5) * 10);
+ }
+
+ public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeExterminationChamber MTE) {
+ MTE.mEUt = mEUt;
+ MTE.mMaxProgresstime = mDuration;
+ ArrayList stacks = new ArrayList<>(mOutputs.size());
+ for (MobDrop o : mOutputs) {
+ if (o.chance == 10000 || rnd.nextInt(10000) < o.chance) {
+ ItemStack s = o.stack.copy();
+ 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 damage : o.damages.entrySet()) {
+ cChance += damage.getValue();
+ if (rChance <= cChance) {
+ s.setItemDamage(damage.getKey());
+ break;
+ }
+ }
+ }
+ stacks.add(s);
+ }
+ }
+
+ if (infernalityAllowed
+ && mEUt * 8 < MTE.getMaxInputVoltage()
+ && !InfernalHelper.getDimensionBlackList()
+ .contains(MTE.getBaseMetaTileEntity().getWorld().provider.dimensionId)) {
+ int p = 0;
+ int mods = 0;
+ if (alwaysinfernal || rnd.nextInt(InfernalHelper.getEliteRarity()) == 0) {
+ p = 1;
+ if (rnd.nextInt(InfernalHelper.getUltraRarity()) == 0) {
+ p = 2;
+ if (rnd.nextInt(InfernalHelper.getInfernoRarity()) == 0) p = 3;
+ }
+ }
+ ArrayList infernalstacks = null;
+ if (p > 0)
+ if (p == 1) {
+ infernalstacks = InfernalHelper.getDropIdListElite();
+ mods = InfernalHelper.getMinEliteModifiers();
+ } else if (p == 2) {
+ infernalstacks = InfernalHelper.getDropIdListUltra();
+ mods = InfernalHelper.getMinUltraModifiers();
+ } else if (p == 3) {
+ infernalstacks = InfernalHelper.getDropIdListInfernal();
+ mods = InfernalHelper.getMinInfernoModifiers();
+ }
+ if (infernalstacks != null) {
+ ItemStack infernalstack = infernalstacks
+ .get(rnd.nextInt(infernalstacks.size()))
+ .copy();
+ EnchantmentHelper.addRandomEnchantment(
+ rnd, infernalstack, infernalstack.getItem().getItemEnchantability());
+ stacks.add(infernalstack);
+ MTE.mEUt *= 8;
+ MTE.mMaxProgresstime *= mods * InfernalMobsCore.instance().getMobModHealthFactor();
+ }
+ }
+
+ return stacks.toArray(new ItemStack[0]);
+ }
+ }
+
+ public static class MobDrop {
+ public enum DropType {
+ Normal,
+ Rare,
+ Additional,
+ Infernal
+ }
+
+ public ItemStack stack;
+ public DropType type;
+ public int chance;
+ public Integer enchantable;
+ public HashMap damages;
+
+ public MobDrop(
+ ItemStack stack, DropType type, int chance, Integer enchantable, HashMap damages) {
+ this.stack = stack;
+ this.type = type;
+ this.chance = chance;
+ this.enchantable = enchantable;
+ this.damages = damages;
+ }
+ }
+
+ 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 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 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 drops = new ArrayList<>();
+ private final HashMap 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 {
+ HashMap damagableChecker = new HashMap<>();
+ private boolean booksAlwaysRandomlyEnchanted = false;
+
+ public void addDrop(droplist fdrops, ArrayList 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");
+ }
+ 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 drops;
+
+ public GeneralMappedMob(EntityLiving mob, MobRecipe recipe, ArrayList drops) {
+ this.mob = mob;
+ this.recipe = recipe;
+ this.drops = drops;
+ }
+ }
+
+ public static final HashMap GeneralMobList = new HashMap<>();
+
+ @SuppressWarnings("unchecked")
+ public static void generateMobRecipeMap() {
+
+ if (alreadyGenerated) return;
+ alreadyGenerated = true;
+ if (!Config.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;
+ }
+
+ @Override
+ public List getEntitiesWithinAABB(Class p_72872_1_, AxisAlignedBB p_72872_2_) {
+ return new ArrayList();
+ }
+ };
+ f.isRemote = true; // quick hack to get around achievements
+
+ fakeRand frand = new fakeRand();
+ f.rand = frand;
+
+ isInGenerationProcess = true;
+
+ LOG.info("Generating Recipe Map for Mob Handler and EEC");
+
+ long time = System.currentTimeMillis();
+
+ Method setSlimeSize;
+ Method dropFewItems;
+ Method dropRareDrop;
+ Method addRandomArmor;
+ Method enchantEquipment;
+ Field rand;
+
+ try {
+ setSlimeSize = EntitySlime.class.getDeclaredMethod(setSlimeSizeName, int.class);
+ setSlimeSize.setAccessible(true);
+ dropFewItems = EntityLivingBase.class.getDeclaredMethod(dropFewItemsName, boolean.class, int.class);
+ dropFewItems.setAccessible(true);
+ dropRareDrop = EntityLivingBase.class.getDeclaredMethod(dropRareDropName, int.class);
+ dropRareDrop.setAccessible(true);
+ addRandomArmor = EntityLiving.class.getDeclaredMethod(addRandomArmorName);
+ addRandomArmor.setAccessible(true);
+ enchantEquipment = EntityLiving.class.getDeclaredMethod(enchantEquipmentName);
+ enchantEquipment.setAccessible(true);
+ rand = Entity.class.getDeclaredField(randName);
+ rand.setAccessible(true);
+ } catch (Exception ex) {
+ LOG.error("Failed to obtain methods");
+ isInGenerationProcess = false;
+ return;
+ }
+
+ dropCollector collector = new dropCollector();
+
+ // Stupid MC code, I need to cast myself
+ ((Map>) EntityList.stringToClassMapping).forEach((k, v) -> {
+ if (v == null) return;
+
+ LOG.info("Generating entry for mob: " + k);
+
+ 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 (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+
+ if (StatCollector.translateToLocal("entity." + k + ".name").equals("entity." + k + ".name")) {
+ LOG.info("Entity " + k + " does't have localized name, skipping");
+ return;
+ }
+
+ e.captureDrops = true;
+
+ // POWERFULL GENERATION
+
+ if (e instanceof EntitySlime)
+ try {
+ setSlimeSize.invoke(e, 1);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+
+ try {
+ rand.set(e, frand);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+
+ droplist drops = new droplist();
+ droplist raredrops = new droplist();
+ droplist additionaldrops = new droplist();
+
+ LOG.info("Generating normal drops");
+
+ frand.newRound();
+ collector.newRound();
+
+ if (v.getName().startsWith("com.emoniph.witchery")) {
+ try {
+ dropFewItems.invoke(e, true, 0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+ frand.newRound();
+ frand.exceptionOnEnchantTry = true;
+ boolean enchantmentDetected = false;
+ try {
+ dropFewItems.invoke(e, true, 0);
+ } catch (Exception ex) {
+ enchantmentDetected = true;
+ }
+ int w = frand.walkCounter;
+ frand.newRound();
+ if (enchantmentDetected) {
+ frand.maxWalkCount = w;
+ collector.booksAlwaysRandomlyEnchanted = true;
+ }
+ e.capturedDrops.clear();
+ }
+
+ do {
+ try {
+ dropFewItems.invoke(e, true, 0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+ collector.addDrop(drops, e.capturedDrops, frand.chance);
+
+ if (frand.chance < 0.0000001d) {
+ LOG.info("Skipping " + k + " normal dropmap because it's too randomized");
+ break;
+ }
+
+ } while (frand.nextRound());
+
+ LOG.info("Generating rare drops");
+
+ frand.newRound();
+ collector.newRound();
+
+ do {
+ try {
+ dropRareDrop.invoke(e, 0);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ return;
+ }
+ collector.addDrop(raredrops, e.capturedDrops, frand.chance);
+
+ if (frand.chance < 0.0000001d) {
+ LOG.info("Skipping " + k + " rare dropmap because it's too randomized");
+ break;
+ }
+ } while (frand.nextRound());
+
+ LOG.info("Generating additional drops");
+
+ frand.newRound();
+ collector.newRound();
+
+ try {
+ Class> cl = e.getClass();
+ boolean detectedException = false;
+ 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;
+ }
+ do {
+ addRandomArmor.invoke(e);
+ if (!usingVanillaEnchantingMethod) enchantEquipment.invoke(e);
+ 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) i.damagesPossible.clone();
+ }
+ }
+ }
+ Arrays.fill(e.getLastActiveItems(), null);
+
+ if (frand.chance < 0.0000001d) {
+ LOG.info("Skipping " + k + " additional dropmap because it's too randomized");
+ break;
+ }
+
+ } while (frand.nextRound());
+ } catch (Exception ignored) {
+ }
+
+ frand.newRound();
+ collector.newRound();
+
+ if (drops.isEmpty() && raredrops.isEmpty() && additionaldrops.isEmpty()) {
+ GeneralMobList.put(k, new GeneralMappedMob(e, null, new ArrayList<>()));
+ LOG.info("Entity " + k + " doesn't drop any items, skipping EEC Recipe map");
+ return;
+ }
+
+ ArrayList 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);
+ while (chance > 10000) {
+ stack.stackSize *= 2;
+ chance /= 2;
+ }
+ moboutputs.add(new MobDrop(
+ stack,
+ MobDrop.DropType.Normal,
+ chance,
+ drop.isEnchatmentRandomized ? drop.enchantmentLevel : null,
+ drop.isDamageRandomized ? drop.damagesPossible : null));
+ }
+ for (dropinstance drop : raredrops.drops) {
+ ItemStack stack = drop.stack;
+ if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString);
+ int chance = drop.getchance(250);
+ while (chance > 10000) {
+ stack.stackSize *= 2;
+ chance /= 2;
+ }
+ moboutputs.add(new MobDrop(
+ stack,
+ MobDrop.DropType.Rare,
+ chance,
+ drop.isEnchatmentRandomized ? drop.enchantmentLevel : null,
+ drop.isDamageRandomized ? drop.damagesPossible : null));
+ }
+ for (dropinstance drop : additionaldrops.drops) {
+ ItemStack stack = drop.stack;
+ if (stack.hasTagCompound()) stack.stackTagCompound.removeTag(randomEnchantmentDetectedString);
+ int chance = drop.getchance(850);
+ while (chance > 10000) {
+ stack.stackSize *= 2;
+ chance /= 2;
+ }
+ moboutputs.add(new MobDrop(
+ stack,
+ MobDrop.DropType.Additional,
+ chance,
+ drop.isEnchatmentRandomized ? drop.enchantmentLevel : null,
+ drop.isDamageRandomized ? drop.damagesPossible : null));
+ }
+
+ GeneralMobList.put(k, new GeneralMappedMob(e, new MobRecipe(e, moboutputs), moboutputs));
+
+ LOG.info("Mapped " + k);
+ });
+
+ time -= System.currentTimeMillis();
+ time = -time;
+
+ LOG.info("Recipe map generated ! It took " + time + "ms");
+
+ isInGenerationProcess = false;
+ }
+
+ public static void processMobRecipeMap() {
+ LOG.info("Loading config");
+
+ if (isClientSided) Mob_Handler.clearRecipes();
+ MobNameToRecipeMap.clear();
+ LoadConfigPacket.instance.mobsToLoad.clear();
+ GeneralMobList.forEach((k, v) -> {
+ if (Arrays.asList(Config.mobBlacklist).contains(k)) {
+ LOG.info("Entity " + k + " is blacklisted, skipping");
+ return;
+ }
+
+ MobRecipe recipe = v.recipe;
+ if (recipe != null) recipe = recipe.copy();
+ ArrayList drops = (ArrayList) v.drops.clone();
+
+ // MT Scripts should already be loaded here
+ if (LoaderReference.MineTweaker) {
+ Optionals.parseMTAdditions(k, drops, recipe);
+ }
+
+ if (drops.isEmpty()) {
+ LOG.info("Entity " + k + " doesn't drop any items, skipping EEC map");
+ if (!Config.includeEmptyMobs) return;
+ LoadConfigPacket.instance.mobsToLoad.add(k);
+ LOG.info("Registered " + k);
+ return;
+ }
+ if (v.recipe != null) MobNameToRecipeMap.put(k, recipe);
+ LoadConfigPacket.instance.mobsToLoad.add(k);
+ LOG.info("Registered " + k);
+ });
+ }
+
+ @SideOnly(Side.CLIENT)
+ public static void processMobRecipeMap(HashSet mobs) {
+ if (isClientSided) Mob_Handler.clearRecipes();
+ MobNameToRecipeMap.clear();
+ mobs.forEach(k -> {
+ GeneralMappedMob v = GeneralMobList.get(k);
+ MobRecipe recipe = v.recipe;
+ if (recipe != null) recipe = recipe.copy();
+ ArrayList drops = (ArrayList) v.drops.clone();
+
+ // MT Scripts should already be loaded here
+ if (LoaderReference.MineTweaker) {
+ Optionals.parseMTAdditions(k, drops, recipe);
+ }
+
+ Mob_Handler.addRecipe(v.mob, drops);
+ if (recipe != null) 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 drops, MobRecipe recipe) {
+ IEntityDefinition ie = MineTweakerAPI.game.getEntity(k);
+ if (ie != null) {
+ for (Map.Entry entry : ie.getDropsToAdd().entrySet()) {
+ IntRange r = entry.getValue();
+ // Get average chance
+ double chance;
+ if (r.getFrom() == 0 && r.getTo() == 0) chance = 1d;
+ else chance = (((double) r.getTo() - (double) r.getFrom()) / 2d) + (double) r.getFrom();
+ ItemStack stack = ((ItemStack) entry.getKey().getInternal()).copy();
+ MobDrop drop = new MobDrop(stack, MobDrop.DropType.Normal, (int) (chance * 10000), null, null);
+ drops.add(drop);
+ if (recipe != null) recipe.mOutputs.add(drop);
+ }
+ for (Map.Entry entry :
+ ie.getDropsToAddPlayerOnly().entrySet()) {
+ IntRange r = entry.getValue();
+ // Get average chance
+ double chance;
+ if (r.getFrom() == 0 && r.getTo() == 0) chance = 1d;
+ else chance = (((double) r.getTo() - (double) r.getFrom()) / 2d) + (double) r.getFrom();
+ ItemStack stack = ((ItemStack) entry.getKey().getInternal()).copy();
+ MobDrop drop = new MobDrop(stack, MobDrop.DropType.Normal, (int) (chance * 10000), null, null);
+ drops.add(drop);
+ if (recipe != null) recipe.mOutputs.add(drop);
+ }
+ for (IItemStack istack : ie.getDropsToRemove()) {
+ List toRemove = drops.stream()
+ .filter(d -> istack.matches(new MCItemStack(d.stack)))
+ .collect(Collectors.toList());
+ drops.removeAll(toRemove);
+ if (recipe != null) recipe.mOutputs.removeAll(toRemove);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java
new file mode 100644
index 0000000000..99908a857f
--- /dev/null
+++ b/src/main/java/kubatech/loaders/RecipeLoader.java
@@ -0,0 +1,77 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 kuba6000
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+package kubatech.loaders;
+
+import gregtech.api.enums.Materials;
+import gregtech.api.enums.OrePrefixes;
+import gregtech.api.util.GT_ModHandler;
+import kubatech.Tags;
+import kubatech.api.LoaderReference;
+import kubatech.api.enums.ItemList;
+import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.ItemStack;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class RecipeLoader {
+
+ private static final Logger LOG = LogManager.getLogger(Tags.MODID + "[Recipe Loader]");
+ protected static final long bitsd = GT_ModHandler.RecipeBits.NOT_REMOVABLE
+ | GT_ModHandler.RecipeBits.REVERSIBLE
+ | GT_ModHandler.RecipeBits.BUFFERED
+ | GT_ModHandler.RecipeBits.DISMANTLEABLE;
+
+ private static int MTEID = 14201;
+ private static final int MTEIDMax = 14300;
+
+ public static void addRecipes() {
+ if (LoaderReference.EnderIO) {
+ ItemList.ExtremeExterminationChamber.set(new GT_MetaTileEntity_ExtremeExterminationChamber(
+ MTEID++, "multimachine.exterminationchamber", "Extreme Extermination Chamber")
+ .getStackForm(1L));
+ GT_ModHandler.addCraftingRecipe(ItemList.ExtremeExterminationChamber.get(1), bitsd, new Object[] {
+ "RCR",
+ "CHC",
+ "VVV",
+ 'R',
+ gregtech.api.enums.ItemList.Robot_Arm_EV,
+ 'C',
+ OrePrefixes.circuit.get(Materials.Data),
+ 'H',
+ gregtech.api.enums.ItemList.Hull_EV,
+ 'V',
+ GT_ModHandler.getModItem("OpenBlocks", "vacuumhopper", 1, new ItemStack(Blocks.hopper))
+ });
+ }
+ if (MTEID > MTEIDMax + 1) throw new RuntimeException("MTE ID's");
+ }
+
+ private static boolean lateRecipesInitialized = false;
+
+ public static void addRecipesLate() {
+ // Runs on server start
+ if (lateRecipesInitialized) return;
+ lateRecipesInitialized = true;
+
+ MobRecipeLoader.generateMobRecipeMap();
+ MobRecipeLoader.processMobRecipeMap();
+ }
+}
--
cgit
From f53a666152aa956a097d67fdaa7fb18757839147 Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Sun, 14 Aug 2022 16:23:54 +0200
Subject: Fix server crash from Blood Magic entities
---
src/main/java/kubatech/loaders/MobRecipeLoader.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
(limited to 'src/main/java/kubatech/loaders')
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index 033beb49fd..fddfb03137 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -618,7 +618,11 @@ public class MobRecipeLoader {
// No constructor ?
LOG.info("Entity " + k + " doesn't have constructor, skipping");
return;
- } catch (Exception ex) {
+ } 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;
}
--
cgit
From 4ad580a05e475a912ff9964cdd09d5ff666b98e8 Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Sun, 14 Aug 2022 21:46:59 +0200
Subject: LGPL 3.0
---
LICENSE | 774 +++++----------------
src/main/java/kubatech/ClientProxy.java | 20 +-
src/main/java/kubatech/CommonProxy.java | 20 +-
src/main/java/kubatech/Config.java | 20 +-
src/main/java/kubatech/FMLEventHandler.java | 19 +
src/main/java/kubatech/Tags.java | 20 +-
src/main/java/kubatech/api/Variables.java | 18 +-
.../java/kubatech/api/utils/InfernalHelper.java | 18 +-
src/main/java/kubatech/api/utils/ModUtils.java | 18 +-
.../java/kubatech/api/utils/ReflectionHelper.java | 18 +-
src/main/java/kubatech/commands/CommandConfig.java | 18 +-
.../java/kubatech/commands/CommandHandler.java | 18 +-
src/main/java/kubatech/commands/CommandHelp.java | 18 +-
...MetaTileEntity_ExtremeExterminationChamber.java | 18 +-
src/main/java/kubatech/kubatech.java | 18 +-
.../java/kubatech/loaders/MobRecipeLoader.java | 18 +-
src/main/java/kubatech/loaders/RecipeLoader.java | 18 +-
src/main/java/kubatech/nei/IMCForNEI.java | 18 +-
src/main/java/kubatech/nei/Mob_Handler.java | 18 +-
src/main/java/kubatech/nei/NEI_Config.java | 18 +-
.../java/kubatech/network/LoadConfigHandler.java | 18 +-
.../java/kubatech/network/LoadConfigPacket.java | 18 +-
src/main/resources/LICENSE | 19 +-
23 files changed, 372 insertions(+), 808 deletions(-)
(limited to 'src/main/java/kubatech/loaders')
diff --git a/LICENSE b/LICENSE
index 09c3f8ddd4..0a041280bd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,621 +1,165 @@
-GNU GENERAL PUBLIC LICENSE
+ GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
- Preamble
-
- The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
- The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works. By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users. We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors. You can apply it to
-your programs, too.
-
- When we speak of free software, we are referring to freedom, not
-price. Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
- To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights. Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
- For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received. You must make sure that they, too, receive
-or can get the source code. And you must show them these terms so they
-know their rights.
-
- Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
- For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software. For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
- Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so. This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software. The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable. Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products. If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
- Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary. To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
- The precise terms and conditions for copying, distribution and
-modification follow.
-
- TERMS AND CONDITIONS
-
- 0. Definitions.
-
- "This License" refers to version 3 of the GNU General Public License.
-
- "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
- "The Program" refers to any copyrightable work licensed under this
-License. Each licensee is addressed as "you". "Licensees" and
-"recipients" may be individuals or organizations.
-
- To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy. The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
- A "covered work" means either the unmodified Program or a work based
-on the Program.
-
- To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy. Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
- To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies. Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
- An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License. If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
- 1. Source Code.
-
- The "source code" for a work means the preferred form of the work
-for making modifications to it. "Object code" means any non-source
-form of a work.
-
- A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
- The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form. A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
- The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities. However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work. For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
- The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
- The Corresponding Source for a work in source code form is that
-same work.
-
- 2. Basic Permissions.
-
- All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met. This License explicitly affirms your unlimited
-permission to run the unmodified Program. The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work. This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
- You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force. You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright. Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
- Conveying under any other circumstances is permitted solely under
-the conditions stated below. Sublicensing is not allowed; section 10
-makes it unnecessary.
-
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
- No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
- When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
- 4. Conveying Verbatim Copies.
-
- You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
- You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
- 5. Conveying Modified Source Versions.
-
- You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
- a) The work must carry prominent notices stating that you modified
- it, and giving a relevant date.
-
- b) The work must carry prominent notices stating that it is
- released under this License and any conditions added under section
- 7. This requirement modifies the requirement in section 4 to
- "keep intact all notices".
-
- c) You must license the entire work, as a whole, under this
- License to anyone who comes into possession of a copy. This
- License will therefore apply, along with any applicable section 7
- additional terms, to the whole of the work, and all its parts,
- regardless of how they are packaged. This License gives no
- permission to license the work in any other way, but it does not
- invalidate such permission if you have separately received it.
-
- d) If the work has interactive user interfaces, each must display
- Appropriate Legal Notices; however, if the Program has interactive
- interfaces that do not display Appropriate Legal Notices, your
- work need not make them do so.
-
- A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit. Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
- 6. Conveying Non-Source Forms.
-
- You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
- a) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by the
- Corresponding Source fixed on a durable physical medium
- customarily used for software interchange.
-
- b) Convey the object code in, or embodied in, a physical product
- (including a physical distribution medium), accompanied by a
- written offer, valid for at least three years and valid for as
- long as you offer spare parts or customer support for that product
- model, to give anyone who possesses the object code either (1) a
- copy of the Corresponding Source for all the software in the
- product that is covered by this License, on a durable physical
- medium customarily used for software interchange, for a price no
- more than your reasonable cost of physically performing this
- conveying of source, or (2) access to copy the
- Corresponding Source from a network server at no charge.
-
- c) Convey individual copies of the object code with a copy of the
- written offer to provide the Corresponding Source. This
- alternative is allowed only occasionally and noncommercially, and
- only if you received the object code with such an offer, in accord
- with subsection 6b.
-
- d) Convey the object code by offering access from a designated
- place (gratis or for a charge), and offer equivalent access to the
- Corresponding Source in the same way through the same place at no
- further charge. You need not require recipients to copy the
- Corresponding Source along with the object code. If the place to
- copy the object code is a network server, the Corresponding Source
- may be on a different server (operated by you or a third party)
- that supports equivalent copying facilities, provided you maintain
- clear directions next to the object code saying where to find the
- Corresponding Source. Regardless of what server hosts the
- Corresponding Source, you remain obligated to ensure that it is
- available for as long as needed to satisfy these requirements.
-
- e) Convey the object code using peer-to-peer transmission, provided
- you inform other peers where the object code and Corresponding
- Source of the work are being offered to the general public at no
- charge under subsection 6d.
-
- A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
- A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling. In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage. For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product. A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
- "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source. The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
- If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information. But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
- The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed. Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
- Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
- 7. Additional Terms.
-
- "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law. If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
- When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it. (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.) You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
- Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
- a) Disclaiming warranty or limiting liability differently from the
- terms of sections 15 and 16 of this License; or
-
- b) Requiring preservation of specified reasonable legal notices or
- author attributions in that material or in the Appropriate Legal
- Notices displayed by works containing it; or
-
- c) Prohibiting misrepresentation of the origin of that material, or
- requiring that modified versions of such material be marked in
- reasonable ways as different from the original version; or
-
- d) Limiting the use for publicity purposes of names of licensors or
- authors of the material; or
-
- e) Declining to grant rights under trademark law for use of some
- trade names, trademarks, or service marks; or
-
- f) Requiring indemnification of licensors and authors of that
- material by anyone who conveys the material (or modified versions of
- it) with contractual assumptions of liability to the recipient, for
- any liability that these contractual assumptions directly impose on
- those licensors and authors.
-
- All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10. If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term. If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
- If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
- Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
- 8. Termination.
-
- You may not propagate or modify a covered work except as expressly
-provided under this License. Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
- However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
- Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
- Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License. If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
- 9. Acceptance Not Required for Having Copies.
-
- You are not required to accept this License in order to receive or
-run a copy of the Program. Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance. However,
-nothing other than this License grants you permission to propagate or
-modify any covered work. These actions infringe copyright if you do
-not accept this License. Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
- 10. Automatic Licensing of Downstream Recipients.
-
- Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License. You are not responsible
-for enforcing compliance by third parties with this License.
-
- An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations. If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
- You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License. For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
- 11. Patents.
-
- A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based. The
-work thus licensed is called the contributor's "contributor version".
-
- A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version. For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
- Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
- In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement). To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
- If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients. "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
- If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
- A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License. You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
- Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
- 12. No Surrender of Others' Freedom.
-
- If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License. If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all. For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
- 13. Use with the GNU Affero General Public License.
-
- Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work. The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
- 14. Revised Versions of this License.
-
- The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time. Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
- Each version is given a distinguishing version number. If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation. If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
- If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
- Later license versions may give you additional or different
-permissions. However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
- 15. Disclaimer of Warranty.
-
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
- 16. Limitation of Liability.
-
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
- 17. Interpretation of Sections 15 and 16.
-
- If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
- END OF TERMS AND CONDITIONS
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/src/main/java/kubatech/ClientProxy.java b/src/main/java/kubatech/ClientProxy.java
index f25f41ee2c..4264536980 100644
--- a/src/main/java/kubatech/ClientProxy.java
+++ b/src/main/java/kubatech/ClientProxy.java
@@ -1,19 +1,19 @@
/*
- * kubatech - Gregtech Addon
+ * KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/CommonProxy.java b/src/main/java/kubatech/CommonProxy.java
index e844cd19d0..e1285a7b84 100644
--- a/src/main/java/kubatech/CommonProxy.java
+++ b/src/main/java/kubatech/CommonProxy.java
@@ -1,19 +1,19 @@
/*
- * kubatech - Gregtech Addon
+ * KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/Config.java b/src/main/java/kubatech/Config.java
index 439557d9a0..f258a9e088 100644
--- a/src/main/java/kubatech/Config.java
+++ b/src/main/java/kubatech/Config.java
@@ -1,19 +1,19 @@
/*
- * kubatech - Gregtech Addon
+ * KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/FMLEventHandler.java b/src/main/java/kubatech/FMLEventHandler.java
index e5acd58a36..6e4bfad541 100644
--- a/src/main/java/kubatech/FMLEventHandler.java
+++ b/src/main/java/kubatech/FMLEventHandler.java
@@ -1,3 +1,22 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 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 .
+ *
+ */
+
package kubatech;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
diff --git a/src/main/java/kubatech/Tags.java b/src/main/java/kubatech/Tags.java
index eb89cfdb6d..6f2393c4e6 100644
--- a/src/main/java/kubatech/Tags.java
+++ b/src/main/java/kubatech/Tags.java
@@ -1,19 +1,19 @@
/*
- * kubatech - Gregtech Addon
+ * KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/api/Variables.java b/src/main/java/kubatech/api/Variables.java
index c989b45f6f..9dba10f6a6 100644
--- a/src/main/java/kubatech/api/Variables.java
+++ b/src/main/java/kubatech/api/Variables.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/api/utils/InfernalHelper.java b/src/main/java/kubatech/api/utils/InfernalHelper.java
index d4e416e9a5..60263b0a17 100644
--- a/src/main/java/kubatech/api/utils/InfernalHelper.java
+++ b/src/main/java/kubatech/api/utils/InfernalHelper.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/api/utils/ModUtils.java b/src/main/java/kubatech/api/utils/ModUtils.java
index 0802294974..0f598dcfa8 100644
--- a/src/main/java/kubatech/api/utils/ModUtils.java
+++ b/src/main/java/kubatech/api/utils/ModUtils.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/api/utils/ReflectionHelper.java b/src/main/java/kubatech/api/utils/ReflectionHelper.java
index 0e5d40e245..7c7301c1c8 100644
--- a/src/main/java/kubatech/api/utils/ReflectionHelper.java
+++ b/src/main/java/kubatech/api/utils/ReflectionHelper.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/commands/CommandConfig.java b/src/main/java/kubatech/commands/CommandConfig.java
index f3bcbb7754..e892ac885b 100644
--- a/src/main/java/kubatech/commands/CommandConfig.java
+++ b/src/main/java/kubatech/commands/CommandConfig.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/commands/CommandHandler.java b/src/main/java/kubatech/commands/CommandHandler.java
index 6f32839472..3bcfb352b2 100644
--- a/src/main/java/kubatech/commands/CommandHandler.java
+++ b/src/main/java/kubatech/commands/CommandHandler.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/commands/CommandHelp.java b/src/main/java/kubatech/commands/CommandHelp.java
index 0165e67c80..2ea9b00d76 100644
--- a/src/main/java/kubatech/commands/CommandHelp.java
+++ b/src/main/java/kubatech/commands/CommandHelp.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java b/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
index f02599f37f..ff6ed02363 100644
--- a/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
+++ b/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/kubatech.java b/src/main/java/kubatech/kubatech.java
index 893928ea60..d5407ff357 100644
--- a/src/main/java/kubatech/kubatech.java
+++ b/src/main/java/kubatech/kubatech.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index fddfb03137..3c087961d9 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java
index 99908a857f..ba6cbb7a1f 100644
--- a/src/main/java/kubatech/loaders/RecipeLoader.java
+++ b/src/main/java/kubatech/loaders/RecipeLoader.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/nei/IMCForNEI.java b/src/main/java/kubatech/nei/IMCForNEI.java
index 75228e19f1..636e028c31 100644
--- a/src/main/java/kubatech/nei/IMCForNEI.java
+++ b/src/main/java/kubatech/nei/IMCForNEI.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/nei/Mob_Handler.java b/src/main/java/kubatech/nei/Mob_Handler.java
index cd172a8797..a231eceffc 100644
--- a/src/main/java/kubatech/nei/Mob_Handler.java
+++ b/src/main/java/kubatech/nei/Mob_Handler.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/nei/NEI_Config.java b/src/main/java/kubatech/nei/NEI_Config.java
index 8b7123a416..a5bf1f58ca 100644
--- a/src/main/java/kubatech/nei/NEI_Config.java
+++ b/src/main/java/kubatech/nei/NEI_Config.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/network/LoadConfigHandler.java b/src/main/java/kubatech/network/LoadConfigHandler.java
index a950c1d849..7bf8bd9756 100644
--- a/src/main/java/kubatech/network/LoadConfigHandler.java
+++ b/src/main/java/kubatech/network/LoadConfigHandler.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/java/kubatech/network/LoadConfigPacket.java b/src/main/java/kubatech/network/LoadConfigPacket.java
index d386d6b071..48f3342486 100644
--- a/src/main/java/kubatech/network/LoadConfigPacket.java
+++ b/src/main/java/kubatech/network/LoadConfigPacket.java
@@ -2,18 +2,18 @@
* KubaTech - Gregtech Addon
* Copyright (C) 2022 kuba6000
*
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+ * 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 General Public License for more details.
+ * 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 General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see .
*
*/
diff --git a/src/main/resources/LICENSE b/src/main/resources/LICENSE
index 49ca66a7bf..8d4cc1a2f3 100644
--- a/src/main/resources/LICENSE
+++ b/src/main/resources/LICENSE
@@ -1,14 +1,15 @@
+KubaTech - Gregtech addon
Copyright (C) 2022 kuba6000
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU 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 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 program is distributed in the hope that it will be useful,
+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 General Public License for more details.
+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 General Public License
-along with this program. If not, see .
+You should have received a copy of the GNU Lesser General Public License
+along with this library. If not, see .
--
cgit
From 76a2834cedfa4f3916d07e2893fc54121268489e Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Wed, 17 Aug 2022 05:01:16 +0200
Subject: Structure
---
dependencies.gradle | 5 +
src/main/java/kubatech/FMLEventHandler.java | 2 +-
src/main/java/kubatech/api/LoaderReference.java | 1 +
.../api/network/CustomTileEntityPacket.java | 119 ++++++
.../kubatech/api/network/LoadConfigPacket.java | 74 ++++
.../tileentity/CustomTileEntityPacketHandler.java | 7 +
.../java/kubatech/api/utils/InfernalHelper.java | 1 +
src/main/java/kubatech/api/utils/MobUtils.java | 57 +++
.../java/kubatech/api/utils/ReflectionHelper.java | 9 +-
.../kubatech/client/effect/EntityRenderer.java | 144 +++++++
src/main/java/kubatech/commands/CommandConfig.java | 2 +-
.../java/kubatech/commands/CommandHandler.java | 1 +
src/main/java/kubatech/commands/CommandHelp.java | 7 +-
...MetaTileEntity_ExtremeExterminationChamber.java | 394 ------------------
src/main/java/kubatech/kubatech.java | 7 +-
.../java/kubatech/loaders/MobRecipeLoader.java | 22 +-
src/main/java/kubatech/loaders/RecipeLoader.java | 2 +-
src/main/java/kubatech/nei/Mob_Handler.java | 3 +-
.../java/kubatech/network/LoadConfigHandler.java | 36 --
.../java/kubatech/network/LoadConfigPacket.java | 61 ---
...MetaTileEntity_ExtremeExterminationChamber.java | 454 +++++++++++++++++++++
21 files changed, 893 insertions(+), 515 deletions(-)
create mode 100644 src/main/java/kubatech/api/network/CustomTileEntityPacket.java
create mode 100644 src/main/java/kubatech/api/network/LoadConfigPacket.java
create mode 100644 src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java
create mode 100644 src/main/java/kubatech/api/utils/MobUtils.java
create mode 100644 src/main/java/kubatech/client/effect/EntityRenderer.java
delete mode 100644 src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
delete mode 100644 src/main/java/kubatech/network/LoadConfigHandler.java
delete mode 100644 src/main/java/kubatech/network/LoadConfigPacket.java
create mode 100644 src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
(limited to 'src/main/java/kubatech/loaders')
diff --git a/dependencies.gradle b/dependencies.gradle
index 39a4c44d2f..77f994b5c0 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -17,11 +17,16 @@ dependencies {
{
transitive = false
}
+ compileOnly("com.github.GTNewHorizons:bartworks:0.5.67:dev")
+ {
+ transitive = false
+ }
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
runtime("curse.maven:cofh-core-69162:2388751")
// For testing
//runtime("com.github.GTNewHorizons:OpenBlocks:1.6.9-GTNH:dev")
+ //runtime("com.github.GTNewHorizons:bartworks:0.5.67:dev")
//runtime("com.github.GTNewHorizons:CraftTweaker:3.2.9:dev")
//compile("com.github.GTNewHorizons:SpecialMobs:3.3.12:dev")
//compile("com.github.GTNewHorizons:twilightforest:2.3.8.15:dev")
diff --git a/src/main/java/kubatech/FMLEventHandler.java b/src/main/java/kubatech/FMLEventHandler.java
index 6e4bfad541..e74e7eeee0 100644
--- a/src/main/java/kubatech/FMLEventHandler.java
+++ b/src/main/java/kubatech/FMLEventHandler.java
@@ -21,7 +21,7 @@ package kubatech;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.PlayerEvent;
-import kubatech.network.LoadConfigPacket;
+import kubatech.api.network.LoadConfigPacket;
import net.minecraft.entity.player.EntityPlayerMP;
public class FMLEventHandler {
diff --git a/src/main/java/kubatech/api/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java
index aef8930905..418fe4a7ab 100644
--- a/src/main/java/kubatech/api/LoaderReference.java
+++ b/src/main/java/kubatech/api/LoaderReference.java
@@ -9,4 +9,5 @@ public class LoaderReference {
public static final boolean InfernalMobs = Loader.isModLoaded("InfernalMobs");
public static final boolean Thaumcraft = Loader.isModLoaded("Thaumcraft");
public static final boolean MineTweaker = Loader.isModLoaded("MineTweaker3");
+ public static final boolean Bartworks = Loader.isModLoaded("bartworks");
}
diff --git a/src/main/java/kubatech/api/network/CustomTileEntityPacket.java b/src/main/java/kubatech/api/network/CustomTileEntityPacket.java
new file mode 100644
index 0000000000..9236594647
--- /dev/null
+++ b/src/main/java/kubatech/api/network/CustomTileEntityPacket.java
@@ -0,0 +1,119 @@
+package kubatech.api.network;
+
+import cpw.mods.fml.common.network.NetworkRegistry;
+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 gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.nio.charset.StandardCharsets;
+import kubatech.api.tileentity.CustomTileEntityPacketHandler;
+import kubatech.api.utils.ModUtils;
+import kubatech.kubatech;
+import net.minecraft.client.Minecraft;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.World;
+
+public class CustomTileEntityPacket implements IMessage {
+ public int w, x, y, z;
+ public ByteBuf customdata = Unpooled.buffer();
+
+ @SuppressWarnings("unused")
+ public CustomTileEntityPacket() {}
+
+ public CustomTileEntityPacket(TileEntity te, byte[] customdata) {
+ this.w = te.getWorldObj().provider.dimensionId;
+ this.x = te.xCoord;
+ this.y = te.yCoord;
+ this.z = te.zCoord;
+ if (customdata != null && customdata.length > 0) this.customdata.writeBytes(customdata);
+ }
+
+ public void sendToAllAround(int range) {
+ kubatech.NETWORK.sendToAllAround(this, new NetworkRegistry.TargetPoint(w, x, y, z, range));
+ }
+
+ // Helper methods
+
+ public void resetHelperData() {
+ customdata.clear();
+ }
+
+ public void addData(byte[] data) {
+ customdata.writeBytes(data);
+ }
+
+ public void addData(byte data) {
+ customdata.writeByte(data);
+ }
+
+ public void addData(int data) {
+ customdata.writeInt(data);
+ }
+
+ public void addData(String data) {
+ byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
+ addData(bytes.length);
+ addData(bytes);
+ }
+
+ public void getData(byte[] bytes) {
+ customdata.readBytes(bytes);
+ }
+
+ public byte[] getData(int len) {
+ byte[] bytes = new byte[len];
+ getData(bytes);
+ return bytes;
+ }
+
+ public int getDataInt() {
+ return customdata.readInt();
+ }
+
+ public String getDataString() {
+ return new String(getData(getDataInt()), StandardCharsets.UTF_8);
+ }
+
+ @Override
+ public void fromBytes(ByteBuf buf) {
+ w = buf.readInt();
+ x = buf.readInt();
+ y = buf.readInt();
+ z = buf.readInt();
+ customdata.clear();
+ buf.readBytes(customdata, buf.readInt());
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ buf.writeInt(w);
+ buf.writeInt(x);
+ buf.writeInt(y);
+ buf.writeInt(z);
+ buf.writeInt(customdata.readableBytes());
+ buf.writeBytes(customdata);
+ }
+
+ public static class Handler implements IMessageHandler {
+ @Override
+ public IMessage onMessage(CustomTileEntityPacket message, MessageContext ctx) {
+ if (!ModUtils.isClientSided) return null;
+ World w = Minecraft.getMinecraft().thePlayer.getEntityWorld();
+ if (message.w != w.provider.dimensionId) return null;
+ TileEntity e = w.getTileEntity(message.x, message.y, message.z);
+ if (e == null || e.isInvalid()) return null;
+ if (e instanceof IGregTechTileEntity && !((IGregTechTileEntity) e).isInvalidTileEntity()) {
+ IMetaTileEntity mte = ((IGregTechTileEntity) e).getMetaTileEntity();
+ if (mte == null) return null;
+ if (!(mte instanceof CustomTileEntityPacketHandler)) return null;
+ ((CustomTileEntityPacketHandler) mte).HandleCustomPacket(message);
+ return null;
+ } else if (!(e instanceof CustomTileEntityPacketHandler)) return null;
+ ((CustomTileEntityPacketHandler) e).HandleCustomPacket(message);
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/kubatech/api/network/LoadConfigPacket.java b/src/main/java/kubatech/api/network/LoadConfigPacket.java
new file mode 100644
index 0000000000..f38293642e
--- /dev/null
+++ b/src/main/java/kubatech/api/network/LoadConfigPacket.java
@@ -0,0 +1,74 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 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 .
+ *
+ */
+
+package kubatech.api.network;
+
+import cpw.mods.fml.common.network.simpleimpl.IMessage;
+import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
+import cpw.mods.fml.common.network.simpleimpl.MessageContext;
+import io.netty.buffer.ByteBuf;
+import java.nio.charset.StandardCharsets;
+import java.util.HashSet;
+import kubatech.Config;
+import kubatech.kubatech;
+import kubatech.loaders.MobRecipeLoader;
+
+public class LoadConfigPacket implements IMessage {
+
+ public static final LoadConfigPacket instance = new LoadConfigPacket();
+
+ public final HashSet mobsToLoad = new HashSet<>();
+
+ @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));
+ }
+ }
+ }
+
+ @Override
+ public void toBytes(ByteBuf buf) {
+ if (!Config.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);
+ });
+ }
+ }
+
+ public static class Handler implements IMessageHandler {
+ @Override
+ public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) {
+ kubatech.info("Received Mob Handler config, parsing");
+ MobRecipeLoader.processMobRecipeMap(message.mobsToLoad);
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java
new file mode 100644
index 0000000000..643ca70d0f
--- /dev/null
+++ b/src/main/java/kubatech/api/tileentity/CustomTileEntityPacketHandler.java
@@ -0,0 +1,7 @@
+package kubatech.api.tileentity;
+
+import kubatech.api.network.CustomTileEntityPacket;
+
+public interface CustomTileEntityPacketHandler {
+ void HandleCustomPacket(CustomTileEntityPacket customdata);
+}
diff --git a/src/main/java/kubatech/api/utils/InfernalHelper.java b/src/main/java/kubatech/api/utils/InfernalHelper.java
index 60263b0a17..4bd48274f3 100644
--- a/src/main/java/kubatech/api/utils/InfernalHelper.java
+++ b/src/main/java/kubatech/api/utils/InfernalHelper.java
@@ -27,6 +27,7 @@ import java.util.ArrayList;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
+@SuppressWarnings("unchecked")
public class InfernalHelper {
private static Method isClassAllowed = null;
diff --git a/src/main/java/kubatech/api/utils/MobUtils.java b/src/main/java/kubatech/api/utils/MobUtils.java
new file mode 100644
index 0000000000..3e20adac1c
--- /dev/null
+++ b/src/main/java/kubatech/api/utils/MobUtils.java
@@ -0,0 +1,57 @@
+package kubatech.api.utils;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import java.lang.reflect.Field;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.model.ModelBox;
+import net.minecraft.client.model.ModelRenderer;
+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;
+
+public class MobUtils {
+
+ private static Field mainmodelfield = null;
+
+ @SideOnly(Side.CLIENT)
+ public static float getDesiredScale(EntityLiving e, float desiredHeight) {
+ try {
+ if (mainmodelfield == null) {
+ mainmodelfield = RendererLivingEntity.class.getDeclaredField(
+ ModUtils.isDeobfuscatedEnvironment ? "mainModel" : "field_77045_g");
+ mainmodelfield.setAccessible(true);
+ }
+ float eheight = e.height;
+ float ewidth = e.width;
+ Render r = RenderManager.instance.getEntityRenderObject(e);
+ if (r instanceof RendererLivingEntity && mainmodelfield != null) {
+ ModelBase mainmodel = (ModelBase) mainmodelfield.get(r);
+ 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 desiredHeight / eheight;
+ } catch (Exception ex) {
+ return 1f;
+ }
+ }
+}
diff --git a/src/main/java/kubatech/api/utils/ReflectionHelper.java b/src/main/java/kubatech/api/utils/ReflectionHelper.java
index 7c7301c1c8..48d07c6eee 100644
--- a/src/main/java/kubatech/api/utils/ReflectionHelper.java
+++ b/src/main/java/kubatech/api/utils/ReflectionHelper.java
@@ -25,7 +25,8 @@ import java.util.HashMap;
public class ReflectionHelper {
private static final HashMap> fields = new HashMap<>();
- public static T getField(Object obj, String fieldName, boolean useBasicTypes, T defaultvalue) {
+ @SuppressWarnings("unchecked")
+ public static T getField(Object obj, String fieldName, T defaultvalue) {
Class> cl = obj.getClass();
String clName = cl.getName();
HashMap classmap = fields.computeIfAbsent(clName, s -> new HashMap<>());
@@ -52,11 +53,7 @@ public class ReflectionHelper {
}
}
- public static T getField(Object obj, String fieldName, boolean useBasicTypes) {
- return getField(obj, fieldName, useBasicTypes, null);
- }
-
public static T getField(Object obj, String fieldName) {
- return getField(obj, fieldName, true, null);
+ return getField(obj, fieldName, null);
}
}
diff --git a/src/main/java/kubatech/client/effect/EntityRenderer.java b/src/main/java/kubatech/client/effect/EntityRenderer.java
new file mode 100644
index 0000000000..23f1a6e44a
--- /dev/null
+++ b/src/main/java/kubatech/client/effect/EntityRenderer.java
@@ -0,0 +1,144 @@
+package kubatech.client.effect;
+
+import static net.minecraft.client.renderer.entity.RenderManager.*;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import kubatech.api.utils.MobUtils;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.particle.EntityFX;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.renderer.RenderHelper;
+import net.minecraft.client.renderer.Tessellator;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.world.World;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL12;
+
+@SideOnly(Side.CLIENT)
+public class EntityRenderer extends EntityFX {
+ private EntityLiving entityToRender = null;
+
+ public EntityRenderer(World p_i1218_1_, double x, double y, double z, int age) {
+ super(p_i1218_1_, x + 0.5d, y, z + 0.5d);
+ this.particleMaxAge = age;
+ this.particleAge = 0;
+ }
+
+ public EntityRenderer(EntityRenderer r, int age) {
+ super(r.worldObj, r.posX, r.posY, r.posZ);
+ this.particleMaxAge = age;
+ this.particleAge = 0;
+ this.ticksExisted = r.ticksExisted;
+ this.entityToRender = r.entityToRender;
+ }
+
+ @Override
+ protected void entityInit() {}
+
+ @Override
+ public void onUpdate() {
+ if (this.entityToRender == null) return;
+ this.ticksExisted++;
+ if (ticksExisted % 20 == 0) entityToRender.hurtTime = 10;
+ else if (entityToRender.hurtTime > 0) entityToRender.hurtTime--;
+ if (this.particleAge++ == this.particleMaxAge) {
+ this.setDead();
+ }
+ }
+
+ @Override
+ public boolean shouldRenderInPass(int pass) {
+ return pass == 3;
+ }
+
+ @Override
+ public int getFXLayer() {
+ return 3;
+ }
+
+ public void setEntity(EntityLiving entity) {
+ this.entityToRender = entity;
+ }
+
+ @Override
+ public void renderParticle(
+ Tessellator p_70539_1_,
+ float p_70539_2_,
+ float p_70539_3_,
+ float p_70539_4_,
+ float p_70539_5_,
+ float p_70539_6_,
+ float p_70539_7_) {
+ if (entityToRender == null) return;
+
+ GL11.glEnable(GL11.GL_LIGHTING);
+ GL11.glEnable(GL11.GL_COLOR_MATERIAL);
+
+ entityToRender.worldObj = this.worldObj;
+ entityToRender.setPosition(this.posX, this.posY, this.posZ);
+
+ double rotation;
+ // double headrotation;
+ {
+ double x1 = this.posX;
+ double x2 = Minecraft.getMinecraft().thePlayer.posX;
+ double y1 = this.posZ;
+ double y2 = Minecraft.getMinecraft().thePlayer.posZ;
+ double k = Math.toDegrees(Math.atan2(x2 - x1, y1 - y2));
+ if (k < 0d) k += 360d;
+ k -= 180d;
+ rotation = k;
+ }
+ /*
+ {
+ double y1 = this.posY;
+ double y2 = Minecraft.getMinecraft().thePlayer.posY;
+ double d = Minecraft.getMinecraft()
+ .thePlayer
+ .getDistance(this.posX, Minecraft.getMinecraft().thePlayer.posY, this.posZ);
+ double k = Math.toDegrees(Math.atan2(y1 - y2, d));
+ if (k < 0d) k += 360d;
+ headrotation = k;
+ }
+
+ */
+
+ entityToRender.prevRotationYawHead = entityToRender.rotationYawHead;
+ entityToRender.prevRenderYawOffset = entityToRender.renderYawOffset;
+ // entityToRender.prevRotationPitch = entityToRender.rotationPitch;
+ entityToRender.renderYawOffset = (float) rotation;
+ entityToRender.rotationYawHead = (float) rotation;
+ // entityToRender.rotationPitch = (float)headrotation;
+
+ float p_147936_2_ = 0.5f;
+
+ float f1 = entityToRender.prevRotationYaw
+ + (entityToRender.rotationYaw - entityToRender.prevRotationYaw) * p_147936_2_;
+ int i = entityToRender.getBrightnessForRender(p_147936_2_);
+
+ if (entityToRender.isBurning()) {
+ i = 15728880;
+ }
+
+ int j = i % 65536;
+ int k = i / 65536;
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float) j, (float) k);
+ GL11.glColor4f(1f, 1f, 1f, 1F);
+ RenderHelper.enableStandardItemLighting();
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glPushMatrix();
+ GL11.glTranslatef(
+ (float) (this.posX - renderPosX), (float) (this.posY - renderPosY), (float) (this.posZ - renderPosZ));
+ GL11.glEnable(GL12.GL_RESCALE_NORMAL);
+ float desiredScale = MobUtils.getDesiredScale(entityToRender, 2f);
+ if (desiredScale < 1f) GL11.glScalef(desiredScale, desiredScale, desiredScale);
+
+ instance.renderEntityWithPosYaw(entityToRender, 0f, 0f, 0f, f1, p_147936_2_);
+
+ GL11.glPopMatrix();
+
+ GL11.glDisable(GL11.GL_LIGHTING);
+ GL11.glDisable(GL11.GL_COLOR_MATERIAL);
+ }
+}
diff --git a/src/main/java/kubatech/commands/CommandConfig.java b/src/main/java/kubatech/commands/CommandConfig.java
index e892ac885b..a1c3659165 100644
--- a/src/main/java/kubatech/commands/CommandConfig.java
+++ b/src/main/java/kubatech/commands/CommandConfig.java
@@ -22,9 +22,9 @@ package kubatech.commands;
import static kubatech.commands.CommandConfig.Translations.*;
import kubatech.Config;
+import kubatech.api.network.LoadConfigPacket;
import kubatech.kubatech;
import kubatech.loaders.MobRecipeLoader;
-import kubatech.network.LoadConfigPacket;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
diff --git a/src/main/java/kubatech/commands/CommandHandler.java b/src/main/java/kubatech/commands/CommandHandler.java
index 3bcfb352b2..d1822a1ff8 100644
--- a/src/main/java/kubatech/commands/CommandHandler.java
+++ b/src/main/java/kubatech/commands/CommandHandler.java
@@ -74,6 +74,7 @@ public class CommandHandler extends CommandBase {
return "kubatech " + USAGE.get();
}
+ @SuppressWarnings("rawtypes")
@Override
public List getCommandAliases() {
return aliases;
diff --git a/src/main/java/kubatech/commands/CommandHelp.java b/src/main/java/kubatech/commands/CommandHelp.java
index 2ea9b00d76..dba8ab622d 100644
--- a/src/main/java/kubatech/commands/CommandHelp.java
+++ b/src/main/java/kubatech/commands/CommandHelp.java
@@ -73,8 +73,9 @@ public class CommandHelp extends CommandBase {
@Override
public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
p_71515_1_.addChatMessage(new ChatComponentText(POSSIBLE_COMMANDS.get()));
- CommandHandler.commands.values().forEach(c -> {
- p_71515_1_.addChatMessage(new ChatComponentText("/kubatech " + c.getCommandUsage(p_71515_1_)));
- });
+ CommandHandler.commands
+ .values()
+ .forEach(c ->
+ p_71515_1_.addChatMessage(new ChatComponentText("/kubatech " + c.getCommandUsage(p_71515_1_))));
}
}
diff --git a/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java b/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
deleted file mode 100644
index ff6ed02363..0000000000
--- a/src/main/java/kubatech/common/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
+++ /dev/null
@@ -1,394 +0,0 @@
-/*
- * KubaTech - Gregtech Addon
- * Copyright (C) 2022 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 .
- *
- */
-
-package kubatech.common.tileentity.gregtech.multiblock;
-
-import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
-import static gregtech.api.enums.Textures.BlockIcons.*;
-import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
-import static kubatech.api.Variables.Author;
-
-import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
-import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
-import WayofTime.alchemicalWizardry.api.rituals.Rituals;
-import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
-import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
-import WayofTime.alchemicalWizardry.common.rituals.RitualEffectWellOfSuffering;
-import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
-import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
-import com.gtnewhorizon.structurelib.structure.StructureDefinition;
-import cpw.mods.fml.common.eventhandler.EventPriority;
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import crazypants.enderio.EnderIO;
-import gregtech.api.GregTech_API;
-import gregtech.api.enums.Textures;
-import gregtech.api.interfaces.ITexture;
-import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
-import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
-import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
-import gregtech.api.render.TextureFactory;
-import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
-import gregtech.api.util.GT_Utility;
-import java.util.HashMap;
-import java.util.Random;
-import kubatech.Tags;
-import kubatech.api.LoaderReference;
-import kubatech.api.utils.FastRandom;
-import kubatech.api.utils.ReflectionHelper;
-import kubatech.loaders.MobRecipeLoader;
-import net.minecraft.block.Block;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.Item;
-import net.minecraft.item.ItemStack;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChunkCoordinates;
-import net.minecraft.world.EnumDifficulty;
-import net.minecraft.world.World;
-import net.minecraftforge.common.MinecraftForge;
-import net.minecraftforge.fluids.FluidRegistry;
-import net.minecraftforge.fluids.FluidStack;
-
-public class GT_MetaTileEntity_ExtremeExterminationChamber
- extends GT_MetaTileEntity_EnhancedMultiBlockBase {
-
- public static final HashMap MobNameToRecipeMap = new HashMap<>();
- public final Random rand = new FastRandom();
-
- public GT_MetaTileEntity_ExtremeExterminationChamber(int aID, String aName, String aNameRegional) {
- super(aID, aName, aNameRegional);
- }
-
- public GT_MetaTileEntity_ExtremeExterminationChamber(String aName) {
- super(aName);
- if (LoaderReference.BloodMagic) MinecraftForge.EVENT_BUS.register(this);
- }
-
- @Override
- public void onRemoval() {
- if (LoaderReference.BloodMagic) MinecraftForge.EVENT_BUS.unregister(this);
- }
-
- private static final String WellOfSufferingRitualName = "AW013Suffering";
-
- private static final Item poweredSpawnerItem = Item.getItemFromBlock(EnderIO.blockPoweredSpawner);
- private static final int CASING_INDEX = 16;
- private static final String STRUCTURE_PIECE_MAIN = "main";
- private static final IStructureDefinition STRUCTURE_DEFINITION =
- StructureDefinition.builder()
- .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] {
- {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"},
- {"ccccc", "c---c", "c---c", "c---c", "ccccc"},
- {"ccccc", "c---c", "c---c", "c---c", "ccccc"},
- {"ccccc", "c---c", "c---c", "c---c", "ccccc"},
- {"ccccc", "c---c", "c---c", "c---c", "ccccc"},
- {"ccccc", "csssc", "csssc", "csssc", "ccccc"},
- {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"},
- }))
- .addElement('c', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings2, 0)))
- .addElement(
- 'C',
- ofChain(
- onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings2, 0)),
- ofHatchAdder(
- GT_MetaTileEntity_ExtremeExterminationChamber::addOutputToMachineList,
- CASING_INDEX,
- 1),
- ofHatchAdder(
- GT_MetaTileEntity_ExtremeExterminationChamber::addEnergyInputToMachineList,
- CASING_INDEX,
- 1),
- ofHatchAdder(
- GT_MetaTileEntity_ExtremeExterminationChamber::addMaintenanceToMachineList,
- CASING_INDEX,
- 1)))
- .addElement(
- 's',
- LoaderReference.ExtraUtilities
- ? ofBlock(Block.getBlockFromName("ExtraUtilities:spike_base_diamond"), 0)
- : isAir())
- .build();
-
- private TileEntity masterStoneRitual = null;
- private TileEntity tileAltar = null;
- private boolean isInRitualMode = false;
- private int mCasing = 0;
-
- @Override
- public void saveNBTData(NBTTagCompound aNBT) {
- super.saveNBTData(aNBT);
- aNBT.setBoolean("isInRitualMode", isInRitualMode);
- }
-
- @Override
- public void loadNBTData(NBTTagCompound aNBT) {
- super.loadNBTData(aNBT);
- isInRitualMode = aNBT.getBoolean("isInRitualMode");
- }
-
- @Override
- public IStructureDefinition getStructureDefinition() {
- return STRUCTURE_DEFINITION;
- }
-
- @Override
- protected GT_Multiblock_Tooltip_Builder createTooltip() {
- GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
- tt.addMachineType("Powered Spawner")
- .addInfo("Controller block for Extreme Extermination Chamber")
- .addInfo("Spawns and Exterminates monsters for you")
- .addInfo("Base energy usage: 2,000 EU/t")
- .addInfo("Recipe time is based on mob health")
- .addInfo("Also produces 120 Liquid XP per operation")
- .addInfo("If the mob spawns infernal")
- .addInfo("it will drain 8 times more power")
- .addInfo("You can enable ritual mode with a screwdriver")
- .addInfo("When in ritual mode and Well Of Suffering ritual is built directly on the machine in center")
- .addInfo("The mobs will start to buffer and die very slowly by a ritual")
- .addInfo(Author)
- .addSeparator()
- .beginStructureBlock(5, 7, 5, true)
- .addController("Front Bottom Center")
- .addCasingInfo("Solid Steel Machine Casing", 10)
- .addOutputBus("Any casing", 1)
- .addOutputHatch("Any casing", 1)
- .addEnergyHatch("Any casing", 1)
- .addMaintenanceHatch("Any casing", 1)
- .toolTipFinisher(Tags.MODNAME);
- return tt;
- }
-
- @Override
- public void construct(ItemStack itemStack, boolean b) {
- buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 6, 0);
- }
-
- @Override
- public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
- return new GT_MetaTileEntity_ExtremeExterminationChamber(this.mName);
- }
-
- @Override
- public ITexture[] getTexture(
- IGregTechTileEntity aBaseMetaTileEntity,
- byte aSide,
- byte aFacing,
- byte aColorIndex,
- boolean aActive,
- boolean aRedstone) {
- if (aSide == aFacing) {
- if (aActive)
- return new ITexture[] {
- Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
- TextureFactory.builder()
- .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE)
- .extFacing()
- .build(),
- TextureFactory.builder()
- .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW)
- .extFacing()
- .glow()
- .build()
- };
- return new ITexture[] {
- Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
- TextureFactory.builder()
- .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER)
- .extFacing()
- .build(),
- TextureFactory.builder()
- .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW)
- .extFacing()
- .glow()
- .build()
- };
- }
- return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)};
- }
-
- @Override
- public boolean isCorrectMachinePart(ItemStack aStack) {
- return true;
- }
-
- @Override
- public void onFirstTick(IGregTechTileEntity aBaseMetaTileEntity) {
- super.onFirstTick(aBaseMetaTileEntity);
- }
-
- @Override
- public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- if (!LoaderReference.BloodMagic) return;
- if (this.mMaxProgresstime > 0) {
- GT_Utility.sendChatToPlayer(aPlayer, "Can't change mode when running !");
- return;
- }
- isInRitualMode = !isInRitualMode;
- if (!isInRitualMode) {
- GT_Utility.sendChatToPlayer(aPlayer, "Ritual mode disabled");
- } else {
- GT_Utility.sendChatToPlayer(aPlayer, "Ritual mode enabled");
- if (connectToRitual()) GT_Utility.sendChatToPlayer(aPlayer, "Successfully connected to the ritual");
- else GT_Utility.sendChatToPlayer(aPlayer, "Can't connect to the ritual");
- }
- }
-
- @SuppressWarnings("unused")
- @SubscribeEvent(priority = EventPriority.LOWEST)
- public void onRitualPerform(RitualRunEvent event) {
- if (!isInRitualMode) return;
- if (masterStoneRitual == null) return;
- if (this.mMaxProgresstime == 0) return;
- if (event.mrs.equals(masterStoneRitual) && event.ritualKey.equals(WellOfSufferingRitualName)) {
- Rituals ritual = Rituals.ritualMap.get(WellOfSufferingRitualName);
- if (ritual != null && ritual.effect instanceof RitualEffectWellOfSuffering) {
- RitualEffectWellOfSuffering effect = (RitualEffectWellOfSuffering) ritual.effect;
- event.setCanceled(true); // we will handle that
- String owner = event.mrs.getOwner();
- int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
- World world = event.mrs.getWorld();
- int x = event.mrs.getXCoord();
- int y = event.mrs.getYCoord();
- int z = event.mrs.getZCoord();
-
- if (world.getWorldTime() % RitualEffectWellOfSuffering.timeDelay != 0) return;
-
- if (tileAltar == null || tileAltar.isInvalid()) {
- tileAltar = null;
- for (int i = -5; i <= 5; i++)
- for (int j = -5; j <= 5; j++)
- for (int k = -10; k <= 10; k++)
- if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar)
- tileAltar = world.getTileEntity(x + i, y + k, z + j);
- }
- if (tileAltar == null) return;
-
- if (currentEssence < effect.getCostPerRefresh() * 100) SoulNetworkHandler.causeNauseaToPlayer(owner);
-
- ((IBloodAltar) tileAltar)
- .sacrificialDaggerCall(
- 100
- * RitualEffectWellOfSuffering.amount
- * (effect.canDrainReagent(
- event.mrs,
- ReagentRegistry.offensaReagent,
- ReflectionHelper.getField(effect, "offensaDrain", true, 3),
- true)
- ? 2
- : 1)
- * (effect.canDrainReagent(
- event.mrs,
- ReagentRegistry.tenebraeReagent,
- ReflectionHelper.getField(effect, "tennebraeDrain", true, 5),
- true)
- ? 2
- : 1),
- true);
-
- SoulNetworkHandler.syphonFromNetwork(owner, effect.getCostPerRefresh() * 100);
- }
- }
- }
-
- @Override
- public boolean checkRecipe(ItemStack aStack) {
- if (aStack == null) return false;
-
- if (aStack.getItem() != poweredSpawnerItem) return false;
-
- if (aStack.getTagCompound() == null) return false;
- String mobType = aStack.getTagCompound().getString("mobType");
- if (mobType.isEmpty()) return false;
-
- MobRecipeLoader.MobRecipe recipe = MobNameToRecipeMap.get(mobType);
-
- if (recipe == null) return false;
- if (!recipe.isPeacefulAllowed
- && this.getBaseMetaTileEntity().getWorld().difficultySetting == EnumDifficulty.PEACEFUL) return false;
-
- this.mOutputItems = recipe.generateOutputs(rand, this);
-
- if (isInRitualMode && isRitualValid()) {
- this.mMaxProgresstime = 400;
- this.mEUt /= 4;
- this.mOutputFluids = new FluidStack[] {FluidRegistry.getFluidStack("xpjuice", 5000)};
- } else {
- calculateOverclockedNessMulti(this.mEUt, this.mMaxProgresstime, 2, getMaxInputVoltage());
- this.mOutputFluids = new FluidStack[] {FluidRegistry.getFluidStack("xpjuice", 120)};
- }
- if (this.mEUt > 0) this.mEUt = -this.mEUt;
- this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
- this.mEfficiencyIncrease = 10000;
-
- return true;
- }
-
- private boolean isRitualValid() {
- if (!isInRitualMode) return false;
- if (masterStoneRitual == null) return false;
- if (masterStoneRitual.isInvalid()
- || !(((TEMasterStone) masterStoneRitual).getCurrentRitual().equals(WellOfSufferingRitualName))) {
- masterStoneRitual = null;
- return false;
- }
- return true;
- }
-
- private boolean connectToRitual() {
- if (!LoaderReference.BloodMagic) return false;
- ChunkCoordinates coords = this.getBaseMetaTileEntity().getCoords();
- int[] abc = new int[] {0, -8, 2};
- int[] xyz = new int[] {0, 0, 0};
- this.getExtendedFacing().getWorldOffset(abc, xyz);
- xyz[0] += coords.posX;
- xyz[1] += coords.posY;
- xyz[2] += coords.posZ;
- TileEntity te = this.getBaseMetaTileEntity().getTileEntity(xyz[0], xyz[1], xyz[2]);
- if (te instanceof TEMasterStone) {
- if (((TEMasterStone) te).getCurrentRitual().equals(WellOfSufferingRitualName)) {
- masterStoneRitual = te;
- return true;
- }
- }
- return false;
- }
-
- @Override
- public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
- if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 6, 0)) return false;
- if (mCasing < 10 || mMaintenanceHatches.size() != 1 || mEnergyHatches.size() == 0) return false;
- if (isInRitualMode) connectToRitual();
- return true;
- }
-
- @Override
- public int getMaxEfficiency(ItemStack aStack) {
- return 10000;
- }
-
- @Override
- public int getDamageToComponent(ItemStack aStack) {
- return 0;
- }
-
- @Override
- public boolean explodesOnComponentBreak(ItemStack aStack) {
- return false;
- }
-}
diff --git a/src/main/java/kubatech/kubatech.java b/src/main/java/kubatech/kubatech.java
index d5407ff357..6973c281b4 100644
--- a/src/main/java/kubatech/kubatech.java
+++ b/src/main/java/kubatech/kubatech.java
@@ -24,8 +24,8 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.relauncher.Side;
-import kubatech.network.LoadConfigHandler;
-import kubatech.network.LoadConfigPacket;
+import kubatech.api.network.CustomTileEntityPacket;
+import kubatech.api.network.LoadConfigPacket;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -44,7 +44,8 @@ public class kubatech {
public static final SimpleNetworkWrapper NETWORK = new SimpleNetworkWrapper(Tags.MODID);
static {
- NETWORK.registerMessage(new LoadConfigHandler(), LoadConfigPacket.class, 0, Side.CLIENT);
+ NETWORK.registerMessage(new LoadConfigPacket.Handler(), LoadConfigPacket.class, 0, Side.CLIENT);
+ NETWORK.registerMessage(new CustomTileEntityPacket.Handler(), CustomTileEntityPacket.class, 1, Side.CLIENT);
}
private static final Logger LOG = LogManager.getLogger(Tags.MODID);
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index 3c087961d9..21c18897f4 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -21,7 +21,7 @@ package kubatech.loaders;
import static kubatech.api.utils.ModUtils.isClientSided;
import static kubatech.api.utils.ModUtils.isDeobfuscatedEnvironment;
-import static kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MobNameToRecipeMap;
+import static kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber.MobNameToRecipeMap;
import atomicstryker.infernalmobs.common.InfernalMobsCore;
import atomicstryker.infernalmobs.common.MobModifier;
@@ -39,10 +39,10 @@ import java.util.stream.Collectors;
import kubatech.Config;
import kubatech.Tags;
import kubatech.api.LoaderReference;
+import kubatech.api.network.LoadConfigPacket;
import kubatech.api.utils.InfernalHelper;
-import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import kubatech.nei.Mob_Handler;
-import kubatech.network.LoadConfigPacket;
+import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import minetweaker.MineTweakerAPI;
import minetweaker.api.entity.IEntityDefinition;
import minetweaker.api.item.IItemStack;
@@ -102,6 +102,7 @@ public class MobRecipeLoader {
public final boolean alwaysinfernal;
public static droplist infernaldrops;
public final boolean isPeacefulAllowed;
+ public final EntityLiving entity;
@SuppressWarnings("unchecked")
public MobRecipe copy() {
@@ -111,7 +112,8 @@ public class MobRecipeLoader {
mMaxDamageChance,
infernalityAllowed,
alwaysinfernal,
- isPeacefulAllowed);
+ isPeacefulAllowed,
+ entity);
}
private MobRecipe(
@@ -120,13 +122,15 @@ public class MobRecipeLoader {
int mMaxDamageChance,
boolean infernalityAllowed,
boolean alwaysinfernal,
- boolean isPeacefulAllowed) {
+ boolean isPeacefulAllowed,
+ EntityLiving entity) {
this.mOutputs = mOutputs;
this.mDuration = mDuration;
this.mMaxDamageChance = mMaxDamageChance;
this.infernalityAllowed = infernalityAllowed;
this.alwaysinfernal = alwaysinfernal;
this.isPeacefulAllowed = isPeacefulAllowed;
+ this.entity = entity;
}
@SuppressWarnings("unchecked")
@@ -185,6 +189,7 @@ public class MobRecipeLoader {
mMaxDamageChance = maxdamagechance;
// Powered spawner with octadic capacitor spawns ~22/min ~= 0.366/sec ~= 2.72s/spawn ~= 54.54t/spawn
mDuration = 55 + 10 + (((int) e.getMaxHealth() / 5) * 10);
+ entity = e;
}
public ItemStack[] generateOutputs(Random rnd, GT_MetaTileEntity_ExtremeExterminationChamber MTE) {
@@ -460,7 +465,7 @@ public class MobRecipeLoader {
}
private static class dropCollector {
- HashMap damagableChecker = new HashMap<>();
+ final HashMap damagableChecker = new HashMap<>();
private boolean booksAlwaysRandomlyEnchanted = false;
public void addDrop(droplist fdrops, ArrayList listToParse, double chance) {
@@ -552,6 +557,7 @@ public class MobRecipeLoader {
return false;
}
+ @SuppressWarnings("rawtypes")
@Override
public List getEntitiesWithinAABB(Class p_72872_1_, AxisAlignedBB p_72872_2_) {
return new ArrayList();
@@ -727,7 +733,7 @@ public class MobRecipeLoader {
try {
Class> cl = e.getClass();
- boolean detectedException = false;
+ boolean detectedException;
do {
detectedException = false;
try {
@@ -894,6 +900,7 @@ public class MobRecipeLoader {
MobRecipe recipe = v.recipe;
if (recipe != null) recipe = recipe.copy();
+ @SuppressWarnings("unchecked")
ArrayList drops = (ArrayList) v.drops.clone();
// MT Scripts should already be loaded here
@@ -922,6 +929,7 @@ public class MobRecipeLoader {
GeneralMappedMob v = GeneralMobList.get(k);
MobRecipe recipe = v.recipe;
if (recipe != null) recipe = recipe.copy();
+ @SuppressWarnings("unchecked")
ArrayList drops = (ArrayList) v.drops.clone();
// MT Scripts should already be loaded here
diff --git a/src/main/java/kubatech/loaders/RecipeLoader.java b/src/main/java/kubatech/loaders/RecipeLoader.java
index ba6cbb7a1f..84c3603225 100644
--- a/src/main/java/kubatech/loaders/RecipeLoader.java
+++ b/src/main/java/kubatech/loaders/RecipeLoader.java
@@ -25,7 +25,7 @@ import gregtech.api.util.GT_ModHandler;
import kubatech.Tags;
import kubatech.api.LoaderReference;
import kubatech.api.enums.ItemList;
-import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
+import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import org.apache.logging.log4j.LogManager;
diff --git a/src/main/java/kubatech/nei/Mob_Handler.java b/src/main/java/kubatech/nei/Mob_Handler.java
index a231eceffc..78294326c9 100644
--- a/src/main/java/kubatech/nei/Mob_Handler.java
+++ b/src/main/java/kubatech/nei/Mob_Handler.java
@@ -39,9 +39,9 @@ import kubatech.api.LoaderReference;
import kubatech.api.utils.FastRandom;
import kubatech.api.utils.InfernalHelper;
import kubatech.api.utils.ModUtils;
-import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import kubatech.kubatech;
import kubatech.loaders.MobRecipeLoader;
+import kubatech.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.gui.inventory.GuiInventory;
@@ -277,7 +277,6 @@ public class Mob_Handler extends TemplateRecipeHandler {
GL11.glPushMatrix();
- ItemStack s = getIngredientStacks(recipe).get(0).item;
try {
EntityLiving e = currentrecipe.mob;
float eheight = e.height;
diff --git a/src/main/java/kubatech/network/LoadConfigHandler.java b/src/main/java/kubatech/network/LoadConfigHandler.java
deleted file mode 100644
index 7bf8bd9756..0000000000
--- a/src/main/java/kubatech/network/LoadConfigHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * KubaTech - Gregtech Addon
- * Copyright (C) 2022 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 .
- *
- */
-
-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 kubatech.kubatech;
-import kubatech.loaders.MobRecipeLoader;
-
-public class LoadConfigHandler implements IMessageHandler {
-
- @Override
- public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) {
- kubatech.info("Received Mob Handler config, parsing");
- MobRecipeLoader.processMobRecipeMap(message.mobsToLoad);
- return null;
- }
-}
diff --git a/src/main/java/kubatech/network/LoadConfigPacket.java b/src/main/java/kubatech/network/LoadConfigPacket.java
deleted file mode 100644
index 48f3342486..0000000000
--- a/src/main/java/kubatech/network/LoadConfigPacket.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * KubaTech - Gregtech Addon
- * Copyright (C) 2022 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 .
- *
- */
-
-package kubatech.network;
-
-import cpw.mods.fml.common.network.simpleimpl.IMessage;
-import io.netty.buffer.ByteBuf;
-import java.nio.charset.StandardCharsets;
-import java.util.HashSet;
-import kubatech.Config;
-
-public class LoadConfigPacket implements IMessage {
-
- public static LoadConfigPacket instance = new LoadConfigPacket();
-
- public HashSet mobsToLoad = new HashSet<>();
-
- @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));
- }
- }
- }
-
- @Override
- public void toBytes(ByteBuf buf) {
- if (!Config.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);
- });
- }
- }
-}
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
new file mode 100644
index 0000000000..5971731fdd
--- /dev/null
+++ b/src/main/java/kubatech/tileentity/gregtech/multiblock/GT_MetaTileEntity_ExtremeExterminationChamber.java
@@ -0,0 +1,454 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 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 .
+ *
+ */
+
+package kubatech.tileentity.gregtech.multiblock;
+
+import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
+import static gregtech.api.enums.Textures.BlockIcons.*;
+import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
+import static kubatech.api.Variables.Author;
+
+import WayofTime.alchemicalWizardry.api.alchemy.energy.ReagentRegistry;
+import WayofTime.alchemicalWizardry.api.event.RitualRunEvent;
+import WayofTime.alchemicalWizardry.api.rituals.Rituals;
+import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
+import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
+import WayofTime.alchemicalWizardry.common.rituals.RitualEffectWellOfSuffering;
+import WayofTime.alchemicalWizardry.common.tileEntity.TEMasterStone;
+import com.github.bartimaeusnek.bartworks.API.BorosilicateGlass;
+import com.gtnewhorizon.structurelib.structure.IStructureDefinition;
+import com.gtnewhorizon.structurelib.structure.StructureDefinition;
+import cpw.mods.fml.common.eventhandler.EventPriority;
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import crazypants.enderio.EnderIO;
+import gregtech.api.GregTech_API;
+import gregtech.api.enums.Textures;
+import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_EnhancedMultiBlockBase;
+import gregtech.api.render.TextureFactory;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
+import gregtech.api.util.GT_Utility;
+import java.util.HashMap;
+import java.util.Random;
+import kubatech.Tags;
+import kubatech.api.LoaderReference;
+import kubatech.api.network.CustomTileEntityPacket;
+import kubatech.api.tileentity.CustomTileEntityPacketHandler;
+import kubatech.api.utils.FastRandom;
+import kubatech.api.utils.ReflectionHelper;
+import kubatech.client.effect.EntityRenderer;
+import kubatech.loaders.MobRecipeLoader;
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.init.Blocks;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.util.ChunkCoordinates;
+import net.minecraft.world.EnumDifficulty;
+import net.minecraft.world.World;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.fluids.FluidRegistry;
+import net.minecraftforge.fluids.FluidStack;
+
+public class GT_MetaTileEntity_ExtremeExterminationChamber
+ extends GT_MetaTileEntity_EnhancedMultiBlockBase
+ implements CustomTileEntityPacketHandler {
+
+ public static final HashMap MobNameToRecipeMap = new HashMap<>();
+ public final Random rand = new FastRandom();
+
+ public GT_MetaTileEntity_ExtremeExterminationChamber(int aID, String aName, String aNameRegional) {
+ super(aID, aName, aNameRegional);
+ }
+
+ public GT_MetaTileEntity_ExtremeExterminationChamber(String aName) {
+ super(aName);
+ if (LoaderReference.BloodMagic) MinecraftForge.EVENT_BUS.register(this);
+ }
+
+ @Override
+ public void onRemoval() {
+ if (LoaderReference.BloodMagic) MinecraftForge.EVENT_BUS.unregister(this);
+ if (getBaseMetaTileEntity().isClientSide()) entityRenderer.setDead();
+ }
+
+ private static final String WellOfSufferingRitualName = "AW013Suffering";
+
+ private static final Item poweredSpawnerItem = Item.getItemFromBlock(EnderIO.blockPoweredSpawner);
+ private static final int CASING_INDEX = 16;
+ private static final String STRUCTURE_PIECE_MAIN = "main";
+ private static final IStructureDefinition STRUCTURE_DEFINITION =
+ StructureDefinition.builder()
+ .addShape(STRUCTURE_PIECE_MAIN, transpose(new String[][] {
+ {"ccccc", "ccccc", "ccccc", "ccccc", "ccccc"},
+ {"cgggc", "g---g", "g---g", "g---g", "cgggc"},
+ {"cgggc", "g---g", "g---g", "g---g", "cgggc"},
+ {"cgggc", "g---g", "g---g", "g---g", "cgggc"},
+ {"cgggc", "g---g", "g---g", "g---g", "cgggc"},
+ {"cgggc", "gsssg", "gsssg", "gsssg", "cgggc"},
+ {"CC~CC", "CCCCC", "CCCCC", "CCCCC", "CCCCC"},
+ }))
+ .addElement('c', onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings2, 0)))
+ .addElement(
+ 'C',
+ ofChain(
+ onElementPass(t -> t.mCasing++, ofBlock(GregTech_API.sBlockCasings2, 0)),
+ ofHatchAdder(
+ GT_MetaTileEntity_ExtremeExterminationChamber::addOutputToMachineList,
+ CASING_INDEX,
+ 1),
+ ofHatchAdder(
+ GT_MetaTileEntity_ExtremeExterminationChamber::addEnergyInputToMachineList,
+ CASING_INDEX,
+ 1),
+ ofHatchAdder(
+ GT_MetaTileEntity_ExtremeExterminationChamber::addMaintenanceToMachineList,
+ CASING_INDEX,
+ 1)))
+ .addElement(
+ 'g',
+ LoaderReference.Bartworks
+ ? BorosilicateGlass.ofBoroGlassAnyTier()
+ : ofBlock(Blocks.glass, 0))
+ .addElement(
+ 's',
+ LoaderReference.ExtraUtilities
+ ? ofBlock(Block.getBlockFromName("ExtraUtilities:spike_base_diamond"), 0)
+ : isAir())
+ .build();
+
+ private TileEntity masterStoneRitual = null;
+ private TileEntity tileAltar = null;
+ private boolean isInRitualMode = false;
+ private int mCasing = 0;
+
+ @SideOnly(Side.CLIENT)
+ private EntityRenderer entityRenderer = null;
+
+ @Override
+ public void saveNBTData(NBTTagCompound aNBT) {
+ super.saveNBTData(aNBT);
+ aNBT.setBoolean("isInRitualMode", isInRitualMode);
+ }
+
+ @Override
+ public void loadNBTData(NBTTagCompound aNBT) {
+ super.loadNBTData(aNBT);
+ isInRitualMode = aNBT.getBoolean("isInRitualMode");
+ }
+
+ @Override
+ public IStructureDefinition getStructureDefinition() {
+ return STRUCTURE_DEFINITION;
+ }
+
+ @Override
+ protected GT_Multiblock_Tooltip_Builder createTooltip() {
+ GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Powered Spawner")
+ .addInfo("Controller block for Extreme Extermination Chamber")
+ .addInfo("Spawns and Exterminates monsters for you")
+ .addInfo("Base energy usage: 2,000 EU/t")
+ .addInfo("Recipe time is based on mob health")
+ .addInfo("Also produces 120 Liquid XP per operation")
+ .addInfo("If the mob spawns infernal")
+ .addInfo("it will drain 8 times more power")
+ .addInfo("You can enable ritual mode with a screwdriver")
+ .addInfo("When in ritual mode and Well Of Suffering ritual is built directly on the machine in center")
+ .addInfo("The mobs will start to buffer and die very slowly by a ritual")
+ .addInfo(Author)
+ .addSeparator()
+ .beginStructureBlock(5, 7, 5, true)
+ .addController("Front Bottom Center")
+ .addCasingInfo("Solid Steel Machine Casing", 10)
+ .addOutputBus("Any casing", 1)
+ .addOutputHatch("Any casing", 1)
+ .addEnergyHatch("Any casing", 1)
+ .addMaintenanceHatch("Any casing", 1)
+ .toolTipFinisher(Tags.MODNAME);
+ return tt;
+ }
+
+ @Override
+ public void construct(ItemStack itemStack, boolean b) {
+ buildPiece(STRUCTURE_PIECE_MAIN, itemStack, b, 2, 6, 0);
+ }
+
+ @Override
+ public IMetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) {
+ return new GT_MetaTileEntity_ExtremeExterminationChamber(this.mName);
+ }
+
+ @Override
+ public ITexture[] getTexture(
+ IGregTechTileEntity aBaseMetaTileEntity,
+ byte aSide,
+ byte aFacing,
+ byte aColorIndex,
+ boolean aActive,
+ boolean aRedstone) {
+ if (aSide == aFacing) {
+ if (aActive)
+ return new ITexture[] {
+ Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
+ TextureFactory.builder()
+ .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE)
+ .extFacing()
+ .build(),
+ TextureFactory.builder()
+ .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_ACTIVE_GLOW)
+ .extFacing()
+ .glow()
+ .build()
+ };
+ return new ITexture[] {
+ Textures.BlockIcons.getCasingTextureForId(CASING_INDEX),
+ TextureFactory.builder()
+ .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER)
+ .extFacing()
+ .build(),
+ TextureFactory.builder()
+ .addIcon(OVERLAY_FRONT_DISTILLATION_TOWER_GLOW)
+ .extFacing()
+ .glow()
+ .build()
+ };
+ }
+ return new ITexture[] {Textures.BlockIcons.getCasingTextureForId(CASING_INDEX)};
+ }
+
+ @Override
+ public boolean isCorrectMachinePart(ItemStack aStack) {
+ return true;
+ }
+
+ @SideOnly(Side.CLIENT)
+ private void setupEntityRenderer(IGregTechTileEntity aBaseMetaTileEntity, int time) {
+ if (entityRenderer == null) {
+ ChunkCoordinates coords = this.getBaseMetaTileEntity().getCoords();
+ int[] abc = new int[] {0, -2, 2};
+ int[] xyz = new int[] {0, 0, 0};
+ this.getExtendedFacing().getWorldOffset(abc, xyz);
+ xyz[0] += coords.posX;
+ xyz[1] += coords.posY;
+ xyz[2] += coords.posZ;
+ entityRenderer = new EntityRenderer(aBaseMetaTileEntity.getWorld(), xyz[0], xyz[1], xyz[2], time);
+ } else {
+ entityRenderer.setDead();
+ entityRenderer = new EntityRenderer(entityRenderer, time);
+ }
+ Minecraft.getMinecraft().effectRenderer.addEffect(entityRenderer);
+ }
+
+ @Override
+ public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) {
+ super.onPostTick(aBaseMetaTileEntity, aTick);
+ if (aBaseMetaTileEntity.isClientSide()) {
+ if (aBaseMetaTileEntity.isActive() && aTick % 40 == 0) {
+ setupEntityRenderer(aBaseMetaTileEntity, 40);
+ }
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public void HandleCustomPacket(CustomTileEntityPacket message) {
+ String mobType = message.getDataString();
+ MobRecipeLoader.MobRecipe r = MobNameToRecipeMap.get(mobType);
+ if (r != null) {
+ if (entityRenderer == null) setupEntityRenderer(getBaseMetaTileEntity(), 40);
+ entityRenderer.setEntity(r.entity);
+ } else entityRenderer.setEntity(null);
+ }
+
+ @Override
+ public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
+ if (!LoaderReference.BloodMagic) return;
+ if (this.mMaxProgresstime > 0) {
+ GT_Utility.sendChatToPlayer(aPlayer, "Can't change mode when running !");
+ return;
+ }
+ isInRitualMode = !isInRitualMode;
+ if (!isInRitualMode) {
+ GT_Utility.sendChatToPlayer(aPlayer, "Ritual mode disabled");
+ } else {
+ GT_Utility.sendChatToPlayer(aPlayer, "Ritual mode enabled");
+ if (connectToRitual()) GT_Utility.sendChatToPlayer(aPlayer, "Successfully connected to the ritual");
+ else GT_Utility.sendChatToPlayer(aPlayer, "Can't connect to the ritual");
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @SubscribeEvent(priority = EventPriority.LOWEST)
+ public void onRitualPerform(RitualRunEvent event) {
+ if (!isInRitualMode) return;
+ if (masterStoneRitual == null) return;
+ if (this.mMaxProgresstime == 0) return;
+ if (event.mrs.equals(masterStoneRitual) && event.ritualKey.equals(WellOfSufferingRitualName)) {
+ Rituals ritual = Rituals.ritualMap.get(WellOfSufferingRitualName);
+ if (ritual != null && ritual.effect instanceof RitualEffectWellOfSuffering) {
+ RitualEffectWellOfSuffering effect = (RitualEffectWellOfSuffering) ritual.effect;
+ event.setCanceled(true); // we will handle that
+ String owner = event.mrs.getOwner();
+ int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
+ World world = event.mrs.getWorld();
+ int x = event.mrs.getXCoord();
+ int y = event.mrs.getYCoord();
+ int z = event.mrs.getZCoord();
+
+ if (world.getWorldTime() % RitualEffectWellOfSuffering.timeDelay != 0) return;
+
+ if (tileAltar == null || tileAltar.isInvalid()) {
+ tileAltar = null;
+ for (int i = -5; i <= 5; i++)
+ for (int j = -5; j <= 5; j++)
+ for (int k = -10; k <= 10; k++)
+ if (world.getTileEntity(x + i, y + k, z + j) instanceof IBloodAltar)
+ tileAltar = world.getTileEntity(x + i, y + k, z + j);
+ }
+ if (tileAltar == null) return;
+
+ if (currentEssence < effect.getCostPerRefresh() * 100) SoulNetworkHandler.causeNauseaToPlayer(owner);
+
+ ((IBloodAltar) tileAltar)
+ .sacrificialDaggerCall(
+ 100
+ * RitualEffectWellOfSuffering.amount
+ * (effect.canDrainReagent(
+ event.mrs,
+ ReagentRegistry.offensaReagent,
+ ReflectionHelper.getField(effect, "offensaDrain", 3),
+ true)
+ ? 2
+ : 1)
+ * (effect.canDrainReagent(
+ event.mrs,
+ ReagentRegistry.tenebraeReagent,
+ ReflectionHelper.getField(effect, "tennebraeDrain", 5),
+ true)
+ ? 2
+ : 1),
+ true);
+
+ SoulNetworkHandler.syphonFromNetwork(owner, effect.getCostPerRefresh() * 100);
+ }
+ }
+ }
+
+ private CustomTileEntityPacket mobPacket = null;
+
+ @Override
+ public boolean checkRecipe(ItemStack aStack) {
+ if (getBaseMetaTileEntity().isClientSide()) return false;
+ if (aStack == null) return false;
+
+ if (aStack.getItem() != poweredSpawnerItem) return false;
+
+ if (aStack.getTagCompound() == null) return false;
+ String mobType = aStack.getTagCompound().getString("mobType");
+ if (mobType.isEmpty()) return false;
+
+ MobRecipeLoader.MobRecipe recipe = MobNameToRecipeMap.get(mobType);
+
+ if (recipe == null) return false;
+ if (!recipe.isPeacefulAllowed
+ && this.getBaseMetaTileEntity().getWorld().difficultySetting == EnumDifficulty.PEACEFUL) return false;
+
+ this.mOutputItems = recipe.generateOutputs(rand, this);
+
+ if (isInRitualMode && isRitualValid()) {
+ this.mMaxProgresstime = 400;
+ this.mEUt /= 4;
+ this.mOutputFluids = new FluidStack[] {FluidRegistry.getFluidStack("xpjuice", 5000)};
+ } else {
+ calculateOverclockedNessMulti(this.mEUt, this.mMaxProgresstime, 2, getMaxInputVoltage());
+ this.mOutputFluids = new FluidStack[] {FluidRegistry.getFluidStack("xpjuice", 120)};
+ }
+ if (this.mEUt > 0) this.mEUt = -this.mEUt;
+ this.mEfficiency = (10000 - (getIdealStatus() - getRepairStatus()) * 1000);
+ this.mEfficiencyIncrease = 10000;
+
+ if (mobPacket == null) mobPacket = new CustomTileEntityPacket((TileEntity) this.getBaseMetaTileEntity(), null);
+ mobPacket.resetHelperData();
+ mobPacket.addData(mobType);
+ mobPacket.sendToAllAround(16);
+
+ return true;
+ }
+
+ private boolean isRitualValid() {
+ if (!isInRitualMode) return false;
+ if (masterStoneRitual == null) return false;
+ if (masterStoneRitual.isInvalid()
+ || !(((TEMasterStone) masterStoneRitual).getCurrentRitual().equals(WellOfSufferingRitualName))) {
+ masterStoneRitual = null;
+ return false;
+ }
+ return true;
+ }
+
+ private boolean connectToRitual() {
+ if (!LoaderReference.BloodMagic) return false;
+ ChunkCoordinates coords = this.getBaseMetaTileEntity().getCoords();
+ int[] abc = new int[] {0, -8, 2};
+ int[] xyz = new int[] {0, 0, 0};
+ this.getExtendedFacing().getWorldOffset(abc, xyz);
+ xyz[0] += coords.posX;
+ xyz[1] += coords.posY;
+ xyz[2] += coords.posZ;
+ TileEntity te = this.getBaseMetaTileEntity().getTileEntity(xyz[0], xyz[1], xyz[2]);
+ if (te instanceof TEMasterStone) {
+ if (((TEMasterStone) te).getCurrentRitual().equals(WellOfSufferingRitualName)) {
+ masterStoneRitual = te;
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
+ if (!checkPiece(STRUCTURE_PIECE_MAIN, 2, 6, 0)) return false;
+ if (mCasing < 10 || mMaintenanceHatches.size() != 1 || mEnergyHatches.size() == 0) return false;
+ if (isInRitualMode) connectToRitual();
+ return true;
+ }
+
+ @Override
+ public int getMaxEfficiency(ItemStack aStack) {
+ return 10000;
+ }
+
+ @Override
+ public int getDamageToComponent(ItemStack aStack) {
+ return 0;
+ }
+
+ @Override
+ public boolean explodesOnComponentBreak(ItemStack aStack) {
+ return false;
+ }
+}
--
cgit
From 01d91c0acd0e8b494578d63683088e6f1d67509f Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Thu, 18 Aug 2022 00:12:14 +0200
Subject: Cache Mob Handler map
---
src/main/java/kubatech/CommonProxy.java | 2 +-
src/main/java/kubatech/Config.java | 8 ++-
src/main/java/kubatech/api/utils/GSONUtils.java | 70 ++++++++++++++++++
src/main/java/kubatech/api/utils/ModUtils.java | 29 +++++++-
.../java/kubatech/loaders/MobRecipeLoader.java | 84 +++++++++++++++++++++-
5 files changed, 187 insertions(+), 6 deletions(-)
create mode 100644 src/main/java/kubatech/api/utils/GSONUtils.java
(limited to 'src/main/java/kubatech/loaders')
diff --git a/src/main/java/kubatech/CommonProxy.java b/src/main/java/kubatech/CommonProxy.java
index e1285a7b84..5f1ec40cad 100644
--- a/src/main/java/kubatech/CommonProxy.java
+++ b/src/main/java/kubatech/CommonProxy.java
@@ -31,7 +31,7 @@ public class CommonProxy {
public void preInit(FMLPreInitializationEvent event) {
kubatech.info("Initializing ! Version: " + Tags.VERSION);
- Config.init(event.getSuggestedConfigurationFile());
+ Config.init(event.getModConfigurationDirectory());
Config.synchronizeConfiguration();
RecipeLoader.addRecipes();
FMLCommonHandler.instance().bus().register(new FMLEventHandler());
diff --git a/src/main/java/kubatech/Config.java b/src/main/java/kubatech/Config.java
index f258a9e088..feb8f96dae 100644
--- a/src/main/java/kubatech/Config.java
+++ b/src/main/java/kubatech/Config.java
@@ -32,9 +32,15 @@ public class Config {
public static boolean includeEmptyMobs = true;
public static String[] mobBlacklist;
public static File configFile;
+ public static File configDirectory;
public static void init(File configFile) {
- Config.configFile = configFile;
+ configDirectory = new File(configFile, Tags.MODID);
+ Config.configFile = new File(configDirectory, Tags.MODID + ".cfg");
+ }
+
+ public static File getConfigFile(String file) {
+ return new File(configDirectory, file);
}
public static void synchronizeConfiguration() {
diff --git a/src/main/java/kubatech/api/utils/GSONUtils.java b/src/main/java/kubatech/api/utils/GSONUtils.java
new file mode 100644
index 0000000000..1c0e7ec3f4
--- /dev/null
+++ b/src/main/java/kubatech/api/utils/GSONUtils.java
@@ -0,0 +1,70 @@
+package kubatech.api.utils;
+
+import com.google.gson.*;
+import java.io.IOException;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.lang.reflect.Type;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTSizeTracker;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class GSONUtils {
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.FIELD)
+ public @interface SkipGSON {}
+
+ private static final ExclusionStrategy GSONStrategy = new ExclusionStrategy() {
+ @Override
+ public boolean shouldSkipField(FieldAttributes f) {
+ return f.getAnnotation(SkipGSON.class) != null;
+ }
+
+ @Override
+ public boolean shouldSkipClass(Class> clazz) {
+ return false;
+ }
+ };
+
+ private static final JsonSerializer NBTTagCompoundSerializer =
+ new JsonSerializer() {
+
+ @Override
+ public JsonElement serialize(NBTTagCompound src, Type typeOfSrc, JsonSerializationContext context) {
+ try {
+ JsonArray array = new JsonArray();
+ for (byte b : CompressedStreamTools.compress(src)) {
+ array.add(new JsonPrimitive(b));
+ }
+ return array;
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
+ private static final JsonDeserializer NBTTagCompoundDeserializer =
+ new JsonDeserializer() {
+ @Override
+ public NBTTagCompound deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+ throws JsonParseException {
+ try {
+ if (!(json instanceof JsonArray)) return null;
+ byte[] bytes = new byte[((JsonArray) json).size()];
+ for (int i = 0; i < bytes.length; i++)
+ bytes[i] = ((JsonArray) json).get(i).getAsByte();
+ return CompressedStreamTools.func_152457_a(bytes, new NBTSizeTracker(2097152L));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+
+ public static final GsonBuilder GSON_BUILDER = new GsonBuilder()
+ .addSerializationExclusionStrategy(GSONStrategy)
+ .addDeserializationExclusionStrategy(GSONStrategy)
+ .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer)
+ .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer);
+}
diff --git a/src/main/java/kubatech/api/utils/ModUtils.java b/src/main/java/kubatech/api/utils/ModUtils.java
index 0f598dcfa8..447796ddbf 100644
--- a/src/main/java/kubatech/api/utils/ModUtils.java
+++ b/src/main/java/kubatech/api/utils/ModUtils.java
@@ -20,9 +20,11 @@
package kubatech.api.utils;
import cpw.mods.fml.common.Loader;
-import java.util.AbstractMap;
-import java.util.HashMap;
-import java.util.Map;
+import cpw.mods.fml.common.ModContainer;
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.util.*;
+import javax.xml.bind.DatatypeConverter;
import net.minecraft.launchwrapper.Launch;
public class ModUtils {
@@ -47,4 +49,25 @@ public class ModUtils {
.orElse(emptyEntry)
.getValue();
}
+
+ private static String modListVersion = null;
+
+ public static String getModListVersion() {
+ if (modListVersion != null) return modListVersion;
+ ArrayList modlist = (ArrayList)
+ ((ArrayList) Loader.instance().getActiveModList()).clone();
+ String sortedList = modlist.stream()
+ .filter(m -> m.getMod() != null)
+ .sorted(Comparator.comparing(ModContainer::getModId))
+ .collect(String::new, (a, b) -> a += b.getModId() + b.getVersion(), (a, b) -> a += ", " + b);
+ 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;
+ }
+ }
}
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index 3c087961d9..b7c5e9781d 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -26,20 +26,28 @@ import static kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_E
import atomicstryker.infernalmobs.common.InfernalMobsCore;
import atomicstryker.infernalmobs.common.MobModifier;
import atomicstryker.infernalmobs.common.mods.api.ModifierLoader;
+import com.google.common.io.Files;
+import com.google.gson.Gson;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import gregtech.api.util.GT_Utility;
import gregtech.common.GT_DummyWorld;
+import java.io.File;
+import java.io.Reader;
+import java.io.Writer;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
import kubatech.Config;
import kubatech.Tags;
import kubatech.api.LoaderReference;
+import kubatech.api.utils.GSONUtils;
import kubatech.api.utils.InfernalHelper;
+import kubatech.api.utils.ModUtils;
import kubatech.common.tileentity.gregtech.multiblock.GT_MetaTileEntity_ExtremeExterminationChamber;
import kubatech.nei.Mob_Handler;
import kubatech.network.LoadConfigPacket;
@@ -259,7 +267,10 @@ public class MobRecipeLoader {
Infernal
}
+ @GSONUtils.SkipGSON
public ItemStack stack;
+
+ public NBTTagCompound reconstructableStack;
public DropType type;
public int chance;
public Integer enchantable;
@@ -268,11 +279,16 @@ public class MobRecipeLoader {
public MobDrop(
ItemStack stack, DropType type, int chance, Integer enchantable, HashMap damages) {
this.stack = stack;
+ this.reconstructableStack = stack.writeToNBT(new NBTTagCompound());
this.type = type;
this.chance = chance;
this.enchantable = enchantable;
this.damages = damages;
}
+
+ public void reconstructStack() {
+ this.stack = ItemStack.loadItemStackFromNBT(this.reconstructableStack);
+ }
}
public static class fakeRand extends Random {
@@ -539,7 +555,12 @@ public class MobRecipeLoader {
public static final HashMap GeneralMobList = new HashMap<>();
- @SuppressWarnings("unchecked")
+ private static class MobRecipeLoaderCacheStructure {
+ String version;
+ Map> moblist;
+ }
+
+ @SuppressWarnings({"unchecked", "UnstableApiUsage"})
public static void generateMobRecipeMap() {
if (alreadyGenerated) return;
@@ -562,6 +583,46 @@ public class MobRecipeLoader {
fakeRand frand = new fakeRand();
f.rand = frand;
+ File cache = Config.getConfigFile("MobRecipeLoader.cache");
+ Gson gson = GSONUtils.GSON_BUILDER.create();
+
+ if (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 (s.version.equals(ModUtils.getModListVersion())) {
+ for (Map.Entry> entry : s.moblist.entrySet()) {
+ try {
+ EntityLiving e =
+ (EntityLiving) ((Class>) EntityList.stringToClassMapping.get(entry.getKey()))
+ .getConstructor(new Class[] {World.class})
+ .newInstance(new Object[] {f});
+ ArrayList drops = entry.getValue();
+ drops.forEach(MobDrop::reconstructStack);
+ GeneralMobList.put(entry.getKey(), new GeneralMappedMob(e, new MobRecipe(e, drops), drops));
+ } catch (Exception ignored) {
+ }
+ }
+ LOG.info("Parsed cached map, skipping generation");
+ return;
+ } else {
+ LOG.info("Cached map version mismatch, generating a new one");
+ }
+ } catch (Exception ignored) {
+ LOG.info("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, generating a new one");
+ }
+
isInGenerationProcess = true;
LOG.info("Generating Recipe Map for Mob Handler and EEC");
@@ -878,6 +939,27 @@ public class MobRecipeLoader {
LOG.info("Recipe map generated ! It took " + time + "ms");
isInGenerationProcess = false;
+
+ LOG.info("Saving generated map to file");
+ MobRecipeLoaderCacheStructure s = new MobRecipeLoaderCacheStructure();
+ s.version = ModUtils.getModListVersion();
+ 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) {
+ }
+ }
}
public static void processMobRecipeMap() {
--
cgit
From c775b9f97779003c3a2366eff607b1d64b6c8040 Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Thu, 18 Aug 2022 00:45:04 +0200
Subject: Update MobRecipeLoader.java
---
src/main/java/kubatech/loaders/MobRecipeLoader.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
(limited to 'src/main/java/kubatech/loaders')
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index b7c5e9781d..283c75391a 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -601,7 +601,9 @@ public class MobRecipeLoader {
.newInstance(new Object[] {f});
ArrayList drops = entry.getValue();
drops.forEach(MobDrop::reconstructStack);
- GeneralMobList.put(entry.getKey(), new GeneralMappedMob(e, new MobRecipe(e, drops), drops));
+ GeneralMobList.put(
+ entry.getKey(),
+ new GeneralMappedMob(e, drops.size() != 0 ? new MobRecipe(e, drops) : null, drops));
} catch (Exception ignored) {
}
}
--
cgit
From a2df13484aa8dcf66f7c05c8d009d4476ceb041e Mon Sep 17 00:00:00 2001
From: kuba6000
Date: Fri, 19 Aug 2022 14:15:58 +0200
Subject: Fix
---
src/main/java/kubatech/loaders/MobRecipeLoader.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
(limited to 'src/main/java/kubatech/loaders')
diff --git a/src/main/java/kubatech/loaders/MobRecipeLoader.java b/src/main/java/kubatech/loaders/MobRecipeLoader.java
index d3b02083e9..eb4d571819 100644
--- a/src/main/java/kubatech/loaders/MobRecipeLoader.java
+++ b/src/main/java/kubatech/loaders/MobRecipeLoader.java
@@ -46,11 +46,11 @@ import kubatech.Config;
import kubatech.Tags;
import kubatech.api.LoaderReference;
import kubatech.api.network.LoadConfigPacket;
-import kubatech.api.utils.InfernalHelper;
import kubatech.api.utils.GSONUtils;
import kubatech.api.utils.InfernalHelper;
import kubatech.api.utils.ModUtils;
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;
--
cgit
From 5d1286092eac1545f819babbee27244504a212f0 Mon Sep 17 00:00:00 2001
From: Jakub <53441451+kuba6000@users.noreply.github.com>
Date: Tue, 23 Aug 2022 00:17:48 +0200
Subject: Add Config to override mob drops + some fixes (#8)
* Add overrides
* GTNHCoreMod custom drops integration
* Update buildscript
* Bump
* EEC blacklist
* NEI info
* Loops optimization
* Warn when 0% loots are detected
* Detect looting drops
* No
* Super rare drops
* Keep the same naming
* Crash
* Fix meta
* maybe
* Run at least twice
* Fix stupid TF Lich boss
* Comments
* Fix EEC blacklist
---
build.gradle | 492 +++++++++++----------
dependencies.gradle | 5 +
settings.gradle | 2 +-
src/main/java/kubatech/CommonProxy.java | 1 +
src/main/java/kubatech/Config.java | 93 ----
.../java/kubatech/api/ConstructableItemStack.java | 97 ++++
src/main/java/kubatech/api/LoaderReference.java | 1 +
src/main/java/kubatech/api/mobhandler/MobDrop.java | 99 +++++
.../kubatech/api/network/LoadConfigPacket.java | 21 +-
src/main/java/kubatech/api/utils/GSONUtils.java | 33 +-
src/main/java/kubatech/commands/CommandConfig.java | 2 +-
src/main/java/kubatech/config/Config.java | 94 ++++
src/main/java/kubatech/config/OverridesConfig.java | 212 +++++++++
.../java/kubatech/loaders/MobRecipeLoader.java | 258 ++++++++---
src/main/java/kubatech/nei/Mob_Handler.java | 31 +-
src/main/resources/assets/kubatech/lang/en_US.lang | 2 +
16 files changed, 1044 insertions(+), 399 deletions(-)
delete mode 100644 src/main/java/kubatech/Config.java
create mode 100644 src/main/java/kubatech/api/ConstructableItemStack.java
create mode 100644 src/main/java/kubatech/api/mobhandler/MobDrop.java
create mode 100644 src/main/java/kubatech/config/Config.java
create mode 100644 src/main/java/kubatech/config/OverridesConfig.java
(limited to 'src/main/java/kubatech/loaders')
diff --git a/build.gradle b/build.gradle
index 046db33f4a..997b94dc30 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,4 +1,4 @@
-//version: 1660491897
+//version: 1661114848
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
@@ -26,6 +26,11 @@ buildscript {
name 'forge'
url 'https://maven.minecraftforge.net'
}
+ maven {
+ // GTNH ForgeGradle Fork
+ name = "GTNH Maven"
+ url = "http://jenkins.usrv.eu:8081/nexus/content/groups/public/"
+ }
maven {
name 'sonatype'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
@@ -34,13 +39,9 @@ buildscript {
name 'Scala CI dependencies'
url 'https://repo1.maven.org/maven2/'
}
- maven {
- name 'jitpack'
- url 'https://jitpack.io'
- }
}
dependencies {
- classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
+ classpath 'net.minecraftforge.gradle:ForgeGradle:1.2.9'
}
}
plugins {
@@ -49,17 +50,20 @@ plugins {
id 'eclipse'
id 'scala'
id 'maven-publish'
- id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
- id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
- id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
- id 'org.ajoberstar.grgit' version '4.1.1'
+ id 'org.jetbrains.kotlin.jvm' version '1.5.30' apply false
+ id 'org.jetbrains.kotlin.kapt' version '1.5.30' apply false
+ id 'com.google.devtools.ksp' version '1.5.30-1.0.0' apply false
+ id 'org.ajoberstar.grgit' version '4.1.1'
id 'com.github.johnrengelman.shadow' version '4.0.4'
- id 'com.palantir.git-version' version '0.13.0' apply false
- id 'de.undercouch.download' version '5.0.1'
- id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
- id "com.diffplug.spotless" version "6.7.2"
+ id 'com.palantir.git-version' version '0.13.0' apply false
+ id 'de.undercouch.download' version '5.0.1'
+ id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
+ id 'com.diffplug.spotless' version '6.7.2' apply false
}
-verifySettingsGradle()
+boolean settingsupdated = verifySettingsGradle()
+settingsupdated = verifyGitAttributes() || settingsupdated
+if (settingsupdated)
+ throw new GradleException("Settings has been updated, please re-run task.")
dependencies {
implementation 'com.diffplug:blowdryer:1.6.0'
@@ -90,9 +94,15 @@ idea {
downloadSources = true
}
}
-apply from: Blowdryer.file('spotless.gradle')
-if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
+boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
+
+if (!disableSpotless) {
+ apply plugin: 'com.diffplug.spotless'
+ apply from: Blowdryer.file('spotless.gradle')
+}
+
+if (JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
@@ -129,53 +139,53 @@ String kotlinSourceDir = "src/main/kotlin/"
String targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/")
String targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/")
-if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
+if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"modGroup\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
-if(apiPackage) {
+if (apiPackage) {
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/")
- if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
+ if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
}
-if(accessTransformersFile) {
+if (accessTransformersFile) {
String targetFile = "src/main/resources/META-INF/" + accessTransformersFile
- if(!getFile(targetFile).exists()) {
+ if (!getFile(targetFile).exists()) {
throw new GradleException("Could not resolve \"accessTransformersFile\"! Could not find " + targetFile)
}
}
-if(usesMixins.toBoolean()) {
- if(mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
+if (usesMixins.toBoolean()) {
+ if (mixinsPackage.isEmpty() || mixinPlugin.isEmpty()) {
throw new GradleException("\"mixinPlugin\" requires \"mixinsPackage\" and \"mixinPlugin\" to be set!")
}
targetPackageJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
targetPackageKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinsPackage.toString().replaceAll("\\.", "/")
- if(!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
- throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
+ if (!(getFile(targetPackageJava).exists() || getFile(targetPackageScala).exists() || getFile(targetPackageKotlin).exists())) {
+ throw new GradleException("Could not resolve \"mixinsPackage\"! Could not find " + targetPackageJava + " or " + targetPackageScala + " or " + targetPackageKotlin)
}
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + mixinPlugin.toString().replaceAll("\\.", "/") + ".kt"
- if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
+ if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"mixinPlugin\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
-if(coreModClass) {
+if (coreModClass) {
String targetFileJava = javaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileScala = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".scala"
String targetFileScalaJava = scalaSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".java"
String targetFileKotlin = kotlinSourceDir + modGroup.toString().replaceAll("\\.", "/") + "/" + coreModClass.toString().replaceAll("\\.", "/") + ".kt"
- if(!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
+ if (!(getFile(targetFileJava).exists() || getFile(targetFileScala).exists() || getFile(targetFileScalaJava).exists() || getFile(targetFileKotlin).exists())) {
throw new GradleException("Could not resolve \"coreModClass\"! Could not find " + targetFileJava + " or " + targetFileScala + " or " + targetFileScalaJava + " or " + targetFileKotlin)
}
}
@@ -204,10 +214,10 @@ try {
}
catch (Exception ignored) {
out.style(Style.Failure).text(
- 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
+ 'This mod must be version controlled by Git AND the repository must provide at least one tag,\n' +
'or the VERSION override must be set! ').style(Style.SuccessHeader).text('(Do NOT download from GitHub using the ZIP option, instead\n' +
- 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
- )
+ 'clone the repository, see ').style(Style.Info).text('https://gtnh.miraheze.org/wiki/Development').style(Style.SuccessHeader).println(' for details.)'
+ )
versionOverride = 'NO-GIT-TAG-SET'
identifiedVersion = versionOverride
}
@@ -216,15 +226,14 @@ ext {
modVersion = identifiedVersion
}
-if(identifiedVersion == versionOverride) {
+if (identifiedVersion == versionOverride) {
out.style(Style.Failure).text('Override version to ').style(Style.Identifier).text(modVersion).style(Style.Failure).println('!\7')
}
group = modGroup
-if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
+if (project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
archivesBaseName = customArchiveBaseName
-}
-else {
+} else {
archivesBaseName = modId
}
@@ -250,16 +259,16 @@ minecraft {
if (replaceGradleTokenInFile) {
replaceIn replaceGradleTokenInFile
- if(gradleTokenModId) {
+ if (gradleTokenModId) {
replace gradleTokenModId, modId
}
- if(gradleTokenModName) {
+ if (gradleTokenModName) {
replace gradleTokenModName, modName
}
- if(gradleTokenVersion) {
+ if (gradleTokenVersion) {
replace gradleTokenVersion, modVersion
}
- if(gradleTokenGroupName) {
+ if (gradleTokenGroupName) {
replace gradleTokenGroupName, modGroup
}
}
@@ -268,7 +277,7 @@ minecraft {
args(arguments)
jvmArgs(jvmArguments)
- if(developmentEnvironmentUserName) {
+ if (developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}
@@ -279,7 +288,7 @@ minecraft {
}
}
-if(file('addon.gradle').exists()) {
+if (file('addon.gradle').exists()) {
apply from: 'addon.gradle'
}
@@ -296,7 +305,7 @@ repositories {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
- if(usesMixins.toBoolean() || forceEnableMixins) {
+ if (usesMixins.toBoolean() || forceEnableMixins) {
maven {
name 'sponge'
url 'https://repo.spongepowered.org/repository/maven-public'
@@ -308,13 +317,13 @@ repositories {
}
dependencies {
- if(usesMixins.toBoolean()) {
+ if (usesMixins.toBoolean()) {
annotationProcessor('org.ow2.asm:asm-debug-all:5.0.3')
annotationProcessor('com.google.guava:guava:24.1.1-jre')
annotationProcessor('com.google.code.gson:gson:2.8.6')
annotationProcessor('org.spongepowered:mixin:0.8-SNAPSHOT')
}
- if(usesMixins.toBoolean() || forceEnableMixins) {
+ if (usesMixins.toBoolean() || forceEnableMixins) {
// using 0.8 to workaround a issue in 0.7 which fails mixin application
compile('com.github.GTNewHorizons:SpongePoweredMixin:0.7.12-GTNH') {
// Mixin includes a lot of dependencies that are too up-to-date
@@ -390,20 +399,20 @@ jar {
attributes(getManifestAttributes())
}
- if(usesShadowedDependencies.toBoolean()) {
+ if (usesShadowedDependencies.toBoolean()) {
dependsOn(shadowJar)
enabled = false
}
}
reobf {
- if(usesMixins.toBoolean() && file(mixinSrg).exists()) {
+ if (usesMixins.toBoolean()) {
addExtraSrgFile mixinSrg
}
}
afterEvaluate {
- if(usesMixins.toBoolean()) {
+ if (usesMixins.toBoolean()) {
tasks.compileJava {
options.compilerArgs += [
"-AreobfSrgFile=${tasks.reobf.srg}",
@@ -418,7 +427,7 @@ afterEvaluate {
}
runClient {
- if(developmentEnvironmentUserName) {
+ if (developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
@@ -436,10 +445,10 @@ runServer {
tasks.withType(JavaExec).configureEach {
javaLauncher.set(
- javaToolchains.launcherFor {
- languageVersion = projectJavaVersion
- }
- )
+ javaToolchains.launcherFor {
+ languageVersion = projectJavaVersion
+ }
+ )
}
processResources {
@@ -454,12 +463,12 @@ processResources {
// replace modVersion and minecraftVersion
expand "minecraftVersion": project.minecraft.version,
- "modVersion": modVersion,
- "modId": modId,
- "modName": modName
+ "modVersion": modVersion,
+ "modId": modId,
+ "modName": modName
}
- if(usesMixins.toBoolean()) {
+ if (usesMixins.toBoolean()) {
from refMap
}
@@ -472,31 +481,31 @@ processResources {
def getManifestAttributes() {
def manifestAttributes = [:]
- if(!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
+ if (!containsMixinsAndOrCoreModOnly.toBoolean() && (usesMixins.toBoolean() || coreModClass)) {
manifestAttributes += ["FMLCorePluginContainsFMLMod": true]
}
- if(accessTransformersFile) {
- manifestAttributes += ["FMLAT" : accessTransformersFile.toString()]
+ if (accessTransformersFile) {
+ manifestAttributes += ["FMLAT": accessTransformersFile.toString()]
}
- if(coreModClass) {
+ if (coreModClass) {
manifestAttributes += ["FMLCorePlugin": modGroup + "." + coreModClass]
}
- if(usesMixins.toBoolean()) {
+ if (usesMixins.toBoolean()) {
manifestAttributes += [
- "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
- "MixinConfigs" : "mixins." + modId + ".json",
- "ForceLoadAsMod" : !containsMixinsAndOrCoreModOnly.toBoolean()
+ "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker",
+ "MixinConfigs" : "mixins." + modId + ".json",
+ "ForceLoadAsMod": !containsMixinsAndOrCoreModOnly.toBoolean()
]
}
return manifestAttributes
}
task sourcesJar(type: Jar) {
- from (sourceSets.main.allSource)
- from (file("$projectDir/LICENSE"))
+ from(sourceSets.main.allSource)
+ from(file("$projectDir/LICENSE"))
getArchiveClassifier().set('sources')
}
@@ -546,22 +555,22 @@ task devJar(type: Jar) {
attributes(getManifestAttributes())
}
- if(usesShadowedDependencies.toBoolean()) {
+ if (usesShadowedDependencies.toBoolean()) {
dependsOn(circularResolverJar)
enabled = false
}
}
task apiJar(type: Jar) {
- from (sourceSets.main.allSource) {
+ from(sourceSets.main.allSource) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
- from (sourceSets.main.output) {
+ from(sourceSets.main.output) {
include modGroup.toString().replaceAll("\\.", "/") + "/" + apiPackage.toString().replaceAll("\\.", "/") + '/**'
}
- from (sourceSets.main.resources.srcDirs) {
+ from(sourceSets.main.resources.srcDirs) {
include("LICENSE")
}
@@ -569,11 +578,11 @@ task apiJar(type: Jar) {
}
artifacts {
- if(!noPublishedSources) {
+ if (!noPublishedSources) {
archives sourcesJar
}
archives devJar
- if(apiPackage) {
+ if (apiPackage) {
archives apiJar
}
}
@@ -591,10 +600,10 @@ publishing {
publications {
maven(MavenPublication) {
from components.java
- if(usesShadowedDependencies.toBoolean()) {
+ if (usesShadowedDependencies.toBoolean()) {
artifact source: shadowJar, classifier: ""
}
- if(!noPublishedSources) {
+ if (!noPublishedSources) {
artifact source: sourcesJar, classifier: "sources"
}
artifact source: usesShadowedDependencies.toBoolean() ? shadowDevJar : devJar, classifier: "dev"
@@ -609,11 +618,11 @@ publishing {
// remove extra garbage from minecraft and minecraftDeps configuration
pom.withXml {
- def badArtifacts = [:].withDefault {[] as Set}
+ def badArtifacts = [:].withDefault { [] as Set }
for (configuration in [
- projectConfigs.minecraft,
- projectConfigs.minecraftDeps
- ]) {
+ projectConfigs.minecraft,
+ projectConfigs.minecraftDeps
+ ]) {
for (dependency in configuration.allDependencies) {
badArtifacts[dependency.group == null ? "" : dependency.group] += dependency.name
}
@@ -647,7 +656,7 @@ task updateBuildScript {
doLast {
if (performBuildScriptUpdate(projectDir.toString())) return
- print("Build script already up-to-date!")
+ print("Build script already up-to-date!")
}
}
@@ -660,20 +669,40 @@ if (!project.getGradle().startParameter.isOffline() && isNewBuildScriptVersionAv
}
static URL availableBuildScriptUrl() {
- new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/build.gradle")
+ new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/build.gradle")
}
+
static URL exampleSettingsGradleUrl() {
- new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/main/settings.gradle.example")
+ new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/settings.gradle.example")
}
+static URL exampleGitAttributesUrl() {
+ new URL("https://raw.githubusercontent.com/GTNewHorizons/ExampleMod1.7.10/master/.gitattributes")
+}
-def verifySettingsGradle() {
+
+boolean verifyGitAttributes() {
+ def gitattributesFile = getFile(".gitattributes")
+ if (!gitattributesFile.exists()) {
+ println("Downloading default .gitattributes")
+ exampleGitAttributesUrl().withInputStream { i -> gitattributesFile.withOutputStream { it << i } }
+ exec {
+ workingDir '.'
+ commandLine 'git', 'add', '--renormalize', '.'
+ }
+ return true
+ }
+ return false
+}
+
+boolean verifySettingsGradle() {
def settingsFile = getFile("settings.gradle")
if (!settingsFile.exists()) {
println("Downloading default settings.gradle")
exampleSettingsGradleUrl().withInputStream { i -> settingsFile.withOutputStream { it << i } }
- throw new GradleException("Settings.gradle has been updated, please re-run task.")
+ return true
}
+ return false
}
boolean performBuildScriptUpdate(String projectDir) {
@@ -681,7 +710,10 @@ boolean performBuildScriptUpdate(String projectDir) {
def buildscriptFile = getFile("build.gradle")
availableBuildScriptUrl().withInputStream { i -> buildscriptFile.withOutputStream { it << i } }
out.style(Style.Success).print("Build script updated. Please REIMPORT the project or RESTART your IDE!")
- verifySettingsGradle()
+ boolean settingsupdated = verifySettingsGradle()
+ settingsupdated = verifyGitAttributes() || settingsupdated
+ if (settingsupdated)
+ throw new GradleException("Settings has been updated, please re-run task.")
return true
}
return false
@@ -701,7 +733,7 @@ boolean isNewBuildScriptVersionAvailable(String projectDir) {
static String getVersionHash(String buildScriptContent) {
String versionLine = buildScriptContent.find("^//version: [a-z0-9]*")
- if(versionLine != null) {
+ if (versionLine != null) {
return versionLine.split(": ").last()
}
return ""
@@ -727,210 +759,210 @@ task deobfParams {
overwrite false
}
- if(!file(paramsCSV).exists()) {
+ if (!file(paramsCSV).exists()) {
println("Extracting MCP archive ...")
unzip(mcpZIP, mcpDir)
}
println("Parsing params.csv ...")
Map params = new HashMap<>()
- Files.lines(Paths.get(paramsCSV)).forEach{line ->
+ Files.lines(Paths.get(paramsCSV)).forEach { line ->
String[] cells = line.split(",")
- if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
+ if (cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
params.put(cells[0], cells[1])
}
}
out.style(Style.Success).println("Modified ${replaceParams(file("$projectDir/src/main/java"), params)} files!")
- out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.")
-}
+ out.style(Style.Failure).println("Don't forget to verify that the code still works as before!\n It could be broken due to duplicate variables existing now\n or parameters taking priority over other variables.")
+ }
}
static int replaceParams(File file, Map params) {
-int fileCount = 0
+ int fileCount = 0
-if(file.isDirectory()) {
- for(File f : file.listFiles()) {
- fileCount += replaceParams(f, params)
- }
- return fileCount
-}
-println("Visiting ${file.getName()} ...")
-try {
- String content = new String(Files.readAllBytes(file.toPath()))
- int hash = content.hashCode()
- params.forEach{key, value ->
- content = content.replaceAll(key, value)
- }
- if(hash != content.hashCode()) {
- Files.write(file.toPath(), content.getBytes("UTF-8"))
- return 1
+ if (file.isDirectory()) {
+ for (File f : file.listFiles()) {
+ fileCount += replaceParams(f, params)
+ }
+ return fileCount
+ }
+ println("Visiting ${file.getName()} ...")
+ try {
+ String content = new String(Files.readAllBytes(file.toPath()))
+ int hash = content.hashCode()
+ params.forEach { key, value ->
+ content = content.replaceAll(key, value)
+ }
+ if (hash != content.hashCode()) {
+ Files.write(file.toPath(), content.getBytes("UTF-8"))
+ return 1
+ }
+ } catch (Exception e) {
+ e.printStackTrace()
}
-} catch(Exception e) {
- e.printStackTrace()
-}
-return 0
+ return 0
}
// Credit: bitsnaps (https://gist.github.com/bitsnaps/00947f2dce66f4bbdabc67d7e7b33681)
static unzip(String zipFileName, String outputDir) {
-byte[] buffer = new byte[16384]
-ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))
-ZipEntry zipEntry = zis.getNextEntry()
-while (zipEntry != null) {
- File newFile = new File(outputDir + File.separator, zipEntry.name)
- if (zipEntry.isDirectory()) {
- if (!newFile.isDirectory() && !newFile.mkdirs()) {
- throw new IOException("Failed to create directory $newFile")
- }
- } else {
- // fix for Windows-created archives
- File parent = newFile.parentFile
- if (!parent.isDirectory() && !parent.mkdirs()) {
- throw new IOException("Failed to create directory $parent")
- }
- // write file content
- FileOutputStream fos = new FileOutputStream(newFile)
- int len = 0
- while ((len = zis.read(buffer)) > 0) {
- fos.write(buffer, 0, len)
+ byte[] buffer = new byte[16384]
+ ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFileName))
+ ZipEntry zipEntry = zis.getNextEntry()
+ while (zipEntry != null) {
+ File newFile = new File(outputDir + File.separator, zipEntry.name)
+ if (zipEntry.isDirectory()) {
+ if (!newFile.isDirectory() && !newFile.mkdirs()) {
+ throw new IOException("Failed to create directory $newFile")
+ }
+ } else {
+ // fix for Windows-created archives
+ File parent = newFile.parentFile
+ if (!parent.isDirectory() && !parent.mkdirs()) {
+ throw new IOException("Failed to create directory $parent")
+ }
+ // write file content
+ FileOutputStream fos = new FileOutputStream(newFile)
+ int len = 0
+ while ((len = zis.read(buffer)) > 0) {
+ fos.write(buffer, 0, len)
+ }
+ fos.close()
}
- fos.close()
+ zipEntry = zis.getNextEntry()
}
- zipEntry = zis.getNextEntry()
-}
-zis.closeEntry()
-zis.close()
+ zis.closeEntry()
+ zis.close()
}
configure(deobfParams) {
-group = 'forgegradle'
-description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
+ group = 'forgegradle'
+ description = 'Rename all obfuscated parameter names inherited from Minecraft classes'
}
// Dependency Deobfuscation
def deobf(String sourceURL) {
-try {
- URL url = new URL(sourceURL)
- String fileName = url.getFile()
+ try {
+ URL url = new URL(sourceURL)
+ String fileName = url.getFile()
+
+ //get rid of directories:
+ int lastSlash = fileName.lastIndexOf("/")
+ if (lastSlash > 0) {
+ fileName = fileName.substring(lastSlash + 1)
+ }
+ //get rid of extension:
+ if (fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
+ fileName = fileName.substring(0, fileName.lastIndexOf("."))
+ }
- //get rid of directories:
- int lastSlash = fileName.lastIndexOf("/")
- if(lastSlash > 0) {
- fileName = fileName.substring(lastSlash + 1)
- }
- //get rid of extension:
- if(fileName.endsWith(".jar") || fileName.endsWith(".litemod")) {
- fileName = fileName.substring(0, fileName.lastIndexOf("."))
- }
+ String hostName = url.getHost()
+ if (hostName.startsWith("www.")) {
+ hostName = hostName.substring(4)
+ }
+ List parts = Arrays.asList(hostName.split("\\."))
+ Collections.reverse(parts)
+ hostName = String.join(".", parts)
- String hostName = url.getHost()
- if(hostName.startsWith("www.")) {
- hostName = hostName.substring(4)
+ return deobf(sourceURL, "$hostName/$fileName")
+ } catch (Exception e) {
+ return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
}
- List parts = Arrays.asList(hostName.split("\\."))
- Collections.reverse(parts)
- hostName = String.join(".", parts)
-
- return deobf(sourceURL, "$hostName/$fileName")
-} catch(Exception e) {
- return deobf(sourceURL, "deobf/${sourceURL.hashCode()}")
-}
}
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String rawFileName) {
-String bon2Version = "2.5.1"
-String fileName = URLDecoder.decode(rawFileName, "UTF-8")
-String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
-String bon2Dir = "$cacheDir/forge_gradle/deobf"
-String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
-String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
-String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
-
-if(file(deobfFile).exists()) {
- return files(deobfFile)
-}
+ String bon2Version = "2.5.1"
+ String fileName = URLDecoder.decode(rawFileName, "UTF-8")
+ String cacheDir = "$project.gradle.gradleUserHomeDir/caches"
+ String bon2Dir = "$cacheDir/forge_gradle/deobf"
+ String bon2File = "$bon2Dir/BON2-${bon2Version}.jar"
+ String obfFile = "$cacheDir/modules-2/files-2.1/${fileName}.jar"
+ String deobfFile = "$cacheDir/modules-2/files-2.1/${fileName}-deobf.jar"
-String mappingsVer
-String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
-if(remoteMappings) {
- String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
- String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
+ if (file(deobfFile).exists()) {
+ return files(deobfFile)
+ }
- zipMappings(mappingsZIP, remoteMappings, bon2Dir)
+ String mappingsVer
+ String remoteMappings = project.hasProperty('remoteMappings') ? project.remoteMappings : 'https://raw.githubusercontent.com/MinecraftForge/FML/1.7.10/conf/'
+ if (remoteMappings) {
+ String id = "${forgeVersion.split("\\.")[3]}-$minecraftVersion"
+ String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
- mappingsVer = "snapshot_$id"
-} else {
- mappingsVer = "${channel}_$mappingsVersion"
-}
+ zipMappings(mappingsZIP, remoteMappings, bon2Dir)
-download.run {
- src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
- dest bon2File
- quiet true
- overwrite false
-}
+ mappingsVer = "snapshot_$id"
+ } else {
+ mappingsVer = "${channel}_$mappingsVersion"
+ }
-download.run {
- src sourceURL
- dest obfFile
- quiet true
- overwrite false
-}
+ download.run {
+ src "http://jenkins.usrv.eu:8081/nexus/content/repositories/releases/com/github/parker8283/BON2/$bon2Version-CUSTOM/BON2-$bon2Version-CUSTOM-all.jar"
+ dest bon2File
+ quiet true
+ overwrite false
+ }
-exec {
- commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
- workingDir bon2Dir
- standardOutput = new FileOutputStream("${deobfFile}.log")
-}
+ download.run {
+ src sourceURL
+ dest obfFile
+ quiet true
+ overwrite false
+ }
+
+ exec {
+ commandLine 'java', '-jar', bon2File, '--inputJar', obfFile, '--outputJar', deobfFile, '--mcVer', minecraftVersion, '--mappingsVer', mappingsVer, '--notch'
+ workingDir bon2Dir
+ standardOutput = new FileOutputStream("${deobfFile}.log")
+ }
-return files(deobfFile)
+ return files(deobfFile)
}
def zipMappings(String zipPath, String url, String bon2Dir) {
-File zipFile = new File(zipPath)
-if(zipFile.exists()) {
- return
-}
+ File zipFile = new File(zipPath)
+ if (zipFile.exists()) {
+ return
+ }
-String fieldsCache = "$bon2Dir/data/fields.csv"
-String methodsCache = "$bon2Dir/data/methods.csv"
+ String fieldsCache = "$bon2Dir/data/fields.csv"
+ String methodsCache = "$bon2Dir/data/methods.csv"
-download.run {
- src "${url}fields.csv"
- dest fieldsCache
- quiet true
-}
-download.run {
- src "${url}methods.csv"
- dest methodsCache
- quiet true
-}
+ download.run {
+ src "${url}fields.csv"
+ dest fieldsCache
+ quiet true
+ }
+ download.run {
+ src "${url}methods.csv"
+ dest methodsCache
+ quiet true
+ }
-zipFile.getParentFile().mkdirs()
-ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
+ zipFile.getParentFile().mkdirs()
+ ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFile))
-zos.putNextEntry(new ZipEntry("fields.csv"))
-Files.copy(Paths.get(fieldsCache), zos)
-zos.closeEntry()
+ zos.putNextEntry(new ZipEntry("fields.csv"))
+ Files.copy(Paths.get(fieldsCache), zos)
+ zos.closeEntry()
-zos.putNextEntry(new ZipEntry("methods.csv"))
-Files.copy(Paths.get(methodsCache), zos)
-zos.closeEntry()
+ zos.putNextEntry(new ZipEntry("methods.csv"))
+ Files.copy(Paths.get(methodsCache), zos)
+ zos.closeEntry()
-zos.close()
+ zos.close()
}
// Helper methods
def checkPropertyExists(String propertyName) {
-if (!project.hasProperty(propertyName)) {
- throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
-}
+ if (!project.hasProperty(propertyName)) {
+ throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/GTNewHorizons/ExampleMod1.7.10/blob/main/gradle.properties")
+ }
}
def getFile(String relativePath) {
-return new File(projectDir, relativePath)
+ return new File(projectDir, relativePath)
}
diff --git a/dependencies.gradle b/dependencies.gradle
index 77f994b5c0..ad722e5fab 100644
--- a/dependencies.gradle
+++ b/dependencies.gradle
@@ -21,10 +21,15 @@ dependencies {
{
transitive = false
}
+ compileOnly("com.github.GTNewHorizons:NewHorizonsCoreMod:1.9.52:dev")
+ {
+ transitive = false
+ }
runtime("com.github.GTNewHorizons:Baubles:1.0.1.14:dev")
runtime("curse.maven:cofh-core-69162:2388751")
// For testing
+ //runtime("com.github.GTNewHorizons:NewHorizonsCoreMod:1.9.52:dev")
//runtime("com.github.GTNewHorizons:OpenBlocks:1.6.9-GTNH:dev")
//runtime("com.github.GTNewHorizons:bartworks:0.5.67:dev")
//runtime("com.github.GTNewHorizons:CraftTweaker:3.2.9:dev")
diff --git a/settings.gradle b/settings.gradle
index 97d8f71c52..93c852a12c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -5,6 +5,6 @@ plugins {
apply plugin: 'com.diffplug.blowdryerSetup'
blowdryerSetup {
- github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.4')
+ github('GTNewHorizons/ExampleMod1.7.10', 'tag', '0.1.5')
//devLocal '.' // Use this when testing config updates locally
}
diff --git a/src/main/java/kubatech/CommonProxy.java b/src/main/java/kubatech/CommonProxy.java
index 5f1ec40cad..db752f9fa0 100644
--- a/src/main/java/kubatech/CommonProxy.java
+++ b/src/main/java/kubatech/CommonProxy.java
@@ -24,6 +24,7 @@ import cpw.mods.fml.common.event.*;
import kubatech.commands.CommandConfig;
import kubatech.commands.CommandHandler;
import kubatech.commands.CommandHelp;
+import kubatech.config.Config;
import kubatech.loaders.RecipeLoader;
public class CommonProxy {
diff --git a/src/main/java/kubatech/Config.java b/src/main/java/kubatech/Config.java
deleted file mode 100644
index feb8f96dae..0000000000
--- a/src/main/java/kubatech/Config.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * KubaTech - Gregtech Addon
- * Copyright (C) 2022 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 .
- *
- */
-
-package kubatech;
-
-import java.io.File;
-import net.minecraftforge.common.config.Configuration;
-
-public class Config {
-
- private static class Categories {
- public static final String mobHandler = "MobHandler";
- }
-
- public static boolean mobHandlerEnabled = true;
- public static boolean includeEmptyMobs = true;
- public static String[] mobBlacklist;
- public static File configFile;
- public static File configDirectory;
-
- public static void init(File configFile) {
- configDirectory = new File(configFile, Tags.MODID);
- Config.configFile = new File(configDirectory, Tags.MODID + ".cfg");
- }
-
- public static File getConfigFile(String file) {
- return new File(configDirectory, file);
- }
-
- public static void synchronizeConfiguration() {
- Configuration configuration = new Configuration(configFile);
- configuration.load();
-
- mobHandlerEnabled = configuration
- .get(
- Categories.mobHandler,
- "Enabled",
- true,
- "Enable \"Mob Drops\" NEI page and Extreme Extermination Chamber")
- .getBoolean();
- includeEmptyMobs = configuration
- .get(Categories.mobHandler, "IncludeEmptyMobs", true, "Include mobs that have no drops in NEI")
- .getBoolean();
- mobBlacklist = configuration
- .get(
- Categories.mobHandler,
- "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();
-
- if (configuration.hasChanged()) {
- configuration.save();
- }
- }
-}
diff --git a/src/main/java/kubatech/api/ConstructableItemStack.java b/src/main/java/kubatech/api/ConstructableItemStack.java
new file mode 100644
index 0000000000..668d21d803
--- /dev/null
+++ b/src/main/java/kubatech/api/ConstructableItemStack.java
@@ -0,0 +1,97 @@
+package kubatech.api;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.nio.charset.StandardCharsets;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.CompressedStreamTools;
+import net.minecraft.nbt.NBTSizeTracker;
+import net.minecraft.nbt.NBTTagCompound;
+
+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/LoaderReference.java b/src/main/java/kubatech/api/LoaderReference.java
index 418fe4a7ab..b41db59904 100644
--- a/src/main/java/kubatech/api/LoaderReference.java
+++ b/src/main/java/kubatech/api/LoaderReference.java
@@ -10,4 +10,5 @@ public class LoaderReference {
public static final boolean Thaumcraft = Loader.isModLoaded("Thaumcraft");
public static final boolean MineTweaker = Loader.isModLoaded("MineTweaker3");
public static final boolean Bartworks = Loader.isModLoaded("bartworks");
+ public static final boolean GTNHCoreMod = Loader.isModLoaded("dreamcraft");
}
diff --git a/src/main/java/kubatech/api/mobhandler/MobDrop.java b/src/main/java/kubatech/api/mobhandler/MobDrop.java
new file mode 100644
index 0000000000..76942b3148
--- /dev/null
+++ b/src/main/java/kubatech/api/mobhandler/MobDrop.java
@@ -0,0 +1,99 @@
+package kubatech.api.mobhandler;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import java.util.HashMap;
+import kubatech.api.ConstructableItemStack;
+import kubatech.api.utils.GSONUtils;
+import net.minecraft.item.ItemStack;
+
+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 damages;
+ public boolean lootable = false;
+ public boolean playerOnly = false;
+
+ private MobDrop() {}
+
+ public MobDrop(
+ ItemStack stack,
+ DropType type,
+ int chance,
+ Integer enchantable,
+ HashMap 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
index f38293642e..2199eb2db9 100644
--- a/src/main/java/kubatech/api/network/LoadConfigPacket.java
+++ b/src/main/java/kubatech/api/network/LoadConfigPacket.java
@@ -24,8 +24,10 @@ import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import io.netty.buffer.ByteBuf;
import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
import java.util.HashSet;
-import kubatech.Config;
+import kubatech.config.Config;
+import kubatech.config.OverridesConfig;
import kubatech.kubatech;
import kubatech.loaders.MobRecipeLoader;
@@ -34,6 +36,7 @@ public class LoadConfigPacket implements IMessage {
public static final LoadConfigPacket instance = new LoadConfigPacket();
public final HashSet mobsToLoad = new HashSet<>();
+ public final HashMap mobsOverrides = new HashMap<>();
@Override
public void fromBytes(ByteBuf buf) {
@@ -46,6 +49,13 @@ public class LoadConfigPacket implements IMessage {
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));
+ }
}
}
@@ -60,6 +70,13 @@ public class LoadConfigPacket implements IMessage {
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);
+ });
}
}
@@ -67,7 +84,7 @@ public class LoadConfigPacket implements IMessage {
@Override
public IMessage onMessage(LoadConfigPacket message, MessageContext ctx) {
kubatech.info("Received Mob Handler config, parsing");
- MobRecipeLoader.processMobRecipeMap(message.mobsToLoad);
+ MobRecipeLoader.processMobRecipeMap(message.mobsToLoad, message.mobsOverrides);
return null;
}
}
diff --git a/src/main/java/kubatech/api/utils/GSONUtils.java b/src/main/java/kubatech/api/utils/GSONUtils.java
index 1c0e7ec3f4..90f777000c 100644
--- a/src/main/java/kubatech/api/utils/GSONUtils.java
+++ b/src/main/java/kubatech/api/utils/GSONUtils.java
@@ -1,12 +1,16 @@
package kubatech.api.utils;
import com.google.gson.*;
+import java.io.File;
import java.io.IOException;
+import java.io.Reader;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTSizeTracker;
import net.minecraft.nbt.NBTTagCompound;
@@ -66,5 +70,32 @@ public class GSONUtils {
.addSerializationExclusionStrategy(GSONStrategy)
.addDeserializationExclusionStrategy(GSONStrategy)
.registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer)
- .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer);
+ .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer)
+ .serializeNulls();
+ public static final GsonBuilder GSON_BUILDER_PRETTY = new GsonBuilder()
+ .addSerializationExclusionStrategy(GSONStrategy)
+ .addDeserializationExclusionStrategy(GSONStrategy)
+ .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundDeserializer)
+ .registerTypeAdapter(NBTTagCompound.class, NBTTagCompoundSerializer)
+ .serializeNulls()
+ .setPrettyPrinting();
+
+ public static T readFile(Gson gson, File file, Class tClass) {
+ if (!file.exists()) return null;
+ if (!file.isFile()) return null;
+ T t = null;
+ Reader reader = null;
+ try {
+ reader = Files.newBufferedReader(file.toPath(), StandardCharsets.UTF_8);
+ t = gson.fromJson(reader, tClass);
+ } catch (Exception ignored) {
+ } finally {
+ if (reader != null)
+ try {
+ reader.close();
+ } catch (Exception ignored) {
+ }
+ }
+ return t;
+ }
}
diff --git a/src/main/java/kubatech/commands/CommandConfig.java b/src/main/java/kubatech/commands/CommandConfig.java
index a1c3659165..0c33c3dedf 100644
--- a/src/main/java/kubatech/commands/CommandConfig.java
+++ b/src/main/java/kubatech/commands/CommandConfig.java
@@ -21,8 +21,8 @@ package kubatech.commands;
import static kubatech.commands.CommandConfig.Translations.*;
-import kubatech.Config;
import kubatech.api.network.LoadConfigPacket;
+import kubatech.config.Config;
import kubatech.kubatech;
import kubatech.loaders.MobRecipeLoader;
import net.minecraft.command.CommandBase;
diff --git a/src/main/java/kubatech/config/Config.java b/src/main/java/kubatech/config/Config.java
new file mode 100644
index 0000000000..72044ae899
--- /dev/null
+++ b/src/main/java/kubatech/config/Config.java
@@ -0,0 +1,94 @@
+/*
+ * KubaTech - Gregtech Addon
+ * Copyright (C) 2022 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 .
+ *
+ */
+
+package kubatech.config;
+
+import java.io.File;
+import kubatech.Tags;
+import net.minecraftforge.common.config.Configuration;
+
+public class Config {
+
+ private static class Categories {
+ public static final String mobHandler = "MobHandler";
+ }
+
+ public static boolean mobHandlerEnabled = true;
+ public static boolean includeEmptyMobs = true;
+ public static String[] mobBlacklist;
+ public static File configFile;
+ public static File configDirectory;
+
+ public static void init(File configFile) {
+ configDirectory = new File(configFile, Tags.MODID);
+ Config.configFile = new File(configDirectory, Tags.MODID + ".cfg");
+ }
+
+ public static File getConfigFile(String file) {
+ return new File(configDirectory, file);
+ }
+
+ public static void synchronizeConfiguration() {
+ Configuration configuration = new Configuration(configFile);
+ configuration.load();
+
+ mobHandlerEnabled = configuration
+ .get(
+ Categories.mobHandler,
+ "Enabled",
+ true,
+ "Enable \"Mob Drops\" NEI page and Extreme Extermination Chamber")
+ .getBoolean();
+ includeEmptyMobs = configuration
+ .get(Categories.mobHandler, "IncludeEmptyMobs", true, "Include mobs that have no drops in NEI")
+ .getBoolean();
+ mobBlacklist = configuration
+ .get(
+ Categories.mobHandler,
+ "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();
+
+ if (configuration.hasChanged()) {
+ configuration.save();
+ }
+ }
+}
diff --git a/src/main/java/kubatech/config/OverridesConfig.java b/src/main/java/kubatech/config/OverridesConfig.java
new file mode 100644
index 0000000000..9c1ca6170c
--- /dev/null
+++ b/src/main/java/kubatech/config/OverridesConfig.java
@@ -0,0 +1,212 @@
+package kubatech.config;
+
+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 java.io.File;
+import java.io.Reader;
+import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.util.*;
+import kubatech.Tags;
+import kubatech.api.ConstructableItemStack;
+import kubatech.api.LoaderReference;
+import kubatech.api.mobhandler.MobDrop;
+import kubatech.api.utils.GSONUtils;
+import kubatech.api.utils.ReflectionHelper;
+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;
+
+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 List additions = new ArrayList<>();
+ public List 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 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.cfg");
+ if (!overrideFile.exists()) writeExampleFile();
+ Reader reader = null;
+ try {
+ reader = Files.newReader(overrideFile, StandardCharsets.UTF_8);
+ overrides = gson.fromJson(reader, new TypeToken