geforkt von Mirrors/FastAsyncWorldEdit
Ursprung
94a14b03b6
Commit
d379b0af9b
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
|
import com.plotsquared.core.util.PseudoRandom;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ public class RandomTextureUtil extends CachedTextureUtil {
|
|||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
int i1 = -i;
|
int i1 = -i;
|
||||||
return -ThreadLocalRandom.current().nextInt(i1);
|
return -ThreadLocalRandom.current().nextInt(i1);
|
||||||
|
} else if( i == 0) {
|
||||||
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
return ThreadLocalRandom.current().nextInt(i);
|
return ThreadLocalRandom.current().nextInt(i);
|
||||||
}
|
}
|
||||||
|
@ -629,7 +629,6 @@ public class TextureUtil implements TextureHolder {
|
|||||||
mods.add(modId);
|
mods.add(modId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
String modelsDir = "assets/%1$s/models/block/%2$s.json";
|
String modelsDir = "assets/%1$s/models/block/%2$s.json";
|
||||||
String texturesDir = "assets/%1$s/textures/%2$s.png";
|
String texturesDir = "assets/%1$s/textures/%2$s.png";
|
||||||
@ -638,14 +637,14 @@ public class TextureUtil implements TextureHolder {
|
|||||||
}.getType();
|
}.getType();
|
||||||
|
|
||||||
for (BlockType blockType : BlockTypesCache.values) {
|
for (BlockType blockType : BlockTypesCache.values) {
|
||||||
if (!blockType.getMaterial().isFullCube()) {
|
if (!blockType.getMaterial().isFullCube() || blockType.getId().toLowerCase().contains("shulker")) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int combined = blockType.getInternalId();
|
int combined = blockType.getInternalId();
|
||||||
String id = blockType.getId();
|
String id = blockType.getId();
|
||||||
String[] split = id.split(":", 2);
|
String[] split = id.split(":", 2);
|
||||||
String name = split.length == 1 ? id : split[1];
|
String name = split.length == 1 ? id : split[1];
|
||||||
String nameSpace = split.length == 1 ? "minecraft" : split[0];
|
String nameSpace = split.length == 1 ? "" : split[0];
|
||||||
|
|
||||||
Map<String, String> texturesMap = new ConcurrentHashMap<>();
|
Map<String, String> texturesMap = new ConcurrentHashMap<>();
|
||||||
// Read models
|
// Read models
|
||||||
@ -684,8 +683,11 @@ public class TextureUtil implements TextureHolder {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String[] texSplit = models.iterator().next().split(":");
|
||||||
|
String texture = texSplit[texSplit.length - 1];
|
||||||
|
|
||||||
textureFileName =
|
textureFileName =
|
||||||
String.format(texturesDir, nameSpace, models.iterator().next());
|
String.format(texturesDir, nameSpace, texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedImage image = readImage(zipFile, textureFileName);
|
BufferedImage image = readImage(zipFile, textureFileName);
|
||||||
|
@ -85,7 +85,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
|||||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extension.platform.binding.ProvideBindings;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.function.Contextual;
|
import com.sk89q.worldedit.function.Contextual;
|
||||||
@ -130,6 +129,7 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.net.URL;
|
||||||
import java.nio.file.FileSystems;
|
import java.nio.file.FileSystems;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -498,22 +498,23 @@ public class BrushCommands {
|
|||||||
set(context, brush).setSize(radius).setFill(fill);
|
set(context, brush).setSize(radius).setFill(fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(name = "image",
|
||||||
name = "image",
|
|
||||||
desc = "Use a height map to paint a surface",
|
desc = "Use a height map to paint a surface",
|
||||||
descFooter = "Use a height map to paint any surface.\n"
|
descFooter = "Use a height map to paint any surface.\n")
|
||||||
)
|
@CommandPermissions("worldedit.brush.image")
|
||||||
@CommandPermissions("worldedit.brush.stencil")
|
public void imageBrush(LocalSession session,
|
||||||
public void imageBrush(LocalSession session, InjectedValueAccess context,
|
InjectedValueAccess context,
|
||||||
@Arg(desc = "The size of the brush", def = "5")
|
@Arg(desc = "Image URL (imgur only)") String imageURL,
|
||||||
Expression radius, ProvideBindings.ImageUri imageUri,
|
@Arg(desc = "The size of the brush", def = "5") Expression radius,
|
||||||
@Arg(def = "1", desc = "scale height")
|
@Arg(def = "1", desc = "scale height") double yscale,
|
||||||
double yscale,
|
@Switch(name = 'a', desc = "Use image Alpha") boolean alpha,
|
||||||
@Switch(name = 'a', desc = "Use image Alpha")
|
@Switch(name = 'f', desc = "Blend the image with existing terrain") boolean fadeOut)
|
||||||
boolean alpha,
|
throws WorldEditException, IOException {
|
||||||
@Switch(name = 'f', desc = "Blend the image with existing terrain")
|
URL url = new URL(imageURL);
|
||||||
boolean fadeOut) throws WorldEditException, IOException {
|
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
||||||
BufferedImage image = imageUri.load();
|
throw new IOException("Only i.imgur.com links are allowed!");
|
||||||
|
}
|
||||||
|
BufferedImage image = MainUtil.readImage(url);
|
||||||
worldEdit.checkMaxBrushRadius(radius);
|
worldEdit.checkMaxBrushRadius(radius);
|
||||||
if (yscale != 1) {
|
if (yscale != 1) {
|
||||||
ImageUtil.scaleAlpha(image, yscale);
|
ImageUtil.scaleAlpha(image, yscale);
|
||||||
|
@ -58,7 +58,7 @@ import org.enginehub.piston.annotation.param.Arg;
|
|||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
import org.jetbrains.annotations.Range;
|
import org.jetbrains.annotations.Range;
|
||||||
|
|
||||||
import java.awt.RenderingHints;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -131,16 +131,22 @@ public class GenerationCommands {
|
|||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.generation.image")
|
@CommandPermissions("worldedit.generation.image")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void image(Actor actor, LocalSession session, EditSession editSession, String argStr, @Arg(desc = "boolean", def = "true") boolean randomize,
|
public void image(Actor actor,
|
||||||
@Arg(desc = "TODO", def = "100") int threshold, @Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
LocalSession session,
|
||||||
|
EditSession editSession,
|
||||||
|
@Arg(desc = "Image URL (imgur only)") String imageURL,
|
||||||
|
@Arg(desc = "boolean", def = "true") boolean randomize,
|
||||||
|
@Arg(desc = "TODO", def = "100") int threshold,
|
||||||
|
@Arg(desc = "BlockVector2", def = "") BlockVector2 dimensions) throws WorldEditException, IOException {
|
||||||
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
TextureUtil tu = Fawe.get().getCachedTextureUtil(randomize, 0, threshold);
|
||||||
URL url = new URL(argStr);
|
URL url = new URL(imageURL);
|
||||||
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
if (!url.getHost().equalsIgnoreCase("i.imgur.com")) {
|
||||||
throw new IOException("Only i.imgur.com links are allowed!");
|
throw new IOException("Only i.imgur.com links are allowed!");
|
||||||
}
|
}
|
||||||
BufferedImage image = MainUtil.readImage(url);
|
BufferedImage image = MainUtil.readImage(url);
|
||||||
if (dimensions != null) {
|
if (dimensions != null) {
|
||||||
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(), RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
image = ImageUtil.getScaledInstance(image, dimensions.getBlockX(), dimensions.getBlockZ(),
|
||||||
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockVector3 pos1 = session.getPlacementPosition(actor);
|
BlockVector3 pos1 = session.getPlacementPosition(actor);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren