fix commit

This commit is contained in:
sainagh
2026-07-25 16:20:42 -05:00
parent 9396611ce0
commit c6df59caf7
3226 changed files with 209810 additions and 0 deletions
@@ -0,0 +1,92 @@
import crafttweaker.liquid.ILiquidStack;
import crafttweaker.item.IItemStack;
import crafttweaker.player.IPlayer;
import crafttweaker.text.ITextComponent;
import mods.modularmachinery.IMachineController;
import mods.modularmachinery.RecipeBuilder;
import mods.modularmachinery.RecipeCheckEvent;
import mods.modularmachinery.RecipeFinishEvent;
import scripts.advancedModulars.experience.XPConfigurator as Configurator;
import scripts.util.ModularEventUtils as Util;
// Crafting recipes
recipes.addShaped(<forge:bucketfilled>.withTag({FluidName: "bewitched_essence_salts", Amount: 1000}),
[[<contenttweaker:salt_of_knowledge>, <contenttweaker:imp_skin>, <contenttweaker:salt_of_knowledge>],
[<contenttweaker:imp_skin>, <forge:bucketfilled>.withTag({FluidName: "mana", Amount: 1000}), <contenttweaker:imp_skin>],
[<contenttweaker:salt_of_knowledge>, <contenttweaker:imp_skin>, <contenttweaker:salt_of_knowledge>]]);
recipes.addShaped(Configurator.withMode(1),
[[<actuallyadditions:item_solidified_experience>, <actuallyadditions:item_solidified_experience>, <actuallyadditions:item_solidified_experience>],
[<actuallyadditions:item_solidified_experience>, <enderio:item_yeta_wrench>, <actuallyadditions:item_solidified_experience>],
[<actuallyadditions:item_solidified_experience>, <actuallyadditions:item_solidified_experience>, <actuallyadditions:item_solidified_experience>]]);
// Item machine recipes
var xpSolidified = buildItemRecipes(<actuallyadditions:item_solidified_experience>, "xp_solidified", 8);
var xpOverworldian = buildItemRecipes(<deepmoblearning:living_matter_overworldian>, "xp_overworldian", 10);
var xpHellish = buildItemRecipes(<deepmoblearning:living_matter_hellish>, "xp_hellish", 14);
var xpExtraterrestrial = buildItemRecipes(<deepmoblearning:living_matter_extraterrestrial>, "xp_extraterrestrial", 20);
var xpTwilight = buildItemRecipes(<deepmoblearning:living_matter_twilight>, "xp_twilight", 30);
var xpBeeEssence = buildItemRecipes(<contenttweaker:condensed_essence>, "xp_bee_essence", 1000);
// Fluid machine recipes
var xpCyclic = buildFluidRecipes(<fluid:xpjuice>, "xp_cyclic", 50);
var xpIndustrialForegoing = buildFluidRecipes(<fluid:essence>, "xp_industrial_foregoing", 50);
var xpThermal = buildFluidRecipes(<fluid:experience>, "xp_thermal", 50);
// Recipe builders
function buildItemRecipes(stack as IItemStack, baseName as string, baseXP as int) {
for mode in Configurator.modes {
var xp = baseXP * mode;
var itemXPRecipe = RecipeBuilder.newBuilder(`${baseName}_${mode}x`, "xp_assimilator", 5);
itemXPRecipe.addItemInput(stack * mode)
.addItemInput(Configurator.withMode(mode))
.setChance(0.0)
.addPostCheckHandler(function(event as RecipeCheckEvent) {
checkForPlayer(event);
}
)
.addFinishHandler(function(event as RecipeFinishEvent) {
giveXPToNearest(event.controller, xp);
}
)
.addRecipeTooltip(ITextComponent.fromTranslation("tile.modularmachinery.xp_assimilator.desc", [xp]).formattedText)
.build();
}
}
function buildFluidRecipes(stack as ILiquidStack, baseName as string, baseXP as int) {
var xp = baseXP;
var fluidXPRecipe = RecipeBuilder.newBuilder(`${baseName}`, "xp_assimilator", 5);
fluidXPRecipe.addFluidInput(stack * 1000)
.addPostCheckHandler(function(event as RecipeCheckEvent) {
checkForPlayer(event);
}
)
.addFinishHandler(function(event as RecipeFinishEvent) {
giveXPToNearest(event.controller, xp);
}
)
.addRecipeTooltip(ITextComponent.fromTranslation("tile.modularmachinery.xp_assimilator.desc", [xp]).formattedText)
.build();
}
// Recipe logic
function checkForPlayer(event as RecipeCheckEvent) as void {
var pos = event.controller.pos;
// I think this is thread safe: doesn't modify world state and MMCE's task executor spins the main thread (?) during execution
var player = event.controller.world.getClosestPlayer(pos.x, pos.y, pos.z, 2, false) as IPlayer;
if (isNull(player)) {
var failureText = ITextComponent.fromTranslation("tile.modularmachinery.xp_assimilator.failure").formattedText;
event.setFailed(failureText);
}
}
function giveXPToNearest(controller as IMachineController, xp as int) {
var sender = Util.getControllerSender(controller);
var pos = controller.pos;
var command = `xp ${xp} @p[x=${pos.x},y=${pos.y},z=${pos.z}]`;
Util.scheduleTask(controller, function() as void {
server.commandManager.executeCommand(sender, command);
});
}
@@ -0,0 +1,69 @@
#priority 10
import crafttweaker.data.IData;
import crafttweaker.item.IItemStack;
import crafttweaker.text.ITextComponent;
static modes as int[] = [1, 64, 256, 1024];
<cotItem:experience_configurator>.itemRightClick = function(itemStack, world, player, hand) {
if (world.remote) {
return "PASS";
}
if (hand == "MAIN_HAND") {
var nbt as IData = itemStack.tag;
var newNBT as IData = {};
if (isNull(nbt) || isNull(nbt.mode)) {
// Set the default mode
newNBT = {
mode: modes[0] as int
} as IData;
} else if (!isNull(nbt.mode)) {
// Cycle the mode
newNBT = {
mode: cycle(nbt.mode)
} as IData;
}
// Update the mode
(itemStack as IItemStack).mutable().withTag(newNBT);
var text = ITextComponent.fromTranslation("chat.contenttweaker.xp_configurator.mode", newNBT.mode);
text.style.color = "LIGHT_PURPLE";
player.sendRichTextStatusMessage(text, true);
return "SUCCESS";
}
return "PASS";
};
<contenttweaker:experience_configurator>.addTooltip(ITextComponent.fromTranslation("item.contenttweaker.xp_configurator.desc").formattedText);
<contenttweaker:experience_configurator>.addAdvancedTooltip(function(item) {
var nbt = item.tag;
if (!(isNull(nbt) || isNull(nbt.mode))) {
var text = ITextComponent.fromTranslation("chat.contenttweaker.xp_configurator.mode", nbt.mode);
text.style.color = "LIGHT_PURPLE";
return text.formattedText;
}
return null;
});
function cycle(currentMode as int) as int {
for i in 0 to modes.length {
if (modes[i] == currentMode) {
return modes[(i + 1) % modes.length];
}
}
}
function withMode(modeIn as int) as IItemStack {
var nbt = {
mode: "Invalid mode, please report this bug!"
} as IData;
for mode in modes {
if (modeIn == mode) {
nbt = {
mode: modeIn
} as IData;
break;
}
}
return <contenttweaker:experience_configurator>.withTag(nbt);
}