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);
}
}
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);
}
}
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);
}
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));
}
}
}
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;
}
Aggregations