diff --git a/src/main/java/kamkeel/npcs/client/renderer/RenderEnergyExplosion.java b/src/main/java/kamkeel/npcs/client/renderer/RenderEnergyExplosion.java new file mode 100644 index 000000000..7f502c575 --- /dev/null +++ b/src/main/java/kamkeel/npcs/client/renderer/RenderEnergyExplosion.java @@ -0,0 +1,180 @@ +package kamkeel.npcs.client.renderer; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import kamkeel.npcs.entity.EntityEnergyExplosion; +import net.minecraft.entity.Entity; +import org.lwjgl.opengl.GL11; + +/** + * Voxel-style renderer for {@link EntityEnergyExplosion}. + * Draws expanding cubic shells with a short fade-out. + */ +@SideOnly(Side.CLIENT) +public class RenderEnergyExplosion extends RenderEnergyAbility { + + private static final float MAX_OUTER_ALPHA = 0.85f; + private static final float MAX_INNER_ALPHA = 1.0f; + private static final float MAX_SMOKE_CUBE_ALPHA = 0.55f; + + @Override + public void doRender(Entity entity, double x, double y, double z, float yaw, float partialTicks) { + if (!(entity instanceof EntityEnergyExplosion)) return; + EntityEnergyExplosion explosion = (EntityEnergyExplosion) entity; + + setupRenderState(); + + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + + float radius = explosion.getInterpolatedRadius(partialTicks); + float life = explosion.getLifeProgress(partialTicks); + if (radius > 0.01f && life < 1.0f) { + renderVoxelBurst(explosion, radius, life); + if (explosion.hasLightningEffect()) { + renderAttachedLightning(explosion, 0.55f, Math.max(0.7f, radius * 0.45f)); + } + } + + GL11.glPopMatrix(); + restoreRenderState(); + } + + private void renderVoxelBurst(EntityEnergyExplosion explosion, float radius, float life) { + int outerColor = explosion.getOuterColor(); + int innerColor = explosion.getInnerColor(); + boolean hasOuter = explosion.isOuterColorEnabled(); + + float fade = 1.0f - life; + float outerAlpha = Math.min(MAX_OUTER_ALPHA, (0.25f + fade * 0.75f) * explosion.getOuterColorAlpha()); + float innerAlpha = Math.min(MAX_INNER_ALPHA, (0.30f + fade * 0.80f) * explosion.getInnerAlpha()); + + int steps = Math.max(2, Math.min(6, (int) Math.ceil(radius * 0.65f) + 1)); + float cell = radius / steps; + float cubeHalf = Math.max(0.04f, cell * 0.22f * (0.90f - life * 0.25f)); + long seed = explosion.getRenderSeed(); + + GL11.glDepthMask(false); + renderSmokeVoxelShell(radius, life, seed); + + for (int ix = -steps; ix <= steps; ix++) { + for (int iy = -steps; iy <= steps; iy++) { + for (int iz = -steps; iz <= steps; iz++) { + int edge = Math.max(Math.abs(ix), Math.max(Math.abs(iy), Math.abs(iz))); + if (edge != steps) continue; + if (!shouldRenderVoxel(ix, iy, iz, steps, seed, life)) continue; + + float px = ix * cell + jitter(ix, iy, iz, seed, 1) * cell * 0.18f; + float py = iy * cell + jitter(ix, iy, iz, seed, 2) * cell * 0.18f; + float pz = iz * cell + jitter(ix, iy, iz, seed, 3) * cell * 0.18f; + + GL11.glPushMatrix(); + GL11.glTranslatef(px, py, pz); + + if (hasOuter) { + GL11.glPushMatrix(); + float outerScale = 1.0f + explosion.getOuterColorWidth() * 0.35f; + GL11.glScalef(outerScale, outerScale, outerScale); + renderCube(outerColor, outerAlpha * fade, cubeHalf); + GL11.glPopMatrix(); + } + + renderCube(innerColor, innerAlpha * fade, cubeHalf * 0.9f); + GL11.glPopMatrix(); + } + } + } + renderCoreFlash(innerColor, innerAlpha, radius, cubeHalf, life); + GL11.glDepthMask(true); + } + + /** + * Adds large translucent white/gray cubes to fake a smoky volumetric expansion. + */ + private void renderSmokeVoxelShell(float radius, float life, long seed) { + int smokeSteps = Math.max(2, Math.min(5, (int) Math.ceil(radius * 0.5f) + 1)); + float smokeCell = radius / smokeSteps * 1.2f; + float smokeJitter = smokeCell * 0.28f; + float smokeCubeHalf = Math.max(0.07f, smokeCell * 0.24f * (0.95f - life * 0.25f)); + float smokeAlpha = Math.min(MAX_SMOKE_CUBE_ALPHA, (0.15f + (1.0f - life) * 0.55f)); + + for (int ix = -smokeSteps; ix <= smokeSteps; ix++) { + for (int iy = -smokeSteps; iy <= smokeSteps; iy++) { + for (int iz = -smokeSteps; iz <= smokeSteps; iz++) { + int edge = Math.max(Math.abs(ix), Math.max(Math.abs(iy), Math.abs(iz))); + if (edge < smokeSteps - 1) continue; + + int h = hash(ix * 5, iy * 7, iz * 11, seed ^ 0x4f1bbcdcL); + if ((h & 3) != 0) continue; + if (life > 0.72f && ((h >>> 5) & 7) > 2) continue; + + float px = ix * smokeCell + jitter(ix, iy, iz, seed ^ 0x2299aa11L, 1) * smokeJitter; + float py = iy * smokeCell + jitter(ix, iy, iz, seed ^ 0x2299aa11L, 2) * smokeJitter; + float pz = iz * smokeCell + jitter(ix, iy, iz, seed ^ 0x2299aa11L, 3) * smokeJitter; + + int smokeColor = ((h >>> 9) & 1) == 0 ? 0xFFFFFF : 0xDCDCDC; + float alpha = smokeAlpha * (0.78f + (((h >>> 10) & 15) / 15.0f) * 0.22f); + + GL11.glPushMatrix(); + GL11.glTranslatef(px, py, pz); + renderCube(smokeColor, alpha, smokeCubeHalf); + GL11.glPopMatrix(); + } + } + } + } + + /** + * White-hot core flash pass for the initial frames. + */ + private void renderCoreFlash(int innerColor, float innerAlpha, float radius, float cubeHalf, float life) { + float flash = saturate((0.60f - life) / 0.60f); + if (flash <= 0.0f) return; + + float coreHalf = Math.max(cubeHalf, radius * 0.07f) * (1.0f + flash * 0.55f); + float whiteAlpha = Math.min(1.0f, 0.25f + flash * 0.95f); + float innerFlashAlpha = Math.min(1.0f, innerAlpha * (0.45f + flash * 0.95f)); + + GL11.glPushMatrix(); + renderCube(0xFFFFFF, whiteAlpha, coreHalf * 1.45f); + GL11.glScalef(0.82f, 0.82f, 0.82f); + renderCube(innerColor, innerFlashAlpha, coreHalf); + GL11.glPopMatrix(); + } + + private float saturate(float value) { + if (value < 0.0f) return 0.0f; + if (value > 1.0f) return 1.0f; + return value; + } + + private boolean shouldRenderVoxel(int ix, int iy, int iz, int steps, long seed, float life) { + int h = hash(ix, iy, iz, seed); + + int keepMask = steps >= 5 ? 3 : 1; + if ((h & keepMask) != 0) return false; + + if (life > 0.55f) { + int decay = (h >>> 3) & 7; + if (decay > 2) return false; + } + + return true; + } + + private float jitter(int ix, int iy, int iz, long seed, int channel) { + int h = hash(ix + channel * 17, iy - channel * 31, iz + channel * 47, seed); + return (((h >>> 8) & 1023) / 1023.0f) - 0.5f; + } + + private int hash(int x, int y, int z, long seed) { + long h = seed; + h ^= (long) x * 73428767L; + h ^= (long) y * 912931L; + h ^= (long) z * 19349663L; + h ^= (h >>> 33); + h *= 0xff51afd7ed558ccdL; + h ^= (h >>> 33); + return (int) h; + } +} diff --git a/src/main/java/kamkeel/npcs/entity/EntityEnergyExplosion.java b/src/main/java/kamkeel/npcs/entity/EntityEnergyExplosion.java new file mode 100644 index 000000000..0132ba2d1 --- /dev/null +++ b/src/main/java/kamkeel/npcs/entity/EntityEnergyExplosion.java @@ -0,0 +1,126 @@ +package kamkeel.npcs.entity; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import kamkeel.npcs.controllers.data.ability.data.energy.EnergyDisplayData; +import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.MathHelper; +import net.minecraft.world.World; + +/** + * Short-lived visual explosion entity for energy projectile impacts. + * This is render-only and never applies damage itself. + */ +public class EntityEnergyExplosion extends EntityEnergyAbility { + + private float maxRadius = 2.0f; + private int durationTicks = 10; + private float prevRenderRadius = 0.0f; + private float renderRadius = 0.0f; + private long renderSeed = 0L; + + public EntityEnergyExplosion(World world) { + super(world); + this.noClip = true; + this.setSize(0.1f, 0.1f); + } + + public EntityEnergyExplosion(World world, EntityEnergyProjectile source, float radius) { + this(world); + + if (source != null) { + this.ownerEntityId = source.getOwnerEntityId(); + EnergyDisplayData sourceDisplay = source.getDisplayData(); + this.displayData = sourceDisplay != null ? sourceDisplay.copy() : new EnergyDisplayData(); + EnergyLightningData sourceLightning = source.getLightningData(); + this.lightningData = sourceLightning != null ? sourceLightning.copy() : new EnergyLightningData(); + this.setPosition(source.posX, source.posY, source.posZ); + } + + setExplosionRadius(radius); + this.renderSeed = world != null ? world.rand.nextLong() : 0L; + } + + @Override + protected void entityInit() { + super.entityInit(); + } + + @Override + public void onUpdate() { + this.prevRenderRadius = this.renderRadius; + + super.onUpdate(); + + float progress = getLifeProgress(0.0f); + float eased = 1.0f - (1.0f - progress) * (1.0f - progress); + this.renderRadius = maxRadius * eased; + + if (ticksExisted >= durationTicks) { + setDead(); + } + } + + public void setExplosionRadius(float radius) { + this.maxRadius = Math.max(0.5f, sanitize(radius, 2.0f, MAX_ENTITY_RADIUS)); + this.durationTicks = Math.max(6, Math.min(18, (int) (6 + this.maxRadius * 1.8f))); + this.setSize(this.maxRadius * 2.0f, this.maxRadius * 2.0f); + } + + public float getInterpolatedRadius(float partialTicks) { + return this.prevRenderRadius + (this.renderRadius - this.prevRenderRadius) * partialTicks; + } + + public float getLifeProgress(float partialTicks) { + if (durationTicks <= 0) return 1.0f; + float age = (ticksExisted + partialTicks) / durationTicks; + return MathHelper.clamp_float(age, 0.0f, 1.0f); + } + + public long getRenderSeed() { + return renderSeed; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isInRangeToRenderDist(double distance) { + double d = Math.max(16.0D, maxRadius * 64.0D); + return distance < d * d; + } + + @Override + public boolean canBeCollidedWith() { + return false; + } + + @Override + protected void readEntityFromNBT(NBTTagCompound nbt) { + // Intentionally empty - transient visual entity. + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbt) { + // Intentionally empty - transient visual entity. + } + + @Override + protected void writeSpawnNBT(NBTTagCompound nbt) { + writeEnergyBaseNBT(nbt); + nbt.setFloat("ExplosionRadius", maxRadius); + nbt.setInteger("ExplosionDuration", durationTicks); + nbt.setLong("ExplosionSeed", renderSeed); + } + + @Override + protected void readSpawnNBT(NBTTagCompound nbt) { + readEnergyBaseNBT(nbt); + setExplosionRadius(nbt.hasKey("ExplosionRadius") ? nbt.getFloat("ExplosionRadius") : 2.0f); + this.durationTicks = nbt.hasKey("ExplosionDuration") ? nbt.getInteger("ExplosionDuration") : durationTicks; + if (durationTicks <= 0) durationTicks = 10; + this.renderSeed = nbt.hasKey("ExplosionSeed") ? nbt.getLong("ExplosionSeed") : 0L; + this.renderRadius = 0.0f; + this.prevRenderRadius = 0.0f; + } +} + diff --git a/src/main/java/kamkeel/npcs/entity/EntityEnergyProjectile.java b/src/main/java/kamkeel/npcs/entity/EntityEnergyProjectile.java index 718fe580f..72d35520c 100644 --- a/src/main/java/kamkeel/npcs/entity/EntityEnergyProjectile.java +++ b/src/main/java/kamkeel/npcs/entity/EntityEnergyProjectile.java @@ -14,19 +14,26 @@ import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLifespanData; import kamkeel.npcs.controllers.data.ability.data.energy.EnergyLightningData; import kamkeel.npcs.controllers.data.ability.data.energy.EnergyTrajectoryData; import kamkeel.npcs.util.AnchorPointHelper; +import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.DamageSource; +import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; +import net.minecraft.world.Explosion; import net.minecraft.world.World; +import net.minecraft.world.WorldServer; import noppes.npcs.EventHooks; import noppes.npcs.NpcDamageSource; import noppes.npcs.api.entity.IEntity; +import noppes.npcs.config.ConfigEnergy; import noppes.npcs.controllers.PartyController; import noppes.npcs.controllers.data.Party; import noppes.npcs.controllers.data.PlayerData; @@ -485,6 +492,8 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility { if (previewMode) return; // Skip explosion in preview mode float explosionRad = getExplosionRadius(); if (Float.isNaN(explosionRad) || explosionRad <= 0) return; + spawnExplosionRenderEntity(explosionRad); + spawnExplosionVisuals(explosionRad); worldObj.playSoundEffect(posX, posY, posZ, "random.explode", 1.0f, 1.0f); Entity owner = getOwnerEntity(); @@ -511,6 +520,221 @@ public abstract class EntityEnergyProjectile extends EntityEnergyAbility { applyDamage(target, getDamage() * falloff, getKnockback() * falloff); } } + + tryDestroyTerrain(explosionRad); + } + + /** + * Spawn a short-lived voxel render entity so explosions are visible as geometry, + * not only as particles. + */ + protected void spawnExplosionRenderEntity(float explosionRad) { + if (worldObj == null || worldObj.isRemote) return; + float renderRad = Math.max(0.75f, Math.min(explosionRad, 12.0f)); + EntityEnergyExplosion fx = new EntityEnergyExplosion(worldObj, this, renderRad); + worldObj.spawnEntityInWorld(fx); + } + + /** + * Shared voxel-style explosion VFX for all energy projectile abilities. + */ + protected void spawnExplosionVisuals(float explosionRad) { + if (worldObj == null) return; + + float visualRad = Math.max(0.75f, Math.min(explosionRad, 12.0f)); + int coreBursts = Math.max(1, Math.min(4, Math.round(visualRad * 0.35f))); + int shellCount = Math.max(1, Math.min(3, Math.round(visualRad / 3.5f) + 1)); + + // Core flash. + emitRandomBurstParticle("largeexplode", coreBursts, visualRad * 0.10, visualRad * 0.08, visualRad * 0.10, 0.01); + + // Expanding voxel shells. + for (int i = 1; i <= shellCount; i++) { + double frac = i / (double) shellCount; + double shellRadius = visualRad * (0.35D + 0.65D * frac); + spawnVoxelShell(shellRadius, i, visualRad); + } + + // Residual smoke volume. + int smokeCount = Math.max(6, Math.min(40, Math.round(visualRad * 4.5f))); + emitRandomBurstParticle("smoke", smokeCount, visualRad * 0.45, visualRad * 0.30, visualRad * 0.45, 0.01); + + // Pull block fragments for stronger voxel feel. + spawnVoxelDebris(visualRad); + } + + /** + * Emit random burst particles centered around this explosion. + */ + protected void emitRandomBurstParticle(String particle, int count, + double spreadX, double spreadY, double spreadZ, + double speed) { + if (worldObj == null || count <= 0 || particle == null || particle.isEmpty()) return; + + if (worldObj.isRemote) { + for (int i = 0; i < count; i++) { + double px = posX + (rand.nextDouble() - 0.5D) * 2.0D * spreadX; + double py = posY + (rand.nextDouble() - 0.5D) * 2.0D * spreadY; + double pz = posZ + (rand.nextDouble() - 0.5D) * 2.0D * spreadZ; + double mx = rand.nextGaussian() * speed; + double my = rand.nextGaussian() * speed; + double mz = rand.nextGaussian() * speed; + worldObj.spawnParticle(particle, px, py, pz, mx, my, mz); + } + return; + } + + if (worldObj instanceof WorldServer) { + ((WorldServer) worldObj).func_147487_a(particle, posX, posY, posZ, count, spreadX, spreadY, spreadZ, speed); + } + } + + /** + * Emits a single directed voxel particle. + * Uses count=0 packet mode on server so motion values are preserved. + */ + protected void emitVoxelParticle(String particle, double x, double y, double z, + double motionX, double motionY, double motionZ) { + if (worldObj == null || particle == null || particle.isEmpty()) return; + + if (worldObj.isRemote) { + worldObj.spawnParticle(particle, x, y, z, motionX, motionY, motionZ); + return; + } + + if (worldObj instanceof WorldServer) { + ((WorldServer) worldObj).func_147487_a(particle, x, y, z, 0, motionX, motionY, motionZ, 1.0D); + } + } + + /** + * Spawn one cubic shell of explosion particles to get a blocky/voxel silhouette. + */ + protected void spawnVoxelShell(double shellRadius, int shellIndex, float visualRad) { + int steps = Math.max(2, Math.min(4, (int) Math.ceil(shellRadius * 0.55D))); + double cell = shellRadius / steps; + double jitter = Math.min(0.15D, cell * 0.20D); + double shellSpeed = 0.03D + (shellRadius / Math.max(1.0D, visualRad)) * 0.05D; + + for (int ix = -steps; ix <= steps; ix++) { + for (int iy = -steps; iy <= steps; iy++) { + for (int iz = -steps; iz <= steps; iz++) { + int edge = Math.max(Math.abs(ix), Math.max(Math.abs(iy), Math.abs(iz))); + if (edge != steps) continue; + if (((ix + iy + iz + shellIndex) & 1) != 0) continue; + + double px = posX + ix * cell + (rand.nextDouble() - 0.5D) * jitter; + double py = posY + iy * cell + (rand.nextDouble() - 0.5D) * jitter; + double pz = posZ + iz * cell + (rand.nextDouble() - 0.5D) * jitter; + + double nx = ix; + double ny = iy; + double nz = iz; + double len = Math.sqrt(nx * nx + ny * ny + nz * nz); + if (len < 0.001D) { + ny = 1.0D; + len = 1.0D; + } + nx /= len; + ny /= len; + nz /= len; + + emitVoxelParticle("explode", px, py, pz, nx * shellSpeed, ny * shellSpeed, nz * shellSpeed); + + if (((ix + iy + iz + shellIndex) % 3) == 0) { + emitVoxelParticle("smoke", px, py, pz, nx * shellSpeed * 0.35D, ny * shellSpeed * 0.35D, nz * shellSpeed * 0.35D); + } + } + } + } + } + + /** + * Spawn debris particles using nearby block textures. + */ + protected void spawnVoxelDebris(float visualRad) { + if (worldObj == null) return; + + int count = Math.max(4, Math.min(24, Math.round(visualRad * 2.5f))); + for (int i = 0; i < count; i++) { + double ox = (rand.nextDouble() - 0.5D) * visualRad * 1.2D; + double oy = (rand.nextDouble() - 0.35D) * visualRad * 0.9D; + double oz = (rand.nextDouble() - 0.5D) * visualRad * 1.2D; + + int bx = MathHelper.floor_double(posX + ox); + int by = MathHelper.floor_double(posY + oy); + int bz = MathHelper.floor_double(posZ + oz); + + Block block = worldObj.getBlock(bx, by, bz); + if (block == null || block == Blocks.air) continue; + + int blockId = Block.getIdFromBlock(block); + if (blockId <= 0) continue; + int meta = worldObj.getBlockMetadata(bx, by, bz); + + String particle = "blockcrack_" + blockId + "_" + Math.max(0, meta); + emitVoxelParticle( + particle, + posX + ox * 0.55D, + posY + oy * 0.55D, + posZ + oz * 0.55D, + ox * 0.03D, oy * 0.03D, oz * 0.03D + ); + } + } + + /** + * Optional terrain damage for energy explosions. + * Controlled server-side by ConfigEnergy.EnableEnergyExplosionBlockDamage. + */ + protected void tryDestroyTerrain(float explosionRad) { + if (worldObj == null || worldObj.isRemote) return; + if (!ConfigEnergy.EnableEnergyExplosionBlockDamage) return; + if (!worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing")) return; + + float terrainRad = Math.max(0.5f, Math.min(explosionRad, 12.0f)); + int minX = MathHelper.floor_double(posX - terrainRad); + int maxX = MathHelper.floor_double(posX + terrainRad); + int minY = MathHelper.floor_double(posY - terrainRad); + int maxY = MathHelper.floor_double(posY + terrainRad); + int minZ = MathHelper.floor_double(posZ - terrainRad); + int maxZ = MathHelper.floor_double(posZ + terrainRad); + float resistanceCutoff = Math.max(4.0f, terrainRad * 6.0f); + + Explosion context = new Explosion(worldObj, this, posX, posY, posZ, terrainRad); + context.isFlaming = false; + context.isSmoking = true; + + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + double cx = x + 0.5D - posX; + double cy = y + 0.5D - posY; + double cz = z + 0.5D - posZ; + + // Chebyshev metric yields a voxel/cubic blast shape. + double chebyshev = Math.max(Math.abs(cx), Math.max(Math.abs(cy), Math.abs(cz))); + if (chebyshev > terrainRad) continue; + + // Soften cube corners a bit for a less artificial crater edge. + double normalized = chebyshev / terrainRad; + if (normalized > 0.72D && rand.nextDouble() < (normalized - 0.72D) * 1.4D) continue; + + Block block = worldObj.getBlock(x, y, z); + if (block == null || block == Blocks.air || block == Blocks.bedrock) continue; + Material material = block.getMaterial(); + if (material == null || material == Material.air) continue; + + float resistance = block.getExplosionResistance(this, worldObj, x, y, z, posX, posY, posZ); + if (resistance > resistanceCutoff) continue; + + try { + block.onBlockExploded(worldObj, x, y, z, context); + } catch (Exception ignored) { + } + } + } + } } // ==================== LAUNCH HELPERS ==================== diff --git a/src/main/java/noppes/npcs/CustomNpcs.java b/src/main/java/noppes/npcs/CustomNpcs.java index 4fd5b3fdf..d8b731322 100644 --- a/src/main/java/noppes/npcs/CustomNpcs.java +++ b/src/main/java/noppes/npcs/CustomNpcs.java @@ -37,6 +37,7 @@ import kamkeel.npcs.entity.EntityAbilityPanel; import kamkeel.npcs.entity.EntityAbilitySweeper; import kamkeel.npcs.entity.EntityAbilityZone; import kamkeel.npcs.entity.EntityAbilityDome; +import kamkeel.npcs.entity.EntityEnergyExplosion; import kamkeel.npcs.entity.EntityEnergySlicer; import kamkeel.npcs.network.PacketHandler; import kamkeel.npcs.util.BukkitUtil; @@ -301,6 +302,7 @@ public class CustomNpcs { registerNewEntity(EntityAbilityDome.class, "energydome", 64, 3, true); registerNewEntity(EntityAbilityPanel.class, "energypanel", 64, 3, true); registerNewEntity(EntityEnergySlicer.class, "energyslicer", 64, 3, true); + registerNewEntity(EntityEnergyExplosion.class, "energyexplosion", 64, 3, true); new RecipeController(); diff --git a/src/main/java/noppes/npcs/client/ClientProxy.java b/src/main/java/noppes/npcs/client/ClientProxy.java index 180a93194..1cff1e838 100644 --- a/src/main/java/noppes/npcs/client/ClientProxy.java +++ b/src/main/java/noppes/npcs/client/ClientProxy.java @@ -15,6 +15,7 @@ import kamkeel.npcs.client.renderer.RenderAbilityZone; import kamkeel.npcs.client.renderer.RenderAbilityDome; import kamkeel.npcs.client.renderer.RenderAbilityPanel; import kamkeel.npcs.client.renderer.EnergyChargePreviewRenderer; +import kamkeel.npcs.client.renderer.RenderEnergyExplosion; import kamkeel.npcs.client.renderer.RenderEnergySlicer; import kamkeel.npcs.client.renderer.TelegraphRenderer; import kamkeel.npcs.client.renderer.lightning.LightningHandler; @@ -28,6 +29,7 @@ import kamkeel.npcs.entity.EntityAbilitySweeper; import kamkeel.npcs.entity.EntityAbilityZone; import kamkeel.npcs.entity.EntityAbilityDome; import kamkeel.npcs.entity.EntityAbilityPanel; +import kamkeel.npcs.entity.EntityEnergyExplosion; import kamkeel.npcs.entity.EntityEnergySlicer; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; @@ -283,6 +285,7 @@ public class ClientProxy extends CommonProxy { RenderingRegistry.registerEntityRenderingHandler(EntityAbilityDome.class, new RenderAbilityDome()); RenderingRegistry.registerEntityRenderingHandler(EntityAbilityPanel.class, new RenderAbilityPanel()); RenderingRegistry.registerEntityRenderingHandler(EntityEnergySlicer.class, new RenderEnergySlicer()); + RenderingRegistry.registerEntityRenderingHandler(EntityEnergyExplosion.class, new RenderEnergyExplosion()); RenderingRegistry.registerEntityRenderingHandler(EntityCustomNpc.class, new RenderCustomNpc()); diff --git a/src/main/java/noppes/npcs/config/ConfigEnergy.java b/src/main/java/noppes/npcs/config/ConfigEnergy.java index f3b36a948..197bb4968 100644 --- a/src/main/java/noppes/npcs/config/ConfigEnergy.java +++ b/src/main/java/noppes/npcs/config/ConfigEnergy.java @@ -10,8 +10,14 @@ public class ConfigEnergy { public static Configuration config; public final static String DOMES = "Domes"; + public final static String EXPLOSIONS = "Explosions"; public static String[] DomeItemBlacklist; + /** + * Server-side toggle for energy projectile terrain destruction. + * Disabled by default to avoid block grief. + */ + public static boolean EnableEnergyExplosionBlockDamage; public static void init(File configFile) { config = new Configuration(configFile); @@ -26,6 +32,13 @@ public class ConfigEnergy { + "Format: modid:itemname (e.g., minecraft:ender_pearl)" ); + EnableEnergyExplosionBlockDamage = config.getBoolean( + "Enable Energy Explosion Block Damage", EXPLOSIONS, + false, + "If true, explosive ENERGY projectile abilities can destroy terrain.\n" + + "This is intended for server-side use and is disabled by default." + ); + } catch (Exception e) { FMLLog.log(Level.ERROR, e, "CustomNPC+ has had a problem loading its energy configuration"); } finally {