1
0
Fork 0
mirror of https://github.com/xHyroM/aetheria.git synced 2024-09-19 12:53:19 +02:00

refactor: better kubejs structure

This commit is contained in:
Jozef Steinhübl 2024-06-17 20:59:21 +02:00
parent 14c7163cf1
commit e87c8550e5
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
27 changed files with 295 additions and 210 deletions

View file

@ -0,0 +1,15 @@
Find out more info on the website: https://kubejs.com/
Directory information:
assets - Acts as a resource pack, you can put any client resources in here, like textures, models, etc. Example: assets/kubejs/textures/item/test_item.png
data - Acts as a datapack, you can put any server resources in here, like loot tables, functions, etc. Example: data/kubejs/loot_tables/blocks/test_block.json
startup_scripts - Scripts that get loaded once during game startup - Used for adding items and other things that can only happen while the game is loading (Can be reloaded with /kubejs reload_startup_scripts, but it may not work!)
server_scripts - Scripts that get loaded every time server resources reload - Used for modifying recipes, tags, loot tables, and handling server events (Can be reloaded with /reload)
client_scripts - Scripts that get loaded every time client resources reload - Used for JEI events, tooltips and other client side things (Can be reloaded with F3+T)
config - KubeJS config storage. This is also the only directory that scripts can access other than world directory
exported - Data dumps like texture atlases end up here
You can find type-specific logs in logs/kubejs/ directory

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

View file

0
packwiz/1.20.1/kubejs/config/client.properties Executable file → Normal file
View file

0
packwiz/1.20.1/kubejs/config/common.properties Executable file → Normal file
View file

View file

@ -0,0 +1,13 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
[
"ad_astra:aeronos_door",
"ad_astra:strophar_door",
"ad_astra:glacian_door",
].forEach((d) => gregifyDoorRecipe(event, "<identifier>:<name>", d));
gregifyDoorRecipe(event, "<identifier>:<name>", "ad_astra:steel_door", [
"gtceu:steel_plate",
]);
});

View file

