mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-21 11:46:46 +01:00
Fixed the server not making entities ticking in the loaded chunks of the loaders
This commit is contained in:
parent
a13e760e8b
commit
723558145c
@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
import net.minecraft.server.v1_12_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_12_R1.EnumGamemode;
|
||||
@ -33,14 +34,16 @@ import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
public ChunkLoaderNPC(Location location, UUID uuid){
|
||||
public ChunkLoaderNPC(Location location, UUID uuid) {
|
||||
super(((CraftServer) Bukkit.getServer()).getServer(),
|
||||
((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
|
||||
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
|
||||
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
|
||||
@ -52,7 +55,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
world.players.add(this);
|
||||
((WorldServer) world).getPlayerChunkMap().addPlayer(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -62,7 +65,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,7 +90,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager{
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
private static Field socketAddressField;
|
||||
@ -103,7 +106,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
}
|
||||
}
|
||||
|
||||
DummyNetworkManager(){
|
||||
DummyNetworkManager() {
|
||||
super(EnumProtocolDirection.SERVERBOUND);
|
||||
updateFields();
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_16_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_16_R3.EnumGamemode;
|
||||
import net.minecraft.server.v1_16_R3.EnumProtocolDirection;
|
||||
@ -32,7 +33,7 @@ import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -42,6 +43,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
|
||||
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
|
||||
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
|
||||
@ -54,7 +57,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
((WorldServer) world).addPlayerJoin(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -64,7 +67,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,6 +4,7 @@ import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -30,17 +31,19 @@ import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPC(MinecraftServer minecraftServer, Location location, UUID uuid){
|
||||
public ChunkLoaderNPC(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
|
||||
@ -53,7 +56,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
((WorldServer) getWorld()).addPlayerJoin(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,17 +66,16 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB cs() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Entity.RemovalReason removalReason) {
|
||||
if(!dieCall) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
removePlayer(getWorldServer(), this);
|
||||
dieCall = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
@ -88,13 +90,13 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer){
|
||||
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
|
||||
worldServer.a(entityPlayer, RemovalReason.d);
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
DummyNetworkManager(){
|
||||
DummyNetworkManager() {
|
||||
super(EnumProtocolDirection.a);
|
||||
this.k = new DummyChannel();
|
||||
this.l = null;
|
||||
|
@ -7,6 +7,7 @@ import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.enti
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -34,9 +35,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +47,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
|
@ -7,6 +7,7 @@ import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.enti
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -34,9 +35,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +47,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
|
@ -7,6 +7,7 @@ import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.enti
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -34,9 +35,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +47,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
remappedName = "cz")
|
||||
@Override
|
||||
public AxisAlignedBB cz() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
|
@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_8_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_8_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_8_R3.DamageSource;
|
||||
import net.minecraft.server.v1_8_R3.EntityPlayer;
|
||||
import net.minecraft.server.v1_8_R3.EnumProtocolDirection;
|
||||
@ -33,7 +34,7 @@ import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
public ChunkLoaderNPC(Location location, UUID uuid) {
|
||||
super(((CraftServer) Bukkit.getServer()).getServer(),
|
||||
@ -41,6 +42,9 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
|
||||
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(location.getX(), location.getY(), location.getZ(),
|
||||
location.getX() + 1, location.getY() + 1, location.getZ() + 1);
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
|
||||
playerInteractManager.setGameMode(WorldSettings.EnumGamemode.CREATIVE);
|
||||
@ -60,7 +64,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
world.players.add(this);
|
||||
((WorldServer) world).getPlayerChunkMap().addPlayer(this);
|
||||
|
||||
super.a(EMPTY_BOUND);
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -70,7 +74,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
return EMPTY_BOUND;
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user