Fixes compatibility with ProtocolSupport

This commit is contained in:
Sotr
2019-03-26 00:01:44 +08:00
parent 95b3a459db
commit 9a9b4c4672
2 changed files with 53 additions and 6 deletions

View File

@@ -1,5 +1,9 @@
package io.akarin.server.core;
import java.util.List;
import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import net.minecraft.server.BlockPosition;
import net.minecraft.server.Entity;
@@ -17,73 +21,113 @@ import net.minecraft.server.WorldManager;
public class AkarinWorldAccessor implements IWorldAccess {
private final WorldManager worldManager;
private final NavigationListener navigationListener;
private IWorldAccess[] customAccessors;
private boolean hasCustomAccessor;
public void add(IWorldAccess worldAccessor) {
List<IWorldAccess> accessors = Lists.newArrayList(customAccessors);
accessors.add(worldAccessor);
customAccessors = accessors.toArray(new IWorldAccess[accessors.size()]);
hasCustomAccessor = true;
}
@Override
public void a(Entity arg0) {
worldManager.a(arg0);
navigationListener.a(arg0);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0);
}
@Override
public void a(int arg0, BlockPosition arg1, int arg2) {
worldManager.a(arg0, arg1, arg2);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1, arg2);
}
@Override
public void a(EntityHuman arg0, int arg1, BlockPosition arg2, int arg3) {
worldManager.a(arg0, arg1, arg2, arg3);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.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);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.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);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
@Override
public void b(Entity arg0) {
worldManager.b(arg0);
navigationListener.b(arg0);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.b(arg0);
}
@Override
public void b(int arg0, BlockPosition arg1, int arg2) {
worldManager.b(arg0, arg1, arg2);
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.b(arg0, arg1, arg2);
}
// unused
@Override
@Deprecated
public void a(BlockPosition arg0) {
;
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0);
}
@Override
@Deprecated
public void a(SoundEffect arg0, BlockPosition arg1) {
;
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1);
}
@Override
@Deprecated
public void a(int arg0, int arg1, int arg2, int arg3, int arg4, int arg5) {
;
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1, arg2, arg3, arg4, arg5);
}
@Override
@Deprecated
public void a(ParticleParam arg0, boolean arg1, double arg2, double arg3, double arg4, double arg5, double arg6, double arg7) {
;
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
}
@Override
@Deprecated
public void a(ParticleParam arg0, boolean arg1, boolean arg2, double arg3, double arg4, double arg5, double arg6, double arg7, double arg8) {
;
if (hasCustomAccessor)
for (IWorldAccess accessor : customAccessors)
accessor.a(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
}
}

View File

@@ -1253,7 +1253,10 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
}
public void addIWorldAccess(IWorldAccess iworldaccess) {
worldAccessor = new AkarinWorldAccessor((WorldManager) iworldaccess, this.u); // Akarin
if (worldAccessor != null)
worldAccessor.add(iworldaccess);
else
worldAccessor = new AkarinWorldAccessor((WorldManager) iworldaccess, this.u); // Akarin
//this.v.add(iworldaccess); // Akarin
}