Plenty of changes to core block behavior to become more compatible with upstream WorldEdit (still more to be done!)

This commit is contained in:
IronApollo
2019-01-31 10:08:58 -05:00
parent 271b45f3ba
commit e53535319d
116 changed files with 3666 additions and 3774 deletions

View File

@ -10,9 +10,9 @@ import java.io.FileNotFoundException;
public class CachedTextureUtil extends DelegateTextureUtil {
private final TextureUtil parent;
private transient Int2ObjectOpenHashMap<BlockTypes> colorBlockMap;
private transient Int2ObjectOpenHashMap<BlockType> colorBlockMap;
private transient Int2ObjectOpenHashMap<Integer> colorBiomeMap;
private transient Int2ObjectOpenHashMap<BlockTypes[]> colorLayerMap;
private transient Int2ObjectOpenHashMap<BlockType[]> colorLayerMap;
public CachedTextureUtil(TextureUtil parent) throws FileNotFoundException {
super(parent);
@ -23,8 +23,8 @@ public class CachedTextureUtil extends DelegateTextureUtil {
}
@Override
public BlockTypes[] getNearestLayer(int color) {
BlockTypes[] closest = colorLayerMap.get(color);
public BlockType[] getNearestLayer(int color) {
BlockType[] closest = colorLayerMap.get(color);
if (closest != null) {
return closest;
}
@ -49,12 +49,12 @@ public class CachedTextureUtil extends DelegateTextureUtil {
}
@Override
public BlockTypes getNearestBlock(int color) {
BlockTypes value = colorBlockMap.get(color);
public BlockType getNearestBlock(int color) {
BlockType value = colorBlockMap.get(color);
if (value != null) {
return value;
}
BlockTypes result = parent.getNearestBlock(color);
BlockType result = parent.getNearestBlock(color);
if (result != null) {
colorBlockMap.put((int) color, result);
}

View File

@ -19,7 +19,7 @@ public class DelegateTextureUtil extends TextureUtil {
}
@Override
public BlockTypes getNearestBlock(int color) {
public BlockType getNearestBlock(int color) {
return parent.getNearestBlock(color);
}
@ -34,7 +34,7 @@ public class DelegateTextureUtil extends TextureUtil {
}
@Override
public BlockTypes[] getNearestLayer(int color) {
public BlockType[] getNearestLayer(int color) {
return parent.getNearestLayer(color);
}

View File

@ -26,14 +26,14 @@ public class FilteredTextureUtil extends TextureUtil {
this.validBlockIds = new int[distances.length];
int num = 0;
for (int i = 0; i < parent.validBlockIds.length; i++) {
BlockTypes block = BlockTypes.get(parent.validBlockIds[i]);
BlockType block = BlockTypes.get(parent.validBlockIds[i]);
if (blocks.contains(block)) num++;
}
this.validBlockIds = new int[num];
this.validColors = new int[num];
num = 0;
for (int i = 0; i < parent.validBlockIds.length; i++) {
BlockTypes block = BlockTypes.get(parent.validBlockIds[i]);
BlockType block = BlockTypes.get(parent.validBlockIds[i]);
if (blocks.contains(block)) {
validBlockIds[num] = parent.validBlockIds[i];
validColors[num++] = parent.validColors[i];

View File

@ -12,6 +12,7 @@ import com.github.luben.zstd.ZstdOutputStream;
import com.sk89q.jnbt.*;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.history.changeset.ChangeSet;
import com.sk89q.worldedit.util.Location;
import java.awt.Graphics2D;
@ -889,7 +890,7 @@ public class MainUtil {
public static File resolve(File dir, String filename, @Nullable ClipboardFormat format, boolean allowDir) {
if (format != null) {
if (!filename.matches(".*\\.[\\w].*")) {
filename = filename + "." + format.getExtension();
filename = filename + "." + format.getPrimaryFileExtension();
}
return MainUtil.resolveRelative(new File(dir, filename));
}
@ -897,8 +898,8 @@ public class MainUtil {
File file = MainUtil.resolveRelative(new File(dir, filename));
if (file.exists() && file.isDirectory()) return file;
}
for (ClipboardFormat f : ClipboardFormat.values) {
File file = MainUtil.resolveRelative(new File(dir, filename + "." + f.getExtension()));
for (ClipboardFormat f : ClipboardFormats.getAll()) {
File file = MainUtil.resolveRelative(new File(dir, filename + "." + f.getPrimaryFileExtension()));
if (file.exists()) return file;
}
return null;

View File

@ -79,14 +79,14 @@ public class RandomTextureUtil extends CachedTextureUtil {
}
@Override
public BlockTypes getNearestBlock(int color) {
public BlockType getNearestBlock(int color) {
int offsetColor = offsets.getOrDefault(color, 0);
if (offsetColor != 0) {
offsetColor = addRandomColor(color, offsetColor);
} else {
offsetColor = color;
}
BlockTypes res = super.getNearestBlock(offsetColor);
BlockType res = super.getNearestBlock(offsetColor);
if (res == null) return null;
int newColor = getColor(res);
{

View File

@ -372,7 +372,7 @@ public class TextureUtil implements TextureHolder{
}
}
public BlockTypes getNearestBlock(int color) {
public BlockType getNearestBlock(int color) {
long min = Long.MAX_VALUE;
int closest = 0;
int red1 = (color >> 16) & 0xFF;
@ -420,7 +420,7 @@ public class TextureUtil implements TextureHolder{
return BlockTypes.get(closest);
}
private BlockTypes[] layerBuffer = new BlockTypes[2];
private BlockType[] layerBuffer = new BlockType[2];
/**
* Returns the block combined ids as an array
@ -428,7 +428,7 @@ public class TextureUtil implements TextureHolder{
* @param color
* @return
*/
public BlockTypes[] getNearestLayer(int color) {
public BlockType[] getNearestLayer(int color) {
int[] closest = null;
long min = Long.MAX_VALUE;
int red1 = (color >> 16) & 0xFF;