Search in sources :

Example 1 with FireballEntity

use of net.minecraft.entity.projectile.FireballEntity in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAIFireball method start.

@Override
public void start() {
    super.start();
    this.cooldown = 140;
    this.entity.getMainHandItem().shrink(1);
    Vector3d v = this.entity.getTarget().position().subtract(this.entity.position());
    DamagingProjectileEntity fireball = this.entity.getRandom().nextDouble() > 0.7 ? new FireballEntity(this.entity.level, this.entity, v.x, v.y, v.z) : new SmallFireballEntity(this.entity.level, this.entity, v.x, v.y, v.z);
    this.entity.level.addFreshEntity(fireball);
}
Also used : Vector3d(net.minecraft.util.math.vector.Vector3d) DamagingProjectileEntity(net.minecraft.entity.projectile.DamagingProjectileEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) SmallFireballEntity(net.minecraft.entity.projectile.SmallFireballEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity)

Example 2 with FireballEntity

use of net.minecraft.entity.projectile.FireballEntity in project bewitchment by MoriyaShiine.

the class BaphometEntity method tick.

@Override
public void tick() {
    super.tick();
    flameIndex = ++flameIndex % 8;
    if (!world.isClient) {
        bossBar.setPercent(getHealth() / getMaxHealth());
        tradeResetTimer++;
        if (tradeResetTimer >= 168000) {
            tradeResetTimer = 0;
            offers.clear();
        }
        LivingEntity target = getTarget();
        int timer = age + getId();
        if (timer % 20 == 0) {
            heal(1);
        }
        if (target != null) {
            timeSinceLastAttack++;
            if (timeSinceLastAttack >= 600) {
                BWUtil.teleport(this, target.getX(), target.getY(), target.getZ(), true);
                timeSinceLastAttack = 0;
            }
            lookAtEntity(target, 360, 360);
            if (timer % 60 == 0) {
                for (int i = -1; i <= 1; i++) {
                    FireballEntity fireball = new FireballEntity(world, this, target.getX() - getX() + (i * 2), target.getBodyY(0.5) - getBodyY(0.5), target.getZ() - getZ() + (i * 2), 1);
                    fireball.updatePosition(fireball.getX(), getBodyY(0.5), fireball.getZ());
                    fireball.setOwner(this);
                    world.playSound(null, getBlockPos(), BWSoundEvents.ENTITY_GENERIC_SHOOT, getSoundCategory(), getSoundVolume(), getSoundPitch());
                    world.spawnEntity(fireball);
                }
                swingHand(Hand.MAIN_HAND);
            }
            if (timer % 600 == 0) {
                summonMinions(this);
            }
        } else {
            if (getY() > -64) {
                heal(8);
            }
            timeSinceLastAttack = 0;
        }
    }
}
Also used : LivingEntity(net.minecraft.entity.LivingEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity)

Example 3 with FireballEntity

use of net.minecraft.entity.projectile.FireballEntity in project Fragile-Glass by fredtargaryen.

the class EntityDataManager method addCapabilityIfPossible.

