> For the complete documentation index, see [llms.txt](https://astaspastagam.gitbook.io/dimensions-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://astaspastagam.gitbook.io/dimensions-api/reference/api-reference/portalgeometry.md).

# PortalGeometry

{% hint style="warning" %}
PortalGeometry will change in a future update
{% endhint %}

## Why would I make a PortalGeometry

If you want portals with weird patterns or weird orientation, etc then you need to override the Dimensions PortalGeometry

{% hint style="info" %}
For example HorizontalPortalsAddon uses its own PortalGeometry
{% endhint %}

## How do I make a custom PortalGeometry

First, you need to create a new class and extend it PortalGeometry

Apart from the constructor, the class **requires** a few other fields to be overridden in order to function properly:

```java
//Return a new instance of your class
public PortalGeometry createGeometry(Vector min, Vector max)

//Return a new instance of your class
//(this method is used to actually find the portal structure)
public PortalGeometry getPortal(CustomPortal customPortal, Location loc)

//Use this method to check if the player is inside the portal
public boolean isInside(Location location, boolean outside, boolean corner)

//Use this to build an exit portal (not that the newLocation is the bottom corner of the portal)
public void buildPortal(Location newLocation, World destinationWorld, CustomPortal customPortal)
```

Example:

```java
public class CustomPortalGeometry extends PortalGeometry {
	
	protected CustomPortalGeometry(Vector min, Vector max) {
		super(min, max);
		
		//If you change these min or max Vectors then you MUST update the bounding box with
		//If you dont, entities will teleport using the default bounding box generated by the min/max vectors
		//getBoundingBox().copy(BoundingBox.of(getInsideMin(), getInsideMax()));
	}
	
	//This method is required if you want Dimensiosn to actually use your custom PortalGeometry
	public PortalGeometry createGeometry(Vector min, Vector max) {
		return new CustomPortalGeometry(min, max);
	}
	
	public PortalGeometry getPortal(CustomPortal customPortal, Location loc) {
		 
		//Do some math and some geometry and when you have the min/max of the portal, you can create a new instance of your PortalGeometry
		//Even if your portal is not a rectangle, you will need to provide with a min/max and do some extra checking when a portal is used
		
		return new CustomPortalGeometry(min, max);		 
	}

	//Use this to check if the player is inside the portal
	public boolean isInside(Location location, boolean outside, boolean corner) {
		
		//Do your thing here and return true if the player is inside the portal
		//If outside is true, then you MUST include the frame of the portal or else the plugin might not function properly
		//Same goes for corner
		return false;
	}
	
	@Override
	public void buildPortal(Location newLocation, World destinationWorld, CustomPortal customPortal) {
		
		//Now we need to build an exit portal
		//Do your thing and build a portal but remember that newLocation is the PortalGeometry#min
		//So you need to build the portal moving up and +x or +z (depending on portal Axis)
		
	}
}

```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://astaspastagam.gitbook.io/dimensions-api/reference/api-reference/portalgeometry.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
