Search in sources :

Example 1 with ExperienceBottleEntity

use of net.minecraft.entity.projectile.thrown.ExperienceBottleEntity in project BleachHack by BleachDrinker420.

the class ProjectileSimulator method simulate.

public static Triple<List<Vec3d>, Entity, BlockPos> simulate(Entity e) {
    List<Vec3d> vecs = new ArrayList<>();
    SimulatedProjectile spoofE = new SimulatedProjectile(e);
    for (int i = 0; i < 100; i++) {
        Vec3d vel = spoofE.velocity;
        Vec3d newVec = spoofE.getPos().add(vel);
        // EntityHitResult entityHit = ProjectileUtil.raycast(mc.player, e.getPos(),
        // newVec, e.getBoundingBox(), null, 1f);
        List<LivingEntity> entities = mc.world.getEntitiesByClass(LivingEntity.class, spoofE.getBoundingBox().expand(0.15), EntityPredicates.VALID_LIVING_ENTITY.and(en -> en != mc.player && en != e));
        if (!entities.isEmpty()) {
            return Triple.of(vecs, entities.get(0), null);
        }
        BlockHitResult blockHit = mc.world.raycast(new RaycastContext(spoofE.getPos(), newVec, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, e));
        if (blockHit.getType() != HitResult.Type.MISS) {
            vecs.add(blockHit.getPos());
            return Triple.of(vecs, null, blockHit.getBlockPos());
        }
        float prevPitch = spoofE.pitch;
        spoofE.pitch = MathHelper.lerp(0.2F, spoofE.prevPitch, spoofE.pitch);
        spoofE.prevPitch = prevPitch;
        double gravity = e instanceof PotionEntity ? 0.05 : e instanceof ExperienceBottleEntity ? 0.07 : e instanceof ThrownEntity ? 0.03 : 0.05000000074505806;
        spoofE.velocity = new Vec3d(vel.x * 0.99, vel.y * 0.99 - gravity, vel.z * 0.99);
        spoofE.setPos(spoofE.getPos().x + spoofE.velocity.x, spoofE.getPos().y + spoofE.velocity.y, spoofE.getPos().z + spoofE.velocity.z);
        vecs.add(spoofE.getPos());
    }
    return Triple.of(vecs, null, null);
}
Also used : Entity(net.minecraft.entity.Entity) PotionEntity(net.minecraft.entity.projectile.thrown.PotionEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) Box(net.minecraft.util.math.Box) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult) net.minecraft.item(net.minecraft.item) BlockPos(net.minecraft.util.math.BlockPos) TridentEntity(net.minecraft.entity.projectile.TridentEntity) ThrownEntity(net.minecraft.entity.projectile.thrown.ThrownEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) ArrayList(java.util.ArrayList) HitResult(net.minecraft.util.hit.HitResult) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) List(java.util.List) Vec3d(net.minecraft.util.math.Vec3d) MathHelper(net.minecraft.util.math.MathHelper) EntityPredicates(net.minecraft.predicate.entity.EntityPredicates) RaycastContext(net.minecraft.world.RaycastContext) MinecraftClient(net.minecraft.client.MinecraftClient) Triple(org.apache.commons.lang3.tuple.Triple) RaycastContext(net.minecraft.world.RaycastContext) ThrownEntity(net.minecraft.entity.projectile.thrown.ThrownEntity) ArrayList(java.util.ArrayList) Vec3d(net.minecraft.util.math.Vec3d) PotionEntity(net.minecraft.entity.projectile.thrown.PotionEntity) LivingEntity(net.minecraft.entity.LivingEntity) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) BlockHitResult(net.minecraft.util.hit.BlockHitResult)

Example 2 with ExperienceBottleEntity

use of net.minecraft.entity.projectile.thrown.ExperienceBottleEntity in project BleachHack by BleachDrinker420.

the class ProjectileSimulator method summonProjectile.

public static Entity summonProjectile(PlayerEntity thrower, boolean allowThrowables, boolean allowXp, boolean allowPotions) {
    ItemStack hand = (isThrowable(thrower.getInventory().getMainHandStack().getItem(), allowThrowables, allowXp, allowPotions) ? thrower.getInventory().getMainHandStack() : isThrowable(thrower.getInventory().offHand.get(0).getItem(), allowThrowables, allowXp, allowPotions) ? thrower.getInventory().offHand.get(0) : null);
    if (hand == null) {
        return null;
    }
    if (hand.getItem() instanceof RangedWeaponItem) {
        float charged = hand.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(hand) ? 1f : hand.getItem() == Items.CROSSBOW ? 0f : BowItem.getPullProgress(thrower.getItemUseTime());
        if (charged > 0f) {
            Entity e = new ArrowEntity(mc.world, mc.player);
            initProjectile(e, thrower, 0f, charged * 3);
            return e;
        }
    } else if (hand.getItem() instanceof SnowballItem || hand.getItem() instanceof EggItem || hand.getItem() instanceof EnderPearlItem) {
        Entity e = new SnowballEntity(mc.world, mc.player);
        initProjectile(e, thrower, 0f, 1.5f);
        return e;
    } else if (hand.getItem() instanceof ExperienceBottleItem) {
        Entity e = new ExperienceBottleEntity(mc.world, mc.player);
        initProjectile(e, thrower, -20f, 0.7f);
        return e;
    } else if (hand.getItem() instanceof ThrowablePotionItem) {
        Entity e = new PotionEntity(mc.world, mc.player);
        initProjectile(e, thrower, -20f, 0.5f);
        return e;
    } else if (hand.getItem() instanceof TridentItem) {
        Entity e = new TridentEntity(mc.world, mc.player, hand);
        initProjectile(e, thrower, 0f, 2.5f);
        return e;
    }
    return null;
}
Also used : Entity(net.minecraft.entity.Entity) PotionEntity(net.minecraft.entity.projectile.thrown.PotionEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) TridentEntity(net.minecraft.entity.projectile.TridentEntity) ThrownEntity(net.minecraft.entity.projectile.thrown.ThrownEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) PotionEntity(net.minecraft.entity.projectile.thrown.PotionEntity) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) TridentEntity(net.minecraft.entity.projectile.TridentEntity) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity)

