Search in sources :

Example 6 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project EdenClient by HahaOO7.

the class TileEntityEsp method tick.

private void tick(ClientPlayerEntity player) {
    if (!enabled) {
        tileEntities = new ArrayList<>();
        return;
    }
    ChunkPos chunkPos = player.getChunkPos();
    ClientChunkManager cm = player.clientWorld.getChunkManager();
    BlockPos pp = player.getBlockPos();
    tileEntities = ChunkPos.stream(chunkPos, distance).flatMap(cp -> {
        WorldChunk wc = cm.getWorldChunk(cp.x, cp.z, false);
        if (wc == null)
            return null;
        return wc.getBlockEntities().entrySet().stream();
    }).filter(e -> types.contains(e.getValue().getType())).map(Map.Entry::getKey).sorted(Comparator.comparingDouble(pos -> pos.getSquaredDistance(pp))).limit(maxCount).map(v -> (Vec3i) v).toList();
}
Also used : java.util(java.util) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) ClientChunkManager(net.minecraft.client.world.ClientChunkManager) GameRenderCallback(at.haha007.edenclient.callbacks.GameRenderCallback) JoinWorldCallback(at.haha007.edenclient.callbacks.JoinWorldCallback) VertexBuffer(net.minecraft.client.gl.VertexBuffer) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) BlockEntityTypeSet(at.haha007.edenclient.utils.config.wrappers.BlockEntityTypeSet) RequiredArgumentBuilder(com.mojang.brigadier.builder.RequiredArgumentBuilder) CommandContext(com.mojang.brigadier.context.CommandContext) net.minecraft.client.render(net.minecraft.client.render) net.minecraft.util.math(net.minecraft.util.math) MatrixStack(net.minecraft.client.util.math.MatrixStack) RenderUtils(at.haha007.edenclient.utils.RenderUtils) BlockEntityType(net.minecraft.block.entity.BlockEntityType) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Registry(net.minecraft.util.registry.Registry) WorldChunk(net.minecraft.world.chunk.WorldChunk) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) RenderSystem(com.mojang.blaze3d.systems.RenderSystem) LeaveWorldCallback(at.haha007.edenclient.callbacks.LeaveWorldCallback) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) WorldChunk(net.minecraft.world.chunk.WorldChunk) ClientChunkManager(net.minecraft.client.world.ClientChunkManager)

Example 7 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project EdenClient by HahaOO7.

the class WorldEditReplaceHelper method registerCommand.

private void registerCommand(String command) {
    LiteralArgumentBuilder<ClientCommandSource> node = literal(command);
    node.then(literal("replace").then(argument("from", StringArgumentType.word()).suggests(this::suggestValidBlocks).then(argument("to", StringArgumentType.word()).suggests(this::suggestValidBlocks).executes(c -> {
        Optional<Block> fromBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("from", String.class)));
        Optional<Block> toBlockOpt = Registry.BLOCK.getOrEmpty(new Identifier(c.getArgument("to", String.class)));
        if (fromBlockOpt.isEmpty() || toBlockOpt.isEmpty()) {
            sendModMessage("One of your block-inputs doesn't exist.");
            return 0;
        }
        Block fromBlock = fromBlockOpt.get();
        Block toBlock = toBlockOpt.get();
        if (fromBlock.equals(toBlock)) {
            sendModMessage("Both input-blocks can't be the same!");
            return 0;
        }
        String[] currentOperation = new String[] { getBlockIDFromBlock(toBlock), getBlockIDFromBlock(fromBlock) };
        undoCommandStack.add(currentOperation);
        return replaceCommandRequest(fromBlock, toBlock, delay, true);
    }))));
    node.then(literal("undo").executes(c -> {
        if (undoCommandStack.size() == 0) {
            sendModMessage("Nothing left to undo.");
            return 0;
        }
        replaceUndoRequest(Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(undoCommandStack.peek()[1])), delay);
        redoCommandStack.add(new String[] { undoCommandStack.peek()[1], undoCommandStack.peek()[0] });
        undoCommandStack.pop();
        return 1;
    }));
    node.then(literal("redo").executes(c -> {
        if (redoCommandStack.size() == 0) {
            sendModMessage("Nothing left to redo.");
            return 0;
        }
        replaceRedoRequest(Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[0])), Registry.BLOCK.get(new Identifier(redoCommandStack.peek()[1])), delay);
        undoCommandStack.add(new String[] { redoCommandStack.peek()[1], redoCommandStack.peek()[0] });
        redoCommandStack.pop();
        return 1;
    }));
    node.then(literal("delay").then(argument("delay", IntegerArgumentType.integer(0, 40)).executes(c -> {
        this.delay = c.getArgument("delay", Integer.class);
        sendModMessage(ChatColor.GOLD + "Set delay to " + ChatColor.AQUA + delay + ChatColor.GOLD + " ticks.");
        return 1;
    })));
    node.then(literal("togglemessages").executes(c -> {
        ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
        entityPlayer.sendChatMessage("/eignoremessage predefined worldedit");
        return 1;
    }));
    register(node, "The WorldEditReplaceHelper helps you replace blocks that have specific properties which normal WorldEdit doesn't take into consideration when replacing blocks.", "Blocks like stairs, slabs, panes, walls, trapdoors, etc. can be replaced by other blocks of their type with their properties (waterlogged, shape, direction, etc.) unaffected.");
}
Also used : net.minecraft.block.enums(net.minecraft.block.enums) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) CompletableFuture(java.util.concurrent.CompletableFuture) Stack(java.util.Stack) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) DefaultedRegistry(net.minecraft.util.registry.DefaultedRegistry) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) net.minecraft.block(net.minecraft.block) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) Scheduler(at.haha007.edenclient.utils.Scheduler) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) Registry(net.minecraft.util.registry.Registry) List(java.util.List) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) IntegerArgumentType(com.mojang.brigadier.arguments.IntegerArgumentType) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Identifier(net.minecraft.util.Identifier) Optional(java.util.Optional) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 8 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project EdenClient by HahaOO7.

