Compare commits

...

2 Commits

Author SHA1 Message Date
Spottedleaf
a33ac1dc01 Implement PlatformHooks#addTicketForEnderPearls
Allows implementing Paper's legacy ender pearl behavior config
option.
2025-06-20 20:24:15 -07:00
Spottedleaf
da21aeca85 Set version to 0.4.0-SNAPSHOT 2025-06-20 19:21:54 -07:00
5 changed files with 14 additions and 4 deletions

View File

@@ -273,7 +273,7 @@ public final class FabricHooks extends BaseChunkSystemHooks implements PlatformH
} }
@Override @Override
public boolean addTicketForEnderPearls() { public boolean addTicketForEnderPearls(final ServerLevel world) {
return true; return true;
} }
} }

View File

@@ -23,6 +23,6 @@ junit_version=5.11.3
fabric_lithium_version=nhc57Td2 fabric_lithium_version=nhc57Td2
neo_lithium_version=P5VT33Jo neo_lithium_version=P5VT33Jo
# Mod Properties # Mod Properties
mod_version=0.4.0-beta.2 mod_version=0.4.0-SNAPSHOT
maven_group=ca.spottedleaf.moonrise maven_group=ca.spottedleaf.moonrise
archives_base_name=moonrise archives_base_name=moonrise

View File

@@ -288,7 +288,7 @@ public final class NeoForgeHooks extends BaseChunkSystemHooks implements Platfor
} }
@Override @Override
public boolean addTicketForEnderPearls() { public boolean addTicketForEnderPearls(final ServerLevel world) {
return true; return true;
} }
} }

View File

@@ -102,7 +102,7 @@ public interface PlatformHooks extends ChunkSystemHooks {
public int modifyEntityTrackingRange(final Entity entity, final int currentRange); public int modifyEntityTrackingRange(final Entity entity, final int currentRange);
public boolean addTicketForEnderPearls(); public boolean addTicketForEnderPearls(final ServerLevel world);
public static final class Holder { public static final class Holder {
private Holder() { private Holder() {

View File

@@ -30,10 +30,12 @@ public final class ServerEntityLookup extends EntityLookup {
// been implemented, but I don't think Vanilla has proper entity add/remove hooks like we do. Fixes MC-297591 // been implemented, but I don't think Vanilla has proper entity add/remove hooks like we do. Fixes MC-297591
private static final TicketType ENDER_PEARL_TICKER = ChunkSystemTicketType.create("chunk_system:ender_pearl_ticker", null); private static final TicketType ENDER_PEARL_TICKER = ChunkSystemTicketType.create("chunk_system:ender_pearl_ticker", null);
private final Long2IntOpenHashMap enderPearlChunkCount = new Long2IntOpenHashMap(); private final Long2IntOpenHashMap enderPearlChunkCount = new Long2IntOpenHashMap();
private final boolean keepEnderPearlsTicking;
public ServerEntityLookup(final ServerLevel world, final LevelCallback<Entity> worldCallback) { public ServerEntityLookup(final ServerLevel world, final LevelCallback<Entity> worldCallback) {
super(world, worldCallback); super(world, worldCallback);
this.serverWorld = world; this.serverWorld = world;
this.keepEnderPearlsTicking = PlatformHooks.get().addTicketForEnderPearls(world);
} }
@Override @Override
@@ -136,6 +138,10 @@ public final class ServerEntityLookup extends EntityLookup {
} }
private void addEnderPearl(final long coordinate) { private void addEnderPearl(final long coordinate) {
if (!this.keepEnderPearlsTicking) {
return;
}
final int oldCount = this.enderPearlChunkCount.addTo(coordinate, 1); final int oldCount = this.enderPearlChunkCount.addTo(coordinate, 1);
if (oldCount != 0) { if (oldCount != 0) {
return; return;
@@ -145,6 +151,10 @@ public final class ServerEntityLookup extends EntityLookup {
} }
private void removeEnderPearl(final long coordinate) { private void removeEnderPearl(final long coordinate) {
if (!this.keepEnderPearlsTicking) {
return;
}
final int oldCount = this.enderPearlChunkCount.addTo(coordinate, -1); final int oldCount = this.enderPearlChunkCount.addTo(coordinate, -1);
if (oldCount != 1) { if (oldCount != 1) {
return; return;