[ci skip] Remove IWorldAccess list

This commit is contained in:
Sotr
2019-03-24 22:47:03 +08:00
parent 0907ab86fc
commit 41b8f59b4c
6 changed files with 138 additions and 4 deletions

View File

@@ -175,4 +175,9 @@ public class AkarinGlobalConfig {
private static void userCacheExpireDays() {
userCacheExpireDays = getSeconds(getString("core.user-cache-expire-time", "30d"));
}
public static double blockbreakAnimationVisibleDistance = 1024;
private static void blockbreakAnimationVisibleDistance() {
blockbreakAnimationVisibleDistance = Math.sqrt(getDouble("alternative.block-break-animation-visible-distance", 32.00));
}
}

View File

@@ -0,0 +1,89 @@
package io.akarin.server.core;
import lombok.RequiredArgsConstructor;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Entity;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.IBlockAccess;
import net.minecraft.server.IBlockData;
import net.minecraft.server.IWorldAccess;
import net.minecraft.server.NavigationListener;
import net.minecraft.server.ParticleParam;
import net.minecraft.server.SoundCategory;
import net.minecraft.server.SoundEffect;
import net.minecraft.server.WorldManager;
@RequiredArgsConstructor
public class AkarinWorldAccessor implements IWorldAccess {
private final WorldManager worldManager;
private final NavigationListener navigationListener;
@Override
public void a(Entity arg0) {
worldManager.a(arg0);
navigationListener.a(arg0);
}
@Override
public void a(int arg0, BlockPosition arg1, int arg2) {
worldManager.a(arg0, arg1, arg2);
}
@Override
public void a(EntityHuman arg0, int arg1, BlockPosition arg2, int arg3) {
worldManager.a(arg0, arg1, arg2, arg3);
}
@Override
public void a(IBlockAccess arg0, BlockPosition arg1, IBlockData arg2, IBlockData arg3, int arg4) {
worldManager.a(arg0, arg1, arg2, arg3, arg4);
navigationListener.a(arg0, arg1, arg2, arg3, arg4);
}
@Override
public void a(EntityHuman arg0, SoundEffect arg1, SoundCategory arg2, double arg3, double arg4, double arg5, float arg6, float arg7) {
worldManager.a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
@Override
public void b(Entity arg0) {
worldManager.b(arg0);
navigationListener.b(arg0);
}
@Override
public void b(int arg0, BlockPosition arg1, int arg2) {
worldManager.b(arg0, arg1, arg2);
}
// unused
@Override
@Deprecated
public void a(BlockPosition arg0) {
;
}
@Override
@Deprecated
public void a(SoundEffect arg0, BlockPosition arg1) {
;
}
@Override
@Deprecated
public void a(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) {
;
}
@Override
@Deprecated
public void a(ParticleParam arg0, boolean arg1, double arg2, double arg3, double arg4, double arg5, double arg6, double arg7) {
;
}
@Override
@Deprecated
public void a(ParticleParam arg0, boolean arg1, boolean arg2, double arg3, double arg4, double arg5, double arg6, double arg7, double arg8) {
;
}
}

View File

@@ -88,6 +88,7 @@ public class AkarinUserCache {
ProfileLookupCallback callbackHandler = new ProfileLookupCallback() {
@Override
public void onProfileLookupSucceeded(GameProfile gameprofile) {
LOGGER.warn("Failed to lookup player {}, using local UUID.", gameprofile.getName());
if (async)
callback.onProfileLookupSucceeded(gameprofile);
else

View File

@@ -1,6 +1,8 @@
package net.minecraft.server;
import co.aikar.timings.Timings;
import io.akarin.server.core.AkarinWorldAccessor;
import com.destroystokyo.paper.antixray.ChunkPacketBlockController; // Paper - Anti-Xray
import com.destroystokyo.paper.antixray.ChunkPacketBlockControllerAntiXray; // Paper - Anti-Xray
import com.destroystokyo.paper.event.server.ServerExceptionEvent;
@@ -97,6 +99,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public WorldProvider worldProvider;
protected NavigationListener u = new NavigationListener();
protected List<IWorldAccess> v;
private AkarinWorldAccessor worldAccessor; // Akarin
protected IChunkProvider chunkProvider;
protected final IDataManager dataManager;
public WorldData worldData;
@@ -193,7 +196,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
this.ticksPerAnimalSpawns = this.getServer().getTicksPerAnimalSpawns(); // CraftBukkit
this.ticksPerMonsterSpawns = this.getServer().getTicksPerMonsterSpawns(); // CraftBukkit
// CraftBukkit end
this.v = new CopyOnWriteArrayList<IWorldAccess>(new IWorldAccess[] { this.u}); // Akarin - ArrayList -> CopyOnWriteArrayList
this.v = Lists.newArrayList(); // Akarin
this.allowMonsters = true;
this.allowAnimals = true;
this.E = new int['\u8000'];
@@ -580,9 +583,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void notify(BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, int i) {
// Akarin start
/*
for (int j = 0; j < this.v.size(); ++j) {
((IWorldAccess) this.v.get(j)).a(this, blockposition, iblockdata, iblockdata1, i);
}
*/
worldAccessor.a(this, blockposition, iblockdata, iblockdata1, i);
// Akarin end
}
@@ -1048,9 +1056,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
// Paper end
public void a(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1) {
// Akarin start
/*
for (int i = 0; i < this.v.size(); ++i) {
((IWorldAccess) this.v.get(i)).a(entityhuman, soundeffect, soundcategory, d0, d1, d2, f, f1);
}
*/
worldAccessor.a(entityhuman, soundeffect, soundcategory, d0, d1, d2, f, f1);
// Akarin end
}
@@ -1136,9 +1149,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
protected void b(Entity entity) {
// Akarin start
/*
for (int i = 0; i < this.v.size(); ++i) {
((IWorldAccess) this.v.get(i)).a(entity);
}
*/
worldAccessor.b(entity);
// Akarin end
entity.valid = true; // CraftBukkit
entity.shouldBeRemoved = false; // Paper - shouldn't be removed after being re-added
@@ -1146,9 +1164,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
protected void c(Entity entity) {
// Akarin start
/*
for (int i = 0; i < this.v.size(); ++i) {
((IWorldAccess) this.v.get(i)).b(entity);
}
*/
worldAccessor.b(entity);
// Akarin end
new com.destroystokyo.paper.event.entity.EntityRemoveFromWorldEvent(entity.getBukkitEntity()).callEvent(); // Paper - fire while valid
entity.valid = false; // CraftBukkit
@@ -1230,7 +1253,8 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void addIWorldAccess(IWorldAccess iworldaccess) {
this.v.add(iworldaccess);
worldAccessor = new AkarinWorldAccessor((WorldManager) iworldaccess, this.u); // Akarin
//this.v.add(iworldaccess); // Akarin
}
public int a(float f) {
@@ -2933,9 +2957,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void a(int i, BlockPosition blockposition, int j) {
// Akarin start
/*
for (int k = 0; k < this.v.size(); ++k) {
((IWorldAccess) this.v.get(k)).a(i, blockposition, j);
}
*/
worldAccessor.a(i, blockposition, j);
// Akarin end
}
@@ -2945,9 +2974,14 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
public void a(@Nullable EntityHuman entityhuman, int i, BlockPosition blockposition, int j) {
try {
// Akarin start
/*
for (int k = 0; k < this.v.size(); ++k) {
((IWorldAccess) this.v.get(k)).a(entityhuman, i, blockposition, j);
}
*/
worldAccessor.a(entityhuman, i, blockposition, j);
// Akarin end
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.a(throwable, "Playing level event");
@@ -2990,11 +3024,16 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void c(int i, BlockPosition blockposition, int j) {
// Akarin start
/*
for (int k = 0; k < this.v.size(); ++k) {
IWorldAccess iworldaccess = (IWorldAccess) this.v.get(k);
iworldaccess.b(i, blockposition, j);
}
*/
worldAccessor.b(i, blockposition, j);
// Akarin end
}

View File

@@ -72,7 +72,7 @@ public class WorldManager implements IWorldAccess {
Iterator<? extends EntityHuman> iterator = list.iterator();
while (iterator.hasNext()) {
EntityHuman human = iterator.next();
if (!(human instanceof EntityPlayer) || human == entity) continue;
if (!(human instanceof EntityPlayer)) continue;
EntityPlayer entityplayer = (EntityPlayer) human;
// Paper end