Search in sources :

Example 6 with EndCrystalEntity

use of net.minecraft.entity.decoration.EndCrystalEntity in project Wurst7 by Wurst-Imperium.

the class TriggerBotHack method isCorrectEntity.

private boolean isCorrectEntity(Entity entity) {
    ClientPlayerEntity player = MC.player;
    ClientWorld world = MC.world;
    double rangeSq = Math.pow(range.getValue(), 2);
    Stream<Entity> stream = Stream.of(entity).filter(e -> !e.isRemoved()).filter(e -> e instanceof LivingEntity && ((LivingEntity) e).getHealth() > 0 || e instanceof EndCrystalEntity).filter(e -> player.squaredDistanceTo(e) <= rangeSq).filter(e -> e != player).filter(e -> !(e instanceof FakePlayerEntity)).filter(e -> !WURST.getFriends().contains(e.getEntityName()));
    if (filterPlayers.isChecked())
        stream = stream.filter(e -> !(e instanceof PlayerEntity));
    if (filterSleeping.isChecked())
        stream = stream.filter(e -> !(e instanceof PlayerEntity && ((PlayerEntity) e).isSleeping()));
    if (filterFlying.getValue() > 0)
        stream = stream.filter(e -> {
            if (!(e instanceof PlayerEntity))
                return true;
            Box box = e.getBoundingBox();
            box = box.union(box.offset(0, -filterFlying.getValue(), 0));
            return !world.isSpaceEmpty(box);
        });
    if (filterMonsters.isChecked())
        stream = stream.filter(e -> !(e instanceof Monster));
    if (filterPigmen.isChecked())
        stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
    if (filterEndermen.isChecked())
        stream = stream.filter(e -> !(e instanceof EndermanEntity));
    if (filterAnimals.isChecked())
        stream = stream.filter(e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity));
    if (filterBabies.isChecked())
        stream = stream.filter(e -> !(e instanceof PassiveEntity && ((PassiveEntity) e).isBaby()));
    if (filterPets.isChecked())
        stream = stream.filter(e -> !(e instanceof TameableEntity && ((TameableEntity) e).isTamed())).filter(e -> !(e instanceof HorseBaseEntity && ((HorseBaseEntity) e).isTame()));
    if (filterTraders.isChecked())
        stream = stream.filter(e -> !(e instanceof MerchantEntity));
    if (filterGolems.isChecked())
        stream = stream.filter(e -> !(e instanceof GolemEntity));
    if (filterInvisible.isChecked())
        stream = stream.filter(e -> !e.isInvisible());
    if (filterNamed.isChecked())
        stream = stream.filter(e -> !e.hasCustomName());
    if (filterStands.isChecked())
        stream = stream.filter(e -> !(e instanceof ArmorStandEntity));
    if (filterCrystals.isChecked())
        stream = stream.filter(e -> !(e instanceof EndCrystalEntity));
    return stream.findFirst().isPresent();
}
Also used : Category(net.wurstclient.Category) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) SearchTags(net.wurstclient.SearchTags) ValueDisplay(net.wurstclient.settings.SliderSetting.ValueDisplay) Hand(net.minecraft.util.Hand) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Box(net.minecraft.util.math.Box) Hack(net.wurstclient.hack.Hack) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) SliderSetting(net.wurstclient.settings.SliderSetting) EntityHitResult(net.minecraft.util.hit.EntityHitResult) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) Stream(java.util.stream.Stream) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Monster(net.minecraft.entity.mob.Monster) UpdateListener(net.wurstclient.events.UpdateListener) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ClientWorld(net.minecraft.client.world.ClientWorld) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Box(net.minecraft.util.math.Box) GolemEntity(net.minecraft.entity.passive.GolemEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) Monster(net.minecraft.entity.mob.Monster) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) ClientWorld(net.minecraft.client.world.ClientWorld) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity)

Example 7 with EndCrystalEntity

use of net.minecraft.entity.decoration.EndCrystalEntity in project Wurst7 by Wurst-Imperium.

the class ClickAuraHack method attack.

