Search in sources :

Example 1 with IAction

use of crafttweaker.IAction in project Charset by CharsetMC.

the class MaterialRegistry method registerRelation.

@ZenMethod
public static boolean registerRelation(IItemStack from, String what, IItemStack to) {
    ItemStack mcStackFrom = CraftTweakerMC.getItemStack(from);
    ItemStack mcStackTo = CraftTweakerMC.getItemStack(to);
    if (mcStackFrom.isEmpty() || mcStackTo.isEmpty()) {
        return false;
    }
    CraftTweakerAPI.apply(new IAction() {

        @Override
        public void apply() {
            ItemMaterialRegistry.INSTANCE.registerRelation(ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(mcStackFrom), ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(mcStackTo), what);
        }

        @Override
        public String describe() {
            return "Registering material relation (" + from + " --[" + what + "]-> " + to + ")";
        }
    });
    return true;
}
Also used : IAction(crafttweaker.IAction) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Example 2 with IAction

use of crafttweaker.IAction in project Charset by CharsetMC.

the class MaterialRegistry method registerTypes.

@ZenMethod
public static boolean registerTypes(IItemStack stack, String... tags) {
    ItemStack mcStack = CraftTweakerMC.getItemStack(stack);
    if (mcStack.isEmpty()) {
        return false;
    }
    CraftTweakerAPI.apply(new IAction() {

        @Override
        public void apply() {
            ItemMaterial material = ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(mcStack);
            ItemMaterialRegistry.INSTANCE.registerTypes(material, tags);
        }

        @Override
        public String describe() {
            return "Registering stack " + stack + " as material with types " + JOINER.join(tags);
        }
    });
    return true;
}
Also used : IAction(crafttweaker.IAction) ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

IAction (crafttweaker.IAction)2 IItemStack (crafttweaker.api.item.IItemStack)2 ItemStack (net.minecraft.item.ItemStack)2 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)2 ItemMaterial (pl.asie.charset.lib.material.ItemMaterial)1