Skip to content

Commit

Permalink
Merge branch 'pr/17' into 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikeatron-User committed Nov 24, 2023
2 parents a3edeef + bd69188 commit 53c5b4b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, Block
SculkAncientNodeBlockEntity::tickAwake);
}

if (ModConfig.SERVER.trigger_ancient_node_automatically.get()) {
return BaseEntityBlock.createTickerHelper(blockEntityType,
ModBlockEntities.SCULK_ANCIENT_NODE_BLOCK_ENTITY.get(),
SculkAncientNodeBlockEntity::tickTriggerAutomatically);
}

return BaseEntityBlock.createTickerHelper(blockEntityType, ModBlockEntities.SCULK_ANCIENT_NODE_BLOCK_ENTITY.get(), (level1, pos, state, entity) -> {
VibrationSystem.Ticker.tick(level1, entity.getVibrationData(), entity.getVibrationUser());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,20 @@ public static void tickAwake(Level level, BlockPos blockPos, BlockState blockSta
BlockEntityChunkLoaderHelper.getChunkLoaderHelper().createChunkLoadRequestSquare((ServerLevel) level, blockPos, ModConfig.SERVER.sculk_node_chunkload_radius.get(), 1, TickUnits.convertMinutesToTicks(30));
}

public static void tickTriggerAutomatically(Level level, BlockPos blockPos, BlockState blockState, SculkAncientNodeBlockEntity blockEntity)
{
// Should never get here but for safety's sake double verify
if (!ModConfig.SERVER.trigger_ancient_node_automatically.get()) { return; }

// Check elapsed days
if (level.getDayTime() < (ModConfig.SERVER.trigger_ancient_node_wait_days.get() * 24000)) { return; }

// Check time of current day
if ((level.getDayTime() % 24000) < (long)(ModConfig.SERVER.trigger_ancient_node_time_of_day.get())) { return; }

tryInitializeHorde(level, blockEntity.getBlockPos(), blockEntity.getBlockState(), blockEntity);
}

private static boolean areAnyPlayersInRange(ServerLevel level, BlockPos blockPos, int range)
{
return level.players().stream().anyMatch((player) ->
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/github/sculkhorde/core/ModConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.sculkhorde.core;

import com.electronwill.nightconfig.core.Config;
import com.electronwill.nightconfig.core.file.CommentedFileConfig;
import com.electronwill.nightconfig.core.io.WritingMode;
import net.minecraftforge.common.ForgeConfigSpec;
Expand All @@ -23,6 +24,10 @@ public static class Server {
public final ForgeConfigSpec.ConfigValue<Boolean> block_infestation_enabled;
public final ForgeConfigSpec.ConfigValue<Boolean> chunk_loading_enabled;

public final ForgeConfigSpec.ConfigValue<Boolean> trigger_ancient_node_automatically;
public final ForgeConfigSpec.ConfigValue<Integer> trigger_ancient_node_wait_days;
public final ForgeConfigSpec.ConfigValue<Integer> trigger_ancient_node_time_of_day;

public final ForgeConfigSpec.ConfigValue<Integer> gravemind_mass_goal_for_immature_stage;
public final ForgeConfigSpec.ConfigValue<Integer> gravemind_mass_goal_for_mature_stage;

Expand All @@ -48,6 +53,8 @@ public static class Server {

public Server(ForgeConfigSpec.Builder builder) {

Config.setInsertionOrderPreserved(true);

builder.push("Mod Compatability");
target_faw_entities = builder.comment("Should the Sculk Horde attack mobs from the mod 'From Another World'? (Default false)").define("target_faw_entities",false);
target_spore_entities = builder.comment("Should the Sculk Horde attack mobs from the mod 'Fungal Infection:Spore'? (Default false)").define("target_spore_entities",false);
Expand All @@ -58,6 +65,12 @@ public Server(ForgeConfigSpec.Builder builder) {
chunk_loading_enabled = builder.comment("Should the Sculk Horde load chunks? If disabled, and will ruin the intended experience. For example, raids wont work properly (Default true)").define("chunk_loading_enabled",true);
builder.pop();

builder.push("Trigger Automatically Variables");
trigger_ancient_node_automatically = builder.comment("Should the Sculk Horde start automatically? Requires that chunk loading is enabled to work reliably, otherwise will only trigger if the ancient node's chunk is loaded. If enabled on a save where previously disabled, the node will trigger automatically if the time conditions are met. (Default false)").define("trigger_ancient_node_automatically", false);
trigger_ancient_node_wait_days = builder.comment("How many days to wait before triggering the ancient node? (Default 0)").defineInRange("trigger_ancient_node_wait_days", 0, 0, Integer.MAX_VALUE);
trigger_ancient_node_time_of_day = builder.comment("What time of day in ticks must pass before triggering the ancient node after the wait days have elapsed? If wait days is set to 0, set time of day to a time greater than 1000 ticks to allow for world startup and lag to finish (Default 2000)").defineInRange("trigger_ancient_node_time_of_day", 2000, 0, 23999);
builder.pop();

builder.push("Infestation / Purification Variables");
infestation_speed_multiplier = builder.comment("How much faster or slower should infestation spread? (Default 0)").defineInRange("infestation_speed_multiplier",0f, -10f, 10f);
purification_speed_multiplier = builder.comment("How much faster or slower should purification spread? (Default 0)").defineInRange("purification_speed_multiplier",0f, -10f, 10f);
Expand Down

0 comments on commit 53c5b4b

Please sign in to comment.