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);
}
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;
}
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));
}
}
}
}
Aggregations