mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Lazy tags + get / set tiles
Lazy tags means tiles/ents are not translated into the nms NBTBase until it is needed. Should be faster in cases where getFullBlock is called, but nbt is not always needed. Commands like Copy and Paste, where the input/output are both nms worlds, can entirely bypass WorldEdit translating to and from the WorldEdit JNBT classes.
This commit is contained in:
@ -21,6 +21,7 @@ package com.sk89q.worldedit.world.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.boydti.fawe.beta.ITileInput;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.jnbt.StringTag;
|
||||
import com.sk89q.jnbt.Tag;
|
||||
@ -162,11 +163,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
return this.nbtData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||
throw new UnsupportedOperationException("This class is immutable.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the type ID and data value are equal.
|
||||
*/
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.ITileInput;
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
@ -53,7 +54,8 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
private final char ordinalChar;
|
||||
private final BlockType blockType;
|
||||
private BlockMaterial material;
|
||||
private BaseBlock emptyBaseBlock;
|
||||
private final BaseBlock emptyBaseBlock;
|
||||
private CompoundInput compoundInput = CompoundInput.NULL;
|
||||
|
||||
protected BlockState(BlockType blockType, int internalId, int ordinal) {
|
||||
this.blockType = blockType;
|
||||
@ -196,7 +198,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
case '=': {
|
||||
charSequence.setSubstring(last, i);
|
||||
property = (AbstractProperty) type.getPropertyMap().get(charSequence);
|
||||
if (property == null) System.out.println("No prop " + charSequence + " | " + type.getPropertyMap());
|
||||
last = i + 1;
|
||||
break;
|
||||
}
|
||||
@ -356,6 +357,9 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
return this.material = blockType.getMaterial();
|
||||
}
|
||||
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
|
||||
if (this.material.hasContainer()) {
|
||||
this.compoundInput = CompoundInput.CONTAINER;
|
||||
}
|
||||
}
|
||||
return material;
|
||||
}
|
||||
@ -388,4 +392,17 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
}
|
||||
|
||||
public boolean isAir() {
|
||||
try {
|
||||
return material.isAir();
|
||||
} catch (NullPointerException ignore) {
|
||||
return getMaterial().isAir();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
|
||||
return compoundInput.get(this, input, x, y, z);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.ITileInput;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.extent.OutputExtent;
|
||||
@ -203,6 +205,10 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends FawePat
|
||||
throw new UnsupportedOperationException("State is immutable");
|
||||
}
|
||||
|
||||
default BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("State is immutable");
|
||||
}
|
||||
|
||||
default String getAsString() {
|
||||
if (getStates().isEmpty()) {
|
||||
return this.getBlockType().getId();
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.ITileInput;
|
||||
|
||||
public enum CompoundInput {
|
||||
NULL,
|
||||
CONTAINER() {
|
||||
@Override
|
||||
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||
return state.toBaseBlock(input.getTag(x, y, z));
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
public BaseBlock get(BlockState state, ITileInput input, int x, int y, int z) {
|
||||
return state.toBaseBlock();
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.ITileInput;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
Reference in New Issue
Block a user