Skip to content

Commit

Permalink
fix: geothermal heat value calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex4386 committed Dec 17, 2024
1 parent 386b354 commit e33c453
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 12 deletions.
22 changes: 22 additions & 0 deletions src/main/java/me/alex4386/plugin/typhon/TyphonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,18 +444,12 @@ public List<Block> 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);
Expand Down

0 comments on commit e33c453

Please sign in to comment.