Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lamp drops and recipes #431

Merged
merged 2 commits into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
171 changes: 167 additions & 4 deletions kubejs/server_scripts/yttr_block_fix.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//Block Drop Fixes
onEvent("block.loot_tables", (event) => {
[
["yttr:yttrium_block"],
Expand Down Expand Up @@ -75,15 +76,177 @@ onEvent("block.loot_tables", (event) => {
["yttr:black_project_table"],
["yttr:neodymium_slab"],
["yttr:neodymium_block"],
["yttr:lamp"],
["yttr:fixture"],
["yttr:cage_lamp"],
["yttr:panel"],
["yttr:aware_hopper"],
["yttr:levitation_chamber"],
["yttr:magtank"],
["yttr:dsu"],
].forEach((loot) => {
event.addSimpleBlock(loot[0], loot[0]);
});
//Lamp Blocks
const lampColors = [ //don't include colorless
"white",
"orange",
"magenta",
"light_blue",
"yellow",
"lime",
"pink",
"gray",
"light_gray",
"cyan",
"purple",
"blue",
"brown",
"green",
"red",
"black",
"teal"
];
[
"yttr:lamp",
"yttr:fixture",
"yttr:cage_lamp",
"yttr:panel"
].forEach((lamp) => {
event.addJson(lamp, {
type: "minecraft:block",
pools: [
{
rolls: 1,
bonus_rolls: 0,
entries: [
{
type: "minecraft:item",
name: lamp,
functions: [
{
function: "minecraft:set_nbt",
tag: "{Inverted: false, LampColor: \"colorless\"}"
},
{
function: "minecraft:set_nbt",
tag: "{Inverted: true}",
conditions: [
{
block: lamp,
condition: "minecraft:block_state_property",
properties: {
inverted: true
}
}
]
}
].concat(lampColors.map(color=>{
return {
function: "minecraft:set_nbt",
tag: `{LampColor: \"${color}\"}`,
conditions: [
{
block: lamp,
condition: "minecraft:block_state_property",
properties: {
color: color
}
}
]
}
}))
}
],
conditions: [
{
condition: "minecraft:survives_explosion"
}
]
}
]
})
})
});

//Lamp Recipe Fixes
onEvent("recipes", (event) => {

const lampTypes = [
"lamp",
"fixture",
"cage_lamp",
"panel"
];
const lampColors = [ //don't include colorless
["white", "$minecraft:white_dye"],
["orange", "minecraft:orange_dye"],
["magenta", "minecraft:white_dye"],
["light_blue", "minecraft:light_blue_dye"],
["yellow", "minecraft:yellow_dye"],
["lime", "minecraft:lime_dye"],
["pink", "minecraft:pink_dye"],
["gray", "minecraft:gray_dye"],
["light_gray", "minecraft:light_gray_dye"],
["cyan", "minecraft:cyan_dye"],
["purple", "minecraft:purple_dye"],
["blue", "minecraft:blue_dye"],
["brown", "minecraft:brown_dye"],
["green", "minecraft:green_dye"],
["red", "minecraft:red_dye"],
["black", "minecraft:black_dye"],
["teal", "yttr:yttrium_dust"]
];


//Lamp recipe fixes
lampTypes.forEach(lamp=>{
//this recipe is shaped for some reason
event.remove({id:`yttr:crafting/lamp/${lamp}_invert`});
//this recipe doesn't even work
event.remove({id:`yttr:crafting/lamp/${lamp}_dye`});

//recreate lamp inversion recipe as a shapeless one. Also make it not consume the redstone torch
event.shapeless(
Item.of(`yttr:${lamp}`).withNBT('{Inverted:true, LampColor:\"colorless\"}'),
[
`yttr:${lamp}`,
'minecraft:redstone_torch'
]
)
.modifyResult((grid, result)=>{
let item = grid.find(Ingredient.of(`yttr:${lamp}`).ignoreNBT());
let inputNbt = item.nbt || {};

let outputNbt = {};
outputNbt.Inverted = !inputNbt.Inverted;
outputNbt.LampColor = inputNbt.LampColor || "colorless";
return result.withNBT(outputNbt);
})
.keepIngredient("minecraft:redstone_torch")
.id(`createastral:crafting/yttr/lamp/${lamp}_invert`)

//Create lamp dyeing recipes that actually work
event.shapeless(
Item.of(`yttr:${lamp}`).withNBT('{Inverted:false, LampColor:\"white\"}'),
[
`yttr:${lamp}`,
'#yttr:lamp_dyes'
]
)
.modifyResult((grid, result)=>{
let item = grid.find(Ingredient.of(`yttr:${lamp}`).ignoreNBT());
let dye = grid.find(`#yttr:lamp_dyes`);
let inputNbt = item.nbt || {};

let outputNbt = {};

outputNbt.Inverted = !!inputNbt.Inverted;
for (let i=0;i<lampColors.length;++i) {
if (dye.getId()===lampColors[i][1]) {
outputNbt.LampColor = lampColors[i][0];
break;
}
}

return result.withNBT(outputNbt);
})
.id(`createastral:crafting/yttr/lamp/${lamp}_dye`)
})
})
Loading