the class WorldEditReplaceHelper method sendStandardReplaceCommand.

private void sendStandardReplaceCommand(Block fromBlock, Block toBlock, String appendix) {
    ClientPlayerEntity entityPlayer = PlayerUtils.getPlayer();
    String message = "//replace " + getBlockIDFromBlock(fromBlock) + appendix + " " + getBlockIDFromBlock(toBlock) + appendix;
    if (message.length() > 256)
        sendModMessage("Cannot execute: " + message + " because this command too long.");
    entityPlayer.sendChatMessage(message);
    System.out.println("[EC] Sent command: " + message);
}
Also used : ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Example 9 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project EdenClient by HahaOO7.

the class ChatHudMixin method onAddMessage.

@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;I)V", cancellable = true)
private void onAddMessage(Text text, int chatLineId, CallbackInfo ci) {
    ci.cancel();
    thread.submit(() -> {
        Text chatText = text;
        ClientPlayerEntity player = PlayerUtils.getPlayer();
        AddChatMessageCallback.ChatAddEvent event = new AddChatMessageCallback.ChatAddEvent(player, chatText, chatLineId, visibleMessages);
        AddChatMessageCallback.EVENT.invoker().interact(event);
        chatText = event.getChatText();
        if (chatText != null && !chatText.getString().isBlank()) {
            addMessage(chatText, chatLineId, MinecraftClient.getInstance().inGameHud.getTicks(), false);
            System.out.println("Chat: " + chatText.getString());
        }
    });
}
Also used : AddChatMessageCallback(at.haha007.edenclient.callbacks.AddChatMessageCallback) OrderedText(net.minecraft.text.OrderedText) Text(net.minecraft.text.Text) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 10 with ClientPlayerEntity

use of net.minecraft.client.network.ClientPlayerEntity in project VeinMining by TheIllusiveC4.

the class ClientVeinMiningMod method onInitializeClient.

@Override
public void onInitializeClient() {
    KeyBindingHelper.registerKeyBinding(VeinMiningKey.get());
    ClientTickEvents.END_CLIENT_TICK.register((client) -> {
        ClientWorld world = client.world;
        ClientPlayerEntity player = client.player;
        if (world != null && player != null && world.getTime() % 5 == 0) {
            boolean enabled;
            if (VeinMiningConfig.VeinMining.activationState == VeinMiningConfig.ActivationState.STANDING) {
                enabled = !player.isSneaking();
            } else if (VeinMiningConfig.VeinMining.activationState == VeinMiningConfig.ActivationState.CROUCHING) {
                enabled = player.isSneaking();
            } else {
                enabled = VeinMiningKey.get().isPressed();
            }
            VeinMiningNetwork.sendState(enabled);
        }
    });
}
Also used : ClientWorld(net.minecraft.client.world.ClientWorld) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity)

Aggregations

ClientPlayerEntity (net.minecraft.client.network.ClientPlayerEntity)58 Identifier (net.minecraft.util.Identifier)11 Inject (org.spongepowered.asm.mixin.injection.Inject)10 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)9 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)9 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)9 LiteralArgumentBuilder (com.mojang.brigadier.builder.LiteralArgumentBuilder)9 MinecraftClient (net.minecraft.client.MinecraftClient)9 ClientCommandSource (net.minecraft.client.network.ClientCommandSource)9 CommandManager (at.haha007.edenclient.command.CommandManager)8 Registry (net.minecraft.util.registry.Registry)8 ChatColor (at.haha007.edenclient.utils.ChatColor)7 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)7 List (java.util.List)7 ClientWorld (net.minecraft.client.world.ClientWorld)7 ItemStack (net.minecraft.item.ItemStack)7 StringArgumentType (com.mojang.brigadier.arguments.StringArgumentType)6 IntegerArgumentType (com.mojang.brigadier.arguments.IntegerArgumentType)5 CommandContext (com.mojang.brigadier.context.CommandContext)5 Comparator (java.util.Comparator)5