Skip to content

Commit

Permalink
build: 1.21.2-pre1
Browse files Browse the repository at this point in the history
  • Loading branch information
ishland committed Oct 9, 2024
1 parent 4bdbdaf commit 8bbc7ff
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 280 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/versions.html
minecraft_version=24w38a
yarn_mappings=24w38a+build.5
minecraft_version=1.21.2-pre1
yarn_mappings=1.21.2-pre1+build.3
loader_version=0.16.5

# Mod Properties
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.ishland.vmp.common.chunkwatching.AreaPlayerChunkWatchingManager;
import com.ishland.vmp.common.playerwatching.TACSExtension;
import com.ishland.vmp.mixins.access.IThreadedAnvilChunkStorage;
import io.papermc.paper.util.MCUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.LivingEntity;
Expand All @@ -16,7 +15,6 @@
import net.minecraft.server.world.ServerChunkManager;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.ChunkSectionPos;
import net.minecraft.util.profiler.Profiler;
import net.minecraft.world.MutableWorldProperties;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.World;
Expand All @@ -25,9 +23,7 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import java.util.Set;
import java.util.function.Predicate;
import java.util.function.Supplier;

@Mixin(ServerWorld.class)
public abstract class MixinServerWorld extends World implements StructureWorldAccess {
Expand Down Expand Up @@ -68,53 +64,6 @@ public PlayerEntity getClosestPlayer(double x, double y, double z, double maxDis
return nearestPlayer;
}

@Nullable
@Override
public PlayerEntity getClosestPlayer(TargetPredicate targetPredicate, LivingEntity entity) {
return this.getClosestPlayer(targetPredicate, entity, entity.getX(), entity.getY(), entity.getZ());
}

@Nullable
@Override
public PlayerEntity getClosestPlayer(TargetPredicate targetPredicate, LivingEntity entity, double x, double y, double z) {
final Object[] playersWatchingChunkArray = getPlayersWatchingChunkArray(x, z);

ServerPlayerEntity nearestPlayer = null;
double nearestDistance = Double.MAX_VALUE;
for (Object __player : playersWatchingChunkArray) {
if (__player instanceof ServerPlayerEntity player) {
if (targetPredicate == null || targetPredicate.test(entity, player)) {
final double distance = player.squaredDistanceTo(x, y, z);
if (distance < nearestDistance) {
nearestDistance = distance;
nearestPlayer = player;
}
}
}
}

return nearestPlayer;
}

private Object[] getPlayersWatchingChunkArray(double x, double z) {
final ServerChunkLoadingManager threadedAnvilChunkStorage = this.getChunkManager().chunkLoadingManager;
final AreaPlayerChunkWatchingManager playerChunkWatchingManager = ((TACSExtension) threadedAnvilChunkStorage).getAreaPlayerChunkWatchingManager();
final int chunkX = ChunkSectionPos.getSectionCoord(x);
final int chunkZ = ChunkSectionPos.getSectionCoord(z);

// no maxDistance here so just search within the range,
// and hopefully it works

final Object[] playersWatchingChunkArray = playerChunkWatchingManager.getPlayersInGeneralAreaMap(MCUtil.getCoordinateKey(chunkX, chunkZ));
return playersWatchingChunkArray;
}

@Nullable
@Override
public PlayerEntity getClosestPlayer(TargetPredicate targetPredicate, double x, double y, double z) {
return this.getClosestPlayer(targetPredicate, null, x, y, z);
}

@Override
public boolean isPlayerInRange(double x, double y, double z, double range) {
final ServerChunkLoadingManager threadedAnvilChunkStorage = this.getChunkManager().chunkLoadingManager;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/vmp.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ accessible class net/minecraft/server/world/ServerChunkLoadingManager$Enti
accessible class net/minecraft/server/world/ServerChunkLoadingManager$TicketManager
accessible class net/minecraft/world/SpawnDensityCapper$DensityCap
accessible class net/minecraft/server/command/SpreadPlayersCommand$Pile
accessible class net/minecraft/server/command/TeleportCommand$LookTarget

extendable class net/minecraft/server/world/ChunkTicket
extendable class net/minecraft/server/world/PlayerChunkWatchingManager
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/vmp.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"access.IChunkHolder",
"access.IChunkTicket",
"access.IClientConnection",
"access.IEntityPositionS2CPacket",
"access.IEntityTrackerEntry",
"access.IPointOfInterestSet",
"access.IServerChunkManager",
Expand All @@ -25,7 +24,6 @@
"chunk.loading.MixinPointOfInterestStorage",
"chunk.loading.commands.MixinCommandFunctionManager",
"chunk.loading.commands.MixinSpreadPlayersCommand",
"chunk.loading.commands.MixinTeleportCommand",
"chunk.ticking.MixinServerWorld",
"entity.move_zero_velocity.MixinEntity",
"entitytracker.MixinThreadedAnvilChunkStorage",
Expand Down

0 comments on commit 8bbc7ff

Please sign in to comment.