Topic category: Help with modding (Java Edition)
In this tutorial, I will be showing you how to create an end portal shaped custom portal. This does not include a feature where you need to add an eye to the block, but all you have to do there is create 2 separate blocks, one with and the other without the eye texture, and make a procedure where when the player right clicks with the eye in main hand, reduce the number of eyes in the inventory by one, and replace that block with the block that has the eye on it, with the same rotation. Anyways, to the tutorial!
First, you need to create 2 blocks and your dimension. Create your dimension with these specific settings so that only your custom portal will take you to the custom dimension:
Now, the blocks needed are the portal frame block and the portal block. For the frame, create a block with y axis rotation (from player side) enabled so that when you place it, the front faces you. The rotation is optional, but this is how end portals work and how I will be doing it. Here are the other properties that should be changed for this block as well:
The actual portal block is what spawns when the portal is complete (in this tutorial the portal will automatically fill when the blocks are placed correctly). For this block, create a block with the "slab" block base. Here are the other properties that should be changed for this block as well:
Second, the procedures. Most of these procedures are reeeaaallly long, so I will add the importable code for each procedure to this tutorial. There are 3 procedures in total. The first should be the actual creation of the portal. This code should be put in the "update tick" and the "when block added" triggers of the portal frame block. Double check you did turn on ticking for this block as shown in the picture of its advanced properties, otherwise it won't work properly. You will need to fill in your portal frame blocks inside of all the empty block selectors in the conditions in the "if" statement. And, you'll need to also fill all of the empty block selectors at the bottom of the procedure that say "place" with your portal block. Here's the code:
Next, put this code, which destroys the portal if any of the frame blocks are broken, in the "when block destroyed by player" trigger of the frame block. You will need to fill in your portal frame blocks inside of all the empty block selectors in the "place" blocks. And, you will need to fill in your portal blocks inside of all the empty block selectors in the conditions in the "if" statements. Here's the code:
Lastly, add this code to the "when entity collides in the block" trigger, which switches the dimension of the player to either your custom dimension or the surface, depending on which one you are in at that moment. You may want to tinker with the "set location" block's numbers so you aren't teleported inside a wall by chance. Here's that code:
I thought I'd also add how you can use these links, so all you have to do is download these procedures (they convert straight into procedure coding blocks), create the procedure, then hit the "import procedure" in the top right corner of the procedure editing UI. Here's a picture:
And that is pretty much it! You may want to create a central portal at the origin of your dimension using structures or some other way of getting back to the surface, or any other adjustments, but other than that this portal works both directions and fills and breaks automatically when created or destroyed. Feel free to ask questions or make comments!