Thaumcraft loot Bags!

This commit is contained in:
jaredlll08 2015-04-24 23:36:03 +02:00
parent 53a906e38d
commit 72eab097c8
2 changed files with 85 additions and 8 deletions

View file

@ -7,15 +7,17 @@ import modtweaker2.mods.thaumcraft.handlers.Crucible;
import modtweaker2.mods.thaumcraft.handlers.Infusion;
import modtweaker2.mods.thaumcraft.handlers.Research;
import modtweaker2.mods.thaumcraft.handlers.Warp;
import modtweaker2.mods.thaumcraft.handlers.Loot;
public class Thaumcraft {
public Thaumcraft() {
MineTweakerAPI.registerClass(Arcane.class);
MineTweakerAPI.registerClass(Aspects.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Infusion.class);
MineTweakerAPI.registerClass(Research.class);
MineTweakerAPI.registerClass(Warp.class);
public Thaumcraft() {
MineTweakerAPI.registerClass(Arcane.class);
MineTweakerAPI.registerClass(Aspects.class);
MineTweakerAPI.registerClass(Crucible.class);
MineTweakerAPI.registerClass(Infusion.class);
MineTweakerAPI.registerClass(Research.class);
MineTweakerAPI.registerClass(Warp.class);
MineTweakerAPI.registerClass(Loot.class);
}
}
}

View file

@ -0,0 +1,75 @@
package modtweaker2.mods.thaumcraft.handlers;
import java.util.List;
import net.minecraft.item.ItemStack;
import minetweaker.MineTweakerAPI;
import minetweaker.api.item.IItemStack;
import modtweaker2.helpers.InputHelper;
import modtweaker2.utils.BaseListAddition;
import modtweaker2.utils.BaseListRemoval;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenMethod;
import thaumcraft.api.ThaumcraftApi;
import thaumcraft.api.internal.WeightedRandomLoot;
@ZenClass("mods.thaumcraft.Loot")
public class Loot {
@ZenMethod
public static void addCommonLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagCommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
@ZenMethod
public static void addUncommonLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagUncommon, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
@ZenMethod
public static void addRareLoot(IItemStack stack, int weight) {
MineTweakerAPI.apply(new Add(WeightedRandomLoot.lootBagRare, new WeightedRandomLoot(InputHelper.toStack(stack), weight)));
}
public static class Add extends BaseListAddition {
public Add(List list, WeightedRandomLoot recipe) {
super(list, recipe);
}
}
@ZenMethod
public static void removeCommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagCommon, InputHelper.toStack(stack)));
}
@ZenMethod
public static void removeUncommonLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagUncommon, InputHelper.toStack(stack)));
}
@ZenMethod
public static void removeRareLoot(IItemStack stack) {
MineTweakerAPI.apply(new Remove(WeightedRandomLoot.lootBagRare, InputHelper.toStack(stack)));
}
public static class Remove extends BaseListRemoval {
public Remove(List list, ItemStack stack) {
super(list, stack);
}
@Override
public void apply() {
List<WeightedRandomLoot> loot = (List<WeightedRandomLoot>) list;
WeightedRandomLoot remove = null;
for (WeightedRandomLoot stack : loot) {
if (stack.item.isItemEqual(this.stack)) {
remove = stack;
break;
}
}
loot.remove(remove);
}
}
}