mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-21 11:46:46 +01:00
Fixed loader npcs can get advancements/achievements (#63)
This commit is contained in:
parent
19e383ad0b
commit
db2b49fbde
@ -4,6 +4,8 @@ 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.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -16,15 +18,20 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderPlayer extends ServerPlayer {
|
||||
@ -34,6 +41,7 @@ public final class ChunkLoaderPlayer extends ServerPlayer {
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -45,6 +53,7 @@ public final class ChunkLoaderPlayer extends ServerPlayer {
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
@ -75,6 +84,11 @@ public final class ChunkLoaderPlayer extends ServerPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -137,4 +151,63 @@ public final class ChunkLoaderPlayer extends ServerPlayer {
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -17,16 +19,21 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
@ -36,6 +43,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +55,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
@ -97,6 +106,11 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -159,4 +173,63 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -17,16 +19,21 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
@ -36,6 +43,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +55,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
@ -97,6 +106,11 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -159,4 +173,63 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -17,16 +19,21 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
@ -36,6 +43,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +55,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
@ -97,6 +106,11 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -159,4 +173,63 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -17,16 +19,21 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
@ -36,6 +43,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -47,6 +55,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
@ -97,6 +106,11 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -159,4 +173,63 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementProgress;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
@ -17,17 +19,22 @@ import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.PlayerAdvancements;
|
||||
import net.minecraft.server.ServerAdvancementManager;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
@ -37,6 +44,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
private final PlayerAdvancements advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -49,6 +57,8 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
this.advancements = new DummyPlayerAdvancements(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
@ -98,6 +108,11 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerAdvancements getAdvancements() {
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
@ -151,7 +166,7 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
@ -160,4 +175,63 @@ public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoade
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends PlayerAdvancements {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
super(server.getFixerUpper(), server.getPlayerList(), server.getAdvancements(),
|
||||
getAdvancementsFile(server, serverPlayer), serverPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, ServerPlayer serverPlayer) {
|
||||
File advancementsDir = server.getWorldPath(LevelResource.PLAYER_ADVANCEMENTS_DIR).toFile();
|
||||
return new File(advancementsDir, serverPlayer.getUUID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlayer(ServerPlayer owner) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopListening() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload(ServerAdvancementManager advancementLoader) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean award(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revoke(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flushDirty(ServerPlayer player) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSelectedTab(@Nullable Advancement advancement) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getOrStartProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,9 @@ package com.bgsoftware.wildloaders.nms.v1_12_R1;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_12_R1.Advancement;
|
||||
import net.minecraft.server.v1_12_R1.AdvancementDataPlayer;
|
||||
import net.minecraft.server.v1_12_R1.AdvancementProgress;
|
||||
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_12_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_12_R1.DamageSource;
|
||||
@ -29,12 +32,14 @@ import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private final AxisAlignedBB boundingBox;
|
||||
private final AdvancementDataPlayer advancements;
|
||||
|
||||
public ChunkLoaderNPC(Location location, UUID uuid) {
|
||||
super(((CraftServer) Bukkit.getServer()).getServer(),
|
||||
@ -44,7 +49,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
this.playerConnection = new DummyPlayerConnection(server, this);
|
||||
this.advancements = new DummyPlayerAdvancements(server, this);
|
||||
|
||||
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
|
||||
fauxSleeping = true;
|
||||
@ -90,6 +96,11 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementDataPlayer getAdvancementData() {
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
@ -175,4 +186,62 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends AdvancementDataPlayer {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, EntityPlayer entityPlayer) {
|
||||
super(server, getAdvancementsFile(server, entityPlayer), entityPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, EntityPlayer entityPlayer) {
|
||||
File advancementsDir = new File(server.getWorldServer(0).getDataManager().getDirectory(), "advancements");
|
||||
return new File(advancementsDir, entityPlayer.getUniqueID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityPlayer owner) {
|
||||
// setPlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
// stopListening
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b() {
|
||||
// reload
|
||||
}
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
// save
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grantCriteria(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeCritera(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(EntityPlayer player) {
|
||||
// flushDirty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Advancement advancement) {
|
||||
// setSelectedTab
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,6 +3,10 @@ package com.bgsoftware.wildloaders.nms.v1_16_R3;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.v1_16_R3.Advancement;
|
||||
import net.minecraft.server.v1_16_R3.AdvancementDataPlayer;
|
||||
import net.minecraft.server.v1_16_R3.AdvancementDataWorld;
|
||||
import net.minecraft.server.v1_16_R3.AdvancementProgress;
|
||||
import net.minecraft.server.v1_16_R3.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_16_R3.BlockPosition;
|
||||
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||
@ -21,19 +25,23 @@ import net.minecraft.server.v1_16_R3.PacketPlayInUpdateSign;
|
||||
import net.minecraft.server.v1_16_R3.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.v1_16_R3.PlayerConnection;
|
||||
import net.minecraft.server.v1_16_R3.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_16_R3.SavedFile;
|
||||
import net.minecraft.server.v1_16_R3.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private final AxisAlignedBB boundingBox;
|
||||
private final AdvancementDataPlayer advancements;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@ -45,7 +53,8 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
playerConnection = new DummyPlayerConnection(server, this);
|
||||
this.playerConnection = new DummyPlayerConnection(server, this);
|
||||
this.advancements = new DummyPlayerAdvancements(server, this);
|
||||
|
||||
this.playerInteractManager.setGameMode(EnumGamemode.CREATIVE);
|
||||
clientViewDistance = 1;
|
||||
@ -91,6 +100,11 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementDataPlayer getAdvancementData() {
|
||||
return this.advancements;
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
private static Field channelField;
|
||||
@ -176,4 +190,63 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
|
||||
}
|
||||
|
||||
private static class DummyPlayerAdvancements extends AdvancementDataPlayer {
|
||||
|
||||
DummyPlayerAdvancements(MinecraftServer server, EntityPlayer entityPlayer) {
|
||||
super(server.getDataFixer(), server.getPlayerList(), server.getAdvancementData(),
|
||||
getAdvancementsFile(server, entityPlayer), entityPlayer);
|
||||
}
|
||||
|
||||
private static File getAdvancementsFile(MinecraftServer server, EntityPlayer entityPlayer) {
|
||||
File advancementsDir = server.a(SavedFile.ADVANCEMENTS).toFile();
|
||||
return new File(advancementsDir, entityPlayer.getUniqueID() + ".json");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(EntityPlayer owner) {
|
||||
// setPlayer
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a() {
|
||||
// stopListening
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(AdvancementDataWorld advancementLoader) {
|
||||
// reload
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b() {
|
||||
// save
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean grantCriteria(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revokeCritera(Advancement advancement, String criterionName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void b(EntityPlayer player) {
|
||||
// flushDirty
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(@Nullable Advancement advancement) {
|
||||
// setSelectedTab
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdvancementProgress getProgress(Advancement advancement) {
|
||||
return new AdvancementProgress();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import net.minecraft.server.v1_7_R4.PacketPlayInUpdateSign;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.v1_7_R4.PlayerConnection;
|
||||
import net.minecraft.server.v1_7_R4.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_7_R4.Statistic;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -74,6 +75,16 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Statistic statistic, int i) {
|
||||
// Prevent achievements from being given to NPCs.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Statistic statistic) {
|
||||
// Prevent achievements from being given to NPCs.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
|
@ -4,7 +4,6 @@ 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;
|
||||
@ -21,6 +20,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayInUpdateSign;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.v1_8_R3.PlayerConnection;
|
||||
import net.minecraft.server.v1_8_R3.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_8_R3.Statistic;
|
||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||
import net.minecraft.server.v1_8_R3.WorldSettings;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -94,6 +94,16 @@ public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Statistic statistic, int i) {
|
||||
// Prevent achievements from being given to NPCs.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Statistic statistic) {
|
||||
// Prevent achievements from being given to NPCs.
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
|
Loading…
Reference in New Issue
Block a user