Skip to content

Commit

Permalink
Added chance of force unstable generated gate
Browse files Browse the repository at this point in the history
  • Loading branch information
MineDragonCZ committed Jul 4, 2023
1 parent 171966a commit 377ee34
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/tauri/dev/jsg/config/JSGConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,14 @@ public static class MystPage {
})
public double despawnDhdChance = 0.05;

@Config.Name("Chance of force unstable gate")
@Config.RangeDouble(min = 0, max = 1)
@Config.SlidingOption
@Config.Comment({
"SIDE: SERVER"
})
public double forcedUnstableGateChance = 0.05;

@Config.Name("Mysterious page cooldown")
@Config.RangeInt(min = 0, max = 400)
@Config.SlidingOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ public JSGConfigOption setType(JSGConfigOptionTypeEnum type) {
return this;
}

public JSGConfigOption setBooleanValue(boolean value) {
return this.setValue(value ? "true" : "false");
}
public JSGConfigOption setValue(String value) {
if (this.type == JSGConfigOptionTypeEnum.NUMBER || this.type == JSGConfigOptionTypeEnum.SWITCH)
return this.setIntValue(value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import tauri.dev.jsg.block.JSGBlocks;
import tauri.dev.jsg.capability.CapabilityEnergyZPM;
import tauri.dev.jsg.config.JSGConfig;
import tauri.dev.jsg.config.ingame.JSGTileEntityConfig;
import tauri.dev.jsg.config.stargate.StargateSizeEnum;
import tauri.dev.jsg.fluid.JSGFluids;
import tauri.dev.jsg.item.JSGItems;
Expand Down Expand Up @@ -281,6 +282,13 @@ public GeneratedStargate generateStructure(World executedInWorld, BlockPos pos,
gateTile.getMergeHelper().updateMembersMergeStatus(worldToSpawn, gateTile.getPos(), gateTile.getFacing(), gateTile.getFacingVertical(), true);
gateTile.markDirty();

double unstableChance = JSGConfig.WorldGen.mystPage.forcedUnstableGateChance;
if(unstableChance > 0 && (random.nextFloat() < unstableChance)){
JSGTileEntityConfig config = gateTile.getConfig();
config.getOption(StargateClassicBaseTile.ConfigOptions.FORCE_UNSTABLE_EH.id).setBooleanValue(true);
gateTile.setConfigAndUpdate(config);
}

StargateAddress address = gateTile.getStargateAddress(symbolType);

if (address != null && !gateTile.getNetwork().isStargateInNetwork(address))
Expand Down

0 comments on commit 377ee34

Please sign in to comment.