From e33c45377a7b390364df589a17b121b5b8d4cd8a Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Wed, 18 Dec 2024 03:44:06 +0900 Subject: [PATCH] fix: geothermal heat value calculation --- .../alex4386/plugin/typhon/TyphonUtils.java | 22 +++++++++++++++++++ .../typhon/volcano/VolcanoGeoThermal.java | 6 ++--- .../typhon/volcano/vent/VolcanoVent.java | 12 +++------- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/main/java/me/alex4386/plugin/typhon/TyphonUtils.java b/src/main/java/me/alex4386/plugin/typhon/TyphonUtils.java index 0aab15a..627bc0b 100644 --- a/src/main/java/me/alex4386/plugin/typhon/TyphonUtils.java +++ b/src/main/java/me/alex4386/plugin/typhon/TyphonUtils.java @@ -12,6 +12,7 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Orientable; import org.bukkit.block.data.Waterlogged; +import org.bukkit.entity.EntityType; import org.bukkit.util.Vector; import org.json.simple.JSONObject; @@ -691,6 +692,27 @@ public static void spawnParticleWithVelocity( } } + public static boolean isNotAffectedByPoisonEffect(EntityType entityType) { + switch (entityType) { + case ZOMBIE: + case ZOMBIE_HORSE: + case ZOMBIE_VILLAGER: + case CREEPER: + case SKELETON: + case WITHER: + case WITHER_SKELETON: + case ZOMBIFIED_PIGLIN: + case HUSK: + case STRAY: + case DROWNED: + case PHANTOM: + case SKELETON_HORSE: + return true; + } + + return false; + } + public static void createRisingSteam(Location location, int radius, int count) { createRisingSteam(location, radius, count, false); } diff --git a/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java b/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java index 67a8ae3..4d7849f 100644 --- a/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java +++ b/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java @@ -361,7 +361,7 @@ public void runGeothermalActivity(VolcanoVent vent, Block block, boolean allowSt if (scaleFactor >= 0.1) { letOffSteam = true; - runPoison = Math.random() < scaleFactor; + runPoison = Math.random() < Math.max(scaleFactor, Math.sqrt(scaleFactor) * Math.pow(Math.min(1, heatValue / 0.85), 2)); } else if (scaleFactor >= 0.04) { letOffSteam = (Math.random() < 0.5); runPoison = (Math.random() < scaleFactor); @@ -662,8 +662,8 @@ public void runVolcanicGas(Location location) { livingEntity.addPotionEffect(new PotionEffect(PotionEffectType.POISON, timespan, poisonousLevel)); // the entity is not affected by poison, then we should damage the entity. - if (!livingEntity.hasPotionEffect(PotionEffectType.POISON) && !livingEntity.isInvulnerable()) { - int calculateDamageWithTimespan = (int) (poisonousLevel * 0.5 * (timespan / 20.0)); + if (TyphonUtils.isNotAffectedByPoisonEffect(entity.getType())) { + int calculateDamageWithTimespan = (int) (poisonousLevel * (timespan / 5.0)); livingEntity.damage(calculateDamageWithTimespan); } diff --git a/src/main/java/me/alex4386/plugin/typhon/volcano/vent/VolcanoVent.java b/src/main/java/me/alex4386/plugin/typhon/volcano/vent/VolcanoVent.java index 3c3acd2..fedef92 100644 --- a/src/main/java/me/alex4386/plugin/typhon/volcano/vent/VolcanoVent.java +++ b/src/main/java/me/alex4386/plugin/typhon/volcano/vent/VolcanoVent.java @@ -444,18 +444,12 @@ public List getVentBlocks() { public double getHeatValue(Location loc) { double distance = this.getTwoDimensionalDistance(loc); double killZone = this.getRadius(); - - boolean isInSea = distance <= this.longestNormalLavaFlowLength; - double pillowRatio = 0.2; - - if (!isInSea) { - isInSea = loc.getWorld().getHighestBlockAt(loc).getY() <= loc.getWorld().getSeaLevel() && loc.getBlock().getType() == Material.WATER; - } + double pillowRatio = 0.5; if (distance < killZone) { - return (isInSea ? pillowRatio : 1); + return 1; } - + double deltaFromNormalLava = (this.longestFlowLength - this.longestNormalLavaFlowLength); double correctedLavaLength = this.longestNormalLavaFlowLength + (deltaFromNormalLava * pillowRatio);