Skip to content

Instantly share code, notes, and snippets.

@Stapleton
Created April 3, 2019 11:05
Show Gist options
  • Save Stapleton/3fb1c6cdb116532c24a1424b5c2925d3 to your computer and use it in GitHub Desktop.
Save Stapleton/3fb1c6cdb116532c24a1424b5c2925d3 to your computer and use it in GitHub Desktop.
#loader contenttweaker
#modloaded tconstruct
import mods.contenttweaker.tconstruct.Material;
import mods.contenttweaker.tconstruct.MaterialBuilder;
import mods.contenttweaker.tconstruct.Trait
import mods.contenttweaker.Color;
import crafttweaker.item.IItemStack;
import crafttweaker.item.IIngredient;
import crafttweaker.liquid.ILiquidStack;
import crafttweaker.oredict.IOreDictEntry;
/*
Usage Example:
var Thaumium = BuildMaterial("Thaumium").setColor("4a3d90").setLiquid(<liquid:water>).setRepItem(<thaumcraft:ingot>).register();
*/
zenClass BuildMaterial {
var Name as string;
var ID as string;
var Builder as MaterialBuilder;
zenConstructor(name as string) {
this.Name = name;
this.ID = name.toLowerCase().replace(" ", "_");
this.Builder = MaterialBuilder.create(this.ID);
}
function getBuilder() as MaterialBuilder {
return this.Builder;
}
function setColor(color as string) as BuildMaterial {
var kolor = Color.fromHex(color);
this.Builder.color = kolor.getIntColor();
//this.Builder.color = color;
return this;
}
function setHidden(hidden as bool) as BuildMaterial {
this.Builder.hidden = hidden;
return this;
}
function setLiquid(liquid as ILiquidStack) as BuildMaterial {
this.Builder.liquid = liquid;
return this;
}
function setCraftable(craftable as bool) as BuildMaterial {
this.Builder.craftable = craftable;
return this;
}
function setCastable(castable as bool) as BuildMaterial {
this.Builder.castable = castable;
return this;
}
function setRepItem(repItem as IItemStack) as BuildMaterial {
this.Builder.representativeItem = repItem;
return this;
}
function setRepOre(repOre as IOreDictEntry) as BuildMaterial {
this.Builder.representativeOre = repOre;
return this;
}
function setShard(shard as IItemStack) as BuildMaterial {
this.Builder.shard = shard;
return this;
}
function addItem(item as IIngredient) as BuildMaterial {
this.Builder.addItem(item);
return this;
}
function addItem(item as IIngredient, needed as int) as BuildMaterial {
this.Builder.addItem(item, needed);
return this;
}
function addItem(item as IIngredient, needed as int, matched as int) as BuildMaterial {
//if (needed == 0) { needed = 1; }
//if (matched == 0) { matched = Volumes.ingot }
this.Builder.addItem(item, needed, matched);
return this;
}
function removeItem(item as IItemStack) as BuildMaterial {
this.Builder.removeItem(item);
return this;
}
function addTrait(id as Trait) as BuildMaterial {
this.Builder.addMaterialTrait(id);
return this;
}
function addTrait(id as string) as BuildMaterial {
this.Builder.addMaterialTrait(id);
return this;
}
function addTrait(id as Trait, dep as string) as BuildMaterial {
this.Builder.addMaterialTrait(id, dep);
return this;
}
function addTrait(id as string, dep as string) as BuildMaterial {
//if (!dep == true) { dep = null; }
this.Builder.addMaterialTrait(id, dep);
return this;
}
function removeTrait(id as string) as BuildMaterial {
this.Builder.removeMaterialTrait(id);
return this;
}
function removeTrait(id as string, dep as string) as BuildMaterial {
//if (!dep == true) { dep = null; }
this.Builder.removeMaterialTrait(id, dep);
return this;
}
function setHead(durability as int, miningSpeed as float, attackDamage as float, harvestLevel as int) as BuildMaterial {
this.Builder.addHeadMaterialStats(durability, miningSpeed, attackDamage, harvestLevel);
return this;
}
function unsetHead() as BuildMaterial {
this.Builder.removeHeadMaterialStats();
return this;
}
function setHandle(modifier as float, durability as int) as BuildMaterial {
this.Builder.addHandleMaterialStats(modifier, durability);
return this;
}
function unsetHandle() as BuildMaterial {
this.Builder.removeHandleMaterialStats();
return this;
}
function setExtra(extraDurability as int) as BuildMaterial {
this.Builder.addExtraMaterialStats(extraDurability);
return this;
}
function unsetExtra() as BuildMaterial {
this.Builder.removeExtraMaterialStats();
return this;
}
function setBow(drawSpeed as float, range as float, bonusDamage as float) as BuildMaterial {
this.Builder.addBowMaterialStats(drawSpeed, range, bonusDamage);
return this;
}
function unsetBow() as BuildMaterial {
this.Builder.removeBowMaterialStats();
return this;
}
function setBString(modifier as float) as BuildMaterial {
this.Builder.addBowStringMaterialStats(modifier);
return this;
}
function unsetBString() as BuildMaterial {
this.Builder.removeBowStringMaterialStats();
return this;
}
function setArrow(modifier as float, bonusAmmo as int) as BuildMaterial {
this.Builder.addArrowShaftMaterialStats(modifier, bonusAmmo);
return this;
}
function unsetArrow() as BuildMaterial {
this.Builder.removeArrowShaftMaterialStats();
return this;
}
function setFletching(accuracy as float, modifier as float) as BuildMaterial {
this.Builder.addFletchingMaterialStats(accuracy, modifier);
return this;
}
function unsetFletching() as BuildMaterial {
this.Builder.removeFletchingMaterialStats();
return this;
}
function setProjectile() as BuildMaterial {
this.Builder.addProjectileMaterialStats();
return this;
}
function unsetProjectile() as BuildMaterial {
this.Builder.removeProjectileMaterialStats();
return this;
}
function register() as Material {
return this.Builder.register();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment