use of net.minecraft.entity.projectile.thrown.ThrownEntity 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);
}
use of net.minecraft.entity.projectile.thrown.ThrownEntity 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));
}
}
}
}
Aggregations