#How to create custom portals with PortalJS
321 messages Β· Page 1 of 1 (latest)
sick
Temp wiki until it gets approved on KubeJS wiki:
https://github.com/wolfieboy09/PortalJS/wiki
would be cooler if you could replace or remove existing portals
true
Can portalJS change the color of the portals? I couldn't pull that off with just hooking into the API
Yes you can with .tint(r, g, b) and with .tint(0x[hex code])
MMM I tried that back with the API, but it always gave me back the black/gray portal
I hava a idea
Portal to Alfheim but only implements it with kubejs
The Portal to Alfheim is a multiblock structure added by Botania. It allows the player to exchange certain blocks and items. Unlike most portals, the Portal to Alfheim cannot be travelled through; if the player were to stand in it, it would not teleport them anywhere.
If the portal runs out of Mana, or a part of the structure is broken, the Port...
honestly wouldnt be that hard
I did not know Botany did that π
but please add this before that
@vernal wing that isnt even a portal. that could be done in "vanilla" kjs
How to create custom portals with PortalJS
Unlike most portals, the Portal to Alfheim cannot be travelled through; if the player were to stand in it, it would not teleport them anywhere.
You can do this with
.beforeTeleportation(entity => return ShouldTP.CANCEL)
That's it, but if you want to simply create a new type of portal, you can use PortalJS, and you can even create multiple "Portal to Alfheim"
It was exactly what I thought of after seeing this method
This is a cool addon
hmm, yeah that would be possible
if i want it to run a command or some kjs code before teleporting where it doesnt teleport but instead does other shenaningans, i couild do that with this right, and then before that / after taht do the code
the before teleportation requires
ShouldTP.CONTINUE => Allow the entity to get teleported
ShouldTP.CANCEL => Do not allow the entity to get telported
You can do
.beforeTeleportation(entity => {
// your code here
return ShouldTP.CANCEL
})
Yay!
Paste version of mclo.gs/mfMtbUp from @vernal wing
Paste version of latest-snippet.log from @vernal wing
ahhh that's why
apparently I do really need a blank mixin json
@vernal wing uploading patch
yay
@vernal wing download the new one
Plans for next update or something
.onRandomTick(context => {...})Like how the nether portal spawns randomlly- "replace or remove existing portals" - @dense current
- Generate dimension at runtime π
nd what about generating dimensions at runtime :HMMM:
How would I even do that??
and i need it for my project
Library to facilitate the runtime addition and removal of minecraft dimensions. - TeamGalacticraft/DynamicDimensions
like this or something
throw an item in the portal
but with kjs implementation
updated the list
Ohhhh idea maybe
where in order to light the portal, you would need to have blocks around the portal, where you could do .canIgnite(levelOrSomething => {}) and you would have to have stuff fullfilled before it can be ignited
just an idea
Damn. 1.21. Great work regardless. This is really cool.
thanks :D
One thing that would be nice is if there were some built in functionality to just try igniting a portal of a certain type at a position. Because as it is now, It seems like if I wanted to do something like, For example, Throwing an experience bottle at the frame of the portal to ignite it, That would not be possible. Similarly, A Twilight Forest style portal opening where you toss an item through the structure would also not be possible.
Love it
There is a custom ignition source, but I'll see how to register it
Going to include infiniverse API into the mod
to do this
Should I include it or just package it with it?
Meaning like you need to have it downloaded
or I just include it...
hm
Aight
Hmmm, in the link to dimension
Maybe in there do custom(name)
And maybe some other params
Like biome
Or sum
Or, .generatecustom(name)
You can specify custom dimensions
And then inside of the .linkto(namefrombefore)
What do you mean by that
.setDestination("minecraft:the_nether")
Yeah
so it could be like
.setDestination("thing")
.preGenerate()
or something
.generateCustom(id,biome,otherParametersYouWantToAdd)
.setDestination(id)
That's what I would say
Well kind kf
But allow for void dimensions
Please
So where it would be
.generateCustom(test_void, "minecraft:void")
.setDestination(test_void)
or, .generateAndSet("test_void", "minecraft:void")
ye
That's not for 1.21 tho ?
Wait, on cf it is
Not on MR tho
Do you have the nausea effect from the portal turned off in this example or does it not work with portaljs?
The API has it on nausea, but on my PR on the API mod, I'll include a way to have it or not
yeah right here in the orignal mod
@twilit egret when can I expect the patch with infiniverseAPI?
Once I figure out how to create the entire system of generation and such π
Oke
Thanks! I was just curious because when I used the custom portal API + custom portal builder on 1.20, there is no nausea at all. So its unclear whether you are actually teleporting or not when you step into the portalπ₯²
well if you don't get teleported in less then 30 seconds, and your in the portal for a while, you know something's wrong
I may or may not backport it to 1.20.1 once I get more featurees in
That would be amazing, but I can understand if its tough to backport. Either way, thanks for making an add-on for easier custom portals with KubeJS π
I want to scream rn
having the random tick method is casuing so many errors
I hate registries
It was in the 200's some hours ago π
const ItemEntity = Java.loadClass("net.minecraft.world.entity.item.ItemEntity");
global.recipes = global.recipes || {};
global.recipes.portal = [
["#c:raw_materials/gold", "2x minecraft:gold_ingot"],
["#c:raw_materials/iron", "2x minecraft:iron_ingot"],
["#c:raw_materials/copper", "2x minecraft:copper_ingot"],
];
PortalEvents.register((event) => {
event
.create()
.frameBlock("minecraft:cherry_log")
.lightWithItem("minecraft:wheat_seeds")
.forcedSize(4, 5)
.tint(Color.LIME_DYE.rgb())
.beforeTeleportation((/**@type {$Entity_}*/ entity) => {
if (!(entity instanceof ItemEntity)) return;
const item = entity.item;
for (let [ingredient, output] of global.recipes.portal) {
if (Ingredient.of(ingredient).test(item)) {
entity.item = Item.of(output);
break;
}
}
return ShouldTP.CANCEL;
});
});
Paste version of mclo.gs/bUGFPRS from @vernal wing
I understand, I didn't install CustomPortalAPI, and this mod is not required in mods.toml
No, he is in mods.toml, but he does not detect it
hmm
I found the problem
should i put PortalJS in Oceanblock and move away from the reflection method we have been using
hmm
.lightWithItem("minecraft:wheat_seeds") not work
Or do items need any characteristics?
I forgot to add it to the release toml π
Yes!
I might look into it later today, if I get the time for it... Mainly the colored portals is what I was missing
Well you have the r, g, b and the 0xFFFFFF way (the color code hex edition)
Alright
I have released the 1.0.2 patch:
Fix the TOML to prevent mod crashes from unknown classes when a mod is not installed
fixed in 1.0.2
CustomPortalParticle... hmmm I would so need to add this
A more correct rebound!
@twilit egret I have an idea
Let us register a Block of the CustomPortalBlock type for use in customPortalBlock
yoo
But I need to fix an issue with setting a custom portal block in the builder of the api π
They have to extend CustomPortalBlock for the API to accept it, and when I try to do this.builder.customPortalBlock(() -> new PJSPortalBlock(randomConsumer));, I get registry errors
Common setup event? NAHHH
Registry event? NAHHH
Registry already frozen!!!
or
some concurrent error
Is it not registering my block???
OHHHHHH
THAT'S WHYYYY
I WAS REGISTERING IT WRONG THE ENTIRE TIME π
THE BLOCK NEVER EXISTED
public static final DeferredBlock<PJSPortalBlock> PORTAL_BLOCK = DeferredBlock.createBlock(ResourceLocation.fromNamespaceAndPath(PortalJS.MODID, "portal_block"));
I do not know how this was not causing any errors because THAT is WRONG
public static final DeferredBlock<PJSPortalBlock> PORTAL_BLOCK = BLOCKS.register("portal_block", registryName -> new PJSPortalBlock(null));
IS the correct way
https://github.com/AzureDoom/customportalapi-reforged/issues/21
Okay it may be an issue with the API lol
Would be awesome if you could disable portal creation with this
declaration: package: net.neoforged.neoforge.event.level, class: BlockEvent, class: PortalSpawnEvent
Idea accepted
I think PortalJS is the new famous mod for me as of yesterday
I will add that
good idea
So would
PortalEvents.onPortalSpawn(event => {
if (event.frame == "minecraft:obsidian") {
event.cancel()
}
})
I will see how I can replace the stuff
It will be in server scripts
Nice!
cancel anybody?
peak
reopen this discord
Just now see this π
https://trello.com/b/PNDSwOJs/portaljs
Made this
Organize anything, together. Trello is a collaboration tool that organizes your projects into boards. In one glance, know what's being worked on, who's working on what, and where something is in a process.
just create an issue?
link a project
Also, Github Projects can be displayed in multiple ways, including Trello-like card formats
like this

