Search in sources :

Example 1 with SignBlockEntity

use of net.minecraft.block.entity.SignBlockEntity in project BleachHack by BleachDrinker420.

the class NoRender method onSignRender.

@BleachSubscribe
public void onSignRender(EventBlockEntityRender.Single.Pre event) {
    if (event.getBlockEntity() instanceof SignBlockEntity && isWorldToggled(0)) {
        SettingToggle signSetting = getWorldChild(0);
        if (signSetting.getChild(0).asMode().getMode() == 0) {
            event.setCancelled(true);
        } else {
            SignBlockEntity sign = new SignBlockEntity(event.getBlockEntity().getPos(), event.getBlockEntity().getCachedState());
            sign.setWorld(mc.world);
            if (signSetting.getChild(0).asMode().getMode() == 2) {
                for (int i = 0; i < 4; i++) {
                    sign.setTextOnRow(i, signText[i]);
                }
            }
            event.setBlockEntity(sign);
        }
    }
}
Also used : SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SettingToggle(org.bleachhack.setting.module.SettingToggle) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 2 with SignBlockEntity

use of net.minecraft.block.entity.SignBlockEntity in project BleachHack by BleachDrinker420.

the class AutoSign method onOpenScreen.

@BleachSubscribe
public void onOpenScreen(EventOpenScreen event) {
    if (text.length < 3)
        return;
    if (event.getScreen() instanceof SignEditScreen) {
        event.setCancelled(true);
        if (getSetting(0).asToggle().getState()) {
            text = new String[] {};
            while (text.length < 4) {
                IntStream chars = new Random().ints(0, 0x10FFFF);
                int amount = getSetting(0).asToggle().getChild(0).asSlider().getValueInt();
                text = chars.limit(amount * 5).mapToObj(i -> String.valueOf((char) i)).collect(Collectors.joining()).split("(?<=\\G.{" + amount + "})");
            }
        }
        SignBlockEntity sign = ((SignEditScreen) event.getScreen()).sign;
        mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), text[0], text[1], text[2], text[3]));
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) SettingSlider(org.bleachhack.setting.module.SettingSlider) IntStream(java.util.stream.IntStream) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) ModuleCategory(org.bleachhack.module.ModuleCategory) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventOpenScreen(org.bleachhack.event.events.EventOpenScreen) Random(java.util.Random) Collectors(java.util.stream.Collectors) Module(org.bleachhack.module.Module) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SettingToggle(org.bleachhack.setting.module.SettingToggle) EventPacket(org.bleachhack.event.events.EventPacket) Random(java.util.Random) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) IntStream(java.util.stream.IntStream) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Example 3 with SignBlockEntity

use of net.minecraft.block.entity.SignBlockEntity in project EdenClient by HahaOO7.

the class ChestShopMod method checkForShops.

private void checkForShops(ChunkManager cm, ChunkPos chunk) {
    if (!cm.isChunkLoaded(chunk.x, chunk.z))
        return;
    WorldChunk c = cm.getWorldChunk(chunk.x, chunk.z, false);
    if (c == null)
        return;
    shops.remove(chunk);
    ChestShopSet cs = new ChestShopSet();
    c.getBlockEntities().values().stream().filter(t -> t instanceof SignBlockEntity).map(t -> (SignBlockEntity) t).map(ChestShopEntry::new).filter(ChestShopEntry::isShop).forEach(cs::add);
    shops.put(chunk, cs);
}
Also used : WaitForTicksTask(at.haha007.edenclient.utils.tasks.WaitForTicksTask) java.util(java.util) PerWorldConfig(at.haha007.edenclient.utils.config.PerWorldConfig) ChatColor(at.haha007.edenclient.utils.ChatColor) SimpleDateFormat(java.text.SimpleDateFormat) ChunkManager(net.minecraft.world.chunk.ChunkManager) CompletableFuture(java.util.concurrent.CompletableFuture) StringArgumentType(com.mojang.brigadier.arguments.StringArgumentType) Vec3i(net.minecraft.util.math.Vec3i) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CommandManager(at.haha007.edenclient.command.CommandManager) PlayerUtils.sendModMessage(at.haha007.edenclient.utils.PlayerUtils.sendModMessage) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) PlayerTickCallback(at.haha007.edenclient.callbacks.PlayerTickCallback) ChestShopItemNames(at.haha007.edenclient.mods.datafetcher.ChestShopItemNames) DataFetcher(at.haha007.edenclient.mods.datafetcher.DataFetcher) SuggestionsBuilder(com.mojang.brigadier.suggestion.SuggestionsBuilder) ClientCommandSource(net.minecraft.client.network.ClientCommandSource) Suggestions(com.mojang.brigadier.suggestion.Suggestions) CommandContext(com.mojang.brigadier.context.CommandContext) BufferedWriter(java.io.BufferedWriter) FileWriter(java.io.FileWriter) GetTo(at.haha007.edenclient.mods.GetTo) ChunkPos(net.minecraft.util.math.ChunkPos) IOException(java.io.IOException) net.minecraft.text(net.minecraft.text) Collectors(java.util.stream.Collectors) LiteralArgumentBuilder(com.mojang.brigadier.builder.LiteralArgumentBuilder) File(java.io.File) WorldChunk(net.minecraft.world.chunk.WorldChunk) RunnableTask(at.haha007.edenclient.utils.tasks.RunnableTask) EdenClient(at.haha007.edenclient.EdenClient) TaskManager(at.haha007.edenclient.utils.tasks.TaskManager) Formatting(net.minecraft.util.Formatting) ConfigSubscriber(at.haha007.edenclient.utils.config.ConfigSubscriber) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) PlayerUtils(at.haha007.edenclient.utils.PlayerUtils) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) WorldChunk(net.minecraft.world.chunk.WorldChunk)

