Search in sources :

Example 1 with ProjectileEntity

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);
        }
    }
}
Also used : PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) BlockPos(net.minecraft.util.math.BlockPos) PlayerEntity(net.minecraft.entity.player.PlayerEntity)

Example 2 with ProjectileEntity

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);
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) World(net.minecraft.world.World) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with ProjectileEntity

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);
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) BarrelEntity(mod.azure.doom.entity.projectiles.BarrelEntity) Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) LivingEntity(net.minecraft.entity.LivingEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) BlockPos(net.minecraft.util.math.BlockPos)

Example 4 with ProjectileEntity

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_);
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) Quaternion(net.minecraft.util.math.vector.Quaternion) Vector3f(net.minecraft.util.math.vector.Vector3f) BlockPos(net.minecraft.util.math.BlockPos) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) ICrossbowUser(net.minecraft.entity.ICrossbowUser)

Example 5 with ProjectileEntity

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));
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) ProjectileEntity(net.minecraft.entity.projectile.ProjectileEntity) TameableEntity(net.minecraft.entity.passive.TameableEntity) UUID(java.util.UUID) HorseBaseEntity(net.minecraft.entity.passive.HorseBaseEntity) ProjectileEntityAccessor(mathax.client.mixin.ProjectileEntityAccessor) EventHandler(mathax.client.eventbus.EventHandler)

Aggregations

ProjectileEntity (net.minecraft.entity.projectile.ProjectileEntity)10 Entity (net.minecraft.entity.Entity)6 LivingEntity (net.minecraft.entity.LivingEntity)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)6 BlockPos (net.minecraft.util.math.BlockPos)3 Vec3d (net.minecraft.util.math.Vec3d)3 World (net.minecraft.world.World)3 UUID (java.util.UUID)2 HorseBaseEntity (net.minecraft.entity.passive.HorseBaseEntity)2 TameableEntity (net.minecraft.entity.passive.TameableEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 ICombatCapability (jackiecrazy.wardance.capability.resources.ICombatCapability)1 FearEntity (jackiecrazy.wardance.entity.FearEntity)1 ProjectileParryEvent (jackiecrazy.wardance.event.ProjectileParryEvent)1 ProjectileImpactMixin (jackiecrazy.wardance.mixin.ProjectileImpactMixin)1 CombatUtils (jackiecrazy.wardance.utils.CombatUtils)1 StealthUtils (jackiecrazy.wardance.utils.StealthUtils)1 EventHandler (mathax.client.eventbus.EventHandler)1 ProjectileEntityAccessor (mathax.client.mixin.ProjectileEntityAccessor)1 ProjectileEntityAccessor (meteordevelopment.meteorclient.mixin.ProjectileEntityAccessor)1