mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Add fluid ticking and refactor post-processing a bit (#1554)
* Make postProcessSet a default method and change to void * Throwable#getMessage is nullable * Move (re-)ticking to a post-processor per "platform" - Add fluid ticking * chore: Ignore (for us) irrelevant rules * chore: Fix correct toml syntax? * Re-add removed method for API-compliance and refactor it to have a use * Switch to javax annotations * Switch to recalcBlockCounts for ticking blocks. * No need to set air count anymore either * We can still "not tick" in fast mode in 1.17.2 * update adapters * Let paper create the chunk section if biomes are null * Adjust notes to settings * 1.17.2 didn't exist * Add 1.18.2 * Don't attempt to cache plains biome ID * Use correct annotation Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
@ -45,6 +45,7 @@ import com.fastasyncworldedit.core.history.changeset.BlockBagChangeSet;
|
||||
import com.fastasyncworldedit.core.history.changeset.NullChangeSet;
|
||||
import com.fastasyncworldedit.core.limit.FaweLimit;
|
||||
import com.fastasyncworldedit.core.limit.PropertyRemap;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.fastasyncworldedit.core.queue.IQueueChunk;
|
||||
import com.fastasyncworldedit.core.queue.IQueueExtent;
|
||||
import com.fastasyncworldedit.core.queue.implementation.ParallelQueueExtent;
|
||||
@ -560,7 +561,7 @@ public final class EditSessionBuilder {
|
||||
}
|
||||
}
|
||||
}
|
||||
// There's no need to do lighting (and it'll also just be a pain to implement) if we're not placing chunks
|
||||
// There's no need to do the below (and it'll also just be a pain to implement) if we're not placing chunks
|
||||
if (placeChunks) {
|
||||
if (((relightMode != null && relightMode != RelightMode.NONE) || (relightMode == null && Settings.settings().LIGHTING.MODE > 0))) {
|
||||
relighter = WorldEdit.getInstance().getPlatformManager()
|
||||
@ -569,6 +570,22 @@ public final class EditSessionBuilder {
|
||||
extent.addProcessor(new RelightProcessor(relighter));
|
||||
}
|
||||
extent.addProcessor(new HeightmapProcessor(world.getMinY(), world.getMaxY()));
|
||||
IBatchProcessor platformProcessor = WorldEdit
|
||||
.getInstance()
|
||||
.getPlatformManager()
|
||||
.queryCapability(Capability.WORLD_EDITING)
|
||||
.getPlatformProcessor(fastMode);
|
||||
if (platformProcessor != null) {
|
||||
extent.addProcessor(platformProcessor);
|
||||
}
|
||||
IBatchProcessor platformPostProcessor = WorldEdit
|
||||
.getInstance()
|
||||
.getPlatformManager()
|
||||
.queryCapability(Capability.WORLD_EDITING)
|
||||
.getPlatformPostProcessor(fastMode);
|
||||
if (platformPostProcessor != null) {
|
||||
extent.addPostProcessor(platformPostProcessor);
|
||||
}
|
||||
} else {
|
||||
relighter = NullRelighter.INSTANCE;
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.extension.platform;
|
||||
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.Relighter;
|
||||
import com.fastasyncworldedit.core.extent.processor.lighting.RelighterFactory;
|
||||
import com.fastasyncworldedit.core.queue.IBatchProcessor;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
@ -248,5 +249,24 @@ public interface Platform extends Keyed {
|
||||
* @since 2.0.0
|
||||
*/
|
||||
int versionMaxY();
|
||||
|
||||
/**
|
||||
* Get a {@link IBatchProcessor} to be used in edit processing. Null if not required.
|
||||
* @since TODO
|
||||
*/
|
||||
@Nullable
|
||||
default IBatchProcessor getPlatformProcessor(boolean fastMode) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a {@link IBatchProcessor} to be used in edit post-processing. Used for things such as tick-placed and tick fluids.
|
||||
* Null if not required.
|
||||
* @since TODO
|
||||
*/
|
||||
@Nullable
|
||||
default IBatchProcessor getPlatformPostProcessor(boolean fastMode) {
|
||||
return null;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -111,12 +111,6 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
|
||||
return filter.filter(chunk, get, set, MaskingExtent.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
// This should not do anything otherwise dangerous...
|
||||
return CompletableFuture.completedFuture(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyBlock(final FilterBlock block) {
|
||||
if (!this.mask.test(block)) {
|
||||
|
@ -471,12 +471,6 @@ public interface Region extends Iterable<BlockVector3>, Cloneable, IBatchProcess
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default Future<IChunkSet> postProcessSet(IChunk chunk, IChunkGet get, IChunkSet set) {
|
||||
// Doesn't need to do anything
|
||||
return CompletableFuture.completedFuture(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
default Extent construct(Extent child) {
|
||||
if (isGlobal()) {
|
||||
|
@ -23,6 +23,7 @@ import com.fastasyncworldedit.core.configuration.Caption;
|
||||
import com.fastasyncworldedit.core.queue.IChunk;
|
||||
import com.fastasyncworldedit.core.queue.IChunkGet;
|
||||
import com.fastasyncworldedit.core.queue.IChunkSet;
|
||||
import com.fastasyncworldedit.core.util.MultiFuture;
|
||||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
@ -35,6 +36,7 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -172,6 +174,15 @@ public class RegionIntersection extends AbstractRegion {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Future<?> postProcessSet(final IChunk chunk, final IChunkGet get, final IChunkSet set) {
|
||||
final ArrayList<Future<?>> futures = new ArrayList<>();
|
||||
for (Region region : regions) {
|
||||
futures.add(region.postProcessSet(chunk, get, set));
|
||||
}
|
||||
return new MultiFuture(futures);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IChunkSet processSet(IChunk chunk, IChunkGet get, IChunkSet set, boolean asBlacklist) {
|
||||
if (!asBlacklist) {
|
||||
|
@ -198,6 +198,9 @@ public class BlockTypesCache {
|
||||
|
||||
public static final BlockType[] values;
|
||||
public static final BlockState[] states;
|
||||
/**
|
||||
* Array of blockstates in order of ordinal indicating if the block ticks, e.g. leaves, water
|
||||
*/
|
||||
public static final boolean[] ticking;
|
||||
private static final Map<String, List<Property<?>>> allProperties = new HashMap<>();
|
||||
|
||||
@ -283,7 +286,8 @@ public class BlockTypesCache {
|
||||
String enumName = (typeName.startsWith("minecraft:") ? typeName.substring(10) : typeName).toUpperCase(Locale.ROOT);
|
||||
int oldsize = states.size();
|
||||
BlockType existing = new BlockType(id, internalId, states);
|
||||
tickList.addAll(Collections.nCopies(states.size() - oldsize, existing.getMaterial().isTicksRandomly()));
|
||||
tickList.addAll(Collections.nCopies(states.size() - oldsize,
|
||||
existing.getMaterial().isTicksRandomly() || existing.getMaterial().isLiquid()));
|
||||
// register states
|
||||
BlockType.REGISTRY.register(typeName, existing);
|
||||
String nameSpace = typeName.substring(0, typeName.indexOf(':'));
|
||||
|
Reference in New Issue
Block a user