private void attack() {
    // set entity
    ClientPlayerEntity player = MC.player;
    ClientWorld world = MC.world;
    if (player.getAttackCooldownProgress(0) < 1)
        return;
    double rangeSq = Math.pow(range.getValue(), 2);
    Stream<Entity> stream = StreamSupport.stream(MC.world.getEntities().spliterator(), true).filter(e -> !e.isRemoved()).filter(e -> e instanceof LivingEntity && ((LivingEntity) e).getHealth() > 0 || e instanceof EndCrystalEntity).filter(e -> player.squaredDistanceTo(e) <= rangeSq).filter(e -> e != player).filter(e -> !(e instanceof FakePlayerEntity)).filter(e -> !WURST.getFriends().contains(e.getEntityName()));
    if (fov.getValue() < 360.0)
        stream = stream.filter(e -> RotationUtils.getAngleToLookVec(e.getBoundingBox().getCenter()) <= fov.getValue() / 2.0);
    if (filterPlayers.isChecked())
        stream = stream.filter(e -> !(e instanceof PlayerEntity));
    if (filterSleeping.isChecked())
        stream = stream.filter(e -> !(e instanceof PlayerEntity && ((PlayerEntity) e).isSleeping()));
    if (filterFlying.getValue() > 0)
        stream = stream.filter(e -> {
            if (!(e instanceof PlayerEntity))
                return true;
            Box box = e.getBoundingBox();
            box = box.union(box.offset(0, -filterFlying.getValue(), 0));
            return !world.isSpaceEmpty(box);
        });
    if (filterMonsters.isChecked())
        stream = stream.filter(e -> !(e instanceof Monster));
    if (filterPigmen.isChecked())
        stream = stream.filter(e -> !(e instanceof ZombifiedPiglinEntity));
    if (filterEndermen.isChecked())
        stream = stream.filter(e -> !(e instanceof EndermanEntity));
    if (filterAnimals.isChecked())
        stream = stream.filter(e -> !(e instanceof AnimalEntity || e instanceof AmbientEntity || e instanceof WaterCreatureEntity));
    if (filterBabies.isChecked())
        stream = stream.filter(e -> !(e instanceof PassiveEntity && ((PassiveEntity) e).isBaby()));
    if (filterPets.isChecked())
        stream = stream.filter(e -> !(e instanceof TameableEntity && ((TameableEntity) e).isTamed())).filter(e -> !(e instanceof HorseBaseEntity && ((HorseBaseEntity) e).isTame()));
    if (filterTraders.isChecked())
        stream = stream.filter(e -> !(e instanceof MerchantEntity));
    if (filterGolems.isChecked())
        stream = stream.filter(e -> !(e instanceof GolemEntity));
    if (filterInvisible.isChecked())
        stream = stream.filter(e -> !e.isInvisible());
    if (filterNamed.isChecked())
        stream = stream.filter(e -> !e.hasCustomName());
    if (filterStands.isChecked())
        stream = stream.filter(e -> !(e instanceof ArmorStandEntity));
    if (filterCrystals.isChecked())
        stream = stream.filter(e -> !(e instanceof EndCrystalEntity));
    Entity target = stream.min(priority.getSelected().comparator).orElse(null);
    if (target == null)
        return;
    WURST.getHax().autoSwordHack.setSlot();
    // face entity
    Rotation rotation = RotationUtils.getNeededRotations(target.getBoundingBox().getCenter());
    PlayerMoveC2SPacket.LookAndOnGround packet = new PlayerMoveC2SPacket.LookAndOnGround(rotation.getYaw(), rotation.getPitch(), MC.player.isOnGround());
    MC.player.networkHandler.sendPacket(packet);
    // attack entity
    WURST.getHax().criticalsHack.doCritical();
    MC.interactionManager.attackEntity(player, target);
    player.swingHand(Hand.MAIN_HAND);
}
Also used : Category(net.wurstclient.Category) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) SearchTags(net.wurstclient.SearchTags) ValueDisplay(net.wurstclient.settings.SliderSetting.ValueDisplay) RotationUtils(net.wurstclient.util.RotationUtils) EnumSetting(net.wurstclient.settings.EnumSetting) StreamSupport(java.util.stream.StreamSupport) Hand(net.minecraft.util.Hand) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) LeftClickListener(net.wurstclient.events.LeftClickListener) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) Box(net.minecraft.util.math.Box) Hack(net.wurstclient.hack.Hack) Rotation(net.wurstclient.util.RotationUtils.Rotation) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) SliderSetting(net.wurstclient.settings.SliderSetting) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) Stream(java.util.stream.Stream) CheckboxSetting(net.wurstclient.settings.CheckboxSetting) Monster(net.minecraft.entity.mob.Monster) ToDoubleFunction(java.util.function.ToDoubleFunction) UpdateListener(net.wurstclient.events.UpdateListener) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) Comparator(java.util.Comparator) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ClientWorld(net.minecraft.client.world.ClientWorld) GolemEntity(net.minecraft.entity.passive.GolemEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) AnimalEntity(net.minecraft.entity.passive.AnimalEntity) PlayerMoveC2SPacket(net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket) GolemEntity(net.minecraft.entity.passive.GolemEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) FakePlayerEntity(net.wurstclient.util.FakePlayerEntity) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) ZombifiedPiglinEntity(net.minecraft.entity.mob.ZombifiedPiglinEntity) AmbientEntity(net.minecraft.entity.mob.AmbientEntity) Monster(net.minecraft.entity.mob.Monster) ClientPlayerEntity(net.minecraft.client.network.ClientPlayerEntity) ArmorStandEntity(net.minecraft.entity.decoration.ArmorStandEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) MerchantEntity(net.minecraft.entity.passive.MerchantEntity) Box(net.minecraft.util.math.Box) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) Rotation(net.wurstclient.util.RotationUtils.Rotation) WaterCreatureEntity(net.minecraft.entity.mob.WaterCreatureEntity) EndermanEntity(net.minecraft.entity.mob.EndermanEntity) PassiveEntity(net.minecraft.entity.passive.PassiveEntity) ClientWorld(net.minecraft.client.world.ClientWorld)

