use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class WorldHelperImpl method setStatic.
@Override
public void setStatic(World world, boolean isStatic) {
ServerLevel worldServer = ((CraftWorld) world).getHandle();
ReflectionHelper.setFieldValue(net.minecraft.world.level.Level.class, ReflectionMappingsInfo.Level_isClientSide, worldServer, isStatic);
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method changeChunkServerThread.
@Override
public void changeChunkServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread != null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
resetServerThread = (Thread) chunkProviderServerThreadField.get(provider);
chunkProviderServerThreadFieldSetter.invoke(provider, Thread.currentThread());
worldThreadFieldSetter.invoke(nmsWorld, Thread.currentThread());
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class ChunkHelperImpl method restoreServerThread.
@Override
public void restoreServerThread(World world) {
if (DenizenCoreImplementation.tagThread == null) {
return;
}
if (resetServerThread == null) {
return;
}
ServerLevel nmsWorld = ((CraftWorld) world).getHandle();
ServerChunkCache provider = nmsWorld.getChunkSource();
try {
chunkProviderServerThreadFieldSetter.invoke(provider, resetServerThread);
worldThreadFieldSetter.invoke(nmsWorld, resetServerThread);
resetServerThread = null;
} catch (Throwable ex) {
Debug.echoError(ex);
}
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class FishingHelperImpl method getRandomReward.
public ItemStack getRandomReward(FishingHook hook, ResourceLocation key) {
ServerLevel worldServer = (ServerLevel) hook.level;
LootContext.Builder playerFishEvent2 = new LootContext.Builder(worldServer);
LootTables registry = ((ServerLevel) hook.level).getServer().getLootTables();
// registry.getLootTable(key).getLootContextParameterSet()
LootContext info = playerFishEvent2.withOptionalParameter(LootContextParams.ORIGIN, new Vec3(hook.getX(), hook.getY(), hook.getZ())).withOptionalParameter(LootContextParams.TOOL, new ItemStack(Items.FISHING_ROD)).create(LootContextParamSets.FISHING);
List<ItemStack> itemStacks = registry.get(key).getRandomItems(info);
return itemStacks.get(worldServer.random.nextInt(itemStacks.size()));
}
use of net.minecraft.server.level.ServerLevel in project Denizen-For-Bukkit by DenizenScript.
the class ProfileEditorImpl method updatePlayer.
@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
final ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
final UUID uuid = player.getUniqueId();
ClientboundRemoveEntitiesPacket destroyPacket = new ClientboundRemoveEntitiesPacket(entityPlayer.getId());
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
if (!p.getUniqueId().equals(uuid)) {
PacketHelperImpl.send(p, destroyPacket);
}
}
new BukkitRunnable() {
@Override
public void run() {
ClientboundPlayerInfoPacket playerInfo = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, entityPlayer);
ClientboundAddPlayerPacket spawnPacket = new ClientboundAddPlayerPacket(entityPlayer);
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
PacketHelperImpl.send(player, playerInfo);
if (!player.getUniqueId().equals(uuid)) {
PacketHelperImpl.send(player, spawnPacket);
} else {
if (isSkinChanging) {
((CraftServer) Bukkit.getServer()).getHandle().respawn(entityPlayer, (ServerLevel) entityPlayer.level, true, player.getLocation(), false);
}
player.updateInventory();
}
}
}
}.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Aggregations