Minor changes

This commit is contained in:
MattBDev
2020-02-14 14:29:08 -05:00
parent 647665c3b0
commit 49dbd4b76b
17 changed files with 49 additions and 70 deletions

View File

@ -1,11 +1,13 @@
package com.boydti.fawe.beta;
import org.jetbrains.annotations.Range;
/**
* IGetBlocks may be cached by the WorldChunkCache so that it can be used between multiple
* IQueueExtents - avoids conversion between a palette and raw data on every block get
*/
public interface IChunkCache<T> extends Trimable {
T get(int chunkX, int chunkZ);
T get(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
@Override
default boolean trim(boolean aggressive) {

View File

@ -13,6 +13,7 @@ import java.io.Flushable;
import java.util.Set;
import java.util.concurrent.Future;
import javax.annotation.Nullable;
import org.jetbrains.annotations.Range;
/**
* TODO: implement Extent (need to refactor Extent first) Interface for a queue based extent which
@ -53,15 +54,15 @@ public interface IQueueExtent<T extends IChunk> extends Flushable, Trimable, ICh
* @param z
* @return
*/
IChunkGet getCachedGet(int x, int z);
IChunkGet getCachedGet(@Range(from = 0, to = 15) int x, @Range(from = 0, to = 15) int z);
/**
* Get the cached chunk set object
* @param x
* @param z
* @param chunkX
* @param chunkZ
* @return
*/
IChunkSet getCachedSet(int x, int z);
IChunkSet getCachedSet(@Range(from = 0, to = 15) int chunkX, @Range(from = 0, to = 15) int chunkZ);
/**
* Submit the chunk so that it's changes are applied to the world

View File

@ -105,7 +105,7 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return delegate.get(this).getEntity(uuid);
}
public static final IBlockDelegate BOTH = new IBlockDelegate() {
private static final IBlockDelegate BOTH = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -144,7 +144,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate GET = new IBlockDelegate() {
private static final IBlockDelegate GET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
return chunk.chunkExisting;
@ -189,7 +190,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.chunkExisting.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate SET = new IBlockDelegate() {
private static final IBlockDelegate SET = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet();
@ -235,7 +237,8 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
return chunk.getFullBlock(x, y, z);
}
};
public static final IBlockDelegate NULL = new IBlockDelegate() {
private static final IBlockDelegate NULL = new IBlockDelegate() {
@Override
public IChunkGet get(ChunkHolder chunk) {
chunk.getOrCreateGet();
@ -287,11 +290,6 @@ public class ChunkHolder<T extends Future<T>> implements IQueueChunk<T> {
}
};
// @Override
// public void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
//// block.flood(get, set, mask, block, );
// }
@Override
public Map<BlockVector3, CompoundTag> getTiles() {
return delegate.get(this).getTiles();

View File

@ -23,27 +23,17 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.block.BlockTypesCache;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable;
import org.jetbrains.annotations.NotNull;
public class CharFilterBlock extends ChunkFilterBlock {
private static final SetDelegate FULL = new SetDelegate() {
@Override
public final void set(CharFilterBlock block, char value) {
block.setArr[block.index] = value;
}
};
private static final SetDelegate NULL = new SetDelegate() {
@Override
public void set(CharFilterBlock block, char value) {
block.initSet().set(block, value);
}
};
private static final SetDelegate FULL = (block, value) -> block.setArr[block.index] = value;
private static final SetDelegate NULL = (block, value) -> block.initSet().set(block, value);
private CharGetBlocks get;
private IChunkSet set;
private char[] getArr;
private @Nullable
char[] setArr;
private @Nullable char[] setArr;
private SetDelegate delegate;
// local
private int layer, index, x, y, z, xx, yy, zz, chunkX, chunkZ;
@ -65,11 +55,10 @@ public class CharFilterBlock extends ChunkFilterBlock {
public final ChunkFilterBlock initLayer(IBlocks iget, IChunkSet iset, int layer) {
this.get = (CharGetBlocks) iget;
this.layer = layer;
final IBlocks get = (CharGetBlocks) iget;
if (!get.hasSection(layer)) {
if (!iget.hasSection(layer)) {
getArr = FaweCache.IMP.EMPTY_CHAR_4096;
} else {
getArr = get.load(layer);
getArr = iget.load(layer);
}
this.set = iset;
if (set.hasSection(layer)) {
@ -445,6 +434,6 @@ public class CharFilterBlock extends ChunkFilterBlock {
private interface SetDelegate {
void set(CharFilterBlock block, char value);
void set(@NotNull CharFilterBlock block, char value);
}
}

View File

@ -72,13 +72,13 @@ public class SingleThreadQueueExtent extends ExtentBatchProcessorHolder implemen
}
@Override
public IChunkGet getCachedGet(int x, int z) {
return cacheGet.get(x, z);
public IChunkGet getCachedGet(int chunkX, int chunkZ) {
return cacheGet.get(chunkX, chunkZ);
}
@Override
public IChunkSet getCachedSet(int x, int z) {
return cacheSet.get(x, z);
public IChunkSet getCachedSet(int chunkX, int chunkZ) {
return cacheSet.get(chunkX, chunkZ);
}
/**

View File

@ -94,6 +94,7 @@ import java.util.Map;
import java.util.TimeZone;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@ -335,7 +336,7 @@ public class LocalSession implements TextureHolder {
}
public List<ChangeSet> getHistory() {
return Lists.transform(history, this::getChangeSet);
return history.stream().map(this::getChangeSet).collect(Collectors.toList());
}
public boolean save() {

View File

@ -111,9 +111,6 @@ public class RegionCommands {
int affected = editSession.setBlocks(region, pattern);
if (affected != 0) {
actor.printInfo(TranslatableComponent.of("worldedit.set.done"));
if (!actor.hasPermission("fawe.tips"))
System.out.println("TODO FIXME TIPS");
// TranslatableComponent.of("fawe.tips.tip.fast").or(TranslatableComponent.of("fawe.tips.tip.cancel"), TranslatableComponent.of("fawe.tips.tip.mask"), TranslatableComponent.of("fawe.tips.tip.mask.angle"), TranslatableComponent.of("fawe.tips.tip.set.linear"), TranslatableComponent.of("fawe.tips.tip.surface.spread"), TranslatableComponent.of("fawe.tips.tip.set.hand")).send(actor);
}
return affected;
}
@ -424,7 +421,7 @@ public class RegionCommands {
if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS;
}
int affected = 0;
int affected;
try {
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
@ -609,9 +606,7 @@ public class RegionCommands {
@Logging(REGION)
@Confirm(Confirm.Processor.REGION)
public void regenerateChunk(Actor actor, World world, LocalSession session,
EditSession editSession, @Selection Region region,
@Arg(def = "", desc = "Regenerate with biome") BiomeType biome,
@Arg(def = "", desc = "Regenerate with seed") Long seed) throws WorldEditException {
EditSession editSession, @Selection Region region) throws WorldEditException {
Mask mask = session.getMask();
boolean success;
try {
@ -702,6 +697,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
actor.printInfo(TranslatableComponent.of("worldedit.hollow.changed", TextComponent.of(affected)));
return affected;