Skip to content

Teleport Entities to Correct World#182

Merged
dumptruckman merged 1 commit into
masterfrom
entities
Oct 6, 2020
Merged

Teleport Entities to Correct World#182
dumptruckman merged 1 commit into
masterfrom
entities

Conversation

@nicegamer7

Copy link
Copy Markdown
Member

This PR makes it so that when an entity enters a portal, they are teleported to the correct world. This fixes #72.

Note, this PR is equivalent to #156, but is rebased on the event_tweaks branch. I will not be making any further changes.

@nicegamer7 nicegamer7 force-pushed the entities branch 3 times, most recently from 34bc451 to 354718a Compare October 5, 2020 16:56
dumptruckman
dumptruckman previously approved these changes Oct 6, 2020

@dumptruckman dumptruckman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome. Nice to see this super old request tackled.

Comment on lines +128 to +170
@Nullable
private Location getLocation(Entity e, Location currentLocation, PortalType type, String currentWorld, String linkedWorld) {
Location newTo;
if (currentWorld.equalsIgnoreCase(linkedWorld)) {
newTo = null;
} else if (linkedWorld != null) {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, linkedWorld, e);
} else if (this.nameChecker.isValidNetherName(currentWorld)) {
if (type == PortalType.NETHER) {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getNormalName(currentWorld, PortalType.NETHER), e);
} else {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getEndName(this.nameChecker.getNormalName(currentWorld, PortalType.NETHER)), e);
}
} else if (this.nameChecker.isValidEndName(currentWorld)) {
if (type == PortalType.NETHER) {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getNetherName(this.nameChecker.getNormalName(currentWorld, PortalType.ENDER)), e);
} else {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getNormalName(currentWorld, PortalType.ENDER), e);
}
} else {
if (type == PortalType.ENDER) {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getEndName(currentWorld), e);
} else {
newTo = this.linkChecker.findNewTeleportLocation(currentLocation, this.nameChecker.getNetherName(currentWorld), e);
}
}

return newTo;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cognitive complexity is quite high for this method. It could be a good place to introduce a new class to handle this.

Base automatically changed from event_tweaks to master October 6, 2020 02:45
@dumptruckman dumptruckman dismissed their stale review October 6, 2020 02:45

The base branch was changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mobs not moving through Nether Portals

2 participants