63 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			63 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| package net.minecraft.world.entity.projectile;
 | |
| 
 | |
| 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.level.storage.ValueInput;
 | |
| import net.minecraft.world.level.storage.ValueOutput;
 | |
| 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
 | |
| 	protected void addAdditionalSaveData(ValueOutput output) {
 | |
| 		super.addAdditionalSaveData(output);
 | |
| 		output.putByte("ExplosionPower", (byte)this.explosionPower);
 | |
| 	}
 | |
| 
 | |
| 	@Override
 | |
| 	protected void readAdditionalSaveData(ValueInput input) {
 | |
| 		super.readAdditionalSaveData(input);
 | |
| 		this.explosionPower = input.getByteOr("ExplosionPower", (byte)1);
 | |
| 	}
 | |
| }
 |