Fix paste -a

This commit is contained in:
Jesse Boyd 2017-03-31 00:54:44 +11:00
parent f4752fe733
commit 5c6a5c48d1
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 28 additions and 13 deletions

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.object.brush;
import com.boydti.fawe.object.PseudoRandom;
import com.boydti.fawe.object.brush.heightmap.HeightMap;
import com.boydti.fawe.object.brush.heightmap.ScalableHeightMap;
import com.boydti.fawe.object.mask.AdjacentAnyMask;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -17,6 +18,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays;
public class StencilBrush extends HeightBrush {
@ -33,13 +35,13 @@ public class StencilBrush extends HeightBrush {
final int cy = position.getBlockY();
final int cz = position.getBlockZ();
int size = (int) sizeDouble;
int maxY = editSession.getMaxY();
int add;
if (yscale < 0) {
add = 255;
add = maxY;
} else {
add = 0;
}
int maxY = editSession.getMaxY();
double scale = (yscale / sizeDouble) * (maxY + 1);
final HeightMap map = getHeightMap();
map.setSize(size);
@ -65,7 +67,7 @@ public class StencilBrush extends HeightBrush {
}
double raise = map.getHeight(dx, dz);
int val = (int) Math.ceil(raise * scale) + add;
if (val <= cutoff) {
if (val < cutoff) {
return true;
}
if (val >= 255 || PseudoRandom.random.random(maxY) < val) {

View File

@ -96,13 +96,16 @@ public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap
int length = heightFile.getHeight();
Raster data = heightFile.getData();
byte[][] array = new byte[width][length];
double third = 1/3.0;
double alphaInverse = 1/255.0;
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
int pixel = heightFile.getRGB(x, z);
int red = (pixel >> 16) & 0xFF;
int green = (pixel >> 8) & 0xFF;
int blue = (pixel >> 0) & 0xFF;
int intensity = (red + green + blue) / 3;
int alpha = (pixel >> 24) & 0xFF;
int intensity = (int) (alpha * ((red + green + blue) * third) * alphaInverse);
array[x][z] = (byte) intensity;
}
}

View File

@ -156,14 +156,25 @@ public class CPUOptimizedClipboard extends FaweClipboard {
@Override
public void forEach(final BlockReader task, boolean air) {
for (int y = 0, index = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
if (!air && block.getId() == 0) {
continue;
if (air) {
for (int y = 0, index = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
task.run(x, y, z, block);
}
}
}
} else {
for (int y = 0, index = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
System.out.println(block);
if (block.getId() != 0) {
task.run(x, y, z, block);
}
}
task.run(x, y, z, block);
}
}
}

View File

@ -377,7 +377,6 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
@Override
public void forEach(final BlockReader task, final boolean air) {
// Fawe.debug("Compressed: " + size() + "b | Uncompressed: " + (volume << 0x5) + "b");
if (air) {
for (int y = 0, index = 0; y < height; y++) {
for (int z = 0; z < length; z++) {
@ -392,7 +391,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
if (block.getId() == 0) {
if (block.getId() != 0) {
task.run(x, y, z, block);
}
}