public void addCapabilityIfPossible(Entity e, AttachCapabilitiesEvent<Entity> evt) {
    // A player would reasonably expect many existing entities to be able to break fragile blocks, but it is
    // very unlikely that anyone would go to the trouble of writing out all the config lines for every entity.
    // The following code does some type checks and creates BreakerDatas if the entity probably would break a block.
    BreakerData breakerData = this.data.get(e.getType());
    if (breakerData == null) {
        // A breakerdata for this entitytype has not been created yet
        if (e instanceof LivingEntity || e instanceof ArrowEntity || e instanceof FireballEntity || e instanceof MinecartEntity || e instanceof FireworkRocketEntity || e instanceof BoatEntity || e instanceof TNTEntity || e instanceof FallingBlockEntity) {
            breakerData = new BreakerData(DataReference.MINIMUM_ENTITY_SPEED_SQUARED, DataReference.MAXIMUM_ENTITY_SPEED_SQUARED, new String[] {});
            this.data.put(e.getType(), breakerData);
        }
    }
    if (breakerData != null) {
        // The entity was predefined (via configs or commands) as being able to break a block,
        // or a BreakerData was automatically created above.
        ICapabilityProvider iCapProv = new ICapabilityProvider() {

            IBreakCapability inst = new IBreakCapability() {

                @Override
                public void init(Entity e) {
                }

                @Override
                public void update(Entity e) {
                }

                @Override
                public double getSpeedSquared(Entity e) {
                    Vector3d motion = e.getMotion();
                    return motion.x * motion.x + motion.y * motion.y + motion.z * motion.z;
                }

                @Override
                public boolean isAbleToBreak(Entity e, double speedSq) {
                    BreakerData breakerData = EntityDataManager.this.data.get(e.getType());
                    if (breakerData == null)
                        return false;
                    return speedSq >= breakerData.getMinSpeedSquared() && speedSq <= breakerData.getMaxSpeedSquared();
                }

                @Override
                public double getMotionX(Entity e) {
                    return e.getMotion().x;
                }

                @Override
                public double getMotionY(Entity e) {
                    return e.getMotion().y;
                }

                @Override
                public double getMotionZ(Entity e) {
                    return e.getMotion().z;
                }

                @Override
                public byte getNoOfBreaks(Entity e) {
                    return 1;
                }
            };

            @Nullable
            @Override
            public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> capability, @Nullable Direction facing) {
                return capability == FragileGlassBase.BREAKCAP ? LazyOptional.of(() -> (T) inst) : LazyOptional.empty();
            }
        };
        evt.addCapability(DataReference.BREAK_LOCATION, iCapProv);
    }
}
Also used : FallingBlockEntity(net.minecraft.entity.item.FallingBlockEntity) BreakerData(com.fredtargaryen.fragileglass.config.behaviour.data.BreakerData) BoatEntity(net.minecraft.entity.item.BoatEntity) FallingBlockEntity(net.minecraft.entity.item.FallingBlockEntity) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) BoatEntity(net.minecraft.entity.item.BoatEntity) TNTEntity(net.minecraft.entity.item.TNTEntity) Entity(net.minecraft.entity.Entity) LivingEntity(net.minecraft.entity.LivingEntity) MinecartEntity(net.minecraft.entity.item.minecart.MinecartEntity) FireballEntity(net.minecraft.entity.projectile.FireballEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) TNTEntity(net.minecraft.entity.item.TNTEntity) IBreakCapability(com.fredtargaryen.fragileglass.entity.capability.IBreakCapability) Capability(net.minecraftforge.common.capabilities.Capability) MinecartEntity(net.minecraft.entity.item.minecart.MinecartEntity) ICapabilityProvider(net.minecraftforge.common.capabilities.ICapabilityProvider) Nonnull(javax.annotation.Nonnull) ArrowEntity(net.minecraft.entity.projectile.ArrowEntity) FireworkRocketEntity(net.minecraft.entity.projectile.FireworkRocketEntity) Direction(net.minecraft.util.Direction) IBreakCapability(com.fredtargaryen.fragileglass.entity.capability.IBreakCapability) LivingEntity(net.minecraft.entity.LivingEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) Nullable(javax.annotation.Nullable) FireballEntity(net.minecraft.entity.projectile.FireballEntity)

Aggregations

FireballEntity (net.minecraft.entity.projectile.FireballEntity)3 LivingEntity (net.minecraft.entity.LivingEntity)2 Vector3d (net.minecraft.util.math.vector.Vector3d)2 BreakerData (com.fredtargaryen.fragileglass.config.behaviour.data.BreakerData)1 IBreakCapability (com.fredtargaryen.fragileglass.entity.capability.IBreakCapability)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 BoatEntity (net.minecraft.entity.item.BoatEntity)1 FallingBlockEntity (net.minecraft.entity.item.FallingBlockEntity)1 TNTEntity (net.minecraft.entity.item.TNTEntity)1 MinecartEntity (net.minecraft.entity.item.minecart.MinecartEntity)1 ArrowEntity (net.minecraft.entity.projectile.ArrowEntity)1 DamagingProjectileEntity (net.minecraft.entity.projectile.DamagingProjectileEntity)1 FireworkRocketEntity (net.minecraft.entity.projectile.FireworkRocketEntity)1 SmallFireballEntity (net.minecraft.entity.projectile.SmallFireballEntity)1 Direction (net.minecraft.util.Direction)1 Capability (net.minecraftforge.common.capabilities.Capability)1 ICapabilityProvider (net.minecraftforge.common.capabilities.ICapabilityProvider)1