Search in sources :

Example 1 with ServerWorld

use of net.minecraft.server.world.ServerWorld in project LuckPerms by lucko.

the class FabricPlayerCalculator method calculate.

@Override
public void calculate(@NonNull ServerPlayerEntity target, @NonNull ContextConsumer consumer) {
    GameMode mode = target.interactionManager.getGameMode();
    // GameMode.NOT_SET with ID -1 was removed in 1.17
    final int GAME_MODE_NOT_SET = -1;
    if (this.gamemode && mode != null && mode.getId() != GAME_MODE_NOT_SET) {
        consumer.accept(DefaultContextKeys.GAMEMODE_KEY, GAMEMODE_NAMER.name(mode));
    }
    // TODO: figure out dimension type context too
    ServerWorld world = target.getWorld();
    if (this.world) {
        this.plugin.getConfiguration().get(ConfigKeys.WORLD_REWRITES).rewriteAndSubmit(getContextKey(world.getRegistryKey().getValue()), consumer);
    }
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) GameMode(net.minecraft.world.GameMode)

Example 2 with ServerWorld

use of net.minecraft.server.world.ServerWorld in project Polymorph by TheIllusiveC4.

the class CommonEventsListener method worldTick.

private static void worldTick(final ServerWorld serverWorld) {
    List<BlockEntity> toRemove = new ArrayList<>();
    for (Map.Entry<BlockEntity, BlockEntityRecipeData> entry : TICKABLE_BLOCKS.entrySet()) {
        BlockEntity be = entry.getKey();
        World beWorld = be.getWorld();
        if (be.isRemoved() || beWorld == null || beWorld.isClient()) {
            toRemove.add(be);
        } else {
            entry.getValue().tick();
        }
    }
    for (BlockEntity be : toRemove) {
        TICKABLE_BLOCKS.remove(be);
    }
}
Also used : ArrayList(java.util.ArrayList) BlockEntityRecipeData(top.theillusivec4.polymorph.api.common.component.BlockEntityRecipeData) World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map) BlockEntity(net.minecraft.block.entity.BlockEntity)

Example 3 with ServerWorld

use of net.minecraft.server.world.ServerWorld in project carpet-discarpet by replaceitem.

the class MinecraftServer_systemMessageEventMixin method redirectChatToScarpet.

