62 lines
2.1 KiB
Java
62 lines
2.1 KiB
Java
package net.minecraft.world.entity.projectile;
|
|
|
|
import net.minecraft.nbt.CompoundTag;
|
|
import net.minecraft.server.level.ServerLevel;
|
|
import net.minecraft.world.damagesource.DamageSource;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.entity.EntityType;
|
|
import net.minecraft.world.entity.LivingEntity;
|
|
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
|
import net.minecraft.world.level.GameRules;
|
|
import net.minecraft.world.level.Level;
|
|
import net.minecraft.world.phys.EntityHitResult;
|
|
import net.minecraft.world.phys.HitResult;
|
|
import net.minecraft.world.phys.Vec3;
|
|
|
|
public class LargeFireball extends Fireball {
|
|
private static final byte DEFAULT_EXPLOSION_POWER = 1;
|
|
private int explosionPower = 1;
|
|
|
|
public LargeFireball(EntityType<? extends LargeFireball> entityType, Level level) {
|
|
super(entityType, level);
|
|
}
|
|
|
|
public LargeFireball(Level level, LivingEntity owner, Vec3 movement, int explosionPower) {
|
|
super(EntityType.FIREBALL, owner, movement, level);
|
|
this.explosionPower = explosionPower;
|
|
}
|
|
|
|
@Override
|
|
protected void onHit(HitResult result) {
|
|
super.onHit(result);
|
|
if (this.level() instanceof ServerLevel serverLevel) {
|
|
boolean bl = serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
|
|
this.level().explode(this, this.getX(), this.getY(), this.getZ(), this.explosionPower, bl, Level.ExplosionInteraction.MOB);
|
|
this.discard();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onHitEntity(EntityHitResult result) {
|
|
super.onHitEntity(result);
|
|
if (this.level() instanceof ServerLevel serverLevel) {
|
|
Entity var6 = result.getEntity();
|
|
Entity entity2 = this.getOwner();
|
|
DamageSource damageSource = this.damageSources().fireball(this, entity2);
|
|
var6.hurtServer(serverLevel, damageSource, 6.0F);
|
|
EnchantmentHelper.doPostAttackEffects(serverLevel, var6, damageSource);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void addAdditionalSaveData(CompoundTag tag) {
|
|
super.addAdditionalSaveData(tag);
|
|
tag.putByte("ExplosionPower", (byte)this.explosionPower);
|
|
}
|
|
|
|
@Override
|
|
public void readAdditionalSaveData(CompoundTag tag) {
|
|
super.readAdditionalSaveData(tag);
|
|
this.explosionPower = tag.getByteOr("ExplosionPower", (byte)1);
|
|
}
|
|
}
|