Example 4 with SignBlockEntity

use of net.minecraft.block.entity.SignBlockEntity in project meteor-client by MeteorDevelopment.

the class AutoSign method onOpenScreen.

@EventHandler
private void onOpenScreen(OpenScreenEvent event) {
    if (!(event.screen instanceof SignEditScreen) || text == null)
        return;
    SignBlockEntity sign = ((SignEditScreenAccessor) event.screen).getSign();
    mc.player.networkHandler.sendPacket(new UpdateSignC2SPacket(sign.getPos(), text[0], text[1], text[2], text[3]));
    event.cancel();
}
Also used : SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) SignEditScreenAccessor(meteordevelopment.meteorclient.mixin.SignEditScreenAccessor) SignEditScreen(net.minecraft.client.gui.screen.ingame.SignEditScreen) UpdateSignC2SPacket(net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket) EventHandler(meteordevelopment.orbit.EventHandler)

Example 5 with SignBlockEntity

use of net.minecraft.block.entity.SignBlockEntity in project tweakermore by Fallen-Breath.

the class SignTextCopier method copySignText.

public static boolean copySignText(KeyAction action, IKeybind key) {
    MinecraftClient mc = MinecraftClient.getInstance();
    if (mc.world != null && mc.crosshairTarget != null && mc.crosshairTarget.getType() == HitResult.Type.BLOCK) {
        BlockPos blockPos = ((BlockHitResult) mc.crosshairTarget).getBlockPos();
        BlockState blockState = mc.world.getBlockState(blockPos);
        if (blockState.getBlock() instanceof AbstractSignBlock) {
            BlockEntity blockEntity = mc.world.getBlockEntity(blockPos);
            if (blockEntity instanceof SignBlockEntity) {
                String text = Joiner.on("\n").join(Arrays.stream(((SignBlockEntity) blockEntity).text).map(Text::getString).collect(Collectors.toList()));
                text = StringUtils.strip(text);
                if (!text.isEmpty()) {
                    mc.keyboard.setClipboard(text);
                    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.sign_copied", blockState.getBlock().getName());
                } else {
                    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.empty_sign", blockState.getBlock().getName());
                }
                return true;
            }
        }
    }
    InfoUtils.printActionbarMessage("tweakermore.config.copySignTextToClipBoard.no_sign");
    return false;
}
Also used : BlockState(net.minecraft.block.BlockState) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity) MinecraftClient(net.minecraft.client.MinecraftClient) BlockPos(net.minecraft.util.math.BlockPos) Text(net.minecraft.text.Text) BlockHitResult(net.minecraft.util.hit.BlockHitResult) AbstractSignBlock(net.minecraft.block.AbstractSignBlock) BlockEntity(net.minecraft.block.entity.BlockEntity) SignBlockEntity(net.minecraft.block.entity.SignBlockEntity)

Aggregations

SignBlockEntity (net.minecraft.block.entity.SignBlockEntity)7 SignEditScreen (net.minecraft.client.gui.screen.ingame.SignEditScreen)3 UpdateSignC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket)3 Collectors (java.util.stream.Collectors)2 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)2 SettingToggle (org.bleachhack.setting.module.SettingToggle)2 EdenClient (at.haha007.edenclient.EdenClient)1 PlayerTickCallback (at.haha007.edenclient.callbacks.PlayerTickCallback)1 CommandManager (at.haha007.edenclient.command.CommandManager)1 GetTo (at.haha007.edenclient.mods.GetTo)1 ChestShopItemNames (at.haha007.edenclient.mods.datafetcher.ChestShopItemNames)1 DataFetcher (at.haha007.edenclient.mods.datafetcher.DataFetcher)1 ChatColor (at.haha007.edenclient.utils.ChatColor)1 PlayerUtils (at.haha007.edenclient.utils.PlayerUtils)1 PlayerUtils.sendModMessage (at.haha007.edenclient.utils.PlayerUtils.sendModMessage)1 ConfigSubscriber (at.haha007.edenclient.utils.config.ConfigSubscriber)1 PerWorldConfig (at.haha007.edenclient.utils.config.PerWorldConfig)1 RunnableTask (at.haha007.edenclient.utils.tasks.RunnableTask)1 TaskManager (at.haha007.edenclient.utils.tasks.TaskManager)1 WaitForTicksTask (at.haha007.edenclient.utils.tasks.WaitForTicksTask)1