Merge branch 'master' into dev

This commit is contained in:
OmerBenGera 2022-08-12 13:36:25 +03:00
commit 4ee9bc0960
7 changed files with 52 additions and 37 deletions

View File

@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_12_R1.AxisAlignedBB; 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.DamageSource;
import net.minecraft.server.v1_12_R1.EntityPlayer; import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumGamemode; 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 { 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(), super(((CraftServer) Bukkit.getServer()).getServer(),
((CraftWorld) location.getWorld()).getHandle(), ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle())); new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
playerConnection = new DummyPlayerConnection(server, this); playerConnection = new DummyPlayerConnection(server, this);
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE); this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
@ -52,7 +55,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
world.players.add(this); world.players.add(this);
((WorldServer) world).getPlayerChunkMap().addPlayer(this); ((WorldServer) world).getPlayerChunkMap().addPlayer(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Override @Override
@ -62,7 +65,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
@Override @Override
public AxisAlignedBB getBoundingBox() { public AxisAlignedBB getBoundingBox() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Override @Override
@ -87,7 +90,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
return false; return false;
} }
public static class DummyNetworkManager extends NetworkManager{ public static class DummyNetworkManager extends NetworkManager {
private static Field channelField; private static Field channelField;
private static Field socketAddressField; private static Field socketAddressField;
@ -103,7 +106,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
} }
} }
DummyNetworkManager(){ DummyNetworkManager() {
super(EnumProtocolDirection.SERVERBOUND); super(EnumProtocolDirection.SERVERBOUND);
updateFields(); updateFields();
} }

View File

