3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-08 04:20:06 +01:00

Simplified switch statements and minor formatting

Dieser Commit ist enthalten in:
matt 2019-03-27 11:36:26 -04:00
Ursprung 67fd0668ee
Commit 1424998327
8 geänderte Dateien mit 50 neuen und 86 gelöschten Zeilen

Datei anzeigen

@ -202,16 +202,12 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
}
vs[j] = combinedId;
this.count[i]++;
switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
this.air[i]++;
return;
default:
heightMap[z << 4 | x] = (byte) y;
return;
if (BlockTypes.getFromStateId(combinedId).getMaterial().isAir()) {
this.air[i]++;
return;
}
heightMap[z << 4 | x] = (byte) y;
return;
}
@Deprecated

Datei anzeigen

@ -284,11 +284,8 @@ public interface FaweQueue extends HasFaweQueue, Extent {
int combined = getCombinedId4Data(xx, y, zz);
BaseBlock block = BlockState.getFromInternalId(combined).toBaseBlock();
BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) {
case "AIR":
case "VOID_AIR":
case "CAVE_AIR":
continue;
if (type.getMaterial().isAir()) {
continue;
}
mutable.mutY(y);
CompoundTag tile = getTileEntity(x, y, z);

Datei anzeigen

@ -115,17 +115,12 @@ public class VisualChunk extends FaweChunk<FaweChunk> {
public void setBlock(int x, int y, int z, int combinedId) {
int index = getIndex(x, y, z);
try {
switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
add.clear(index);
remove.set(index);
break;
default:
remove.clear(index);
add.set(index);
break;
if (BlockTypes.getFromStateId(combinedId).getMaterial().isAir()) {
add.clear(index);
remove.set(index);
} else {
remove.clear(index);
add.set(index);
}
} catch (Throwable e) {
e.printStackTrace();

Datei anzeigen

@ -175,13 +175,8 @@ public class CPUOptimizedClipboard extends FaweClipboard {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
switch (block.getBlockType().getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
continue;
default:
task.run(x, y, z, block);
if (!block.getMaterial().isAir()) {
task.run(x, y, z, block);
}
}
}

Datei anzeigen

@ -404,23 +404,18 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
for (int x = 0; x < width; x++, pos += 4) {
int combinedId = mbb.getInt(pos);
BlockType type = BlockTypes.getFromStateId(combinedId);
switch (type.getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
continue;
default:
BlockState state = type.withStateId(combinedId);
if (type.getMaterial().hasContainer()) {
trio.set(x, y, z);
CompoundTag nbt = nbtMap.get(trio);
if (nbt != null) {
BaseBlock block = new BaseBlock(state, nbt);
task.run(x, y, z, block);
continue;
}
if (!type.getMaterial().isAir()) {
BlockState state = type.withStateId(combinedId);
if (type.getMaterial().hasContainer()) {
trio.set(x, y, z);
CompoundTag nbt = nbtMap.get(trio);
if (nbt != null) {
BaseBlock block = new BaseBlock(state, nbt);
task.run(x, y, z, block);
continue;
}
task.run(x, y, z, state);
}
task.run(x, y, z, state);
}
}
}

Datei anzeigen

@ -205,11 +205,8 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
}
if (lastCombinedIds == null) {
BlockType bt = BlockTypes.getFromStateId(v);
switch (bt.getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
return;
if (bt.getMaterial().isAir()) {
return;
}
lastCombinedIds = new byte[BLOCK_SIZE];
}
@ -299,13 +296,8 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
for (int z = 0; z < length; z++) {
for (int x = 0; x < width; x++, index++) {
BaseBlock block = getBlock(index);
switch (block.getBlockType().getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
continue;
default:
task.run(x, y, z, block);
if (!block.getMaterial().isAir()) {
task.run(x, y, z, block);
}
}
}

Datei anzeigen

@ -84,7 +84,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
ListTag blocks = (ListTag) tags.get("blocks");
if (blocks != null) {
// Palette
List<CompoundTag> palette = (List<CompoundTag>) (List<?>) tags.get("palette").getValue();
List<CompoundTag> palette = (List<CompoundTag>) tags.get("palette").getValue();
BlockState[] combinedArray = new BlockState[palette.size()];
for (int i = 0; i < palette.size(); i++) {
CompoundTag compound = palette.get(i);
@ -108,7 +108,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
combinedArray[i] = state;
}
// Populate blocks
List<CompoundTag> blocksList = (List<CompoundTag>) (List<?>) tags.get("blocks").getValue();
List<CompoundTag> blocksList = (List<CompoundTag>) tags.get("blocks").getValue();
try {
for (CompoundTag compound : blocksList) {
Map<String, Tag> blockMap = compound.getValue();
@ -184,7 +184,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
continue;
}
indexes.put((int) combined, (Integer) palette.size());
indexes.put(combined, (Integer) palette.size());
HashMap<String, Object> paletteEntry = new HashMap<>();
paletteEntry.put("Name", type.getId());
if (block.getInternalId() != type.getInternalId()) {
@ -213,18 +213,17 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
BlockVector3 min = region.getMinimumPoint();
for (BlockVector3 point : region) {
BaseBlock block = clipboard.getFullBlock(point);
switch (block.getBlockType().getResource().toUpperCase()) {
case "STRUCTURE_VOID":
continue;
default:
int combined = block.getInternalId();
int index = indexes.get(combined);
List<Integer> pos = Arrays.asList((int) (point.getX() - min.getX()), (int) (point.getY() - min.getY()), (int) (point.getZ() - min.getZ()));
if (!block.hasNbtData()) {
blocks.add(FaweCache.asMap("state", index, "pos", pos));
} else {
blocks.add(FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
}
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
int combined = block.getInternalId();
int index = indexes.get(combined);
List<Integer> pos = Arrays.asList(point.getX() - min.getX(),
point.getY() - min.getY(), point.getZ() - min.getZ());
if (!block.hasNbtData()) {
blocks.add(FaweCache.asMap("state", index, "pos", pos));
} else {
blocks.add(
FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
}
}
}
if (!blocks.isEmpty()) {
@ -268,7 +267,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
}
private Tag writeVector(BlockVector3 vector, String name) {
List<DoubleTag> list = new ArrayList<DoubleTag>();
List<DoubleTag> list = new ArrayList<>();
list.add(new DoubleTag(vector.getX()));
list.add(new DoubleTag(vector.getY()));
list.add(new DoubleTag(vector.getZ()));
@ -276,7 +275,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
}
private Tag writeRotation(Location location, String name) {
List<FloatTag> list = new ArrayList<FloatTag>();
List<FloatTag> list = new ArrayList<>();
list.add(new FloatTag(location.getYaw()));
list.add(new FloatTag(location.getPitch()));
return new ListTag(FloatTag.class, list);

Datei anzeigen

@ -66,7 +66,7 @@ public class FloatingTreeRemover implements BlockTool {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config,
Player player, LocalSession session, Location clicked) {
Player player, LocalSession session, Location clicked) {
final World world = (World) clicked.getExtent();
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());
@ -132,13 +132,8 @@ public class FloatingTreeRemover implements BlockTool {
if (visited.add(next)) {
BlockState state = world.getBlock(next);
BlockType type = state.getBlockType();
switch (type.getResource().toUpperCase()) {
case "AIR":
case "CAVE_AIR":
case "VOID_AIR":
case "SNOW":
continue;
if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) {
continue;
}
if (isTreeBlock(state.getBlockType())) {
queue.addLast(next);
@ -156,4 +151,4 @@ public class FloatingTreeRemover implements BlockTool {
return visited;
}
}
}