Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////Imports
- import crafttweaker.data.IData;
- import crafttweaker.item.IItemStack;
- ////Variables
- function itemWithAttributes(item as IItemStack, attribute as string, op as string, amount as int, slot as string) as IItemStack {
- var attributeMap = {
- maxHealth : "generic.maxHealth",
- mobFollowRange : "generic.followRange",
- knockbackResistance : "generic.knockbackResistance",
- speed : "generic.movementSpeed",
- damage : "generic.attackDamage",
- armour : "generic.armor",
- armourToughness : "generic.armorToughness",
- attackSpeed : "generic.attackSpeed",
- luck : "generic.luck"
- } as string[string];
- val operation = {
- //add to the base value
- additive : 0,
- //add together, then multiply by base
- multisum : 1,
- //multiply by base individually
- multiplicative : 2
- } as int[string];
- if (item.hasTag() == true) {
- var inputTag = item.tag().asString();
- var inputAttributes = inputTag.split(???????????);
- print(inputAttributes);
- }
- /*
- var modifiers = {} as IData[IData];
- modifiers[attribute] = "{Slot:" ~ slot ~ ",AttributeName:" ~ attributeMap[attribute] ~ ",Name:" ~ attributeMap[attribute] ~ ",Amount:" ~ amount ~ ",Operation:" ~ operation[op] ~ ",UUIDLeast:0,UUIDMost:1000000}";
- var modifiersBuilder = "";
- for key, modifier in modifiers {
- modifiersBuilder = modifiersBuilder ~ "," ~ modifier;
- }
- var finalNBT = "{AttributeModifiers: [" ~ modifiersBuilder ~ "]}";*/
- }
- //Lets try and play with attributes shall we
- /*function addAttribute(attribute as string, op as string, amount as int, slot as string) as string[string] {
- var attributeMap = {
- maxHealth : "generic.maxHealth",
- mobFollowRange : "generic.followRange",
- knockbackResistance : "generic.knockbackResistance",
- speed : "generic.movementSpeed",
- damage : "generic.attackDamage",
- armour : "generic.armor",
- armourToughness : "generic.armorToughness",
- attackSpeed : "generic.attackSpeed",
- luck : "generic.luck"
- } as string[string];
- val operation = {
- //add to the base value
- additive : 0,
- //add together, then multiply by base
- multisum : 1,
- //multiply by base individually
- multiplicative : 2
- } as int[string];
- //var attributesToAdd = {} as string[][string];
- modifiers[attribute] = "{Slot:" ~ slot ~ ",AttributeName:" ~ attributeMap[attribute] ~ ",Name:" ~ attributeMap[attribute] ~ ",Amount:" ~ amount ~ ",Operation:" ~ operation[op] ~ ",UUIDLeast:0,UUIDMost:1000000}";
- return modifiers;
- }
- function setAttributes(attributes as any) as IData {
- var modifiersBuilder = "";
- for key, modifier in modifiers {
- modifiersBuilder = modifiersBuilder ~ "," ~ modifier;
- }
- var finalNBT = "{AttributeModifiers: [" ~ modifiersBuilder ~ "]}";
- return finalNBT;
- }
- //test recipe
- recipes.addShaped(<minecraft:diamond_sword>.withTag(setAttributes([addAttribute("maxHealth", "additive", 10, "chest")])), [[<minecraft:dirt>]]);
- //recipes.addShaped(<minecraft:diamond_sword>.withTag(setAttributes([addAttribute("maxHealth", "additive", 10, "chest"), addAttribute("speed", "multisum", 2, "chest")])), [[<minecraft:dirt>, <minecraft:dirt>]]);
- //example
- //item.withTag(setAttributes([addAttribute("damage", "additive", 5, "mainHand"), addAttribute("maxHealth", "additive", )]))
- /*
- .withTag({AttributeModifiers: [
- {Slot:"chest",AttributeName:"generic.movementSpeed",Name:"generic.movementSpeed",Amount:0.2,Operation:1,UUIDLeast:1,UUIDMost:1},
- {Slot:"chest",AttributeName:"generic.armor",Name:"generic.armor",Amount:5,Operation:0,UUIDLeast:10,UUIDMost:10}],
- display:{Name:"Light Iron Chestplate"}})*/
Advertisement
Add Comment
Please, Sign In to add comment