Example 3 with ExperienceBottleEntity

use of net.minecraft.entity.projectile.thrown.ExperienceBottleEntity in project BleachHack by BleachDrinker420.

the class Trajectories method onTick.

@BleachSubscribe
public void onTick(EventTick event) {
    poses.clear();
    Entity entity = ProjectileSimulator.summonProjectile(mc.player, getSetting(1).asToggle().getState(), getSetting(2).asToggle().getState(), getSetting(3).asToggle().getState());
    if (entity != null) {
        poses.add(ProjectileSimulator.simulate(entity));
    }
    if (getSetting(4).asToggle().getState()) {
        for (Entity e : mc.world.getEntities()) {
            if (e instanceof ThrownEntity || e instanceof PersistentProjectileEntity) {
                if (!getSetting(4).asToggle().getChild(0).asToggle().getState() && (e instanceof SnowballEntity || e instanceof EggEntity || e instanceof EnderPearlEntity)) {
                    continue;
                }
                if (!getSetting(4).asToggle().getChild(1).asToggle().getState() && e instanceof ExperienceBottleEntity) {
                    continue;
                }
                if (!mc.world.getBlockCollisions(e, e.getBoundingBox()).allMatch(VoxelShape::isEmpty))
                    continue;
                Triple<List<Vec3d>, Entity, BlockPos> p = ProjectileSimulator.simulate(e);
                if (p.getLeft().size() >= 2)
                    poses.add(p);
            }
        }
    }
    if (getSetting(5).asToggle().getState()) {
        for (PlayerEntity e : mc.world.getPlayers()) {
            if (e == mc.player)
                continue;
            Entity proj = ProjectileSimulator.summonProjectile(e, getSetting(1).asToggle().getState(), getSetting(2).asToggle().getState(), getSetting(3).asToggle().getState());
            if (proj != null) {
                poses.add(ProjectileSimulator.simulate(proj));
            }
        }
    }
}
Also used : EnderPearlEntity(net.minecraft.entity.projectile.thrown.EnderPearlEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) ThrownEntity(net.minecraft.entity.projectile.thrown.ThrownEntity) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) EggEntity(net.minecraft.entity.projectile.thrown.EggEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) EnderPearlEntity(net.minecraft.entity.projectile.thrown.EnderPearlEntity) ThrownEntity(net.minecraft.entity.projectile.thrown.ThrownEntity) PersistentProjectileEntity(net.minecraft.entity.projectile.PersistentProjectileEntity) EggEntity(net.minecraft.entity.projectile.thrown.EggEntity) ExperienceBottleEntity(net.minecraft.entity.projectile.thrown.ExperienceBottleEntity) ArrayList(java.util.ArrayList) List(java.util.List) BlockPos(net.minecraft.util.math.BlockPos) SnowballEntity(net.minecraft.entity.projectile.thrown.SnowballEntity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) BleachSubscribe(org.bleachhack.eventbus.BleachSubscribe)

Aggregations

Entity (net.minecraft.entity.Entity)3 PlayerEntity (net.minecraft.entity.player.PlayerEntity)3 ExperienceBottleEntity (net.minecraft.entity.projectile.thrown.ExperienceBottleEntity)3 SnowballEntity (net.minecraft.entity.projectile.thrown.SnowballEntity)3 ThrownEntity (net.minecraft.entity.projectile.thrown.ThrownEntity)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 LivingEntity (net.minecraft.entity.LivingEntity)2 ArrowEntity (net.minecraft.entity.projectile.ArrowEntity)2 TridentEntity (net.minecraft.entity.projectile.TridentEntity)2 PotionEntity (net.minecraft.entity.projectile.thrown.PotionEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 MinecraftClient (net.minecraft.client.MinecraftClient)1 PersistentProjectileEntity (net.minecraft.entity.projectile.PersistentProjectileEntity)1 EggEntity (net.minecraft.entity.projectile.thrown.EggEntity)1 EnderPearlEntity (net.minecraft.entity.projectile.thrown.EnderPearlEntity)1 net.minecraft.item (net.minecraft.item)1 EntityPredicates (net.minecraft.predicate.entity.EntityPredicates)1 BlockHitResult (net.minecraft.util.hit.BlockHitResult)1 HitResult (net.minecraft.util.hit.HitResult)1