I was doing a thing wrong which caused it
fixed
now to figure out how to get it to summon a thing
i am also doing a lot of things wrong
Anyone want to test 1.1.0?
I haven't been keeping up but have the Cancel Portal function to disable portal creation been released yet?
Ah right, there was a thing I was trying to solve, and forgot about it π
XD
Stop slacking 

Stop hitting me in the head π
So will it be added in?
Paste version of mclo.gs/h6H4bly from @vernal wing
Did you set a dimension with the code?
WHat's your code?
@nocturne pewter Portal colors are fixed on the latest API version to let you know
i shal gib it a try later today
alright
.setDestination("dim")
I need to change the errors
where portal JS would say "Hey, you did not set X"
Ohhhh
I see what you mean now
PortalEvents.register(event => {
event.create()
.frameBlock("minecraft:infested_cobblestone")
.setDestination("minecraft:the_end")
.returnDim("minecraft:the_nether")
.tint(0xFFAAFF)
})
works fine
using this; portal tint still not workin 
New feature: Shows you errors for incorrect portal registration. (Messages will be changed to tell more info)
one mixin later you can now see what portal block is erroring
if there is no frame block, it will just be null
ORRR "No frame block set"
muahaha errors
is it gonna error if you dont have any of those set?
i'd just.. set defaults
or are those only gonna fire if they try to set a non-registered block as a frame cause if so nvm then
If it does not have anything, it will just error out on that
https://github.com/wolfieboy09/PortalJS/blob/master/src/main/java/dev/wolfieboy09/portaljs/PortalJS.java#L36 is the code in that screenshot
I just took the Portal API errors, and just kube'd it
Want to go to the end? Nice try!
when they un cancel it how will they re light the end portal?
i think its impossible cause ender eye right click only runs the code if the blockstate isnt already a filled end portal frame lol
Updating the wiki rn
I'll have to see how to not use the last eye of ender
just check how they tell when to fill in the portal shape in the ender eye item right click
its some helper method i forget which one tho
I have a mixin on the blockPatternMatch#getFrontTopLeft
@Inject(method = "useOn", at= @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/pattern/BlockPattern$BlockPatternMatch;getFrontTopLeft()Lnet/minecraft/core/BlockPos;"), cancellable = true)
private void portalCreationInjection(@NotNull UseOnContext context, CallbackInfoReturnable<InteractionResult> cir) {
BlockPos blockpos = context.getClickedPos();
CreatedPortalEvent event = new CreatedPortalEvent(context.getLevel(), blockpos, Blocks.END_PORTAL_FRAME, true);
ModLoader.postEvent(event);
if (event.isCanceled()) {
cir.setReturnValue(InteractionResult.CONSUME);
}
}
but that does the strange thing
i dont think this even needs a mixin, just get the level from your event context and cancel it by default if the block shape matches an end portal frame
The end portal does not post an event
The nether portal is the one portal that posts an event on the portal event thingy
or ig mixin to the "HEAD" or invoke of the ender pearl item right click tho forge event right click is what i'd do personally
yeah i wish they had an event for ender portal lighting, itd be so easy to add a hook there
working on the wiki rn
Contribute to wolfieboy09/PortalJS development by creating an account on GitHub.
suggestions?
started working on portaljs again
That class is for on item use
So I can do BiHolder<? super Item, Consumer<? super Item>> or however it would go
so I can do consumer.accept(the item on the left)
and such
I'm working on it π
i was forced to use that cursed script that was posted recently lol
How goes the porting? π
in the mean time, this script works just fine for me.
https://discord.com/channels/303440391124942858/1358758512116891849
am I stupid? my portal doesn't light up. I've written;
PortalEvents.register(event => {
event.create()
.frameBlock("minecraft:glowstone") // required
.lightWithWater()
.setDestination("minecraft:the_nether") // required
.forcedSize(4, 5)
})
I guess I was stupid, I should've guessed that it didn't count the corners
You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes
```js :arrow_left:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
``` :arrow_left:
This example will look like this:
ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
Sup portaljs dude
Paste version of crash-2025-08-24_19.53.37-server.txt from @forest river
got you a crash report
Haven't even started using it
ONly had it in my pack
π€£
I wanted to use it in future to remove portals if that was a thing
oh π
haha
Have fun
Oh and did you add functionality to remove a portal from working completely yet?
What about modded ones?
Mods have their own way of making portals π
Dang
You fixed shit yet`?
@twilit egret another one It lags like crazy when I try make a portal with this script
PortalEvents.onPortalSpawn(event => {
if (event.frame == "minecraft:obsidian") {
event.cancel()
}
})```
it stops it sure but lags then it crashed me when I used Fire charge
Paste version of crash-2025-08-25_09.36.41-server.txt from @forest river
What about end portals
or you mean my crash?
then yes same issue
π€£
About the snapshot, but okay π


