PortalProcessor .java

net.minecraft.world.entity.PortalProcessor (class): members: processPortalTeleportation, setAsInsidePortalThisTick, getPortalLocalTransition, isSamePortal.

net.minecraft.world.entityclass71 linescommon1.9 KB

API Surface (9)

boolean processPortalTeleportation(final ServerLevel serverLevel, final Entity entity, final boolean allowedToTeleport)
Portal.Transition getPortalLocalTransition()
boolean hasExpired()
BlockPos getEntryPosition()
void updateEntryPosition(final BlockPos entryPosition)
int getPortalTime()
boolean isInsidePortalThisTick()
void setAsInsidePortalThisTick(final boolean insidePortal)
boolean isSamePortal(final Portal portal)

Fields & Constants (4)

portal
entryPosition
portalTime
insidePortalThisTick

Code Graph: Dependencies (5)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

PortalProcessor.java71 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.entity;
2
3
import net.minecraft.core.BlockPos;
4
import net.minecraft.server.level.ServerLevel;
5
import net.minecraft.world.level.block.Portal;
6
import net.minecraft.world.level.portal.TeleportTransition;
7
import org.jspecify.annotations.Nullable;
8
9
public class PortalProcessor {
10
	private final Portal portal;
11
	private BlockPos entryPosition;
12
	private int portalTime;
13
	private boolean insidePortalThisTick;
14
15
	public PortalProcessor(final Portal portal, final BlockPos portalEntryPosition) {
16
		this.portal = portal;
17
		this.entryPosition = portalEntryPosition;
18
		this.insidePortalThisTick = true;
19
	}
20
21
	public boolean processPortalTeleportation(final ServerLevel serverLevel, final Entity entity, final boolean allowedToTeleport) {
22
		if (!this.insidePortalThisTick) {
23
			this.decayTick();
24
			return false;
25
		} else {
26
			this.insidePortalThisTick = false;
27
			return allowedToTeleport && this.portalTime++ >= this.portal.getPortalTransitionTime(serverLevel, entity);
28
		}
29
	}
30
31
	public @Nullable TeleportTransition getPortalDestination(final ServerLevel serverLevel, final Entity entity) {
32
		return this.portal.getPortalDestination(serverLevel, entity, this.entryPosition);
33
	}
34
35
	public Portal.Transition getPortalLocalTransition() {
36
		return this.portal.getLocalTransition();
37
	}
38
39
	private void decayTick() {
40
		this.portalTime = Math.max(this.portalTime - 4, 0);
41
	}
42
43
	public boolean hasExpired() {
44
		return this.portalTime <= 0;
45
	}
46
47
	public BlockPos getEntryPosition() {
48
		return this.entryPosition;
49
	}
50
51
	public void updateEntryPosition(final BlockPos entryPosition) {
52
		this.entryPosition = entryPosition;
53
	}
54
55
	public int getPortalTime() {
56
		return this.portalTime;
57
	}
58
59
	public boolean isInsidePortalThisTick() {
60
		return this.insidePortalThisTick;
61
	}
62
63
	public void setAsInsidePortalThisTick(final boolean insidePortal) {
64
		this.insidePortalThisTick = insidePortal;
65
	}
66
67
	public boolean isSamePortal(final Portal portal) {
68
		return this.portal == portal;
69
	}
70
}
71

Decompiled Minecraft 26.3 source of PortalProcessor (net/minecraft/world/entity/PortalProcessor.java) with Mojang official mappings, stored verbatim on the site.