use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.
the class FuelTankBlock method onProjectileHit.
@Override
public void onProjectileHit(World world, BlockState state, BlockHitResult hit, ProjectileEntity projectile) {
if (!world.isClient) {
Entity entity = projectile.getOwner();
BlockPos blockPos = hit.getBlockPos();
primeBlock(world, blockPos, entity instanceof LivingEntity ? (LivingEntity) entity : null);
world.removeBlock(blockPos, false);
}
}
use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.
the class AbstractRangedAttack method shoot1.
public void shoot1() {
LivingEntity livingentity = this.parentEntity.getTarget();
World world = this.parentEntity.getEntityWorld();
Vec3d vector3d = this.parentEntity.getRotationVec(1.0F);
double d2 = livingentity.getX() - (this.parentEntity.getX() + vector3d.x * xOffSetModifier);
double d3 = livingentity.getBodyY(0.5D) - (this.parentEntity.getBodyY(entityHeightFraction));
double d4 = livingentity.getZ() - (this.parentEntity.getZ() + vector3d.z * zOffSetModifier);
ProjectileEntity projectile = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
projectile.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
projectile.hasNoGravity();
ProjectileEntity projectile1 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile1.setVelocity(parentEntity, parentEntity.getPitch() + 2, parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
projectile1.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
projectile1.hasNoGravity();
ProjectileEntity projectile2 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile2.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw() + 2, 0.0F, 0.25F * 3.0F, 1.0F);
projectile2.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
projectile2.hasNoGravity();
ProjectileEntity projectile3 = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile3.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw() - 2, 0.0F, 0.25F * 3.0F, 1.0F);
projectile3.refreshPositionAndAngles(parentEntity.getX(), parentEntity.getBodyY(0.85), parentEntity.getZ(), 0, 0);
projectile3.hasNoGravity();
world.spawnEntity(projectile);
world.spawnEntity(projectile1);
world.spawnEntity(projectile2);
world.spawnEntity(projectile3);
if (sound == null)
getDefaultAttackSound().play(this.parentEntity);
else
sound.play(this.parentEntity);
}
use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.
the class AbstractRangedAttack method shoot.
public void shoot() {
LivingEntity livingentity = this.parentEntity.getTarget();
World world = this.parentEntity.getEntityWorld();
Vec3d vector3d = this.parentEntity.getRotationVec(1.0F);
double d2 = livingentity.getX() - (this.parentEntity.getX() + vector3d.x * xOffSetModifier);
double d3 = livingentity.getBodyY(0.5D) - (this.parentEntity.getBodyY(entityHeightFraction));
double d4 = livingentity.getZ() - (this.parentEntity.getZ() + vector3d.z * zOffSetModifier);
ProjectileEntity projectile = getProjectile(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile.setVelocity(parentEntity, parentEntity.getPitch(), parentEntity.getYaw(), 0.0F, 0.25F * 3.0F, 1.0F);
world.spawnEntity(projectile);
if (sound == null)
getDefaultAttackSound().play(this.parentEntity);
else
sound.play(this.parentEntity);
}
use of net.minecraft.entity.projectile.ProjectileEntity in project HWG by cybercat-mods.
the class FlareGunItem method shoot.
private static void shoot(World world, LivingEntity shooter, Hand hand, ItemStack stack, ItemStack projectile, float soundPitch, boolean creative, float speed, float divergence, float simulated) {
if (!world.isClient) {
BaseFlareEntity flareEntity = new BaseFlareEntity(world, projectile, shooter, shooter.getX(), shooter.getEyeY() - 0.15000000596046448D, shooter.getZ(), true);
boolean bl = projectile.getItem() == HWGItems.BLACK_FLARE;
boolean b2 = projectile.getItem() == HWGItems.BLUE_FLARE;
boolean b3 = projectile.getItem() == HWGItems.BROWN_FLARE;
boolean b4 = projectile.getItem() == HWGItems.CYAN_FLARE;
boolean b5 = projectile.getItem() == HWGItems.GRAY_FLARE;
boolean b6 = projectile.getItem() == HWGItems.GREEN_FLARE;
boolean b7 = projectile.getItem() == HWGItems.LIGHTBLUE_FLARE;
boolean b8 = projectile.getItem() == HWGItems.LIGHTGRAY_FLARE;
boolean b9 = projectile.getItem() == HWGItems.LIME_FLARE;
boolean b10 = projectile.getItem() == HWGItems.MAGENTA_FLARE;
boolean b11 = projectile.getItem() == HWGItems.ORANGE_FLARE;
boolean b12 = projectile.getItem() == HWGItems.PINK_FLARE;
boolean b13 = projectile.getItem() == HWGItems.PURPLE_FLARE;
boolean b14 = projectile.getItem() == HWGItems.RED_FLARE;
boolean b15 = projectile.getItem() == HWGItems.YELLOW_FLARE;
if (bl) {
flareEntity.setColor(1);
} else if (b2) {
flareEntity.setColor(2);
} else if (b3) {
flareEntity.setColor(3);
} else if (b4) {
flareEntity.setColor(4);
} else if (b5) {
flareEntity.setColor(5);
} else if (b6) {
flareEntity.setColor(6);
} else if (b7) {
flareEntity.setColor(7);
} else if (b8) {
flareEntity.setColor(8);
} else if (b9) {
flareEntity.setColor(9);
} else if (b10) {
flareEntity.setColor(10);
} else if (b11) {
flareEntity.setColor(11);
} else if (b12) {
flareEntity.setColor(12);
} else if (b13) {
flareEntity.setColor(13);
} else if (b14) {
flareEntity.setColor(14);
} else if (b15) {
flareEntity.setColor(15);
} else {
flareEntity.setColor(16);
}
Vec3d vec3d = shooter.getOppositeRotationVector(1.0F);
Quaternion quaternion = new Quaternion(new Vec3f(vec3d), simulated, true);
Vec3d vec3d2 = shooter.getRotationVec(1.0F);
Vec3f vector3f = new Vec3f(vec3d2);
vector3f.rotate(quaternion);
((ProjectileEntity) flareEntity).setVelocity((double) vector3f.getX(), (double) vector3f.getY(), (double) vector3f.getZ(), speed, divergence);
((PersistentProjectileEntity) flareEntity).setDamage(0.3D);
((PersistentProjectileEntity) flareEntity).pickupType = PersistentProjectileEntity.PickupPermission.DISALLOWED;
stack.damage(1, shooter, p -> p.sendToolBreakStatus(shooter.getActiveHand()));
world.spawnEntity((Entity) flareEntity);
}
}
use of net.minecraft.entity.projectile.ProjectileEntity in project Magma-1.16.x by magmafoundation.
the class CraftEventFactory method callBlockIgniteEvent.
public static BlockIgniteEvent callBlockIgniteEvent(World world, BlockPos pos, Entity igniter) {
org.bukkit.World bukkitWorld = world.getWorldCB();
org.bukkit.entity.Entity bukkitIgniter = igniter.getBukkitEntity();
IgniteCause cause;
switch(bukkitIgniter.getType()) {
case ENDER_CRYSTAL:
cause = IgniteCause.ENDER_CRYSTAL;
break;
case LIGHTNING:
cause = IgniteCause.LIGHTNING;
break;
case SMALL_FIREBALL:
case FIREBALL:
cause = IgniteCause.FIREBALL;
break;
case ARROW:
cause = IgniteCause.ARROW;
break;
default:
cause = IgniteCause.FLINT_AND_STEEL;
}
if (igniter instanceof ProjectileEntity) {
Entity shooter = ((ProjectileEntity) igniter).getEntity();
if (shooter != null) {
bukkitIgniter = shooter.getBukkitEntity();
}
}
BlockIgniteEvent event = new BlockIgniteEvent(bukkitWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), cause, bukkitIgniter);
world.getServerCB().getPluginManager().callEvent(event);
return event;
}
Aggregations