Example 8 with EndCrystalEntity

use of net.minecraft.entity.decoration.EndCrystalEntity in project vector-addon by cally72jhb.

the class AutoCityPlus method getCrystals.

private ArrayList<Entity> getCrystals(BlockPos pos) {
    ArrayList<BlockPos> crystals = new ArrayList<>();
    ArrayList<Entity> entities = new ArrayList<>();
    if (canInteract(pos.down()))
        crystals.add(pos.down());
    for (int i = 0; i <= 1; i++) {
        for (BlockPos position : plus) {
            if (canInteract(pos.add(position).down(i)))
                crystals.add(pos.add(position).down(i));
        }
    }
    for (Entity entity : mc.world.getEntities()) {
        if (entity instanceof EndCrystalEntity && crystals.contains(entity.getBlockPos()))
            entities.add(entity);
    }
    entities.sort(Comparator.comparingDouble(entity -> VectorUtils.distance(mc.player.getPos(), Vec3d.ofCenter(entity.getBlockPos()))));
    return entities;
}
Also used : BlockUtils(meteordevelopment.meteorclient.utils.world.BlockUtils) Categories(cally72jhb.addon.system.categories.Categories) ShapeMode(meteordevelopment.meteorclient.renderer.ShapeMode) meteordevelopment.meteorclient.settings(meteordevelopment.meteorclient.settings) PlayerActionC2SPacket(net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket) TickEvent(meteordevelopment.meteorclient.events.world.TickEvent) ArrayList(java.util.ArrayList) Direction(net.minecraft.util.math.Direction) Module(meteordevelopment.meteorclient.systems.modules.Module) PlayerUtils(meteordevelopment.meteorclient.utils.player.PlayerUtils) Vec3d(net.minecraft.util.math.Vec3d) FindItemResult(meteordevelopment.meteorclient.utils.player.FindItemResult) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) PlayerInteractEntityC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket) Hand(net.minecraft.util.Hand) Utils(meteordevelopment.meteorclient.utils.Utils) SortPriority(meteordevelopment.meteorclient.utils.entity.SortPriority) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) EntityUtils(meteordevelopment.meteorclient.utils.entity.EntityUtils) PlayerEntity(net.minecraft.entity.player.PlayerEntity) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) BlockPos(net.minecraft.util.math.BlockPos) SettingColor(meteordevelopment.meteorclient.utils.render.color.SettingColor) Items(net.minecraft.item.Items) VectorUtils(cally72jhb.addon.utils.VectorUtils) Comparator(java.util.Comparator) TargetUtils(meteordevelopment.meteorclient.utils.entity.TargetUtils) EventHandler(meteordevelopment.orbit.EventHandler) Render3DEvent(meteordevelopment.meteorclient.events.render.Render3DEvent) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Example 9 with EndCrystalEntity

use of net.minecraft.entity.decoration.EndCrystalEntity in project orion by AntiCope.

the class SurroundPlus method onTick.

