mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Simplified switch statements and minor formatting
This commit is contained in:
parent
67fd0668ee
commit
1424998327
@ -202,17 +202,13 @@ public abstract class IntFaweChunk<T, V extends FaweQueue> extends FaweChunk<T>
|
|||||||
}
|
}
|
||||||
vs[j] = combinedId;
|
vs[j] = combinedId;
|
||||||
this.count[i]++;
|
this.count[i]++;
|
||||||
switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) {
|
if (BlockTypes.getFromStateId(combinedId).getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
this.air[i]++;
|
this.air[i]++;
|
||||||
return;
|
return;
|
||||||
default:
|
}
|
||||||
heightMap[z << 4 | x] = (byte) y;
|
heightMap[z << 4 | x] = (byte) y;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setBitMask(int ignore) {
|
public void setBitMask(int ignore) {
|
||||||
|
@ -284,10 +284,7 @@ public interface FaweQueue extends HasFaweQueue, Extent {
|
|||||||
int combined = getCombinedId4Data(xx, y, zz);
|
int combined = getCombinedId4Data(xx, y, zz);
|
||||||
BaseBlock block = BlockState.getFromInternalId(combined).toBaseBlock();
|
BaseBlock block = BlockState.getFromInternalId(combined).toBaseBlock();
|
||||||
BlockType type = block.getBlockType();
|
BlockType type = block.getBlockType();
|
||||||
switch (type.getResource().toUpperCase()) {
|
if (type.getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
mutable.mutY(y);
|
mutable.mutY(y);
|
||||||
|
@ -115,17 +115,12 @@ public class VisualChunk extends FaweChunk<FaweChunk> {
|
|||||||
public void setBlock(int x, int y, int z, int combinedId) {
|
public void setBlock(int x, int y, int z, int combinedId) {
|
||||||
int index = getIndex(x, y, z);
|
int index = getIndex(x, y, z);
|
||||||
try {
|
try {
|
||||||
switch (BlockTypes.getFromStateId(combinedId).getResource().toUpperCase()) {
|
if (BlockTypes.getFromStateId(combinedId).getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
add.clear(index);
|
add.clear(index);
|
||||||
remove.set(index);
|
remove.set(index);
|
||||||
break;
|
} else {
|
||||||
default:
|
|
||||||
remove.clear(index);
|
remove.clear(index);
|
||||||
add.set(index);
|
add.set(index);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -175,12 +175,7 @@ public class CPUOptimizedClipboard extends FaweClipboard {
|
|||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, index++) {
|
for (int x = 0; x < width; x++, index++) {
|
||||||
BaseBlock block = getBlock(index);
|
BaseBlock block = getBlock(index);
|
||||||
switch (block.getBlockType().getResource().toUpperCase()) {
|
if (!block.getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
task.run(x, y, z, block);
|
task.run(x, y, z, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -404,12 +404,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
|
|||||||
for (int x = 0; x < width; x++, pos += 4) {
|
for (int x = 0; x < width; x++, pos += 4) {
|
||||||
int combinedId = mbb.getInt(pos);
|
int combinedId = mbb.getInt(pos);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId);
|
BlockType type = BlockTypes.getFromStateId(combinedId);
|
||||||
switch (type.getResource().toUpperCase()) {
|
if (!type.getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
BlockState state = type.withStateId(combinedId);
|
BlockState state = type.withStateId(combinedId);
|
||||||
if (type.getMaterial().hasContainer()) {
|
if (type.getMaterial().hasContainer()) {
|
||||||
trio.set(x, y, z);
|
trio.set(x, y, z);
|
||||||
|
@ -205,10 +205,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
|||||||
}
|
}
|
||||||
if (lastCombinedIds == null) {
|
if (lastCombinedIds == null) {
|
||||||
BlockType bt = BlockTypes.getFromStateId(v);
|
BlockType bt = BlockTypes.getFromStateId(v);
|
||||||
switch (bt.getResource().toUpperCase()) {
|
if (bt.getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastCombinedIds = new byte[BLOCK_SIZE];
|
lastCombinedIds = new byte[BLOCK_SIZE];
|
||||||
@ -299,12 +296,7 @@ public class MemoryOptimizedClipboard extends FaweClipboard {
|
|||||||
for (int z = 0; z < length; z++) {
|
for (int z = 0; z < length; z++) {
|
||||||
for (int x = 0; x < width; x++, index++) {
|
for (int x = 0; x < width; x++, index++) {
|
||||||
BaseBlock block = getBlock(index);
|
BaseBlock block = getBlock(index);
|
||||||
switch (block.getBlockType().getResource().toUpperCase()) {
|
if (!block.getMaterial().isAir()) {
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
task.run(x, y, z, block);
|
task.run(x, y, z, block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
ListTag blocks = (ListTag) tags.get("blocks");
|
ListTag blocks = (ListTag) tags.get("blocks");
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
// Palette
|
// 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()];
|
BlockState[] combinedArray = new BlockState[palette.size()];
|
||||||
for (int i = 0; i < palette.size(); i++) {
|
for (int i = 0; i < palette.size(); i++) {
|
||||||
CompoundTag compound = palette.get(i);
|
CompoundTag compound = palette.get(i);
|
||||||
@ -108,7 +108,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
combinedArray[i] = state;
|
combinedArray[i] = state;
|
||||||
}
|
}
|
||||||
// Populate blocks
|
// Populate blocks
|
||||||
List<CompoundTag> blocksList = (List<CompoundTag>) (List<?>) tags.get("blocks").getValue();
|
List<CompoundTag> blocksList = (List<CompoundTag>) tags.get("blocks").getValue();
|
||||||
try {
|
try {
|
||||||
for (CompoundTag compound : blocksList) {
|
for (CompoundTag compound : blocksList) {
|
||||||
Map<String, Tag> blockMap = compound.getValue();
|
Map<String, Tag> blockMap = compound.getValue();
|
||||||
@ -184,7 +184,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
indexes.put((int) combined, (Integer) palette.size());
|
indexes.put(combined, (Integer) palette.size());
|
||||||
HashMap<String, Object> paletteEntry = new HashMap<>();
|
HashMap<String, Object> paletteEntry = new HashMap<>();
|
||||||
paletteEntry.put("Name", type.getId());
|
paletteEntry.put("Name", type.getId());
|
||||||
if (block.getInternalId() != type.getInternalId()) {
|
if (block.getInternalId() != type.getInternalId()) {
|
||||||
@ -213,17 +213,16 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
for (BlockVector3 point : region) {
|
for (BlockVector3 point : region) {
|
||||||
BaseBlock block = clipboard.getFullBlock(point);
|
BaseBlock block = clipboard.getFullBlock(point);
|
||||||
switch (block.getBlockType().getResource().toUpperCase()) {
|
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
|
||||||
case "STRUCTURE_VOID":
|
|
||||||
continue;
|
|
||||||
default:
|
|
||||||
int combined = block.getInternalId();
|
int combined = block.getInternalId();
|
||||||
int index = indexes.get(combined);
|
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()));
|
List<Integer> pos = Arrays.asList(point.getX() - min.getX(),
|
||||||
|
point.getY() - min.getY(), point.getZ() - min.getZ());
|
||||||
if (!block.hasNbtData()) {
|
if (!block.hasNbtData()) {
|
||||||
blocks.add(FaweCache.asMap("state", index, "pos", pos));
|
blocks.add(FaweCache.asMap("state", index, "pos", pos));
|
||||||
} else {
|
} else {
|
||||||
blocks.add(FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
blocks.add(
|
||||||
|
FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,7 +267,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Tag writeVector(BlockVector3 vector, String name) {
|
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.getX()));
|
||||||
list.add(new DoubleTag(vector.getY()));
|
list.add(new DoubleTag(vector.getY()));
|
||||||
list.add(new DoubleTag(vector.getZ()));
|
list.add(new DoubleTag(vector.getZ()));
|
||||||
@ -276,7 +275,7 @@ public class StructureFormat implements ClipboardReader, ClipboardWriter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Tag writeRotation(Location location, String name) {
|
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.getYaw()));
|
||||||
list.add(new FloatTag(location.getPitch()));
|
list.add(new FloatTag(location.getPitch()));
|
||||||
return new ListTag(FloatTag.class, list);
|
return new ListTag(FloatTag.class, list);
|
||||||
|
@ -132,12 +132,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
|
|
||||||
if (visited.add(next)) {
|
if (visited.add(next)) {
|
||||||
BlockState state = world.getBlock(next);
|
BlockState state = world.getBlock(next);
|
||||||
BlockType type = state.getBlockType();
|
if (state.getBlockType().getMaterial().isAir() || state.getBlockType() == BlockTypes.SNOW) {
|
||||||
switch (type.getResource().toUpperCase()) {
|
|
||||||
case "AIR":
|
|
||||||
case "CAVE_AIR":
|
|
||||||
case "VOID_AIR":
|
|
||||||
case "SNOW":
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (isTreeBlock(state.getBlockType())) {
|
if (isTreeBlock(state.getBlockType())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user