Skip to content

Commit

Permalink
fix: geothermal activities that overrides over succession and reflect…
Browse files Browse the repository at this point in the history
… based on heat value
  • Loading branch information
Alex4386 committed Jan 7, 2025
1 parent 92b15a0 commit 4a226aa
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
}
}

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

Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4a226aa

Please sign in to comment.