@EventHandler
private void onTick(TickEvent.Pre event) {
    int bpt = 0;
    if ((disableJump.get() && (mc.options.jumpKey.isPressed() || mc.player.input.jumping)) || (disableYchange.get() && mc.player.prevY < mc.player.getY())) {
        toggle();
        return;
    }
    if (groundOnly.get() && !mc.player.isOnGround())
        return;
    if (sneakOnly.get() && !mc.options.sneakKey.isPressed())
        return;
    if (BlockHelper.isVecComplete(getSurrDesign())) {
        if (disableAfter.get()) {
            info("Surround Complete.");
            toggle();
        }
    } else {
        BlockPos ppos = mc.player.getBlockPos();
        for (Vec3d b : getSurrDesign()) {
            if (bpt >= blockPerTick.get())
                return;
            BlockPos bb = ppos.add(b.x, b.y, b.z);
            if (BlockHelper.getBlock(bb) == Blocks.AIR) {
                if (placeInside.get()) {
                    BlockUtils.place(bb, InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem()))), rotation.get(), 100, false);
                } else {
                    BlockUtils.place(bb, InvUtils.findInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem()))), rotation.get(), 100, true);
                }
                bpt++;
            }
        }
    }
    if (protect.get()) {
        for (Entity entity : mc.world.getEntities()) {
            if (entity instanceof EndCrystalEntity) {
                BlockPos crystalPos = entity.getBlockPos();
                if (isDangerousCrystal(crystalPos)) {
                    mc.player.networkHandler.sendPacket(PlayerInteractEntityC2SPacket.attack(entity, mc.player.isSneaking()));
                    mc.getNetworkHandler().sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
                    return;
                }
            }
        }
    }
}
Also used : BlockUtils(meteordevelopment.meteorclient.utils.world.BlockUtils) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) ShapeMode(meteordevelopment.meteorclient.renderer.ShapeMode) meteordevelopment.meteorclient.settings(meteordevelopment.meteorclient.settings) BlockHelper(me.ghosttypes.orion.utils.world.BlockHelper) BlockPos(net.minecraft.util.math.BlockPos) SettingColor(meteordevelopment.meteorclient.utils.render.color.SettingColor) Blocks(net.minecraft.block.Blocks) TickEvent(meteordevelopment.meteorclient.events.world.TickEvent) ArrayList(java.util.ArrayList) List(java.util.List) Module(meteordevelopment.meteorclient.systems.modules.Module) PlayerUtils(meteordevelopment.meteorclient.utils.player.PlayerUtils) Block(net.minecraft.block.Block) Vec3d(net.minecraft.util.math.Vec3d) InvUtils(meteordevelopment.meteorclient.utils.player.InvUtils) PlayerInteractEntityC2SPacket(net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket) Orion(me.ghosttypes.orion.Orion) Hand(net.minecraft.util.Hand) EventHandler(meteordevelopment.orbit.EventHandler) Collections(java.util.Collections) Render3DEvent(meteordevelopment.meteorclient.events.render.Render3DEvent) Entity(net.minecraft.entity.Entity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) BlockPos(net.minecraft.util.math.BlockPos) Vec3d(net.minecraft.util.math.Vec3d) EventHandler(meteordevelopment.orbit.EventHandler)

Example 10 with EndCrystalEntity

use of net.minecraft.entity.decoration.EndCrystalEntity in project BleachHack by BleachDrinker420.

