Search in sources :

Example 1 with EventOpenScreen

use of org.bleachhack.event.events.EventOpenScreen 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 2 with EventOpenScreen

use of org.bleachhack.event.events.EventOpenScreen in project BleachHack by BleachDrinker420.

the class MixinMinecraftClient method setScreen.

@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
private void setScreen(Screen screen, CallbackInfo info) {
    EventOpenScreen event = new EventOpenScreen(screen);
    BleachHack.eventBus.post(event);
    if (event.isCancelled()) {
        info.cancel();
    }
}
Also used : EventOpenScreen(org.bleachhack.event.events.EventOpenScreen) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

EventOpenScreen (org.bleachhack.event.events.EventOpenScreen)2 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 IntStream (java.util.stream.IntStream)1 SignBlockEntity (net.minecraft.block.entity.SignBlockEntity)1 SignEditScreen (net.minecraft.client.gui.screen.ingame.SignEditScreen)1 UpdateSignC2SPacket (net.minecraft.network.packet.c2s.play.UpdateSignC2SPacket)1 EventPacket (org.bleachhack.event.events.EventPacket)1 BleachSubscribe (org.bleachhack.eventbus.BleachSubscribe)1 Module (org.bleachhack.module.Module)1 ModuleCategory (org.bleachhack.module.ModuleCategory)1 SettingSlider (org.bleachhack.setting.module.SettingSlider)1 SettingToggle (org.bleachhack.setting.module.SettingToggle)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1