mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Merge branch '1.15' of https://github.com/IntellectualSites/FastAsyncWorldEdit-1.13 into 1.15
This commit is contained in:
@ -72,6 +72,7 @@ import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
@ -366,7 +367,7 @@ public class ClipboardCommands {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
player.print(Caption.of("fawe.web.download.link" , urlText));
|
||||
player.print(Caption.of("fawe.web.download.link" , urlText).clickEvent(ClickEvent.openUrl(urlText)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,8 +134,8 @@ public class GenerationCommands {
|
||||
@Arg(desc = "TODO", def = "100") int threshold, @Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||
URL url = new URL(argStr);
|
||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com") && !url.getHost().equalsIgnoreCase("empcraft.com")) {
|
||||
throw new IOException("Only i.imgur.com or empcraft.com/ui links are allowed!");
|
||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
||||
throw new IOException("Only i.imgur.com links are allowed!");
|
||||
}
|
||||
BufferedImage image = MainUtil.readImage(url);
|
||||
if (dimensions != null) {
|
||||
|
@ -212,6 +212,7 @@ public class SchematicCommands {
|
||||
}
|
||||
UUID uuid = UUID.fromString(filename.substring(4));
|
||||
URL webUrl = new URL(Settings.IMP.WEB.URL);
|
||||
format = ClipboardFormats.findByAlias(formatName);
|
||||
URL url = new URL(webUrl, "uploads/" + uuid + "." + format.getPrimaryFileExtension());
|
||||
ReadableByteChannel byteChannel = Channels.newChannel(url.openStream());
|
||||
in = Channels.newInputStream(byteChannel);
|
||||
|
@ -364,6 +364,12 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
|
||||
}
|
||||
state = fuzzyBuilder.build();
|
||||
}
|
||||
} else {
|
||||
for (Map.Entry<Property<?>, Object> blockState : blockStates.entrySet()) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Property<Object> objProp = (Property<Object>) blockState.getKey();
|
||||
state = state.with(objProp, blockState.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
// this should be impossible but IntelliJ isn't that smart
|
||||
|
@ -223,11 +223,13 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
int volume = width * height * length;
|
||||
if (palette.length < 128) {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
linear.setBlock(index, getBlockState(fis.read()));
|
||||
int ordinal = fis.read();
|
||||
linear.setBlock(index, getBlockState(ordinal));
|
||||
}
|
||||
} else {
|
||||
for (int index = 0; index < volume; index++) {
|
||||
linear.setBlock(index, getBlockState(fis.readVarInt()));
|
||||
int ordinal = fis.readVarInt();
|
||||
linear.setBlock(index, getBlockState(ordinal));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -235,7 +237,8 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
clipboard.setBlock(x, y, z, getBlockState(fis.read()));
|
||||
int ordinal = fis.read();
|
||||
clipboard.setBlock(x, y, z, getBlockState(ordinal));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -243,7 +246,8 @@ public class FastSchematicReader extends NBTSchematicReader {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
clipboard.setBlock(x, y, z, getBlockState(fis.readVarInt()));
|
||||
int ordinal = fis.readVarInt();
|
||||
clipboard.setBlock(x, y, z, getBlockState(ordinal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.extent.clipboard.io;
|
||||
|
||||
import com.boydti.fawe.jnbt.streamer.IntValueReader;
|
||||
import com.boydti.fawe.object.FaweOutputStream;
|
||||
import com.boydti.fawe.object.clipboard.LinearClipboard;
|
||||
import com.boydti.fawe.util.IOUtil;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
@ -45,7 +44,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
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;
|
||||
@ -181,6 +179,9 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
}
|
||||
|
||||
int ordinal = block.getOrdinal();
|
||||
if (ordinal == 0) {
|
||||
ordinal = 1;
|
||||
}
|
||||
char value = palette[ordinal];
|
||||
if (value == Character.MAX_VALUE) {
|
||||
int size = paletteMax++;
|
||||
@ -338,4 +339,4 @@ public class FastSchematicWriter implements ClipboardWriter {
|
||||
public void close() throws IOException {
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +189,15 @@ public class BlockMask extends ABlockMask {
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return ordinals[vector.getOrdinal(extent)];
|
||||
int test = vector.getOrdinal(extent);
|
||||
return ordinals[test] || replacesAir() && test == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesAir() {
|
||||
return ordinals[BlockTypes.AIR.getDefaultState().getOrdinal()]
|
||||
|| ordinals[BlockTypes.CAVE_AIR.getDefaultState().getOrdinal()]
|
||||
|| ordinals[BlockTypes.VOID_AIR.getDefaultState().getOrdinal()];
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -65,6 +67,11 @@ public class BlockStateMask extends AbstractExtentMask {
|
||||
.allMatch(entry -> block.getState(entry.getKey()) == entry.getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesAir() {
|
||||
return test(BlockTypes.AIR.getDefaultState()) || test(BlockTypes.CAVE_AIR.getDefaultState()) || test(BlockTypes.VOID_AIR.getDefaultState());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Mask2D toMask2D() {
|
||||
|
@ -43,6 +43,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class BlockTypeMask extends AbstractExtentMask {
|
||||
|
||||
private final boolean[] types;
|
||||
private boolean hasAir;
|
||||
|
||||
/**
|
||||
* Create a new block mask.
|
||||
@ -63,7 +64,9 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
public BlockTypeMask(Extent extent, @NotNull BlockType... block) {
|
||||
super(extent);
|
||||
this.types = new boolean[BlockTypes.size()];
|
||||
for (BlockType type : block) this.types[type.getInternalId()] = true;
|
||||
for (BlockType type : block) {
|
||||
add(type);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,9 +79,6 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
for (BlockType type : blocks) {
|
||||
add(type);
|
||||
}
|
||||
for (BlockType type : blocks) {
|
||||
this.types[type.getInternalId()] = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -88,6 +88,9 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
*/
|
||||
public void add(@NotNull BlockType... block) {
|
||||
for (BlockType type : block) {
|
||||
if (!hasAir && (type == BlockTypes.AIR || type == BlockTypes.CAVE_AIR || type == BlockTypes.VOID_AIR)) {
|
||||
hasAir = true;
|
||||
}
|
||||
this.types[type.getInternalId()] = true;
|
||||
}
|
||||
}
|
||||
@ -110,6 +113,11 @@ public class BlockTypeMask extends AbstractExtentMask {
|
||||
return test(vector.getBlock(extent).getBlockType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesAir() {
|
||||
return hasAir;
|
||||
}
|
||||
|
||||
public boolean test(BlockType block) {
|
||||
return types[block.getInternalId()];
|
||||
}
|
||||
|
@ -123,4 +123,8 @@ public interface Mask {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
default boolean replacesAir() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +88,11 @@ public class OffsetMask extends AbstractMask {
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 pos) {
|
||||
return getMask().test(extent, pos);
|
||||
BlockVector3 testPos = pos.add(offset);
|
||||
if (testPos.getBlockY() < 0 || testPos.getBlockY() > 255) {
|
||||
return false;
|
||||
}
|
||||
return getMask().test(extent, pos.add(offset));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
@ -1,13 +1,12 @@
|
||||
package com.sk89q.worldedit.function.mask;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class SingleBlockStateMask extends ABlockMask {
|
||||
private final char ordinal;
|
||||
private final boolean isAir;
|
||||
|
||||
public BlockState getBlockState() {
|
||||
return BlockState.getFromOrdinal(ordinal);
|
||||
@ -15,12 +14,14 @@ public class SingleBlockStateMask extends ABlockMask {
|
||||
|
||||
public SingleBlockStateMask(Extent extent, BlockState state) {
|
||||
super(extent);
|
||||
isAir = state.isAir();
|
||||
this.ordinal = state.getOrdinalChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean test(Extent extent, BlockVector3 vector) {
|
||||
return ordinal == vector.getOrdinal(extent);
|
||||
int test = vector.getOrdinal(extent);
|
||||
return ordinal == test || isAir && test == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -33,6 +34,11 @@ public class SingleBlockStateMask extends ABlockMask {
|
||||
return new InverseSingleBlockStateMask(getExtent(), BlockState.getFromOrdinal(ordinal));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesAir() {
|
||||
return isAir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mask tryCombine(Mask mask) {
|
||||
if (mask instanceof ABlockMask) {
|
||||
|
@ -8,10 +8,12 @@ import com.sk89q.worldedit.world.block.BlockTypesCache;
|
||||
|
||||
public class SingleBlockTypeMask extends ABlockMask {
|
||||
private final int internalId;
|
||||
private final boolean isAir;
|
||||
|
||||
public SingleBlockTypeMask(Extent extent, BlockType type) {
|
||||
super(extent);
|
||||
this.internalId = type.getInternalId();
|
||||
isAir = type == BlockTypes.AIR || type == BlockTypes.CAVE_AIR || type == BlockTypes.VOID_AIR;
|
||||
this.internalId = type.getInternalId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -27,4 +29,9 @@ public class SingleBlockTypeMask extends ABlockMask {
|
||||
public BlockType getBlockType() {
|
||||
return BlockTypes.get(internalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean replacesAir() {
|
||||
return isAir;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.google.common.primitives.Booleans;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
@ -166,12 +167,14 @@ public class BlockTypesCache {
|
||||
|
||||
public static final BlockType[] values;
|
||||
public static final BlockState[] states;
|
||||
public static final boolean[] ticking;
|
||||
|
||||
protected static final Set<String> $NAMESPACES = new LinkedHashSet<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
ArrayList<BlockState> stateList = new ArrayList<>();
|
||||
ArrayList<Boolean> tickList = new ArrayList<>();
|
||||
|
||||
Platform platform = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS);
|
||||
Registries registries = platform.getRegistries();
|
||||
@ -202,7 +205,7 @@ public class BlockTypesCache {
|
||||
if (values[internalId] != null) {
|
||||
throw new IllegalStateException("Invalid duplicate id for " + field.getName());
|
||||
}
|
||||
BlockType type = register(defaultState, internalId, stateList);
|
||||
BlockType type = register(defaultState, internalId, stateList, tickList);
|
||||
// Note: Throws IndexOutOfBoundsError if nothing is registered and blocksMap is empty
|
||||
values[internalId] = type;
|
||||
}
|
||||
@ -214,7 +217,7 @@ public class BlockTypesCache {
|
||||
String defaultState = entry.getValue();
|
||||
// Skip already registered ids
|
||||
for (; values[internalId] != null; internalId++);
|
||||
BlockType type = register(defaultState, internalId, stateList);
|
||||
BlockType type = register(defaultState, internalId, stateList, tickList);
|
||||
values[internalId] = type;
|
||||
}
|
||||
}
|
||||
@ -223,7 +226,7 @@ public class BlockTypesCache {
|
||||
}
|
||||
|
||||
states = stateList.toArray(new BlockState[stateList.size()]);
|
||||
|
||||
ticking = Booleans.toArray(tickList);
|
||||
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -231,12 +234,14 @@ public class BlockTypesCache {
|
||||
}
|
||||
}
|
||||
|
||||
private static BlockType register(final String id, int internalId, List<BlockState> states) {
|
||||
private static BlockType register(final String id, int internalId, List<BlockState> states, List<Boolean> tickList) {
|
||||
// Get the enum name (remove namespace if minecraft:)
|
||||
int propStart = id.indexOf('[');
|
||||
String typeName = id.substring(0, propStart == -1 ? id.length() : propStart);
|
||||
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()));
|
||||
// register states
|
||||
BlockType.REGISTRY.register(typeName, existing);
|
||||
String nameSpace = typeName.substring(0, typeName.indexOf(':'));
|
||||
|
Reference in New Issue
Block a user