the class CrystalAura method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    breakCooldown = Math.max(0, breakCooldown - 1);
    placeCooldown = Math.max(0, placeCooldown - 1);
    for (Entry<BlockPos, Integer> e : new HashMap<>(blacklist).entrySet()) {
        if (e.getValue() > 0) {
            blacklist.replace(e.getKey(), e.getValue() - 1);
        } else {
            blacklist.remove(e.getKey());
        }
    }
    if (mc.player.isUsingItem() && mc.player.getMainHandStack().isFood()) {
        return;
    }
    List<LivingEntity> targets = Streams.stream(mc.world.getEntities()).filter(e -> EntityUtils.isAttackable(e, true)).filter(e -> (getSetting(0).asToggle().getState() && EntityUtils.isPlayer(e)) || (getSetting(1).asToggle().getState() && EntityUtils.isMob(e)) || (getSetting(2).asToggle().getState() && EntityUtils.isAnimal(e))).map(e -> (LivingEntity) e).toList();
    if (targets.isEmpty()) {
        return;
    }
    // Explode
    SettingToggle explodeToggle = getSetting(3).asToggle();
    List<EndCrystalEntity> nearestCrystals = Streams.stream(mc.world.getEntities()).filter(e -> e instanceof EndCrystalEntity).map(e -> (EndCrystalEntity) e).sorted(Comparator.comparing(mc.player::distanceTo)).toList();
    int breaks = 0;
    if (explodeToggle.getState() && !nearestCrystals.isEmpty() && breakCooldown <= 0) {
        boolean end = false;
        for (EndCrystalEntity c : nearestCrystals) {
            if (mc.player.distanceTo(c) > getSetting(7).asSlider().getValue() || mc.world.getOtherEntities(null, new Box(c.getPos(), c.getPos()).expand(7), targets::contains).isEmpty())
                continue;
            float damage = DamageUtils.getExplosionDamage(c.getPos(), 6f, mc.player);
            if (DamageUtils.willGoBelowHealth(mc.player, damage, explodeToggle.getChild(4).asSlider().getValueFloat()))
                continue;
            int oldSlot = mc.player.getInventory().selectedSlot;
            if (explodeToggle.getChild(0).asToggle().getState() && mc.player.hasStatusEffect(StatusEffects.WEAKNESS)) {
                InventoryUtils.selectSlot(false, true, Comparator.comparing(i -> DamageUtils.getItemAttackDamage(mc.player.getInventory().getStack(i))));
            }
            if (getSetting(6).asRotate().getState()) {
                Vec3d eyeVec = mc.player.getEyePos();
                Vec3d v = new Vec3d(c.getX(), c.getY() + 0.5, c.getZ());
                for (Direction d : Direction.values()) {
                    Vec3d vd = WorldUtils.getLegitLookPos(c.getBoundingBox(), d, true, 5, -0.001);
                    if (vd != null && eyeVec.distanceTo(vd) <= eyeVec.distanceTo(v)) {
                        v = vd;
                    }
                }
                WorldUtils.facePosAuto(v.x, v.y, v.z, getSetting(6).asRotate());
            }
            mc.interactionManager.attackEntity(mc.player, c);
            mc.player.swingHand(Hand.MAIN_HAND);
            blacklist.remove(c.getBlockPos().down());
            InventoryUtils.selectSlot(oldSlot);
            end = true;
            breaks++;
            if (breaks >= explodeToggle.getChild(2).asSlider().getValue()) {
                break;
            }
        }
        breakCooldown = explodeToggle.getChild(3).asSlider().getValueInt() + 1;
        if (!getSetting(5).asToggle().getState() && end) {
            return;
        }
    }
    // Place
    SettingToggle placeToggle = getSetting(4).asToggle();
    if (placeToggle.getState() && placeCooldown <= 0) {
        int crystalSlot = !placeToggle.getChild(0).asToggle().getState() ? (mc.player.getMainHandStack().getItem() == Items.END_CRYSTAL ? mc.player.getInventory().selectedSlot : mc.player.getOffHandStack().getItem() == Items.END_CRYSTAL ? 40 : -1) : InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.END_CRYSTAL);
        if (crystalSlot == -1) {
            return;
        }
        Map<BlockPos, Float> placeBlocks = new LinkedHashMap<>();
        for (Vec3d v : getCrystalPoses()) {
            float playerDamg = DamageUtils.getExplosionDamage(v, 6f, mc.player);
            if (DamageUtils.willKill(mc.player, playerDamg))
                continue;
            for (LivingEntity e : targets) {
                float targetDamg = DamageUtils.getExplosionDamage(v, 6f, e);
                if (DamageUtils.willPop(mc.player, playerDamg) && !DamageUtils.willPopOrKill(e, targetDamg)) {
                    continue;
                }
                if (targetDamg >= placeToggle.getChild(4).asSlider().getValue()) {
                    float ratio = playerDamg == 0 ? targetDamg : targetDamg / playerDamg;
                    if (ratio > placeToggle.getChild(5).asSlider().getValue()) {
                        placeBlocks.put(new BlockPos(v).down(), ratio);
                    }
                }
            }
        }
        placeBlocks = placeBlocks.entrySet().stream().sorted((b1, b2) -> Float.compare(b2.getValue(), b1.getValue())).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (x, y) -> y, LinkedHashMap::new));
        int oldSlot = mc.player.getInventory().selectedSlot;
        int places = 0;
        for (Entry<BlockPos, Float> e : placeBlocks.entrySet()) {
            BlockPos block = e.getKey();
            Vec3d eyeVec = mc.player.getEyePos();
            Vec3d vec = Vec3d.ofCenter(block, 1);
            Direction dir = null;
            for (Direction d : Direction.values()) {
                Vec3d vd = WorldUtils.getLegitLookPos(block, d, true, 5);
                if (vd != null && eyeVec.distanceTo(vd) <= eyeVec.distanceTo(vec)) {
                    vec = vd;
                    dir = d;
                }
            }
            if (dir == null) {
                if (placeToggle.getChild(3).asToggle().getState())
                    continue;
                dir = Direction.UP;
            }
            if (placeToggle.getChild(2).asToggle().getState())
                blacklist.put(block, 4);
            if (getSetting(6).asRotate().getState()) {
                WorldUtils.facePosAuto(vec.x, vec.y, vec.z, getSetting(6).asRotate());
            }
            Hand hand = InventoryUtils.selectSlot(crystalSlot);
            render = block;
            mc.interactionManager.interactBlock(mc.player, mc.world, hand, new BlockHitResult(vec, dir, block, false));
            places++;
            if (places >= placeToggle.getChild(6).asSlider().getValueInt()) {
                break;
            }
        }
        if (places > 0) {
            if (placeToggle.getChild(0).asToggle().getState() && placeToggle.getChild(0).asToggle().getChild(0).asToggle().getState()) {
                InventoryUtils.selectSlot(oldSlot);
            }
            placeCooldown = placeToggle.getChild(7).asSlider().getValueInt() + 1;
        }
    }
}
Also used : BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe) EntityUtils(org.bleachhack.util.world.EntityUtils) java.util(java.util) ModuleCategory(org.bleachhack.module.ModuleCategory) StatusEffects(net.minecraft.entity.effect.StatusEffects) InventoryUtils(org.bleachhack.util.InventoryUtils) Renderer(org.bleachhack.util.render.Renderer) Direction(net.minecraft.util.math.Direction) WorldUtils(org.bleachhack.util.world.WorldUtils) Vec3d(net.minecraft.util.math.Vec3d) DamageUtils(org.bleachhack.util.world.DamageUtils) Hand(net.minecraft.util.Hand) BlockState(net.minecraft.block.BlockState) SettingRotate(org.bleachhack.setting.module.SettingRotate) SettingSlider(org.bleachhack.setting.module.SettingSlider) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) LivingEntity(net.minecraft.entity.LivingEntity) Box(net.minecraft.util.math.Box) BlockHitResult(net.minecraft.util.hit.BlockHitResult) EventWorldRender(org.bleachhack.event.events.EventWorldRender) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) Blocks(net.minecraft.block.Blocks) Module(org.bleachhack.module.Module) QuadColor(org.bleachhack.util.render.color.QuadColor) SettingColor(org.bleachhack.setting.module.SettingColor) Entry(java.util.Map.Entry) SettingToggle(org.bleachhack.setting.module.SettingToggle) EventTick(org.bleachhack.event.events.EventTick) Direction(net.minecraft.util.math.Direction) LivingEntity(net.minecraft.entity.LivingEntity) EndCrystalEntity(net.minecraft.entity.decoration.EndCrystalEntity) Entry(java.util.Map.Entry) BlockPos(net.minecraft.util.math.BlockPos) BlockHitResult(net.minecraft.util.hit.BlockHitResult) Box(net.minecraft.util.math.Box) Hand(net.minecraft.util.Hand) Vec3d(net.minecraft.util.math.Vec3d) SettingToggle(org.bleachhack.setting.module.SettingToggle) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

