This commit is contained in:
Jesse Boyd 2018-04-29 12:22:17 +10:00
parent 4d62867cb6
commit 916bca59ba
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 8 additions and 6 deletions

View File

@ -9,15 +9,16 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
public class DataAnglePattern extends AbstractPattern { public class DataAnglePattern extends AbstractPattern {
public final double FACTOR;
public final Extent extent; public final Extent extent;
public final int maxY; public final int maxY;
public final double factor = 1d / 255;
public final int distance; public final int distance;
public DataAnglePattern(Extent extent, int distance) { public DataAnglePattern(Extent extent, int distance) {
this.extent = new ExtentHeightCacher(extent); this.extent = new ExtentHeightCacher(extent);
this.maxY = extent.getMaximumPoint().getBlockY(); this.maxY = extent.getMaximumPoint().getBlockY();
this.distance = distance; this.distance = distance;
this.FACTOR = (1D / distance) * (1D / 255);
} }
public int getSlope(BaseBlock block, Vector vector) { public int getSlope(BaseBlock block, Vector vector) {

View File

@ -11,7 +11,6 @@ import com.sk89q.worldedit.extent.Extent;
import java.io.IOException; import java.io.IOException;
public class AngleColorPattern extends DataAnglePattern { public class AngleColorPattern extends DataAnglePattern {
private static final double FACTOR = 1d / 256;
private transient TextureUtil util; private transient TextureUtil util;
private final boolean randomize; private final boolean randomize;
@ -26,7 +25,7 @@ public class AngleColorPattern extends DataAnglePattern {
public int getColor(int color, int slope) { public int getColor(int color, int slope) {
if (slope == 0) return color; 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 newRed = (int) (((color >> 16) & 0xFF) * newFactor);
int newGreen = (int) (((color >> 8) & 0xFF) * newFactor); int newGreen = (int) (((color >> 8) & 0xFF) * newFactor);
int newBlue = (int) (((color >> 0) & 0xFF) * newFactor); int newBlue = (int) (((color >> 0) & 0xFF) * newFactor);

View File

@ -628,6 +628,7 @@ public class TextureUtil {
BufferedImage image = ImageIO.read(is); BufferedImage image = ImageIO.read(is);
int color = ImageUtil.getColor(image); int color = ImageUtil.getColor(image);
long distance = getDistance(image, color); long distance = getDistance(image, color);
if (combined == BlockID.MYCELIUM << 4) distance = Long.MAX_VALUE;
distanceMap.put((int) combined, (Long) distance); distanceMap.put((int) combined, (Long) distance);
colorMap.put((int) combined, (Integer) color); colorMap.put((int) combined, (Integer) color);
} }

View File

@ -135,10 +135,11 @@ public class PatternCommands extends MethodCommands {
@Command( @Command(
aliases = {"#angledata"}, aliases = {"#angledata"},
usage = "[distance=1]",
desc = "Block data based on the existing terrain angle" desc = "Block data based on the existing terrain angle"
) )
public Pattern angledata(Extent extent) { public Pattern angledata(Extent extent, @Optional("1") int distance) {
return new DataAnglePattern(extent, 1); return new DataAnglePattern(extent, distance);
} }
@Command( @Command(