apply lastest changes to 1.14 and 1.15

This commit is contained in:
Esmorall 2020-07-02 11:21:56 -03:00
parent 370af0f6f7
commit 45f26c28e9
No known key found for this signature in database
GPG Key ID: 3F4DD7CEC746EEB3
6 changed files with 10 additions and 11 deletions

View File

@ -1,6 +1,6 @@
name: EntityTrackerFixer
main: net.minemora.entitytrackerfixer.EntityTrackerFixer
version: 1.2.6
version: 1.2.7
api-version: 1.14
author: Esmorall
description: Untrack entities that are not used at all by the server.

View File

@ -29,9 +29,6 @@ public final class NMSEntityTracker {
public static void trackEntities(ChunkProviderServer cps, Set<net.minecraft.server.v1_14_R1.Entity> trackList) {
try {
for(net.minecraft.server.v1_14_R1.Entity entity : trackList) {
if(cps.playerChunkMap.trackedEntities.containsKey(entity.getId())) {
continue;
}
addEntityMethod.invoke(cps.playerChunkMap, entity);
}
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {

View File

@ -39,6 +39,10 @@ public class CheckTask extends BukkitRunnable {
int d = ConfigMain.getTrackingRange();
for(Player player : Bukkit.getWorld(worldName).getPlayers()) {
for(Entity ent : player.getNearbyEntities(d, d, d)) {
net.minecraft.server.v1_14_R1.Entity nms = ((CraftEntity)ent).getHandle();
if(cps.playerChunkMap.trackedEntities.containsKey(nms.getId()) || !nms.valid) {
continue;
}
trackAgain.add(((CraftEntity)ent).getHandle());
}
}

View File

@ -29,9 +29,6 @@ public final class NMSEntityTracker {
public static void trackEntities(ChunkProviderServer cps, Set<net.minecraft.server.v1_15_R1.Entity> trackList) {
try {
for(net.minecraft.server.v1_15_R1.Entity entity : trackList) {
if(cps.playerChunkMap.trackedEntities.containsKey(entity.getId())) {
continue;
}
addEntityMethod.invoke(cps.playerChunkMap, entity);
}
} catch (SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {

View File

@ -39,6 +39,10 @@ public class CheckTask extends BukkitRunnable {
int d = ConfigMain.getTrackingRange();
for(Player player : Bukkit.getWorld(worldName).getPlayers()) {
for(Entity ent : player.getNearbyEntities(d, d, d)) {
net.minecraft.server.v1_15_R1.Entity nms = ((CraftEntity)ent).getHandle();
if(cps.playerChunkMap.trackedEntities.containsKey(nms.getId()) || !nms.valid) {
continue;
}
trackAgain.add(((CraftEntity)ent).getHandle());
}
}

View File

@ -41,10 +41,7 @@ public class CheckTask extends BukkitRunnable {
for(Player player : Bukkit.getWorld(worldName).getPlayers()) {
for(Entity ent : player.getNearbyEntities(d, d, d)) {
net.minecraft.server.v1_16_R1.Entity nms = ((CraftEntity)ent).getHandle();
if(cps.playerChunkMap.trackedEntities.containsKey(nms.getId())) {
continue;
}
if(!nms.valid) {
if(cps.playerChunkMap.trackedEntities.containsKey(nms.getId()) || !nms.valid) {
continue;
}
trackAgain.add(nms);