EndCrystalEntity (net.minecraft.entity.decoration.EndCrystalEntity)18 Entity (net.minecraft.entity.Entity)14 PlayerEntity (net.minecraft.entity.player.PlayerEntity)14 LivingEntity (net.minecraft.entity.LivingEntity)11 Hand (net.minecraft.util.Hand)11 Box (net.minecraft.util.math.Box)11 Comparator (java.util.Comparator)9 Stream (java.util.stream.Stream)8 ArmorStandEntity (net.minecraft.entity.decoration.ArmorStandEntity)8 AmbientEntity (net.minecraft.entity.mob.AmbientEntity)8 Monster (net.minecraft.entity.mob.Monster)8 WaterCreatureEntity (net.minecraft.entity.mob.WaterCreatureEntity)8 AnimalEntity (net.minecraft.entity.passive.AnimalEntity)8 GolemEntity (net.minecraft.entity.passive.GolemEntity)8 MerchantEntity (net.minecraft.entity.passive.MerchantEntity)8 Category (net.wurstclient.Category)8 UpdateListener (net.wurstclient.events.UpdateListener)8 Hack (net.wurstclient.hack.Hack)8 CheckboxSetting (net.wurstclient.settings.CheckboxSetting)8 SliderSetting (net.wurstclient.settings.SliderSetting)8