*
This commit is contained in:
parent
4d62867cb6
commit
916bca59ba
@ -9,15 +9,16 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
|
||||
public class DataAnglePattern extends AbstractPattern {
|
||||
public final double FACTOR;
|
||||
public final Extent extent;
|
||||
public final int maxY;
|
||||
public final double factor = 1d / 255;
|
||||
public final int distance;
|
||||
|
||||
public DataAnglePattern(Extent extent, int distance) {
|
||||
this.extent = new ExtentHeightCacher(extent);
|
||||
this.maxY = extent.getMaximumPoint().getBlockY();
|
||||
this.distance = distance;
|
||||
this.FACTOR = (1D / distance) * (1D / 255);
|
||||
}
|
||||
|
||||
public int getSlope(BaseBlock block, Vector vector) {
|
||||
|
@ -11,7 +11,6 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AngleColorPattern extends DataAnglePattern {
|
||||
private static final double FACTOR = 1d / 256;
|
||||
private transient TextureUtil util;
|
||||
|
||||
private final boolean randomize;
|
||||
@ -26,7 +25,7 @@ public class AngleColorPattern extends DataAnglePattern {
|
||||
|
||||
public int getColor(int color, int slope) {
|
||||
if (slope == 0) return color;
|
||||
double newFactor = (256 - Math.min(256, slope)) * FACTOR;
|
||||
double newFactor = (1 - Math.min(1, slope * FACTOR));
|
||||
int newRed = (int) (((color >> 16) & 0xFF) * newFactor);
|
||||
int newGreen = (int) (((color >> 8) & 0xFF) * newFactor);
|
||||
int newBlue = (int) (((color >> 0) & 0xFF) * newFactor);
|
||||
|
@ -628,6 +628,7 @@ public class TextureUtil {
|
||||
BufferedImage image = ImageIO.read(is);
|
||||
int color = ImageUtil.getColor(image);
|
||||
long distance = getDistance(image, color);
|
||||
if (combined == BlockID.MYCELIUM << 4) distance = Long.MAX_VALUE;
|
||||
distanceMap.put((int) combined, (Long) distance);
|
||||
colorMap.put((int) combined, (Integer) color);
|
||||
}
|
||||
|
@ -135,10 +135,11 @@ public class PatternCommands extends MethodCommands {
|
||||
|
||||
@Command(
|
||||
aliases = {"#angledata"},
|
||||
usage = "[distance=1]",
|
||||
desc = "Block data based on the existing terrain angle"
|
||||
)
|
||||
public Pattern angledata(Extent extent) {
|
||||
return new DataAnglePattern(extent, 1);
|
||||
public Pattern angledata(Extent extent, @Optional("1") int distance) {
|
||||
return new DataAnglePattern(extent, distance);
|
||||
}
|
||||
|
||||
@Command(
|
||||
|
Loading…
Reference in New Issue
Block a user