SteamWar/BauSystem2.0
Archiviert
12
0

Optimize Region_15

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-08-01 22:01:25 +02:00
Ursprung 9c050370a9
Commit 2c42dfafe9
5 geänderte Dateien mit 33 neuen und 103 gelöschten Zeilen

Datei anzeigen

@ -20,8 +20,6 @@
package de.steamwar.bausystem.region;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.experimental.UtilityClass;
@UtilityClass
@ -30,102 +28,4 @@ public class RegionUtils_15 {
public BlockVector3 toBlockVector3(Point point) {
return BlockVector3.at(point.getX(), point.getY(), point.getZ());
}
public BlockType mapColor(BlockType original, Color color) {
switch (color) {
case WHITE:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.WHITE_CONCRETE;
} else {
return BlockTypes.WHITE_STAINED_GLASS;
}
case ORANGE:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.ORANGE_CONCRETE;
} else {
return BlockTypes.ORANGE_STAINED_GLASS;
}
case MAGENTA:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.MAGENTA_CONCRETE;
} else {
return BlockTypes.MAGENTA_STAINED_GLASS;
}
case LIGHT_BLUE:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.LIGHT_BLUE_CONCRETE;
} else {
return BlockTypes.LIGHT_BLUE_STAINED_GLASS;
}
case LIME:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.LIME_CONCRETE;
} else {
return BlockTypes.LIME_STAINED_GLASS;
}
case PINK:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.PINK_CONCRETE;
} else {
return BlockTypes.PINK_STAINED_GLASS;
}
case GRAY:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.GRAY_CONCRETE;
} else {
return BlockTypes.GRAY_STAINED_GLASS;
}
case LIGHT_GRAY:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.LIGHT_GRAY_CONCRETE;
} else {
return BlockTypes.LIGHT_GRAY_STAINED_GLASS;
}
case CYAN:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.CYAN_CONCRETE;
} else {
return BlockTypes.CYAN_STAINED_GLASS;
}
case PURPLE:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.PURPLE_CONCRETE;
} else {
return BlockTypes.PURPLE_STAINED_GLASS;
}
case BLUE:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.BLUE_CONCRETE;
} else {
return BlockTypes.BLUE_STAINED_GLASS;
}
case BROWN:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.BROWN_CONCRETE;
} else {
return BlockTypes.BROWN_STAINED_GLASS;
}
case GREEN:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.GREEN_CONCRETE;
} else {
return BlockTypes.GREEN_STAINED_GLASS;
}
case RED:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.RED_CONCRETE;
} else {
return BlockTypes.RED_STAINED_GLASS;
}
case BLACK:
if (original == BlockTypes.YELLOW_CONCRETE) {
return BlockTypes.BLACK_CONCRETE;
} else {
return BlockTypes.BLACK_STAINED_GLASS;
}
case YELLOW:
default:
return original;
}
}
}

Datei anzeigen

@ -29,6 +29,10 @@ import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3;
@ -36,10 +40,12 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import javax.annotation.Nullable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -94,6 +100,21 @@ public class Region_15 {
if (pasteOptions.getColor() != Color.YELLOW) {
changeColor(clipboard, pasteOptions.getColor());
}
if (pasteOptions.isOnlyColors()) {
e.setMask(new AbstractExtentMask(clipboard) {
@Override
public boolean test(BlockVector3 blockVector3) {
BaseBlock block = getExtent().getFullBlock(blockVector3);
return !(block.equals(WOOL) || block.equals(CLAY) || block.equals(GLASS) || block.equals(GLASS2) || block.equals(GLASS_PANE) || block.equals(CARPET) || block.equals(CONCRETE) || block.equals(CONCRETE2) || block.equals(CONCRETE_POWDER));
}
@Nullable
@Override
public Mask2D toMask2D() {
return null;
}
});
}
System.out.println("ChangeColor: " + stop("changeColor"));
start("transform");

Datei anzeigen

@ -43,6 +43,11 @@ public class PasteOptions {
*/
private final Color color;
/**
* Used in 1.15
*/
private final boolean onlyColors;
/**
* Used in 1.15
*/

Datei anzeigen

@ -131,7 +131,7 @@ public class RegionCommand extends SWCommand {
if(checkGlobalRegion(region, p)) return;
try {
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true);
region.reset(null, RegionType.NORMAL, RegionExtensionType.NORMAL, true, true);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (IOException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);

Datei anzeigen

@ -371,12 +371,16 @@ public class Region {
}
public void reset(File file) {
EditSession editSession = paste(file, minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2), new PasteOptions(false, false, Color.YELLOW, false, getMinPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), getMaxPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), waterLevel));
EditSession editSession = paste(file, minPoint.add(prototype.getSizeX() / 2, 0, prototype.getSizeZ() / 2), new PasteOptions(false, false, Color.YELLOW, false, false, getMinPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), getMaxPoint(RegionType.NORMAL, RegionExtensionType.NORMAL), waterLevel));
initSessions();
undoSessions.push(editSession);
}
public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir) throws IOException {
reset(schematic, regionType, regionExtensionType, ignoreAir, false);
}
public void reset(Schematic schematic, RegionType regionType, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors) throws IOException {
if (!hasReset(regionType)) {
return;
}
@ -384,7 +388,7 @@ public class Region {
regionExtensionType = RegionExtensionType.NORMAL;
}
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
PasteOptions pasteOptions = new PasteOptions((schematic != null && (schematic.getSchemType().fightType() || schematic.getSchemType().check())), ignoreAir, getPlain(Flag.COLOR, ColorMode.class).getColor(), onlyColors, regionExtensionType == RegionExtensionType.EXTENSION, getMinPoint(regionType, regionExtensionType), getMaxPoint(regionType, regionExtensionType), waterLevel);
Point pastePoint;
File tempFile = null;