@Inject(at = @At("RETURN"), method = "sendSystemMessage(Lnet/minecraft/text/Text;Ljava/util/UUID;)V")
public void redirectChatToScarpet(Text message, UUID senderUuid, CallbackInfo ci) {
    Iterator<ServerWorld> worlds = this.getWorlds().iterator();
    Entity entity = null;
    while (worlds.hasNext() && entity == null) {
        entity = worlds.next().getEntity(senderUuid);
    }
    ChatEvents.SYSTEM_MESSAGE.onSystemMessage(message, entity);
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Entity(net.minecraft.entity.Entity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 4 with ServerWorld

use of net.minecraft.server.world.ServerWorld in project SpeedRunIGT by RedLime.

the class ServerPlayerEntityMixin method onChangedDimension.

@Inject(method = "changeDimension", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/world/ServerWorld;onPlayerChangeDimension(Lnet/minecraft/server/network/ServerPlayerEntity;)V", shift = At.Shift.AFTER))
public void onChangedDimension(ServerWorld destination, CallbackInfoReturnable<Entity> cir) {
    RegistryKey<World> oldRegistryKey = beforeWorld.getRegistryKey();
    RegistryKey<World> newRegistryKey = world.getRegistryKey();
    InGameTimer timer = InGameTimer.getInstance();
    if (timer.getStatus() != TimerStatus.NONE && !timer.isCoop() && InGameTimer.getInstance().getCategory() == RunCategories.ANY) {
        if (oldRegistryKey == World.OVERWORLD && newRegistryKey == World.NETHER) {
            InGameTimerUtils.IS_CAN_WAIT_WORLD_LOAD = InGameTimerUtils.isLoadableBlind(World.NETHER, this.getPos().add(0, 0, 0), lastPortalPos.add(0, 0, 0));
        }
        if (oldRegistryKey == World.NETHER && newRegistryKey == World.OVERWORLD) {
            if (InGameTimerUtils.isBlindTraveled(lastPortalPos)) {
                InGameTimer.getInstance().tryInsertNewTimeline("nether_travel");
            }
            InGameTimerUtils.IS_CAN_WAIT_WORLD_LOAD = InGameTimerUtils.isLoadableBlind(World.OVERWORLD, lastPortalPos.add(0, 0, 0), this.getPos().add(0, 0, 0));
        }
    }
}
Also used : InGameTimer(com.redlimerl.speedrunigt.timer.InGameTimer) World(net.minecraft.world.World) ServerWorld(net.minecraft.server.world.ServerWorld) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 5 with ServerWorld

use of net.minecraft.server.world.ServerWorld in project Rug by RubixDev.

the class PeekCommand method execute.

private static int execute(CommandContext<ServerCommandSource> context, boolean isEnderChest) throws CommandSyntaxException {
    ServerCommandSource source = context.getSource();
    PlayerManager playerManager = source.getServer().getPlayerManager();
    GameProfile targetPlayerProfile = GameProfileArgumentType.getProfileArgument(context, "player").iterator().next();
    ServerPlayerEntity targetPlayer = playerManager.getPlayer(targetPlayerProfile.getName());
    ServerPlayerEntity executingPlayer = source.getPlayer();
    if (targetPlayer == null) {
        targetPlayer = playerManager.createPlayer(targetPlayerProfile);
        NbtCompound targetPlayerData = playerManager.loadPlayerData(targetPlayer);
        if (targetPlayerData == null) {
            source.sendError(Text.of("Targeted player's data could not be found. Was he ever in this world?"));
            return 0;
        }
        @SuppressWarnings("deprecation") ServerWorld world = source.getServer().getWorld(DimensionType.worldFromDimensionNbt(new Dynamic<>(NbtOps.INSTANCE, targetPlayerData.get("Dimension"))).result().orElseThrow());
        if (world != null)
            targetPlayer.setWorld(world);
    }
    if (isEnderChest) {
        showEnderChest(executingPlayer, targetPlayer);
    } else {
        showInventory(executingPlayer, targetPlayer);
    }
    return 1;
}
Also used : ServerWorld(net.minecraft.server.world.ServerWorld) Dynamic(com.mojang.serialization.Dynamic) NbtCompound(net.minecraft.nbt.NbtCompound) PlayerManager(net.minecraft.server.PlayerManager) GameProfile(com.mojang.authlib.GameProfile) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) ServerCommandSource(net.minecraft.server.command.ServerCommandSource)

Aggregations

ServerWorld (net.minecraft.server.world.ServerWorld)75 BlockPos (net.minecraft.util.math.BlockPos)23 World (net.minecraft.world.World)13 ItemStack (net.minecraft.item.ItemStack)11 ServerPlayerEntity (net.minecraft.server.network.ServerPlayerEntity)11 Vec3d (net.minecraft.util.math.Vec3d)8 ChunkPos (net.minecraft.util.math.ChunkPos)7 Portal (com.qouteall.immersive_portals.portal.Portal)6 ArrayList (java.util.ArrayList)6 Inject (org.spongepowered.asm.mixin.injection.Inject)6 CommandSyntaxException (com.mojang.brigadier.exceptions.CommandSyntaxException)5 McHelper (com.qouteall.immersive_portals.McHelper)5 BlockState (net.minecraft.block.BlockState)5 Identifier (net.minecraft.util.Identifier)5 ChunkStatus (net.minecraft.world.chunk.ChunkStatus)5 DimensionType (net.minecraft.world.dimension.DimensionType)5 Helper (com.qouteall.immersive_portals.Helper)4 Blocks (net.minecraft.block.Blocks)4 BlockEntity (net.minecraft.block.entity.BlockEntity)4 WorldChunk (net.minecraft.world.chunk.WorldChunk)4