@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_16_R3.AxisAlignedBB; 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.EntityPlayer;
import net.minecraft.server.v1_16_R3.EnumGamemode; import net.minecraft.server.v1_16_R3.EnumGamemode;
import net.minecraft.server.v1_16_R3.EnumProtocolDirection; 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 { 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; 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 GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle())); new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle()));
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
playerConnection = new DummyPlayerConnection(server, this); playerConnection = new DummyPlayerConnection(server, this);
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE); this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
@ -54,7 +57,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
((WorldServer) world).addPlayerJoin(this); ((WorldServer) world).addPlayerJoin(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Override @Override
@ -64,7 +67,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
@Override @Override
public AxisAlignedBB getBoundingBox() { public AxisAlignedBB getBoundingBox() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Override @Override

View File

@ -4,6 +4,7 @@ import com.bgsoftware.common.reflection.ReflectMethod;
import com.bgsoftware.wildloaders.handlers.NPCHandler; import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.protocol.EnumProtocolDirection; import net.minecraft.network.protocol.EnumProtocolDirection;
import net.minecraft.network.protocol.Packet; 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 { 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, private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
1, EnumGamemode.class, EnumGamemode.class); 1, EnumGamemode.class, EnumGamemode.class);
private final AxisAlignedBB boundingBox;
private boolean dieCall = false; 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(), super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName()))); 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); this.b = new DummyPlayerConnection(minecraftServer, this);
SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null); 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); ((WorldServer) getWorld()).addPlayerJoin(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Override @Override
@ -63,17 +66,16 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
@Override @Override
public AxisAlignedBB cs() { public AxisAlignedBB cs() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Override @Override
public void a(Entity.RemovalReason removalReason) { public void a(Entity.RemovalReason removalReason) {
if(!dieCall) { if (!dieCall) {
dieCall = true; dieCall = true;
removePlayer(getWorldServer(), this); removePlayer(getWorldServer(), this);
dieCall = false; dieCall = false;
} } else {
else {
super.a(removalReason); super.a(removalReason);
} }
} }
@ -88,13 +90,13 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
return getBukkitEntity(); return getBukkitEntity();
} }
private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer){ private static void removePlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
worldServer.a(entityPlayer, RemovalReason.d); worldServer.a(entityPlayer, RemovalReason.d);
} }
public static class DummyNetworkManager extends NetworkManager { public static class DummyNetworkManager extends NetworkManager {
DummyNetworkManager(){ DummyNetworkManager() {
super(EnumProtocolDirection.a); super(EnumProtocolDirection.a);
this.k = new DummyChannel(); this.k = new DummyChannel();
this.l = null; this.l = null;

View File

@ -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.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.protocol.EnumProtocolDirection; import net.minecraft.network.protocol.EnumProtocolDirection;
import net.minecraft.network.protocol.Packet; 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, private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
1, EnumGamemode.class, EnumGamemode.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 World world;
private final AxisAlignedBB boundingBox;
private boolean dieCall = false; private boolean dieCall = false;
@ -47,10 +47,11 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
Entity entity = new Entity(this); Entity entity = new Entity(this);
this.world = entity.getWorld(); this.world = entity.getWorld();
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
this.b = new DummyPlayerConnection(minecraftServer, this); this.b = new DummyPlayerConnection(minecraftServer, this);
SET_GAMEMODE.invoke(this.d, EnumGamemode.b); SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
clientViewDistance = 1; clientViewDistance = 1;
fauxSleeping = true; fauxSleeping = true;
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
this.world.addNewPlayer(this); this.world.addNewPlayer(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
remappedName = "cx") remappedName = "cx")
@Override @Override
public AxisAlignedBB cx() { public AxisAlignedBB cx() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",

View File

@ -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.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.protocol.EnumProtocolDirection; import net.minecraft.network.protocol.EnumProtocolDirection;
import net.minecraft.network.protocol.Packet; 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, private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
1, EnumGamemode.class, EnumGamemode.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 World world;
private final AxisAlignedBB boundingBox;
private boolean dieCall = false; private boolean dieCall = false;
@ -47,10 +47,11 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
Entity entity = new Entity(this); Entity entity = new Entity(this);
this.world = entity.getWorld(); this.world = entity.getWorld();
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
this.b = new DummyPlayerConnection(minecraftServer, this); this.b = new DummyPlayerConnection(minecraftServer, this);
SET_GAMEMODE.invoke(this.d, EnumGamemode.b); SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
clientViewDistance = 1; clientViewDistance = 1;
fauxSleeping = true; fauxSleeping = true;
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
this.world.addNewPlayer(this); this.world.addNewPlayer(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
remappedName = "cx") remappedName = "cx")
@Override @Override
public AxisAlignedBB cx() { public AxisAlignedBB cx() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",

View File

@ -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.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.core.BlockPosition;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.protocol.EnumProtocolDirection; import net.minecraft.network.protocol.EnumProtocolDirection;
import net.minecraft.network.protocol.Packet; 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, private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
1, EnumGamemode.class, EnumGamemode.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 World world;
private final AxisAlignedBB boundingBox;
private boolean dieCall = false; private boolean dieCall = false;
@ -47,10 +47,11 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
Entity entity = new Entity(this); Entity entity = new Entity(this);
this.world = entity.getWorld(); this.world = entity.getWorld();
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
this.b = new DummyPlayerConnection(minecraftServer, this); this.b = new DummyPlayerConnection(minecraftServer, this);
SET_GAMEMODE.invoke(this.d, EnumGamemode.b); SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
clientViewDistance = 1; clientViewDistance = 1;
fauxSleeping = true; fauxSleeping = true;
@ -60,7 +61,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
this.world.addNewPlayer(this); this.world.addNewPlayer(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",
@ -87,7 +88,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
remappedName = "cz") remappedName = "cz")
@Override @Override
public AxisAlignedBB cz() { public AxisAlignedBB cz() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Remap(classPath = "net.minecraft.world.entity.Entity", @Remap(classPath = "net.minecraft.world.entity.Entity",

View File

@ -4,6 +4,7 @@ import com.bgsoftware.wildloaders.handlers.NPCHandler;
import com.bgsoftware.wildloaders.npc.DummyChannel; import com.bgsoftware.wildloaders.npc.DummyChannel;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import net.minecraft.server.v1_8_R3.AxisAlignedBB; 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.DamageSource;
import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EnumProtocolDirection; 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 { 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(), 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 GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())),
new PlayerInteractManager(((CraftWorld) location.getWorld()).getHandle())); 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); playerConnection = new DummyPlayerConnection(server, this);
playerInteractManager.setGameMode(WorldSettings.EnumGamemode.CREATIVE); playerInteractManager.setGameMode(WorldSettings.EnumGamemode.CREATIVE);
@ -60,7 +64,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
world.players.add(this); world.players.add(this);
((WorldServer) world).getPlayerChunkMap().addPlayer(this); ((WorldServer) world).getPlayerChunkMap().addPlayer(this);
super.a(EMPTY_BOUND); super.a(this.boundingBox);
} }
@Override @Override
@ -70,7 +74,7 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
@Override @Override
public AxisAlignedBB getBoundingBox() { public AxisAlignedBB getBoundingBox() {
return EMPTY_BOUND; return this.boundingBox;
} }
@Override @Override