mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-11 20:13:55 +00:00
Update favs
This commit is contained in:
@ -387,7 +387,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
CHUNKSECTIONS sections = getSections(lastChunk);
|
||||
SECTION section = getCachedSection(sections, y >> 4);
|
||||
if (section == null) {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
return getCombinedId4Data(lastSection, x, y, z);
|
||||
}
|
||||
@ -723,17 +723,17 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
lastSection = getCachedSection(lastChunkSections, cy);
|
||||
} else {
|
||||
lastChunkSections = null;
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
} else if (cy != lastSectionY) {
|
||||
if (lastChunkSections != null) {
|
||||
lastSection = getCachedSection(lastChunkSections, cy);
|
||||
} else {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
}
|
||||
if (lastSection == null) {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
return getCombinedId4Data(lastSection, x, y, z);
|
||||
}
|
||||
@ -752,17 +752,17 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, CHUNKSECTIONS, SECTION> impl
|
||||
lastSection = getCachedSection(lastChunkSections, cy);
|
||||
} else {
|
||||
lastChunkSections = null;
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
} else if (cy != lastSectionY) {
|
||||
if (lastChunkSections != null) {
|
||||
lastSection = getCachedSection(lastChunkSections, cy);
|
||||
} else {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
}
|
||||
if (lastSection == null) {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
return getCombinedId4Data(lastSection, x, y, z);
|
||||
}
|
||||
|
@ -141,10 +141,10 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
|
||||
|
||||
public int getId(final char[][] sections, final int x, final int y, final int z) {
|
||||
if ((x < 0) || (x > 15) || (z < 0) || (z > 15)) {
|
||||
return 1;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
if ((y < 0) || (y > maxY)) {
|
||||
return 1;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
final int i = FaweCache.CACHE_I[y][z][x];
|
||||
final char[] section = sections[i];
|
||||
|
@ -4,6 +4,8 @@ import com.boydti.fawe.object.FaweChunk;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -46,7 +48,7 @@ public class NullFaweChunk extends FaweChunk<Void> {
|
||||
|
||||
@Override
|
||||
public int getBlockCombinedId(int x, int y, int z) {
|
||||
return 0;
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -455,7 +455,8 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
||||
session.debug(BBC.WORLDEDIT_FAILED_LOAD_CHUNK, x >> 4, z >> 4);
|
||||
return def;
|
||||
} catch (Throwable e) {
|
||||
return 0;
|
||||
e.printStackTrace();
|
||||
return BlockTypes.AIR.getInternalId();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,101 @@
|
||||
package com.boydti.fawe.object.queue;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.MutableBlockVector2D;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.world.biome.BaseBiome;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
||||
private final FaweQueue parentQueue;
|
||||
private final Extent parentExtent;
|
||||
private final MutableBlockVector2D mutable2d = new MutableBlockVector2D();
|
||||
|
||||
public FaweQueueDelegateExtent(FaweQueue parentQueue, Extent parentExtent) {
|
||||
super(parentQueue);
|
||||
checkNotNull(parentExtent);
|
||||
checkNotNull(parentQueue);
|
||||
this.parentQueue = parentQueue;
|
||||
this.parentExtent = parentExtent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int combinedId) {
|
||||
return setBlock(x, y, z, BlockState.get(combinedId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, int combinedId, CompoundTag nbt) {
|
||||
if (nbt != null) {
|
||||
return setBlock(x, y, z, BaseBlock.getFromInternalId(combinedId, nbt));
|
||||
}
|
||||
return setBlock(x, y, z, BlockState.get(combinedId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCachedCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getCombinedId4Data(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getLazyBlock(x, y, z).getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||
return getLazyBlock(x, y, z).getNbtData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBiomeId(int x, int z) throws FaweException.FaweChunkLoadException {
|
||||
return parentExtent.getBiome(mutable2d.setComponents(x, z)).getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(Vector2D position, BaseBiome biome) {
|
||||
return parentExtent.setBiome(position, biome);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(Vector position) {
|
||||
return parentExtent.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBiome getBiome(Vector2D position) {
|
||||
return parentExtent.getBiome(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BlockStateHolder block) throws WorldEditException {
|
||||
return parentExtent.setBlock(position, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(int x, int y, int z, BlockStateHolder block) throws WorldEditException {
|
||||
return parentExtent.setBlock(x, y, z, block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(Vector position) {
|
||||
return parentExtent.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return parentExtent.getLazyBlock(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.boydti.fawe.object.collection.FastBitSet;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -15,6 +16,7 @@ import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -43,6 +45,31 @@ public class BlockMask extends AbstractExtentMask {
|
||||
this.bitSets = bitSets;
|
||||
}
|
||||
|
||||
public BlockMaskBuilder toBuilder() {
|
||||
return new BlockMaskBuilder(this.bitSets);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
List<String> strings = new ArrayList<>();
|
||||
for (int i = 0; i < bitSets.length; i++) {
|
||||
if (bitSets[i] != null) {
|
||||
long[] set = bitSets[i];
|
||||
BlockTypes type = BlockTypes.get(i);
|
||||
if (set == ALL) {
|
||||
strings.add(type.getId());
|
||||
} else {
|
||||
for (BlockState state : type.getStates()) {
|
||||
if (test(state)) {
|
||||
strings.add(state.getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return StringMan.join(strings, ",");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask optimize() {
|
||||
Map<Object, Integer> states = new HashMap<>();
|
||||
@ -179,6 +206,13 @@ public class BlockMask extends AbstractExtentMask {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean test(BlockState block) {
|
||||
long[] bitSet = bitSets[block.getInternalBlockTypeId()];
|
||||
if (bitSet == null) return false;
|
||||
if (bitSet.length == 0) return true;
|
||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
BlockStateHolder block = getExtent().getBlock(vector);
|
||||
|
@ -553,7 +553,7 @@ public class BlockMaskBuilder {
|
||||
return this.bitSets;
|
||||
}
|
||||
|
||||
public Mask build(Extent extent) {
|
||||
public BlockMask build(Extent extent) {
|
||||
optimize();
|
||||
return new BlockMask(extent, bitSets);
|
||||
}
|
||||
|
@ -775,6 +775,24 @@ public enum BlockTypes implements BlockType {
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Slow
|
||||
* @return collection of states
|
||||
*/
|
||||
@Deprecated
|
||||
public Collection<BlockState> getStates() {
|
||||
if (this.settings.states == null || this.settings.states.length <= 1) {
|
||||
return Collections.singletonList(getDefaultState());
|
||||
}
|
||||
ArrayList<BlockState> states = new ArrayList<>();
|
||||
for (BlockState state : settings.states) {
|
||||
if (state != null) {
|
||||
states.add(state);
|
||||
}
|
||||
}
|
||||
return states;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMaxStateId() {
|
||||
return settings.permutations;
|
||||
|
Reference in New Issue
Block a user