| 1 | package net.minecraft.world.entity.projectile.hurtingprojectile;
|
| 2 |
|
| 3 | import net.minecraft.core.BlockPos;
|
| 4 | import net.minecraft.server.level.ServerLevel;
|
| 5 | import net.minecraft.world.damagesource.DamageSource;
|
| 6 | import net.minecraft.world.entity.Entity;
|
| 7 | import net.minecraft.world.entity.EntityType;
|
| 8 | import net.minecraft.world.entity.EntityTypes;
|
| 9 | import net.minecraft.world.entity.LivingEntity;
|
| 10 | import net.minecraft.world.entity.Mob;
|
| 11 | import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
| 12 | import net.minecraft.world.level.Level;
|
| 13 | import net.minecraft.world.level.block.BaseFireBlock;
|
| 14 | import net.minecraft.world.level.gamerules.GameRules;
|
| 15 | import net.minecraft.world.phys.BlockHitResult;
|
| 16 | import net.minecraft.world.phys.EntityHitResult;
|
| 17 | import net.minecraft.world.phys.HitResult;
|
| 18 | import net.minecraft.world.phys.Vec3;
|
| 19 |
|
| 20 | public class SmallFireball extends Fireball {
|
| 21 | public SmallFireball(final EntityType<? extends SmallFireball> type, final Level level) {
|
| 22 | super(type, level);
|
| 23 | }
|
| 24 |
|
| 25 | public SmallFireball(final Level level, final LivingEntity mob, final Vec3 direction) {
|
| 26 | super(EntityTypes.SMALL_FIREBALL, mob, direction, level);
|
| 27 | }
|
| 28 |
|
| 29 | public SmallFireball(final Level level, final double x, final double y, final double z, final Vec3 direction) {
|
| 30 | super(EntityTypes.SMALL_FIREBALL, x, y, z, direction, level);
|
| 31 | }
|
| 32 |
|
| 33 | @Override
|
| 34 | protected void onHitEntity(final EntityHitResult hitResult) {
|
| 35 | super.onHitEntity(hitResult);
|
| 36 | if (this.level() instanceof ServerLevel serverLevel) {
|
| 37 | Entity var7 = hitResult.getEntity();
|
| 38 | Entity owner = this.getOwner();
|
| 39 | int remainingFireTicks = var7.getRemainingFireTicks();
|
| 40 | var7.igniteForSeconds(5.0F);
|
| 41 | DamageSource damageSource = this.damageSources().fireball(this, owner);
|
| 42 | if (!var7.hurtServer(serverLevel, damageSource, 5.0F)) {
|
| 43 | var7.setRemainingFireTicks(remainingFireTicks);
|
| 44 | } else {
|
| 45 | EnchantmentHelper.doPostAttackEffects(serverLevel, var7, damageSource);
|
| 46 | }
|
| 47 | }
|
| 48 | }
|
| 49 |
|
| 50 | @Override
|
| 51 | protected void onHitBlock(final BlockHitResult hitResult) {
|
| 52 | super.onHitBlock(hitResult);
|
| 53 | if (this.level() instanceof ServerLevel serverLevel) {
|
| 54 | Entity owner = this.getOwner();
|
| 55 | if (!(owner instanceof Mob) || serverLevel.getGameRules().get(GameRules.MOB_GRIEFING)) {
|
| 56 | BlockPos pos = hitResult.getBlockPos().relative(hitResult.getDirection());
|
| 57 | if (this.level().isEmptyBlock(pos)) {
|
| 58 | this.level().setBlockAndUpdate(pos, BaseFireBlock.getState(this.level(), pos));
|
| 59 | }
|
| 60 | }
|
| 61 | }
|
| 62 | }
|
| 63 |
|
| 64 | @Override
|
| 65 | protected void onHit(final HitResult hitResult) {
|
| 66 | super.onHit(hitResult);
|
| 67 | if (!this.level().isClientSide()) {
|
| 68 | this.discard();
|
| 69 | }
|
| 70 | }
|
| 71 | }
|
| 72 |
|