@ -1,10 +1,10 @@
ServerEvents.recipes((event) => {
const AD_ASTRA_REMOVED_PLATE_RECIPES = ["steel", "iron"];
const AD_ASTRA_REMOVED_ROD_RECIPES = ["steel"];
const AD_ASTRA_REMOVED_NUGGET_RECIPES = ["steel"];
ServerEvents.recipes((event) => {
// Remove Ad Astra recipes for plates
AD_ASTRA_REMOVED_PLATE_RECIPES.forEach((metal) => {
event.remove({

View file

@ -0,0 +1,5 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyBoatRecipe(event, "<identifier>:<name>", "aether:skyroot_boat");
});

View file

@ -0,0 +1,5 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "aether:skyroot_door");
});

View file

@ -0,0 +1,55 @@
function idToType(id) {
return id.split(":")[1].split("_").slice(0, -1).join("_");
}
function optionalNullChaining(obj, keys) {
for (const key of keys) {
if (obj[key]) return obj[key];
}
}
function gregifyBoatRecipe(event, recipePattern, id) {
const [identifier, name] = id.split(":");
const type = idToType(id);
event.remove({
id: recipePattern
.replace("<identifier>", identifier)
.replace("<name>", name)
.replace("<type>", type),
});
event.shaped(Item.of(id, 1), ["WHW", "WKW", "SSS"], {
W: `${identifier}:${type}_planks`,
H: "minecraft:wooden_shovel",
K: "#forge:tools/knives",
S: `${identifier}:${identifier === "quark" ? `${type}_planks` : type}_slab`,
});
}
function gregifyDoorRecipe(event, recipePattern, id, materials) {
const [identifier, name] = id.split(":");
const type = idToType(id);
event.remove({
id: recipePattern
.replace("<identifier>", identifier)
.replace("<name>", name)
.replace("<type>", type),
});
if (!materials) materials = [];
if (materials.length === 0) materials.push(`${identifier}:${type}_planks`);
event.shaped(Item.of(id, 1), ["WTS", "GRC", "OPB"], {
W: materials[0],
G: optionalNullChaining(materials, [1, 0]),
O: optionalNullChaining(materials, [2, 1, 0]),
P: optionalNullChaining(materials, [3, 1, 0]),
T: `${identifier}:${type}_trapdoor`,
S: "#forge:tools/screwdrivers",
R: "gtceu:iron_ring",
C: "gtceu:iron_screw",
B: "#forge:tools/saws",
});
}

View file

@ -1,82 +0,0 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
const MINECRAFT_BOATS = [
"minecraft:oak_boat", // allow only wooden shovel
"minecraft:spruce_boat", // allow only wooden shovel
"minecraft:birch_boat", // allow only wooden shovel
"minecraft:jungle_boat", // allow only wooden shovel
"minecraft:acacia_boat", // allow only wooden shovel
"minecraft:dark_oak_boat", // allow only wooden shovel
"minecraft:mangrove_boat", // allow only wooden shovel
"minecraft:cherry_boat", // allow only wooden shovel
];
const BOATS_RECIPES = [
"quark:ancient_boat",
"quark:azalea_boat",
"quark:blossom_boat",
"aether:skyroot_boat",
"thermal:rubberwood_boat",
"meadow:pine_boat",
"regions_unexplored:baobab_boat",
"regions_unexplored:blackwood_boat",
"regions_unexplored:cypress_boat",
"regions_unexplored:dead_boat",
"regions_unexplored:eucalyptus_boat",
"regions_unexplored:joshua_boat",
"regions_unexplored:kapok_boat",
"regions_unexplored:larch_boat",
"regions_unexplored:magnolia_boat",
"regions_unexplored:maple_boat",
"regions_unexplored:mauve_boat",
"regions_unexplored:palm_boat",
"regions_unexplored:pine_boat",
"regions_unexplored:redwood_boat",
"regions_unexplored:socotra_boat",
"regions_unexplored:willow_boat",
];
MINECRAFT_BOATS.forEach((b) => BOATS_RECIPES.push(b)); // spread syntax not supported
const BOATS_MOD_RECIPE_IDS_PATTERN = {
minecraft: "<identifier>:<name>",
quark: "quark:world/crafting/woodsets/<type>/boat",
aether: "<identifier>:<name>",
thermal: "<identifier>:<name>",
meadow: "<identifier>:<name>",
regions_unexplored: "<identifier>:<name>",
};
BOATS_RECIPES.forEach((recipe) => {
const [identifier, name] = recipe.split(":");
const type = name.split("_").slice(0, -1).join("_");
event.remove({
id: BOATS_MOD_RECIPE_IDS_PATTERN[identifier]
.replace("<identifier>", identifier)
.replace("<name>", name)
.replace("<type>", type),
});
if (identifier === "minecraft" || identifier === "quark") {
event.remove({
id: `quark:tweaks/crafting/utility/chest_boat/direct_${type}_chest_boat`,
});
}
event.shaped(Item.of(recipe, 1), ["WHW", "WKW", "SSS"], {
W: `${identifier}:${type}_planks`,
H: "minecraft:wooden_shovel",
K: "#forge:tools/knives",
S: `${identifier}:${
identifier === "quark" ? `${type}_planks` : type
}_slab`,
});
});
MINECRAFT_BOATS.forEach((id) => {
event.remove({ id: `gtceu:shaped/${id.split(":")[1]}` });
});
event.remove({ id: "regions_unexplored:oak_boat" });
});

View file

@ -1,82 +0,0 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
const RECIPES = {
"minecraft:iron_door": ["minecraft:iron_ingot"],
"ad_astra:steel_door": ["gtceu:steel_plate"],
"ad_astra:aeronos_door": [],
"ad_astra:strophar_door": [],
"ad_astra:glacian_door": [],
"quark:ancient_door": [],
"quark:azalea_door": [],
"quark:blossom_door": [],
"snowyspirit:gingerbread_door": ["#snowyspirit:gingerbreads"],
"vinery:dark_cherry_door": [],
"supplementaries:gold_door": ["minecraft:gold_ingot"],
"aether:skyroot_door": [],
"thermal:rubberwood_door": [],
"meadow:pine_door": [],
"meadow:pine_barn_door": ["meadow:pine_planks"],
"regions_unexplored:baobab_door": [],
"regions_unexplored:blackwood_door": [],
"regions_unexplored:blue_bioshroom_door": [],
"regions_unexplored:brimwood_door": [],
"regions_unexplored:cobalt_door": [],
"regions_unexplored:cypress_door": [],
"regions_unexplored:dead_door": [],
"regions_unexplored:eucalyptus_door": [],
"regions_unexplored:green_bioshroom_door": [],
"regions_unexplored:joshua_door": [],
"regions_unexplored:kapok_door": [],
"regions_unexplored:larch_door": [],
"regions_unexplored:magnolia_door": [],
"regions_unexplored:maple_door": [],
"regions_unexplored:mauve_door": [],
"regions_unexplored:palm_door": [],
"regions_unexplored:pine_door": [],
"regions_unexplored:pink_bioshroom_door": [],
"regions_unexplored:redwood_door": [],
"regions_unexplored:socotra_door": [],
"regions_unexplored:willow_door": [],
"regions_unexplored:yellow_bioshroom_door": [],
};
const MOD_RECIPE_IDS_PATTERN = {
minecraft: "<identifier>:<name>",
ad_astra: "<identifier>:<name>",
quark: "quark:world/crafting/woodsets/<type>/door",
snowyspirit: "<identifier>:<name>",
vinery: "<identifier>:<name>",
supplementaries: "<identifier>:<name>",
aether: "<identifier>:<name>",
thermal: "<identifier>:<name>",
meadow: "<identifier>:<name>",
regions_unexplored: "<identifier>:<name>",
};
Object.entries(RECIPES).forEach(([recipeId, materials]) => {
const [identifier, name] = recipeId.split(":");
const type = name.split("_").slice(0, -1).join("_");
event.remove({
id: MOD_RECIPE_IDS_PATTERN[identifier]
.replace("<identifier>", identifier)
.replace("<name>", name)
.replace("<type>", type),
});
if (materials.length === 0) materials.push(`${identifier}:${type}_planks`);
event.shaped(Item.of(recipeId, 1), ["WTS", "WRC", "WWB"], {
W: materials[0],
T: `${identifier}:${type}_trapdoor`,
S: "#forge:tools/screwdrivers",
R: "gtceu:iron_ring",
C: "gtceu:iron_screw",
B: "#forge:tools/saws",
});
});
event.remove({ id: "regions_unexplored:oak_door" });
});

