Skip to content

Instantly share code, notes, and snippets.

@kindlich
Last active September 26, 2021 22:14
Show Gist options
  • Save kindlich/8a61763a31f1d2b2fa70c896bf879504 to your computer and use it in GitHub Desktop.
Save kindlich/8a61763a31f1d2b2fa70c896bf879504 to your computer and use it in GitHub Desktop.
import crafttweaker.data.IData;
import crafttweaker.item.IItemStack;
val goldBlock=<minecraft:gold_block>;
val sideItems = {
efficiency: <minecraft:potion>.withTag({Potion: "minecraft:strong_swiftness"}),
unbreaking: <minecraft:potion>.withTag({Potion: "minecraft:strong_strength"})
} as IItemStack[string];
val topItems = {
efficiency: <minecraft:potion>.withTag({Potion: "minecraft:strong_swiftness"}),
unbreaking: <minecraft:potion>.withTag({Potion: "minecraft:strong_strength"})
} as IItemStack[string];
val baseMaxLevels = {
efficiency: 5,
unbreaking: 3
} as int[string];
val enchantIDs = {
efficiency: 32,
unbreaking: 34
} as int[string];
val booksToMake = ["efficiency", "unbreaking"] as string[];
for book in booksToMake {
var enchantID = enchantIDs[book] + 0;
var baseMaxLevel = baseMaxLevels[book];
var sideItem = sideItems[book];
var topItem = topItems[book];
for fromLevel in (baseMaxLevel .. 10) {
var toLevel = fromLevel + 1;
var fromTag as IData = {StoredEnchantments: [{lvl: fromLevel, id: enchantID}]};
var toTag as IData = {StoredEnchantments: [{lvl: toLevel, id: enchantID}]};
recipes.addShaped(book ~ fromLevel ~ "_" ~ toLevel,
<minecraft:enchanted_book>.withTag(toTag),
[
[null, topItem, null],
[sideItem, <minecraft:enchanted_book>.withTag(fromTag), sideItem],
[null, goldBlock, null]
]
);
mods.jei.JEI.addItem(<minecraft:enchanted_book>.withTag(toTag));
}
}
import crafttweaker.data.IData;
import crafttweaker.item.IItemStack;
val goldBlock=<minecraft:gold_block>;
val sideItems = {
efficiency: <minecraft:potion>.withTag({Potion: "minecraft:strong_swiftness"}),
unbreaking: <minecraft:potion>.withTag({Potion: "minecraft:strong_strength"})
} as IItemStack[string];
val topItems = {
efficiency: <minecraft:potion>.withTag({Potion: "minecraft:strong_swiftness"}),
unbreaking: <minecraft:potion>.withTag({Potion: "minecraft:strong_strength"})
} as IItemStack[string];
val baseMaxLevels = {
efficiency: 5,
unbreaking: 3
} as IData[string];
val enchantIDs = {
efficiency: 32,
unbreaking: 34
} as IData[string];
val booksToMake = ["efficiency", "unbreaking"] as string[];
for book in booksToMake {
var enchantID = enchantIDs[book];
var baseMaxLevel = baseMaxLevels[book].asInt();
var sideItem = sideItems[book];
var topItem = topItems[book];
for fromLevel in baseMaxLevel .. 10 {
var toLevel = fromLevel + 1;
var fromTag as IData = {StoredEnchantments: [{lvl: fromLevel, id: enchantID}]};
var toTag as IData = {StoredEnchantments: [{lvl: toLevel, id: enchantID}]};
recipes.addShaped("alt" ~ book ~ fromLevel ~ "_" ~ toLevel,
<minecraft:enchanted_book>.withTag(toTag),
[
[null, topItem, null],
[sideItem, <minecraft:enchanted_book>.withTag(fromTag), sideItem],
[null, goldBlock, null]
]
);
mods.jei.JEI.addItem(<minecraft:enchanted_book>.withTag(toTag));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment