Added a bit of tweaking to limbo decay via CreepyCree's suggestion.

This commit is contained in:
Waterpicker 2021-10-09 19:07:03 -05:00
parent fa202dfc1e
commit 3dbd77dfa1
6 changed files with 21 additions and 43 deletions

View file

@ -168,7 +168,7 @@ public final class ModConfig implements ConfigData {
public static class Limbo {
@Tooltip public boolean universalLimbo = false;
@Tooltip public boolean hardcoreLimbo = false;
@Tooltip public double decaySpreadChance = 0.5;
@Tooltip public double decaySpreadChance = 1.0;
@Tooltip public float limboBlocksCorruptingOverworldAmount = 5;
}

View file

@ -22,24 +22,9 @@ public class UnravelledFabricBlock extends Block {
@SuppressWarnings("deprecation")
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (ModDimensions.isLimboDimension(world)) {
LimboDecay.applySpreadDecay(world, pos);
}
}
@SuppressWarnings("deprecation")
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
this.scheduledTick(state, world, pos, random);
}
@SuppressWarnings("deprecation")
@Override
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState newState, WorldAccess world, BlockPos pos, BlockPos posFrom) {
if (world instanceof ServerWorld) {
world.getBlockTickScheduler().schedule(pos, this, 10, TickPriority.NORMAL);
}
return state;
}
}

View file

@ -30,13 +30,12 @@ public class DecayPattern {
return DecayPattern.builder().predicate(predicate).processor(processor).create();
}
public boolean run(World world, BlockPos pos, BlockState origin, BlockState target) {
if(predicate.test(world, pos, origin, target)) {
ENTROPY_EVENT.invoker().entropy(world, pos, processor.process(world, pos, origin, target));
return true;
}
public boolean test(World world, BlockPos pos, BlockState origin, BlockState target) {
return predicate.test(world, pos, origin, target);
}
return false;
public void process(World world, BlockPos pos, BlockState origin, BlockState target) {
ENTROPY_EVENT.invoker().entropy(world, pos, processor.process(world, pos, origin, target));
}
public static DecayPattern.Builder builder() {

View file

@ -54,38 +54,29 @@ public final class LimboDecay {
BlockState origin = world.getBlockState(pos);
//Apply decay to the blocks above, below, and on all four sides.
//World.getBlockId() implements bounds checking, so we don't have to worry about reaching out of the world/*
/*boolean flag = */decayBlock(world, pos.up(), origin);
/*flag = flag && */decayBlock(world, pos.down(), origin);
/*flag = flag && */decayBlock(world, pos.north(), origin);
/*flag = flag && */decayBlock(world, pos.south(), origin);
/*flag = flag && */decayBlock(world, pos.west(), origin);
/*flag = flag && */decayBlock(world, pos.east(), origin);
// if (flag) {
// LOGGER.debug("Applied limbo decay to block at all six sides at position {} in dimension {}", pos, world.getRegistryKey().getValue());
// }
decayBlock(world, pos.up(), origin);
decayBlock(world, pos.down(), origin);
decayBlock(world, pos.north(), origin);
decayBlock(world, pos.south(), origin);
decayBlock(world, pos.west(), origin);
decayBlock(world, pos.east(), origin);
}
}
/**
* Checks if a block can be decayed and, if so, changes it to the next block ID along the decay sequence.
*/
private static boolean decayBlock(World world, BlockPos pos, BlockState origin) {
private static void decayBlock(World world, BlockPos pos, BlockState origin) {
@NotNull Collection<DecayPattern> patterns = DecayLoader.getInstance().getPatterns();
if(patterns.isEmpty()) return false;
if(patterns.isEmpty()) return;
BlockState target = world.getBlockState(pos);
for (DecayPattern pattern : DecayLoader.getInstance().getPatterns()) {
if(pattern.run(world, pos, origin, target)) return true;
}
return false;
patterns.stream().filter(decayPattern -> decayPattern.test(world, pos, origin, target)).findAny().ifPresent(pattern -> pattern.process(world, pos, origin, target));
}
public static class DecayLoader implements SimpleSynchronousResourceReloadListener {
private static final Logger LOGGER = LogManager.getLogger();
private static final Gson GSON = new GsonBuilder().setLenient().setPrettyPrinting().create();
private static final DecayLoader INSTANCE = new DecayLoader();
private List<DecayPattern> patterns = new ArrayList<>();
@ -112,7 +103,7 @@ public final class LimboDecay {
Collection<Identifier> ids = manager.findResources(startingPath, str -> str.endsWith(".json"));
return CompletableFuture.supplyAsync(() -> {
List<T> tree = new ArrayList<>();
ids.parallelStream().unordered().<T>map(
ids.parallelStream().unordered().map(
id -> {
try {
JsonElement json = GSON.fromJson(new InputStreamReader(manager.getResource(id).getInputStream()), JsonElement.class);
@ -120,7 +111,7 @@ public final class LimboDecay {
} catch (IOException e) {
throw new RuntimeException("Error loading resource: " + id);
}
}).forEach(tree::add);
}).sequential().forEach(tree::add);
return tree;
});
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 391 B

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,3 @@
{
"animation": { "frametime": 5 }
}