View file

@ -0,0 +1,5 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyBoatRecipe(event, "<identifier>:<name>", "meadow:pine_boat");
});

View file

@ -0,0 +1,12 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "meadow:pine_door");
gregifyDoorRecipe(event, "<identifier>:<name>", "meadow:pine_barn_door", [
"meadow:pine_planks",
"meadow:pine_slab",
"meadow:pine_planks",
"meadow:pine_planks",
]);
});

View file

@ -0,0 +1,25 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
const boats = [
"minecraft:oak_boat", // allow only wooden shovel
"minecraft:spruce_boat", // allow only wooden shovel
"minecraft:birch_boat", // allow only wooden shovel
"minecraft:jungle_boat", // allow only wooden shovel
"minecraft:acacia_boat", // allow only wooden shovel
"minecraft:dark_oak_boat", // allow only wooden shovel
"minecraft:mangrove_boat", // allow only wooden shovel
"minecraft:cherry_boat", // allow only wooden shovel
];
boats.forEach((id) => {
gregifyBoatRecipe(event, "<identifier>:<name>", id);
event.remove({ id: `gtceu:shaped/${id.split(":")[1]}` });
event.remove({
id: `quark:tweaks/crafting/utility/chest_boat/direct_${idToType(
id
)}_chest_boat`,
});
});
});

View file

@ -0,0 +1,7 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "minecraft:iron_door", [
"minecraft:iron_ingot",
]);
});

View file

