use of net.minecraft.entity.projectile.ProjectileEntity in project Hyper-Lighting by Exploding-Creeper.
the class CampFireBlock method onProjectileCollision.
@Override
public void onProjectileCollision(World worldIn, BlockState state, BlockRayTraceResult hit, ProjectileEntity projectile) {
if (!worldIn.isRemote && projectile.isBurning()) {
Entity entity = projectile.getShooter();
boolean flag = entity == null || entity instanceof PlayerEntity || net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(worldIn, entity);
if (flag && !state.get(LIT) && !state.get(WATERLOGGED)) {
BlockPos blockpos = hit.getPos();
worldIn.setBlockState(blockpos, state.with(BlockStateProperties.LIT, Boolean.valueOf(true)), 11);
}
}
}
use of net.minecraft.entity.projectile.ProjectileEntity in project MCDoom by AzureDoom.
the class AbstractDoubleRangedAttack method shoot2.
public void shoot2() {
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 = getProjectile2(world, rollAccuracy(d2), rollAccuracy(d3), rollAccuracy(d4));
projectile.updatePosition(this.parentEntity.getX() + vector3d.x * xOffSetModifier, this.parentEntity.getBodyY(entityHeightFraction), this.parentEntity.getZ() + vector3d.z * zOffSetModifier);
world.spawnEntity(projectile);
if (sound == null)
getDefaultAttackSound().play(this.parentEntity);
else
sound.play(this.parentEntity);
}
use of net.minecraft.entity.projectile.ProjectileEntity in project MCDoom by AzureDoom.
the class BarrelBlock 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 bioplethora by AquexTheSeal.
the class ArbitraryBallistaItem method shootProjectile.
private static void shootProjectile(World level, LivingEntity entity, Hand hand, ItemStack stack, ItemStack itemStack, float p_220016_5_, boolean b, float p_220016_7_, float p_220016_8_, float v) {
double x = entity.getX(), y = entity.getY(), z = entity.getZ();
BlockPos pos = entity.getEntity().blockPosition();
if (!level.isClientSide) {
boolean flag = itemStack.getItem() == Items.FIREWORK_ROCKET;
ProjectileEntity projectileentity;
if (flag) {
projectileentity = new FireworkRocketEntity(level, itemStack, entity, entity.getX(), entity.getEyeY() - (double) 0.15F, entity.getZ(), true);
} else {
projectileentity = getArrow(level, entity, stack, itemStack);
if (b || v != 0.0F) {
((AbstractArrowEntity) projectileentity).pickup = AbstractArrowEntity.PickupStatus.CREATIVE_ONLY;
}
}
if ((!(level.isClientSide()))) {
((ServerWorld) level).sendParticles(ParticleTypes.CLOUD, x, y + 1.2, z, 25, 0.75, 0.75, 0.75, 0.01);
((ServerWorld) level).sendParticles(ParticleTypes.EXPLOSION, x, y + 1.2, z, 25, 0.75, 0.75, 0.75, 0);
}
level.playSound(null, x, y, z, SoundEvents.GENERIC_EXPLODE, SoundCategory.PLAYERS, 1, 1);
if (entity instanceof ICrossbowUser) {
ICrossbowUser icrossbowuser = (ICrossbowUser) entity;
icrossbowuser.shootCrossbowProjectile(icrossbowuser.getTarget(), stack, projectileentity, v);
} else {
Vector3d vector3d1 = entity.getUpVector(1.0F);
Quaternion quaternion = new Quaternion(new Vector3f(vector3d1), v, true);
Vector3d vector3d = entity.getViewVector(1.0F);
Vector3f vector3f = new Vector3f(vector3d);
vector3f.transform(quaternion);
projectileentity.shoot(vector3f.x(), vector3f.y(), vector3f.z(), p_220016_7_, p_220016_8_);
}
stack.hurtAndBreak(flag ? 3 : 1, entity, (living) -> living.broadcastBreakEvent(hand));
level.addFreshEntity(projectileentity);
level.playSound(null, entity.getX(), entity.getY(), entity.getZ(), SoundEvents.CROSSBOW_SHOOT, SoundCategory.PLAYERS, 1.0F, p_220016_5_);
}
}
use of net.minecraft.entity.projectile.ProjectileEntity in project Client by MatHax.
the class EntityOwner method onRender2D.
@EventHandler
private void onRender2D(Render2DEvent event) {
for (Entity entity : mc.world.getEntities()) {
UUID ownerUuid;
if (entity instanceof TameableEntity)
ownerUuid = ((TameableEntity) entity).getOwnerUuid();
else if (entity instanceof HorseBaseEntity)
ownerUuid = ((HorseBaseEntity) entity).getOwnerUuid();
else if (entity instanceof ProjectileEntity && projectiles.get())
ownerUuid = ((ProjectileEntityAccessor) entity).getOwnerUuid();
else
continue;
if (ownerUuid != null) {
pos.set(entity, event.tickDelta);
pos.add(0, entity.getEyeHeight(entity.getPose()) + 0.75, 0);
if (NametagUtils.to2D(pos, scale.get())) {
renderNametag(getOwnerName(ownerUuid));
}
}
}
}
Aggregations