mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 04:46:40 +00:00
static blocktype initialization
instead of using hacky reflection
This commit is contained in:
@ -53,6 +53,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.sk89q.worldedit.world.entity.EntityTypes;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
@ -198,7 +199,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
||||
}
|
||||
|
||||
private BlockState getBlockState(int id) {
|
||||
return BlockTypes.states[palette[id]];
|
||||
return BlockTypesCache.states[palette[id]];
|
||||
}
|
||||
|
||||
private BiomeType getBiomeType(FaweInputStream fis) throws IOException {
|
||||
|
@ -42,6 +42,7 @@ import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import net.jpountz.lz4.LZ4BlockOutputStream;
|
||||
|
||||
@ -138,7 +139,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
NBTOutputStream tilesOut = new NBTOutputStream(new LZ4BlockOutputStream(tilesCompressed));
|
||||
|
||||
List<Integer> paletteList = new ArrayList<>();
|
||||
char[] palette = new char[BlockTypes.states.length];
|
||||
char[] palette = new char[BlockTypesCache.states.length];
|
||||
Arrays.fill(palette, Character.MAX_VALUE);
|
||||
int[] paletteMax = {0};
|
||||
int numTiles = 0;
|
||||
@ -175,7 +176,7 @@ public class SpongeSchematicWriter implements ClipboardWriter {
|
||||
out.writeLazyCompoundTag("Palette", out12 -> {
|
||||
for (int i = 0; i < paletteList.size(); i++) {
|
||||
int stateOrdinal = paletteList.get(i);
|
||||
BlockState state = BlockTypes.states[stateOrdinal];
|
||||
BlockState state = BlockTypesCache.states[stateOrdinal];
|
||||
out12.writeNamedTag(state.getAsString(), i);
|
||||
}
|
||||
});
|
||||
|
@ -67,6 +67,8 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -468,14 +470,14 @@ public class BlockTransformExtent extends ResettableExtent {
|
||||
int internalId = state.getInternalId();
|
||||
|
||||
int maskedId = internalId & mask;
|
||||
int newMaskedId = arr[maskedId >> BlockTypes.BIT_OFFSET];
|
||||
int newMaskedId = arr[maskedId >> BlockTypesCache.BIT_OFFSET];
|
||||
if (newMaskedId != -1) {
|
||||
return BlockState.getFromInternalId(newMaskedId | (internalId & (~mask)));
|
||||
}
|
||||
|
||||
newMaskedId = transformState(state, transform);
|
||||
|
||||
arr[maskedId >> BlockTypes.BIT_OFFSET] = newMaskedId & mask;
|
||||
arr[maskedId >> BlockTypesCache.BIT_OFFSET] = newMaskedId & mask;
|
||||
return BlockState.getFromInternalId(newMaskedId);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user