@ -0,0 +1,15 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
["quark:ancient_boat", "quark:azalea_boat", "quark:blossom_boat"].forEach(
(b) => {
gregifyBoatRecipe(event, "quark:world/crafting/woodsets/<type>/boat", b);
event.remove({
id: `quark:tweaks/crafting/utility/chest_boat/direct_${idToType(
b
)}_chest_boat`,
});
}
);
});

View file

@ -0,0 +1,8 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
["quark:ancient_door", "quark:azalea_door", "quark:blossom_door"].forEach(
(d) =>
gregifyDoorRecipe(event, "quark:world/crafting/woodsets/<type>/door", d)
);
});

View file

@ -0,0 +1,24 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
[
"regions_unexplored:baobab_boat",
"regions_unexplored:blackwood_boat",
"regions_unexplored:cypress_boat",
"regions_unexplored:dead_boat",
"regions_unexplored:eucalyptus_boat",
"regions_unexplored:joshua_boat",
"regions_unexplored:kapok_boat",
"regions_unexplored:larch_boat",
"regions_unexplored:magnolia_boat",
"regions_unexplored:maple_boat",
"regions_unexplored:mauve_boat",
"regions_unexplored:palm_boat",
"regions_unexplored:pine_boat",
"regions_unexplored:redwood_boat",
"regions_unexplored:socotra_boat",
"regions_unexplored:willow_boat",
].forEach((b) => gregifyBoatRecipe(event, "<identifier>:<name>", b));
event.remove({ id: "regions_unexplored:oak_boat" }); // remove recipe for minecraft's oak boat
});

View file

@ -0,0 +1,28 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
[
"regions_unexplored:baobab_door",
"regions_unexplored:blackwood_door",
"regions_unexplored:blue_bioshroom_door",
"regions_unexplored:brimwood_door",
"regions_unexplored:cobalt_door",
"regions_unexplored:cypress_door",
"regions_unexplored:dead_door",
"regions_unexplored:eucalyptus_door",
"regions_unexplored:green_bioshroom_door",
"regions_unexplored:joshua_door",
"regions_unexplored:kapok_door",
"regions_unexplored:larch_door",
"regions_unexplored:magnolia_door",
"regions_unexplored:maple_door",
"regions_unexplored:mauve_door",
"regions_unexplored:palm_door",
"regions_unexplored:pine_door",
"regions_unexplored:pink_bioshroom_door",
"regions_unexplored:redwood_door",
"regions_unexplored:socotra_door",
"regions_unexplored:willow_door",
"regions_unexplored:yellow_bioshroom_door",
].forEach((d) => gregifyDoorRecipe(event, "<identifier>:<name>", d));
});

View file

@ -0,0 +1,10 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(
event,
"<identifier>:<name>",
"snowyspirit:gingerbread_door",
["#snowyspirit:gingerbreads"]
);
});

View file

@ -0,0 +1,7 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "supplementaries:gold_door", [
"minecraft:gold_ingot",
]);
});

View file

@ -0,0 +1,5 @@
// Modifies the recipes for boats to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyBoatRecipe(event, "<identifier>:<name>", "thermal:rubberwood_boat");
});

View file

@ -0,0 +1,5 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "thermal:rubberwood_door");
});

2
packwiz/1.20.1/kubejs/server_scripts/thermal_gtc_integration.js vendored Executable file → Normal file
View file

@ -1,3 +1,4 @@
ServerEvents.recipes((event) => {
const THERMAL_REMOVED_PLATE_RECIPES = [
"tin",
"lead",
@ -38,7 +39,6 @@ const THERMAL_REMOVED_NUGGET_RECIPES = [
"copper",
];
ServerEvents.recipes((event) => {
// Remove Thermal Foundation recipes for plates
THERMAL_REMOVED_PLATE_RECIPES.forEach((metal) => {
event.remove({

View file

@ -0,0 +1,5 @@
// Modifies the recipes for doors to match the Gregified Integrations recipes
ServerEvents.recipes((event) => {
gregifyDoorRecipe(event, "<identifier>:<name>", "vinery:dark_cherry_door");
});