use of net.minecraft.entity.projectile.thrown.PotionEntity in project bewitchment by MoriyaShiine.
the class LeonardEntity method spawnPotion.
private void spawnPotion(BlockPos target, Potion potionType) {
PotionEntity potion = new PotionEntity(world, this);
potion.setItem(PotionUtil.setPotion(new ItemStack(Items.SPLASH_POTION), potionType));
potion.updatePosition(potion.getX(), getBodyY(0.5), potion.getZ());
double targetX = target.getX() - getX();
double targetY = target.getY() - 1 - getY();
double targetZ = target.getZ() - getZ();
potion.setVelocity(targetX, targetY + (MathHelper.sqrt((float) (targetX * targetX + targetZ * targetZ)) * 0.4), targetZ, 1, 0);
world.playSound(null, getBlockPos(), SoundEvents.ENTITY_SPLASH_POTION_THROW, getSoundCategory(), getSoundVolume(), getSoundPitch());
world.spawnEntity(potion);
swingHand(Hand.MAIN_HAND);
}
use of net.minecraft.entity.projectile.thrown.PotionEntity in project MCDoom by AzureDoom.
the class PossessedScientistEntity method attack.
@Override
public void attack(LivingEntity target, float pullProgress) {
Vec3d vec3d = target.getVelocity();
double d = target.getX() + vec3d.x - this.getX();
double e = target.getEyeY() - (double) 1.1f - this.getY();
double f = target.getZ() + vec3d.z - this.getZ();
double g = Math.sqrt(d * d + f * f);
Potion potion;
if (target instanceof DemonEntity) {
potion = target.getHealth() <= 4.0f ? Potions.HEALING : Potions.REGENERATION;
this.setTarget(null);
} else {
potion = Potions.POISON;
}
PotionEntity potionEntity = new PotionEntity(this.world, this);
potionEntity.setItem(PotionUtil.setPotion(new ItemStack(Items.SPLASH_POTION), potion));
potionEntity.setPitch(potionEntity.getPitch() - -20.0f);
potionEntity.setVelocity(d, e + g * 0.2, f, 0.75f, 8.0f);
if (!this.isSilent()) {
this.world.playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0f, 0.8f + this.random.nextFloat() * 0.4f);
}
this.world.spawnEntity(potionEntity);
}
use of net.minecraft.entity.projectile.thrown.PotionEntity 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.PotionEntity 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;
}
Aggregations