From 4a226aae1e3901449d5a94be3ce1dee1907bd150 Mon Sep 17 00:00:00 2001 From: Alex4386 Date: Tue, 7 Jan 2025 19:17:47 +0900 Subject: [PATCH] fix: geothermal activities that overrides over succession and reflect based on heat value --- .../typhon/volcano/VolcanoGeoThermal.java | 46 +++++++---- .../volcano/lavaflow/VolcanoLavaFlow.java | 2 +- .../volcano/succession/VolcanoSuccession.java | 81 ++++++++++++------- 3 files changed, 83 insertions(+), 46 deletions(-) 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 9b215a5..7f85da4 100644 --- a/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java +++ b/src/main/java/me/alex4386/plugin/typhon/volcano/VolcanoGeoThermal.java @@ -136,30 +136,42 @@ public void runCraterGeothermal(VolcanoVent vent, Block block, boolean onTop) { } // check if there are trees nearby - Block treeBlock = TyphonUtils.getHighestLocation(block.getLocation()).getBlock(); + Block treeBlock = TyphonUtils.getHighestLocation(block.getLocation()).getBlock(); + double probability = Math.pow(vent.getHeatValue(block.getLocation()), 2); + boolean isInLavaRange = vent.currentNormalLavaFlowLength >= vent.getTwoDimensionalDistance(targetLoc); - if (!VolcanoComposition.isVolcanicRock(block.getType())) { - vent.volcano.metamorphism.metamorphoseBlock(block, false); + if (vent.isStarted() && isInLavaRange) { + probability = 1; } - if (TyphonUtils.isMaterialTree(upperBlock.getType())) { - if (vent.isInVent(upperBlock.getLocation())) { - vent.volcano.metamorphism.removeTree(upperBlock); - } else { - vent.volcano.metamorphism.killTree(upperBlock); + if (Math.random() < probability) { + if (!VolcanoComposition.isVolcanicRock(block.getType())) { + if (vent.isStarted()) { + vent.volcano.metamorphism.metamorphoseBlock(block, isInLavaRange); + } else { + // use proper counterparts. + } + } + + if (TyphonUtils.isMaterialTree(upperBlock.getType())) { + if (vent.isInVent(upperBlock.getLocation())) { + vent.volcano.metamorphism.removeTree(upperBlock); + } else { + vent.volcano.metamorphism.killTree(upperBlock); + } + } else if (TyphonUtils.isMaterialPlant(upperBlock.getType())) { + vent.volcano.metamorphism.removePlant(upperBlock); } - } else if (TyphonUtils.isMaterialPlant(upperBlock.getType())) { - vent.volcano.metamorphism.removePlant(upperBlock); - } - if (TyphonUtils.isMaterialTree(treeBlock.getType())) { - if (vent.isInVent(treeBlock.getLocation())) { - vent.volcano.metamorphism.removeTree(treeBlock); - } else { - vent.volcano.metamorphism.killTree(treeBlock); + if (TyphonUtils.isMaterialTree(treeBlock.getType())) { + if (vent.isInVent(treeBlock.getLocation())) { + vent.volcano.metamorphism.removeTree(treeBlock); + } else { + vent.volcano.metamorphism.killTree(treeBlock); + } } - } + } } } diff --git a/src/main/java/me/alex4386/plugin/typhon/volcano/lavaflow/VolcanoLavaFlow.java b/src/main/java/me/alex4386/plugin/typhon/volcano/lavaflow/VolcanoLavaFlow.java index 68bf5e6..35d0ecd 100644 --- a/src/main/java/me/alex4386/plugin/typhon/volcano/lavaflow/VolcanoLavaFlow.java +++ b/src/main/java/me/alex4386/plugin/typhon/volcano/lavaflow/VolcanoLavaFlow.java @@ -638,7 +638,7 @@ public void onBlockFromTo(BlockFromToEvent event) { boolean underIsAir = underToBlock.getType().isAir(); if (!underIsAir && underToBlock.getType() != Material.LAVA) { - getVolcano().metamorphism.metamorphoseBlock(underToBlock, true); + getVolcano().metamorphism.metamorphoseBlock(vent, underToBlock, true); } boolean fillUnderUnder = true; diff --git a/src/main/java/me/alex4386/plugin/typhon/volcano/succession/VolcanoSuccession.java b/src/main/java/me/alex4386/plugin/typhon/volcano/succession/VolcanoSuccession.java index d5aa95d..460025d 100644 --- a/src/main/java/me/alex4386/plugin/typhon/volcano/succession/VolcanoSuccession.java +++ b/src/main/java/me/alex4386/plugin/typhon/volcano/succession/VolcanoSuccession.java @@ -216,6 +216,11 @@ public void runSuccession(Block block) { if (!this.volcano.manager.isInAnyVent(block)) { if (rawHeatValue < 0.5) { + if (Math.random() < 0.1) { + this.removeOre(targetBlock); + return; + } + double probability = 1.0; if (heatValue > 0.4) { @@ -224,9 +229,9 @@ public void runSuccession(Block block) { probability = Math.pow(0.5, Math.max(probability * 10, 1)); } - // succession usually takes minimum "years" - probability *= 0.1; + // check for probability if (Math.random() < probability) { + this.removeOre(targetBlock); return; } @@ -300,22 +305,36 @@ public void runSuccession(Block block) { VolcanoLogClass.SUCCESSION, "Eroding rock on block "+TyphonUtils.blockLocationTostring(block)); } + } else if (rawHeatValue < 0.65) { + if (Math.random() < 0.1) { + this.removeOre(targetBlock); + return; + } + + double amount = 1 - Math.min(1, Math.max(0, (rawHeatValue - 0.5) / 0.15)); + + if (isDebug) this.volcano.logger.log( + VolcanoLogClass.SUCCESSION, + "Succession on block "+TyphonUtils.blockLocationTostring(block)+" / amount: "+amount); + + if (Math.random() < Math.pow(amount, 2)) { + targetBlock.applyBoneMeal(BlockFace.UP); + } + spreadSoil(targetBlock, (int)(amount * 5), false); + return; } else { VolcanoVent vent = this.volcano.manager.getNearestVent(targetBlock); - if (!vent.isStarted()) { - if (rawHeatValue < 0.65) { - double amount = 1 - Math.min(1, Math.max(0, (rawHeatValue - 0.5) / 0.15)); + double distance = vent.getTwoDimensionalDistance(block.getLocation()); + boolean isInRange = distance < vent.getRadius() * 2; - if (isDebug) this.volcano.logger.log( - VolcanoLogClass.SUCCESSION, - "Succession on block "+TyphonUtils.blockLocationTostring(block)+" / amount: "+amount); - - if (Math.random() < Math.pow(amount, 2)) { - targetBlock.applyBoneMeal(BlockFace.UP); - } - spreadSoil(targetBlock, (int)(amount * 5), false); + // add random for matching the probability on t + if (!vent.isStarted() && !isInRange) { + if (Math.random() < 0.1) { + this.removeOre(vent, targetBlock); return; - } else if (rawHeatValue < 0.8) { + } + + if (rawHeatValue < 0.8) { double percentage = (rawHeatValue - 0.65) / 0.15; percentage = Math.min(1, Math.max(0, percentage)); @@ -355,25 +374,31 @@ public void runSuccession(Block block) { } } } - - - } - } - - if (isTypeOfVolcanicOre(targetBlock.getType())) { - vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, VolcanoComposition.getExtrusiveRock(vent.lavaFlow.settings.silicateLevel)); - } else if (targetBlock.getType() == Material.BLACKSTONE) { - if (Math.random() < 0.01) { - vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, Material.NETHERRACK); - } - } else if (targetBlock.getType() == Material.NETHERRACK) { - if (Math.random() < 0.01 * 0.01) { - vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, Material.TUFF); } } + + this.removeOre(vent, targetBlock); } } + } + + private void removeOre(Block targetBlock) { + VolcanoVent vent = this.volcano.manager.getNearestVent(targetBlock); + removeOre(vent, targetBlock); + } + public void removeOre(VolcanoVent vent, Block targetBlock) { + if (isTypeOfVolcanicOre(targetBlock.getType())) { + vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, VolcanoComposition.getExtrusiveRock(vent.lavaFlow.settings.silicateLevel)); + } else if (targetBlock.getType() == Material.BLACKSTONE) { + if (Math.random() < 0.01) { + vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, Material.NETHERRACK); + } + } else if (targetBlock.getType() == Material.NETHERRACK) { + if (Math.random() < 0.01 * 0.01) { + vent.lavaFlow.queueImmediateBlockUpdate(targetBlock, Material.TUFF); + } + } } public void erodeBlock(Block targetBlock) {