update with upstream

This commit is contained in:
ZHAY10086
2025-06-16 20:19:53 +08:00
parent 91f960d6b0
commit 147afd6157
22 changed files with 686 additions and 440 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: "无效模式,请反馈该bug"
} as IData;
for mode in modes {
if (modeIn == mode) {
nbt = {
mode: modeIn
} as IData;
break;
}
}
return <contenttweaker:experience_configurator>.withTag(nbt);
}
@@ -0,0 +1,181 @@
#loader contenttweaker
import native.net.minecraft.util.math.BlockPos;
import crafttweaker.block.IBlockState;
import crafttweaker.player.IPlayer;
import crafttweaker.text.ITextComponent;
import crafttweaker.world.IBlockPos;
import mods.contenttweaker.Commands;
import mods.contenttweaker.VanillaFactory;
import mods.zenutils.cotx.Block;
# Bee stargate portals
var sednaportal = VanillaFactory.createExpandBlock("sedna_portal_block", <blockmaterial:glass>);
setPortalProps(sednaportal);
setPortalLogic(sednaportal, 147, true);
sednaportal.register();
var rheniaportal = VanillaFactory.createExpandBlock("rhenia_portal_block", <blockmaterial:glass>);
setPortalProps(rheniaportal);
setPortalLogic(rheniaportal, 163, true);
rheniaportal.register();
var haumeaportal = VanillaFactory.createExpandBlock("haumea_portal_block", <blockmaterial:glass>);
setPortalProps(haumeaportal);
setPortalLogic(haumeaportal, 146, true);
haumeaportal.register();
var lunaportal = VanillaFactory.createExpandBlock("luna_portal_block", <blockmaterial:glass>);
setPortalProps(lunaportal);
setPortalLogic(lunaportal, 145, true);
lunaportal.register();
var osirisportal = VanillaFactory.createExpandBlock("osiris_portal_block", <blockmaterial:glass>);
setPortalProps(osirisportal);
setPortalLogic(osirisportal, 148, true);
osirisportal.register();
var ptahportal = VanillaFactory.createExpandBlock("ptah_portal_block", <blockmaterial:glass>);
setPortalProps(ptahportal);
setPortalLogic(ptahportal, 149, true);
ptahportal.register();
var hatorportal = VanillaFactory.createExpandBlock("hator_portal_block", <blockmaterial:glass>);
setPortalProps(hatorportal);
setPortalLogic(hatorportal, 150, true);
hatorportal.register();
var europaportal = VanillaFactory.createExpandBlock("europa_portal_block", <blockmaterial:glass>);
setPortalProps(europaportal);
setPortalLogic(europaportal, 151, true);
europaportal.register();
var oiportal = VanillaFactory.createExpandBlock("oi_portal_block", <blockmaterial:glass>);
setPortalProps(oiportal);
setPortalLogic(oiportal, 152, true);
oiportal.register();
var falacerportal = VanillaFactory.createExpandBlock("falacer_portal_block", <blockmaterial:glass>);
setPortalProps(falacerportal);
setPortalLogic(falacerportal, 160, true);
falacerportal.register();
var orcusportal = VanillaFactory.createExpandBlock("orcus_portal_block", <blockmaterial:glass>);
setPortalProps(orcusportal);
setPortalLogic(orcusportal, 161, true);
orcusportal.register();
var myrmexportal = VanillaFactory.createExpandBlock("myrmex_portal_block", <blockmaterial:glass>);
setPortalProps(myrmexportal);
setPortalLogic(myrmexportal, 164, true);
myrmexportal.register();
var pixoniaportal = VanillaFactory.createExpandBlock("pixonia_portal_block", <blockmaterial:glass>);
setPortalProps(pixoniaportal);
setPortalLogic(pixoniaportal, 165, true);
pixoniaportal.register();
var proximaportal = VanillaFactory.createExpandBlock("proxima_portal_block", <blockmaterial:glass>);
setPortalProps(proximaportal);
setPortalLogic(proximaportal, 166, true);
proximaportal.register();
var neroportal = VanillaFactory.createExpandBlock("nero_portal_block", <blockmaterial:glass>);
setPortalProps(neroportal);
setPortalLogic(neroportal, 170, true);
neroportal.register();
var zoiportal = VanillaFactory.createExpandBlock("zoi_portal_block", <blockmaterial:glass>);
setPortalProps(zoiportal);
setPortalLogic(zoiportal, 171, true);
zoiportal.register();
var akathartosportal = VanillaFactory.createExpandBlock("akathartos_portal_block", <blockmaterial:glass>);
setPortalProps(akathartosportal);
setPortalLogic(akathartosportal, 172, true);
akathartosportal.register();
var pauramportal = VanillaFactory.createExpandBlock("pauram_portal_block", <blockmaterial:glass>);
setPortalProps(pauramportal);
setPortalLogic(pauramportal, 173, true);
pauramportal.register();
var alkemiaportal = VanillaFactory.createExpandBlock("alkemia_portal_block", <blockmaterial:glass>);
setPortalProps(alkemiaportal);
setPortalLogic(alkemiaportal, 174, true);
alkemiaportal.register();
# Wormhole generator portals
var taerrapiattaportal = VanillaFactory.createExpandBlock("taerrapiatta_portal_block", <blockmaterial:glass>);
setPortalProps(taerrapiattaportal);
setPortalLogic(taerrapiattaportal, 180, false);
taerrapiattaportal.register();
var diamerismaportal = VanillaFactory.createExpandBlock("diamerisma_portal_block", <blockmaterial:glass>);
setPortalProps(diamerismaportal);
setPortalLogic(diamerismaportal, 181, false);
diamerismaportal.register();
var furattoportal = VanillaFactory.createExpandBlock("furatto_portal_block", <blockmaterial:glass>);
setPortalProps(furattoportal);
setPortalLogic(furattoportal, 182, false);
furattoportal.register();
var finemportal = VanillaFactory.createExpandBlock("finem_portal_block", <blockmaterial:glass>);
setPortalProps(finemportal);
setPortalLogic(finemportal, 185, false);
finemportal.register();
var apichisiportal = VanillaFactory.createExpandBlock("apichisi_portal_block", <blockmaterial:glass>);
setPortalProps(apichisiportal);
setPortalLogic(apichisiportal, 184, false);
apichisiportal.register();
var lyndenwyrmportal = VanillaFactory.createExpandBlock("lyndenwyrm_portal_block", <blockmaterial:glass>);
setPortalProps(lyndenwyrmportal);
setPortalLogic(lyndenwyrmportal, 162, false);
lyndenwyrmportal.register();
var gallifreyportal = VanillaFactory.createExpandBlock("gallifrey_portal_block", <blockmaterial:glass>);
setPortalProps(gallifreyportal);
setPortalLogic(gallifreyportal, 624, false);
gallifreyportal.register();
function setPortalProps(block as Block) as Block {
block.setBlockHardness(-1.0);
block.setToolClass("pickaxe");
block.setPassable(true);
block.setFullBlock(false);
block.setLightValue(0.5);
block.setBlockLayer("TRANSLUCENT");
block.setLightOpacity(0);
block.setTranslucent(true);
return block;
}
// Based off end portal logic.
function setPortalLogic(block as Block, dimId as int, inSpace as bool) as Block {
block.onEntityCollidedWithBlock = function(world, pos, state, entity) {
if (world.isRemote() || world.time % 20 != 0 || !(entity instanceof IPlayer)) {
return;
}
var player as IPlayer = entity;
// CoT type -> native type
var blockPos as BlockPos = BlockPos(pos.x, pos.y, pos.z);
var entityBB = entity.native.getEntityBoundingBox();
// Ugly casting because of CoT types
var blockBB = (state as IBlockState).native.getBoundingBox(entity.world.native, blockPos);
if (!inSpace || world.getBiome(player.position as IBlockPos).name == "Space") {
if (!entity.isRiding && !entity.isBeingRidden && entityBB.intersects(blockBB.offset(blockPos))) {
Commands.call(`cofh tpx @s ${dimId}`, player, world, true, true);
Commands.call("summon astralsorcery:entitystarburst", player, world, true, true);
}
} else {
var text = ITextComponent.fromTranslation("chat.contenttweaker.stargate.NotInSpace");
text.style.color = "RED";
player.sendRichTextStatusMessage(text, true);
}
};
return block;
}
@@ -0,0 +1,294 @@
import native.net.minecraft.item.Item;
import native.net.minecraft.item.ItemStack;
import crafttweaker.block.IBlockState;
import crafttweaker.command.ICommandSender;
import crafttweaker.world.IBlockPos;
import mods.modularmachinery.RecipeBuilder;
import mods.modularmachinery.MachineTickEvent;
import mods.modularmachinery.RecipeStartEvent;
import mods.modularmachinery.MMEvents;
import mods.modularmachinery.IMachineController;
// Shared code
import scripts.util.ModularEventUtils as Util;
static offset as Util.Offset = Util.Offset(5, -4);
var portal = <ore:blockCustomPortal>;
portal.addItems([
<contenttweaker:sedna_portal_block>,
<contenttweaker:rhenia_portal_block>,
<contenttweaker:haumea_portal_block>,
<contenttweaker:luna_portal_block>,
<contenttweaker:osiris_portal_block>,
<contenttweaker:ptah_portal_block>,
<contenttweaker:hator_portal_block>,
<contenttweaker:europa_portal_block>,
<contenttweaker:oi_portal_block>,
<contenttweaker:falacer_portal_block>,
<contenttweaker:orcus_portal_block>,
<contenttweaker:myrmex_portal_block>,
<contenttweaker:pixonia_portal_block>,
<contenttweaker:proxima_portal_block>,
<contenttweaker:nero_portal_block>,
<contenttweaker:zoi_portal_block>,
<contenttweaker:akathartos_portal_block>,
<contenttweaker:pauram_portal_block>,
<contenttweaker:alkemia_portal_block>
]);
var tooltip = [
"该配方在激活时会生成一个传送门。",
"多方块结构必须位于空间站。",
"站在传送门中以进行传送。"
] as string[];
var stargatesedna = RecipeBuilder.newBuilder("stargate_sedna", "bee_stargate", 100);
stargatesedna.addItemInput(<contenttweaker:sedna_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:sedna_portal_block", "Sedna");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargaterhenia = RecipeBuilder.newBuilder("stargate_rhenia", "bee_stargate", 100);
stargaterhenia.addItemInput(<contenttweaker:rhenia_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:rhenia_portal_block", "Rhenia");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatehaumea = RecipeBuilder.newBuilder("stargate_haumea", "bee_stargate", 100);
stargatehaumea.addItemInput(<contenttweaker:haumea_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:haumea_portal_block", "Haumea");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateluna = RecipeBuilder.newBuilder("stargate_luna", "bee_stargate", 100);
stargateluna.addItemInput(<contenttweaker:luna_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:luna_portal_block", "Luna");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateosiris = RecipeBuilder.newBuilder("stargate_osiris", "bee_stargate", 100);
stargateosiris.addItemInput(<contenttweaker:osiris_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:osiris_portal_block", "Osiris");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateptah = RecipeBuilder.newBuilder("stargate_ptah", "bee_stargate", 100);
stargateptah.addItemInput(<contenttweaker:ptah_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:ptah_portal_block", "Ptah");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatehator = RecipeBuilder.newBuilder("stargate_hator", "bee_stargate", 100);
stargatehator.addItemInput(<contenttweaker:hator_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:hator_portal_block", "Hator");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateeuropa = RecipeBuilder.newBuilder("stargate_europa", "bee_stargate", 100);
stargateeuropa.addItemInput(<contenttweaker:europa_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:europa_portal_block", "Europa");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateoi = RecipeBuilder.newBuilder("stargate_oi", "bee_stargate", 100);
stargateoi.addItemInput(<contenttweaker:oi_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:oi_portal_block", "Oi");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatefalacer = RecipeBuilder.newBuilder("stargate_falacer", "bee_stargate", 100);
stargatefalacer.addItemInput(<contenttweaker:falacer_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:falacer_portal_block", "Falacer");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateorcus = RecipeBuilder.newBuilder("stargate_orcus", "bee_stargate", 100);
stargateorcus.addItemInput(<contenttweaker:orcus_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:orcus_portal_block", "Orcus");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatemyrmex = RecipeBuilder.newBuilder("stargate_myrmex", "bee_stargate", 100);
stargatemyrmex.addItemInput(<contenttweaker:myrmex_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:myrmex_portal_block", "Myrmex");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatepixonia = RecipeBuilder.newBuilder("stargate_pixonia", "bee_stargate", 100);
stargatepixonia.addItemInput(<contenttweaker:pixonia_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:pixonia_portal_block", "Pixonia");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateproxima = RecipeBuilder.newBuilder("stargate_proxima", "bee_stargate", 100);
stargateproxima.addItemInput(<contenttweaker:proximabelt_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:proxima_portal_block", "Proxima");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatenero = RecipeBuilder.newBuilder("stargate_nero", "bee_stargate", 100);
stargatenero.addItemInput(<contenttweaker:nero_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:nero_portal_block", "Nero");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatezoi = RecipeBuilder.newBuilder("stargate_zoi", "bee_stargate", 100);
stargatezoi.addItemInput(<contenttweaker:zoi_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:zoi_portal_block", "Zoi");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargateakathartos = RecipeBuilder.newBuilder("stargate_akathartos", "bee_stargate", 100);
stargateakathartos.addItemInput(<contenttweaker:akathartos_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:akathartos_portal_block", "Akathartos");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatepauram = RecipeBuilder.newBuilder("stargate_pauram", "bee_stargate", 100);
stargatepauram.addItemInput(<contenttweaker:pauram_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:pauram_portal_block", "Pauram");
}
)
.addRecipeTooltip(tooltip)
.build();
var stargatealkemia = RecipeBuilder.newBuilder("stargate_alkemia", "bee_stargate", 100);
stargatealkemia.addItemInput(<contenttweaker:alkemia_warper>).setChance(0)
.addFluidInput(<fluid:for.honey> * 100)
.addStartHandler(function(event as RecipeStartEvent) {
beeStargateRecipeStart(event.controller, "contenttweaker:alkemia_portal_block", "Alkemia");
}
)
.addRecipeTooltip(tooltip)
.build();
// Do start up sound and message if no current portal, spawn portal if different recipe, or nothing if same portal:
function beeStargateRecipeStart(controller as IMachineController, portalBlock as string, destination as string) {
var pos = offset.getCenter(controller);
var sender = Util.getControllerSender(controller);
Util.scheduleTask(controller, function() as void {
var currentPortalBlock = controller.world.getBlockState(pos);
if (currentPortalBlock != IBlockState.getBlockState(portalBlock,"")) {
if (currentPortalBlock == IBlockState.getBlockState("minecraft:air","")) {
var onlineText = '{"translate":"chat.contenttweaker.stargate.online"}';
server.commandManager.executeCommand(sender, "playsound minecraft:entity.evocation_illager.prepare_summon ambient @a " + pos.x + " " + pos.y + " " + pos.z + " 1 1");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + onlineText);
}
beeStargatePlacePortal(controller, portalBlock, pos, sender);
var destinationText = '{"translate":"chat.contenttweaker.portals.destination","with":["' + destination + '"]}';
server.commandManager.executeCommand(sender, "playsound minecraft:block.portal.trigger block @a " + pos.x + " " + pos.y + " " + pos.z + " 1 1");
server.commandManager.executeCommand(sender, "particle portal " + pos.x + " " + pos.y + " " + pos.z + " 1 1 1 0.1 1000");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + destinationText);
}
});
}
// Destroy portal if the controller is not running.
MMEvents.onMachinePostTick("bee_stargate", function(event as MachineTickEvent) {
var ctrl = event.controller;
if (ctrl.world.time % 20 != 0 || ctrl.isWorking) {
return;
}
var pos = offset.getCenter(ctrl);
Util.scheduleTask(ctrl, function() as void {
var centerState = ctrl.world.getBlockState(pos);
var itemBlock = ItemStack(Item.getItemFromBlock(centerState.block.native));
// Only clear blocks that aren't unbreakable or are known portal blocks.
if(centerState != IBlockState.getBlockState("minecraft:air","") && !isNull(itemBlock)
&& (centerState.block.definition.hardness >= 0 || itemBlock.wrapper.definition.ores has portal)) {
beeStargateClear(ctrl, pos);
}
});
});
// Clear portal blocks.
function beeStargateClear(controller as IMachineController, pos as IBlockPos) {
var sender = Util.getControllerSender(controller);
beeStargatePlacePortal(controller, "minecraft:air", pos, sender);
var offlineText = '{"translate":"chat.contenttweaker.stargate.offline"}';
server.commandManager.executeCommand(sender, "playsound minecraft:entity.evocation_illager.cast_spell ambient @a " + pos.x + " " + pos.y + " " + pos.z + " 1 0.5");
server.commandManager.executeCommand(sender, "particle smoke " + pos.x + " " + pos.y + " " + pos.z + " 1 1 1 0.1 200");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + offlineText);
}
// Places portal blocks inside the stargate frame:
function beeStargatePlacePortal(controller as IMachineController, portalBlock as string, pos as IBlockPos, sender as ICommandSender) {
var facing = controller.facing;
var dx = 0;
var dz = 0;
// The plane direction
if (facing == crafttweaker.world.IFacing.north() || facing == crafttweaker.world.IFacing.south()) { dx = 1; }
else { dz = 1; }
server.commandManager.executeCommand(sender, "fill " + (pos.x - dx) + " " + (pos.y - 1) + " " + (pos.z - dz) + " " + (pos.x + dx) + " " + (pos.y + 1) + " " + (pos.z + dz) + " " + portalBlock);
}
@@ -0,0 +1,157 @@
import native.net.minecraft.item.Item;
import native.net.minecraft.item.ItemStack;
import crafttweaker.block.IBlockState;
import crafttweaker.command.ICommandSender;
import crafttweaker.world.IBlockPos;
import mods.modularmachinery.RecipeBuilder;
import mods.modularmachinery.MachineTickEvent;
import mods.modularmachinery.RecipeStartEvent;
import mods.modularmachinery.MMEvents;
import mods.modularmachinery.IMachineController;
// Shared code
import scripts.util.ModularEventUtils as Util;
static offset as Util.Offset = Util.Offset(4, -3);
var portal = <ore:blockCustomPortal>;
portal.addItems([
<contenttweaker:taerrapiatta_portal_block>,
<contenttweaker:diamerisma_portal_block>,
<contenttweaker:furatto_portal_block>,
<contenttweaker:finem_portal_block>,
<contenttweaker:apichisi_portal_block>,
<contenttweaker:lyndenwyrm_portal_block>,
<contenttweaker:gallifrey_portal_block>
]);
var tooltip = [
"该配方在激活时会生成一个传送门。",
"站在传送门中以进行传送。"
] as string[];
var wormholetaerrapiatta = RecipeBuilder.newBuilder("wormholetaerrapiatta","wormhole_field_generator",100);
wormholetaerrapiatta.addItemInput(<contenttweaker:taerrapiatta_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:taerrapiatta_portal_block", "Taerrapiatta");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholediamerisma = RecipeBuilder.newBuilder("wormholediamerisma","wormhole_field_generator",100);
wormholediamerisma.addItemInput(<contenttweaker:diamerisma_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:diamerisma_portal_block", "Diamerisma");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholefuratto = RecipeBuilder.newBuilder("wormholefuratto","wormhole_field_generator",100);
wormholefuratto.addItemInput(<contenttweaker:furatto_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:furatto_portal_block", "Furatto");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholefinem = RecipeBuilder.newBuilder("wormholefinem","wormhole_field_generator",100);
wormholefinem.addItemInput(<contenttweaker:finem_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:finem_portal_block", "Finem");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholeapichisi = RecipeBuilder.newBuilder("wormholeapichisi","wormhole_field_generator",100);
wormholeapichisi.addItemInput(<contenttweaker:apichisi_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:apichisi_portal_block", "Apichisi");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholelyndenwyrm = RecipeBuilder.newBuilder("wormholelyndenwyrm","wormhole_field_generator",100);
wormholelyndenwyrm.addItemInput(<contenttweaker:lyndenwyrm_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:lyndenwyrm_portal_block", "Lyndenwyrm");
}
)
.addRecipeTooltip(tooltip)
.build();
var wormholegallifrey = RecipeBuilder.newBuilder("wormholegallifrey","wormhole_field_generator",100);
wormholegallifrey.addItemInput(<contenttweaker:gallifrey_warper>).setChance(0)
.addEnergyPerTickInput(10000)
.addStartHandler(function(event as RecipeStartEvent) {
wormholeGeneratorRecipeStart(event.controller, "contenttweaker:gallifrey_portal_block", "Gallifrey");
}
)
.addRecipeTooltip(tooltip)
.build();
// Do start up sound and message if no current portal, spawn portal if different recipe, or nothing if same portal:
function wormholeGeneratorRecipeStart(controller as IMachineController, portalBlock as string, destination as string) {
var pos = offset.getCenter(controller);
var sender = Util.getControllerSender(controller);
Util.scheduleTask(controller, function() as void {
var currentPortalBlock = controller.world.getBlockState(pos);
if (currentPortalBlock != IBlockState.getBlockState(portalBlock,"")) {
if (currentPortalBlock == IBlockState.getBlockState("minecraft:air","")) {
var onlineText = '{"translate":"chat.contenttweaker.wormhole_generator.online"}';
server.commandManager.executeCommand(sender, "playsound minecraft:entity.evocation_illager.prepare_summon ambient @a " + pos.x + " " + pos.y + " " + pos.z + " 1 1");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + onlineText);
}
wormholeGeneratorPlacePortal(controller, portalBlock, pos, sender);
var destinationText = '{"translate":"chat.contenttweaker.portals.destination","with":["' + destination + '"]}';
server.commandManager.executeCommand(sender, "playsound minecraft:block.portal.trigger block @a " + pos.x + " " + pos.y + " " + pos.z + " 1 1");
server.commandManager.executeCommand(sender, "particle portal " + pos.x + " " + pos.y + " " + pos.z + " 1 1 1 0.1 1000");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + destinationText);
}
});
}
// Destroy portal if the controller is not running.
MMEvents.onMachinePostTick("wormhole_field_generator", function(event as MachineTickEvent) {
var ctrl = event.controller;
if (ctrl.world.time % 20 != 0 || ctrl.isWorking) {
return;
}
var pos = offset.getCenter(ctrl);
Util.scheduleTask(ctrl, function() as void {
var centerState = ctrl.world.getBlockState(pos);
var itemBlock = ItemStack(Item.getItemFromBlock(centerState.block.native));
// Only clear blocks that aren't unbreakable or are known portal blocks.
if(centerState != IBlockState.getBlockState("minecraft:air","") && !isNull(itemBlock)
&& (centerState.block.definition.hardness >= 0 || itemBlock.wrapper.definition.ores has portal)) {
wormholeGeneratorClear(ctrl, pos);
}
});
});
// Clear portal blocks.
function wormholeGeneratorClear(controller as IMachineController, pos as IBlockPos) {
var sender = Util.getControllerSender(controller);
wormholeGeneratorPlacePortal(controller, "minecraft:air", pos, sender);
var offlineText = '{"translate":"chat.contenttweaker.wormhole_generator.offline"}';
server.commandManager.executeCommand(sender, "playsound minecraft:entity.evocation_illager.cast_spell ambient @a " + pos.x + " " + pos.y + " " + pos.z + " 1 0.5");
server.commandManager.executeCommand(sender, "particle smoke " + pos.x + " " + pos.y + " " + pos.z + " 1 1 1 0.1 200");
server.commandManager.executeCommand(sender, 'execute @a[x=' + pos.x + ',y=' + pos.y + ',z=' + pos.z + ',r=25] ~ ~ ~ tellraw @s ' + offlineText);
}
// Places portal blocks inside the wormhole area:
function wormholeGeneratorPlacePortal(controller as IMachineController, portalBlock as string, pos as IBlockPos, sender as ICommandSender) {
var facing = controller.facing;
server.commandManager.executeCommand(sender, "fill " + (pos.x - 1) + " " + (pos.y - 1) + " " + (pos.z - 1) + " " + (pos.x + 1) + " " + (pos.y + 1) + " " + (pos.z + 1) + " " + portalBlock);
}