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