diff --git a/src/main/java/net/mcreator/superbwarfare/entity/projectile/MortarShellEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/projectile/MortarShellEntity.java index 0d11fc4fa..cc0c1f4eb 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/projectile/MortarShellEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/projectile/MortarShellEntity.java @@ -7,6 +7,7 @@ import net.mcreator.superbwarfare.tools.ParticleTool; import net.mcreator.superbwarfare.tools.ProjectileTool; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.server.level.ServerLevel; @@ -24,7 +25,10 @@ import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PlayMessages; public class MortarShellEntity extends ThrowableItemProjectile { + private float damage = 150f; + private int life = 600; + private float radius = 12.5f; public MortarShellEntity(EntityType type, Level world) { super(type, world); @@ -43,6 +47,36 @@ public class MortarShellEntity extends ThrowableItemProjectile { this(ModEntities.MORTAR_SHELL.get(), level); } + @Override + public void addAdditionalSaveData(CompoundTag pCompound) { + super.addAdditionalSaveData(pCompound); + pCompound.putFloat("Damage", this.damage); + pCompound.putInt("Life", this.life); + pCompound.putFloat("Radius", this.radius); + } + + @Override + public void readAdditionalSaveData(CompoundTag pCompound) { + super.readAdditionalSaveData(pCompound); + if (pCompound.contains("Damage")) { + this.damage = pCompound.getFloat("Damage"); + } else { + this.damage = 150f; + } + + if (pCompound.contains("Life")) { + this.life = pCompound.getInt("Life"); + } else { + this.life = 600; + } + + if (pCompound.contains("Radius")) { + this.radius = pCompound.getFloat("Radius"); + } else { + this.radius = 12.5f; + } + } + @Override public Packet getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); @@ -65,7 +99,7 @@ public class MortarShellEntity extends ThrowableItemProjectile { entity.hurt(ModDamageTypes.causeCannonFireDamage(this.level().registryAccess(), this, this.getOwner()), this.damage); if (this.level() instanceof ServerLevel) { - ProjectileTool.causeCustomExplode(this, this.damage, 12.5f); + ProjectileTool.causeCustomExplode(this, this.damage, this.radius); } this.discard(); } @@ -79,7 +113,7 @@ public class MortarShellEntity extends ThrowableItemProjectile { bell.attemptToRing(this.level(), resultPos, blockHitResult.getDirection()); } if (!this.level().isClientSide() && this.level() instanceof ServerLevel) { - ProjectileTool.causeCustomExplode(this, this.damage, 12.5f); + ProjectileTool.causeCustomExplode(this, this.damage, this.radius); } this.discard(); } @@ -91,9 +125,9 @@ public class MortarShellEntity extends ThrowableItemProjectile { ParticleTool.sendParticle(serverLevel, ParticleTypes.CAMPFIRE_COSY_SMOKE, this.xo, this.yo, this.zo, 1, 0, 0, 0, 0.001, true); } - if (this.tickCount > 600 || this.isInWater()) { + if (this.tickCount > this.life || this.isInWater()) { if (this.level() instanceof ServerLevel) { - ProjectileTool.causeCustomExplode(this, this.damage, 12.5f); + ProjectileTool.causeCustomExplode(this, this.damage, this.radius); } this.discard(); } diff --git a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java index 90d6d0dcd..f7d2910c5 100644 --- a/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java +++ b/src/main/java/net/mcreator/superbwarfare/entity/projectile/ProjectileEntity.java @@ -70,6 +70,7 @@ import static net.mcreator.superbwarfare.entity.TargetEntity.DOWN_TIME; @SuppressWarnings({"unused", "UnusedReturnValue", "SuspiciousNameCombination"}) public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnData, GeoEntity, AnimatedEntity { + public static final EntityDataAccessor COLOR_R = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor COLOR_G = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor COLOR_B = SynchedEntityData.defineId(ProjectileEntity.class, EntityDataSerializers.FLOAT); @@ -357,10 +358,10 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa } } - protected void explosionBulletBlock(Entity projectile , float damage, int heLevel, float monsterMultiple, Vec3 hitVec) { + protected void explosionBulletBlock(Entity projectile, float damage, int heLevel, float monsterMultiple, Vec3 hitVec) { CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, ModDamageTypes.causeProjectileBoomDamage(projectile.level().registryAccess(), projectile, this.getShooter()), (float) ((0.9 * damage) * (1 + 0.1 * heLevel)), - hitVec.x, hitVec.y, hitVec.z, (float)((1.5 + 0.02 * damage) * (1 + 0.05 * heLevel)) , Explosion.BlockInteraction.KEEP).setDamageMultiplier(monsterMultiple); + hitVec.x, hitVec.y, hitVec.z, (float) ((1.5 + 0.02 * damage) * (1 + 0.05 * heLevel)), Explosion.BlockInteraction.KEEP).setDamageMultiplier(monsterMultiple); explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion); explosion.finalizeExplosion(false); @@ -494,7 +495,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa } if (entity instanceof LivingEntity living && jhpBullet) { - this.damage *= (1.0f + 0.12f * jhpLevel) * ((float)(10 / (living.getAttributeValue(Attributes.ARMOR) + 10)) + 0.25f); + this.damage *= (1.0f + 0.12f * jhpLevel) * ((float) (10 / (living.getAttributeValue(Attributes.ARMOR) + 10)) + 0.25f); } if (heBullet) { @@ -543,7 +544,7 @@ public class ProjectileEntity extends Entity implements IEntityAdditionalSpawnDa protected void explosionBulletEntity(Entity projectile, Entity target, float damage, int heLevel, float monsterMultiple) { CustomExplosion explosion = new CustomExplosion(projectile.level(), projectile, ModDamageTypes.causeProjectileBoomDamage(projectile.level().registryAccess(), projectile, this.getShooter()), (float) ((0.8 * damage) * (1 + 0.1 * heLevel)), - target.getX(), target.getY(), target.getZ(), (float)((1.5 + 0.02 * damage) * (1 + 0.05 * heLevel)) , Explosion.BlockInteraction.KEEP).setDamageMultiplier(monsterMultiple); + target.getX(), target.getY(), target.getZ(), (float) ((1.5 + 0.02 * damage) * (1 + 0.05 * heLevel)), Explosion.BlockInteraction.KEEP).setDamageMultiplier(monsterMultiple); explosion.explode(); net.minecraftforge.event.ForgeEventFactory.onExplosionStart(projectile.level(), explosion); explosion.finalizeExplosion(false);