Remove string switches for BlockType

Dieser Commit ist enthalten in:
Jesse Boyd 2019-04-06 03:34:11 +11:00
Ursprung d49c5ebe74
Commit 0afae082c2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 59F1DE6293AF6E1F
12 geänderte Dateien mit 293 neuen und 244 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,7 @@
package com.thevoxelbox.voxelsniper.brush; package com.thevoxelbox.voxelsniper.brush;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial; import com.sk89q.worldedit.world.registry.BlockMaterial;
@ -70,13 +71,16 @@ public class OverlayBrush extends PerformBrush {
@SuppressWarnings("deprecation") private boolean isIgnoredBlock(int materialId) { @SuppressWarnings("deprecation") private boolean isIgnoredBlock(int materialId) {
BlockType type = BlockTypes.get(materialId); BlockType type = BlockTypes.get(materialId);
String s = type.getResource().toUpperCase(); switch (type.getInternalId()) {
if (type == BlockTypes.WATER || type == BlockTypes.LAVA || type == BlockTypes.CACTUS) { case BlockID.WATER:
case BlockID.LAVA:
case BlockID.CACTUS:
return true; return true;
} default:
BlockMaterial mat = type.getMaterial(); BlockMaterial mat = type.getMaterial();
return mat.isTranslucent(); return mat.isTranslucent();
} }
}
@SuppressWarnings("deprecation") private boolean isOverrideableMaterial(int materialId) { @SuppressWarnings("deprecation") private boolean isOverrideableMaterial(int materialId) {
BlockMaterial mat = BlockTypes.get(materialId).getMaterial(); BlockMaterial mat = BlockTypes.get(materialId).getMaterial();

Datei anzeigen

@ -3,8 +3,21 @@ package com.boydti.fawe.bukkit;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.IFawe; import com.boydti.fawe.IFawe;
import com.boydti.fawe.bukkit.chat.BukkitChatManager; import com.boydti.fawe.bukkit.chat.BukkitChatManager;
import com.boydti.fawe.bukkit.listener.*; import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.regions.*; import com.boydti.fawe.bukkit.listener.BukkitImageListener;
import com.boydti.fawe.bukkit.listener.CFIPacketListener;
import com.boydti.fawe.bukkit.listener.RenderListener;
import com.boydti.fawe.bukkit.regions.ASkyBlockHook;
import com.boydti.fawe.bukkit.regions.FactionsFeature;
import com.boydti.fawe.bukkit.regions.FactionsOneFeature;
import com.boydti.fawe.bukkit.regions.FactionsUUIDFeature;
import com.boydti.fawe.bukkit.regions.FreeBuildRegion;
import com.boydti.fawe.bukkit.regions.GriefPreventionFeature;
import com.boydti.fawe.bukkit.regions.PreciousStonesFeature;
import com.boydti.fawe.bukkit.regions.ResidenceFeature;
import com.boydti.fawe.bukkit.regions.TownyFeature;
import com.boydti.fawe.bukkit.regions.Worldguard;
import com.boydti.fawe.bukkit.regions.WorldguardFlag;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils; import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.bukkit.util.BukkitTaskMan; import com.boydti.fawe.bukkit.util.BukkitTaskMan;
import com.boydti.fawe.bukkit.util.ItemUtil; import com.boydti.fawe.bukkit.util.ItemUtil;
@ -40,7 +53,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -48,7 +60,6 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

Datei anzeigen

@ -10,6 +10,7 @@ import java.util.List;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -219,12 +220,14 @@ public class AsyncBlock implements Block {
public AsyncBlockState getState() { public AsyncBlockState getState() {
int combined = queue.getCombinedId4Data(x, y, z, 0); int combined = queue.getCombinedId4Data(x, y, z, 0);
BlockType type = BlockTypes.getFromStateId(combined); BlockType type = BlockTypes.getFromStateId(combined);
String s = type.getResource().toUpperCase(); switch (type.getInternalId()) {
if (type == BlockTypes.SIGN || type == BlockTypes.WALL_SIGN) { case BlockID.SIGN:
case BlockID.WALL_SIGN:
return new AsyncSign(this, combined); return new AsyncSign(this, combined);
} default:
return new AsyncBlockState(this, combined); return new AsyncBlockState(this, combined);
} }
}
@Override @Override
public AsyncBlockState getState(boolean useSnapshot) { public AsyncBlockState getState(boolean useSnapshot) {

Datei anzeigen

@ -197,24 +197,24 @@ public class SchematicStreamer extends NBTStreamer {
@Override @Override
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) { public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
BlockType type = block.getBlockType(); BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) { switch (type.getInternalId()) {
case "ACACIA_STAIRS": case BlockID.ACACIA_STAIRS:
case "BIRCH_STAIRS": case BlockID.BIRCH_STAIRS:
case "BRICK_STAIRS": case BlockID.BRICK_STAIRS:
case "COBBLESTONE_STAIRS": case BlockID.COBBLESTONE_STAIRS:
case "DARK_OAK_STAIRS": case BlockID.DARK_OAK_STAIRS:
case "DARK_PRISMARINE_STAIRS": case BlockID.DARK_PRISMARINE_STAIRS:
case "JUNGLE_STAIRS": case BlockID.JUNGLE_STAIRS:
case "NETHER_BRICK_STAIRS": case BlockID.NETHER_BRICK_STAIRS:
case "OAK_STAIRS": case BlockID.OAK_STAIRS:
case "PRISMARINE_BRICK_STAIRS": case BlockID.PRISMARINE_BRICK_STAIRS:
case "PRISMARINE_STAIRS": case BlockID.PRISMARINE_STAIRS:
case "PURPUR_STAIRS": case BlockID.PURPUR_STAIRS:
case "QUARTZ_STAIRS": case BlockID.QUARTZ_STAIRS:
case "RED_SANDSTONE_STAIRS": case BlockID.RED_SANDSTONE_STAIRS:
case "SANDSTONE_STAIRS": case BlockID.SANDSTONE_STAIRS:
case "SPRUCE_STAIRS": case BlockID.SPRUCE_STAIRS:
case "STONE_BRICK_STAIRS": case BlockID.STONE_BRICK_STAIRS:
Object half = block.getState(PropertyKey.HALF); Object half = block.getState(PropertyKey.HALF);
Direction facing = block.getState(PropertyKey.FACING); Direction facing = block.getState(PropertyKey.FACING);
@ -301,38 +301,38 @@ public class SchematicStreamer extends NBTStreamer {
} }
private int group(BlockType type) { private int group(BlockType type) {
switch (type.getResource().toUpperCase()) { switch (type.getInternalId()) {
case "ACACIA_FENCE": case BlockID.ACACIA_FENCE:
case "BIRCH_FENCE": case BlockID.BIRCH_FENCE:
case "DARK_OAK_FENCE": case BlockID.DARK_OAK_FENCE:
case "JUNGLE_FENCE": case BlockID.JUNGLE_FENCE:
case "OAK_FENCE": case BlockID.OAK_FENCE:
case "SPRUCE_FENCE": case BlockID.SPRUCE_FENCE:
return 0; return 0;
case "NETHER_BRICK_FENCE": case BlockID.NETHER_BRICK_FENCE:
return 1; return 1;
case "COBBLESTONE_WALL": case BlockID.COBBLESTONE_WALL:
case "MOSSY_COBBLESTONE_WALL": case BlockID.MOSSY_COBBLESTONE_WALL:
return 2; return 2;
case "IRON_BARS": case BlockID.IRON_BARS:
case "BLACK_STAINED_GLASS_PANE": case BlockID.BLACK_STAINED_GLASS_PANE:
case "BLUE_STAINED_GLASS_PANE": case BlockID.BLUE_STAINED_GLASS_PANE:
case "BROWN_MUSHROOM_BLOCK": case BlockID.BROWN_MUSHROOM_BLOCK:
case "BROWN_STAINED_GLASS_PANE": case BlockID.BROWN_STAINED_GLASS_PANE:
case "CYAN_STAINED_GLASS_PANE": case BlockID.CYAN_STAINED_GLASS_PANE:
case "GLASS_PANE": case BlockID.GLASS_PANE:
case "GRAY_STAINED_GLASS_PANE": case BlockID.GRAY_STAINED_GLASS_PANE:
case "GREEN_STAINED_GLASS_PANE": case BlockID.GREEN_STAINED_GLASS_PANE:
case "LIGHT_BLUE_STAINED_GLASS_PANE": case BlockID.LIGHT_BLUE_STAINED_GLASS_PANE:
case "LIGHT_GRAY_STAINED_GLASS_PANE": case BlockID.LIGHT_GRAY_STAINED_GLASS_PANE:
case "LIME_STAINED_GLASS_PANE": case BlockID.LIME_STAINED_GLASS_PANE:
case "MAGENTA_STAINED_GLASS_PANE": case BlockID.MAGENTA_STAINED_GLASS_PANE:
case "ORANGE_STAINED_GLASS_PANE": case BlockID.ORANGE_STAINED_GLASS_PANE:
case "PINK_STAINED_GLASS_PANE": case BlockID.PINK_STAINED_GLASS_PANE:
case "PURPLE_STAINED_GLASS_PANE": case BlockID.PURPLE_STAINED_GLASS_PANE:
case "RED_STAINED_GLASS_PANE": case BlockID.RED_STAINED_GLASS_PANE:
case "WHITE_STAINED_GLASS_PANE": case BlockID.WHITE_STAINED_GLASS_PANE:
case "YELLOW_STAINED_GLASS_PANE": case BlockID.YELLOW_STAINED_GLASS_PANE:
return 3; return 3;
default: default:
return -1; return -1;

Datei anzeigen

@ -4,6 +4,7 @@ import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -82,13 +83,16 @@ public final class HeightMapMCADrawer {
int waterId = gen.primtives.waterId; int waterId = gen.primtives.waterId;
int waterColor = 0; int waterColor = 0;
BlockType waterType = BlockTypes.get(waterId); BlockType waterType = BlockTypes.get(waterId);
String s = waterType.getResource().toUpperCase(); switch (waterType.getInternalId()) {
if (waterType == BlockTypes.WATER) { case BlockID.WATER:
color = tu.averageColor((0x11 << 16) + (0x66 << 8) + (0xCC), color); color = tu.averageColor((0x11 << 16) + (0x66 << 8) + (0xCC), color);
} else if (waterType == BlockTypes.LAVA) { break;
case BlockID.LAVA:
color = (0xCC << 16) + (0x33 << 8) + (0); color = (0xCC << 16) + (0x33 << 8) + (0);
} else { break;
default:
color = tu.getColor(waterType); color = tu.getColor(waterType);
break;
} }
} }
raw[index] = color; raw[index] = color;

Datei anzeigen

@ -17,6 +17,7 @@ import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -446,7 +447,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private final void setLayerHeight(int index, int blockHeight, int layerHeight) { private final void setLayerHeight(int index, int blockHeight, int layerHeight) {
int floorState = floor.get()[index]; int floorState = floor.get()[index];
BlockType type = BlockTypes.getFromStateId(floorState); BlockType type = BlockTypes.getFromStateId(floorState);
if (type == BlockTypes.SNOW || type == BlockTypes.SNOW_BLOCK) { switch (type.getInternalId()) {
case BlockID.SNOW:
case BlockID.SNOW_BLOCK:
if (layerHeight != 0) { if (layerHeight != 0) {
this.heights.setByte(index, (byte) (blockHeight + 1)); this.heights.setByte(index, (byte) (blockHeight + 1));
this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight)); this.floor.setInt(index, (BlockTypes.SNOW.getInternalId() + layerHeight));
@ -454,8 +457,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
this.heights.setByte(index, (byte) (blockHeight)); this.heights.setByte(index, (byte) (blockHeight));
this.floor.setInt(index, (BlockTypes.SNOW_BLOCK.getInternalId())); this.floor.setInt(index, (BlockTypes.SNOW_BLOCK.getInternalId()));
} }
} else { break;
default:
this.heights.setByte(index, (byte) (blockHeight)); this.heights.setByte(index, (byte) (blockHeight));
break;
} }
} }
@ -468,7 +473,9 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
private final void setLayerHeightRaw(int index, int blockHeight, int layerHeight) { private final void setLayerHeightRaw(int index, int blockHeight, int layerHeight) {
int floorState = floor.get()[index]; int floorState = floor.get()[index];
BlockType type = BlockTypes.getFromStateId(floorState); BlockType type = BlockTypes.getFromStateId(floorState);
if (type == BlockTypes.SNOW || type == BlockTypes.SNOW_BLOCK) { switch (type.getInternalId()) {
case BlockID.SNOW:
case BlockID.SNOW_BLOCK:
if (layerHeight != 0) { if (layerHeight != 0) {
this.heights.getByteArray()[index] = (byte) (blockHeight + 1); this.heights.getByteArray()[index] = (byte) (blockHeight + 1);
this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight); this.floor.getIntArray()[index] = (BlockTypes.SNOW.getInternalId() + layerHeight);
@ -476,8 +483,10 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
this.heights.getByteArray()[index] = (byte) (blockHeight); this.heights.getByteArray()[index] = (byte) (blockHeight);
this.floor.getIntArray()[index] = (BlockTypes.SNOW_BLOCK.getInternalId()); this.floor.getIntArray()[index] = (BlockTypes.SNOW_BLOCK.getInternalId());
} }
} else { break;
default:
this.heights.getByteArray()[index] = (byte) (blockHeight); this.heights.getByteArray()[index] = (byte) (blockHeight);
break;
} }
} }

Datei anzeigen

@ -5,6 +5,7 @@ import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -176,8 +177,11 @@ public class CavesGen extends GenBase {
BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z); BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z); BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z);
BlockType blockType = material.getBlockType(); BlockType blockType = material.getBlockType();
if (blockType == BlockTypes.MYCELIUM || blockType == BlockTypes.GRASS) { switch (blockType.getInternalId()) {
case BlockID.MYCELIUM:
case BlockID.GRASS:
grassFound = true; grassFound = true;
} }
if (this.isSuitableBlock(material, materialAbove)) { if (this.isSuitableBlock(material, materialAbove)) {
if (local_y - 1 < 10) { if (local_y - 1 < 10) {
@ -206,13 +210,13 @@ public class CavesGen extends GenBase {
} }
protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) { protected boolean isSuitableBlock(BlockStateHolder material, BlockStateHolder materialAbove) {
switch (material.getBlockType().getResource().toUpperCase()) { switch (material.getBlockType().getInternalId()) {
case "AIR": case BlockID.AIR:
case "CAVE_AIR": case BlockID.CAVE_AIR:
case "VOID_AIR": case BlockID.VOID_AIR:
case "WATER": case BlockID.WATER:
case "LAVA": case BlockID.LAVA:
case "BEDROCK": case BlockID.BEDROCK:
return false; return false;
default: default:
return true; return true;

Datei anzeigen

@ -2731,13 +2731,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
loop: loop:
for (int y = maxY; y >= 1; --y) { for (int y = maxY; y >= 1; --y) {
BlockType block = getBlockType(x, y, z); BlockType block = getBlockType(x, y, z);
switch (block.getResource().toUpperCase()) { switch (block.getInternalId()) {
// TODO onlyNormalDirt case BlockID.DIRT:
case "DIRT":
this.setBlock(x, y, z, BlockTypes.GRASS_BLOCK.getDefaultState()); this.setBlock(x, y, z, BlockTypes.GRASS_BLOCK.getDefaultState());
break loop; break loop;
case "WATER": case BlockID.WATER:
case "LAVA": case BlockID.LAVA:
break loop; break loop;
default: default:
if (block.getMaterial().isMovementBlocker()) { if (block.getMaterial().isMovementBlocker()) {
@ -2812,14 +2811,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
this.changes++; this.changes++;
for (int y = basePosition.getBlockY(); y >= (basePosition.getBlockY() - 10); --y) { for (int y = basePosition.getBlockY(); y >= (basePosition.getBlockY() - 10); --y) {
BlockType type = getBlockType(x, y, z); BlockType type = getBlockType(x, y, z);
String s = type.getResource().toUpperCase(); switch (type.getInternalId()) {
if (type == BlockTypes.GRASS || type == BlockTypes.DIRT) { case BlockID.GRASS:
case BlockID.DIRT:
treeType.generate(this, BlockVector3.at(x, y + 1, z)); treeType.generate(this, BlockVector3.at(x, y + 1, z));
this.changes++; this.changes++;
} else if (type == BlockTypes.SNOW) { break;
case BlockID.SNOW:
setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState()); setBlock(BlockVector3.at(x, y, z), BlockTypes.AIR.getDefaultState());
} else if (type.getMaterial().isAir()) { break;
continue;
} }
} }
} }

Datei anzeigen

@ -311,7 +311,9 @@ public class BrushCommands extends BrushProcessor {
} else { } else {
if (fill instanceof BlockStateHolder) { if (fill instanceof BlockStateHolder) {
BlockType type = ((BlockStateHolder) fill).getBlockType(); BlockType type = ((BlockStateHolder) fill).getBlockType();
if (type == BlockTypes.SAND || type == BlockTypes.GRAVEL) { switch (type.getInternalId()) {
case BlockID.SAND:
case BlockID.GRAVEL:
BBC.BRUSH_TRY_OTHER.send(player); BBC.BRUSH_TRY_OTHER.send(player);
falling = true; falling = true;
} }

Datei anzeigen

@ -26,6 +26,7 @@ import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -36,7 +37,13 @@ public class SignCompatibilityHandler implements NBTCompatibilityHandler {
@Override @Override
public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) { public <B extends BlockStateHolder<B>> boolean isAffectedBlock(B block) {
return block.getBlockType() == BlockTypes.SIGN || block.getBlockType() == BlockTypes.WALL_SIGN; switch (block.getBlockType().getInternalId()) {
case BlockID.SIGN:
case BlockID.WALL_SIGN:
return true;
default:
return false;
}
} }
@Override @Override

Datei anzeigen

@ -24,6 +24,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.RegionFunction; import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.TreeGenerator; import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
@ -52,11 +53,15 @@ public class ForestGenerator implements RegionFunction {
public boolean apply(BlockVector3 position) throws WorldEditException { public boolean apply(BlockVector3 position) throws WorldEditException {
BlockState block = editSession.getBlock(position); BlockState block = editSession.getBlock(position);
BlockType t = block.getBlockType(); BlockType t = block.getBlockType();
switch (t.getInternalId()) {
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) { case BlockID.GRASS_BLOCK:
case BlockID.DIRT:
treeType.generate(editSession, position.add(0, 1, 0)); treeType.generate(editSession, position.add(0, 1, 0));
return true; return true;
} else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved case BlockID.TALL_GRASS: // TODO: This list needs to be moved
case BlockID.DEAD_BUSH:
case BlockID.POPPY:
case BlockID.DANDELION:
editSession.setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
// and then trick the generator here by directly setting into the world // and then trick the generator here by directly setting into the world
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState()); editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
@ -66,7 +71,7 @@ public class ForestGenerator implements RegionFunction {
editSession.setBlock(position, block); // restore on failure editSession.setBlock(position, block); // restore on failure
} }
return success; return success;
} else { // Trees won't grow on this! default: // Trees won't grow on this!
return false; return false;
} }
} }

Datei anzeigen

@ -36,30 +36,30 @@ public class BlockTypeUtil {
public static double centralBottomLimit(BlockStateHolder block) { public static double centralBottomLimit(BlockStateHolder block) {
checkNotNull(block); checkNotNull(block);
BlockType type = block.getBlockType(); BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) { switch (type.getInternalId()) {
case "CREEPER_WALL_HEAD": case BlockID.CREEPER_WALL_HEAD:
case "DRAGON_WALL_HEAD": case BlockID.DRAGON_WALL_HEAD:
case "PLAYER_WALL_HEAD": case BlockID.PLAYER_WALL_HEAD:
case "ZOMBIE_WALL_HEAD": return 0.25; case BlockID.ZOMBIE_WALL_HEAD: return 0.25;
case "ACACIA_SLAB": case BlockID.ACACIA_SLAB:
case "BIRCH_SLAB": case BlockID.BIRCH_SLAB:
case "BRICK_SLAB": case BlockID.BRICK_SLAB:
case "COBBLESTONE_SLAB": case BlockID.COBBLESTONE_SLAB:
case "DARK_OAK_SLAB": case BlockID.DARK_OAK_SLAB:
case "DARK_PRISMARINE_SLAB": case BlockID.DARK_PRISMARINE_SLAB:
case "JUNGLE_SLAB": case BlockID.JUNGLE_SLAB:
case "NETHER_BRICK_SLAB": case BlockID.NETHER_BRICK_SLAB:
case "OAK_SLAB": case BlockID.OAK_SLAB:
case "PETRIFIED_OAK_SLAB": case BlockID.PETRIFIED_OAK_SLAB:
case "PRISMARINE_BRICK_SLAB": case BlockID.PRISMARINE_BRICK_SLAB:
case "PRISMARINE_SLAB": case BlockID.PRISMARINE_SLAB:
case "PURPUR_SLAB": case BlockID.PURPUR_SLAB:
case "QUARTZ_SLAB": case BlockID.QUARTZ_SLAB:
case "RED_SANDSTONE_SLAB": case BlockID.RED_SANDSTONE_SLAB:
case "SANDSTONE_SLAB": case BlockID.SANDSTONE_SLAB:
case "SPRUCE_SLAB": case BlockID.SPRUCE_SLAB:
case "STONE_BRICK_SLAB": case BlockID.STONE_BRICK_SLAB:
case "STONE_SLAB": { case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE); String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) return 0; if (state == null) return 0;
switch (state) { switch (state) {
@ -70,13 +70,13 @@ public class BlockTypeUtil {
return 0.5; return 0.5;
} }
} }
case "ACACIA_TRAPDOOR": case BlockID.ACACIA_TRAPDOOR:
case "BIRCH_TRAPDOOR": case BlockID.BIRCH_TRAPDOOR:
case "DARK_OAK_TRAPDOOR": case BlockID.DARK_OAK_TRAPDOOR:
case "IRON_TRAPDOOR": case BlockID.IRON_TRAPDOOR:
case "JUNGLE_TRAPDOOR": case BlockID.JUNGLE_TRAPDOOR:
case "OAK_TRAPDOOR": case BlockID.OAK_TRAPDOOR:
case "SPRUCE_TRAPDOOR": case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 1; return 1;
} else if ("bottom".equals(block.getState(PropertyKey.HALF))) { } else if ("bottom".equals(block.getState(PropertyKey.HALF))) {
@ -84,12 +84,12 @@ public class BlockTypeUtil {
} else { } else {
return 0; return 0;
} }
case "ACACIA_FENCE_GATE": case BlockID.ACACIA_FENCE_GATE:
case "BIRCH_FENCE_GATE": case BlockID.BIRCH_FENCE_GATE:
case "DARK_OAK_FENCE_GATE": case BlockID.DARK_OAK_FENCE_GATE:
case "JUNGLE_FENCE_GATE": case BlockID.JUNGLE_FENCE_GATE:
case "OAK_FENCE_GATE": case BlockID.OAK_FENCE_GATE:
case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0; case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 1 : 0;
default: default:
if (type.getMaterial().isMovementBlocker()) return 0; if (type.getMaterial().isMovementBlocker()) return 0;
return 1; return 1;
@ -105,64 +105,64 @@ public class BlockTypeUtil {
public static double centralTopLimit(BlockStateHolder block) { public static double centralTopLimit(BlockStateHolder block) {
checkNotNull(block); checkNotNull(block);
BlockType type = block.getBlockType(); BlockType type = block.getBlockType();
switch (type.getResource().toUpperCase()) { switch (type.getInternalId()) {
case "BLACK_BED": case BlockID.BLACK_BED:
case "BLUE_BED": case BlockID.BLUE_BED:
case "BROWN_BED": case BlockID.BROWN_BED:
case "CYAN_BED": case BlockID.CYAN_BED:
case "GRAY_BED": case BlockID.GRAY_BED:
case "GREEN_BED": case BlockID.GREEN_BED:
case "LIGHT_BLUE_BED": case BlockID.LIGHT_BLUE_BED:
case "LIGHT_GRAY_BED": case BlockID.LIGHT_GRAY_BED:
case "LIME_BED": case BlockID.LIME_BED:
case "MAGENTA_BED": case BlockID.MAGENTA_BED:
case "ORANGE_BED": case BlockID.ORANGE_BED:
case "PINK_BED": case BlockID.PINK_BED:
case "PURPLE_BED": case BlockID.PURPLE_BED:
case "RED_BED": case BlockID.RED_BED:
case "WHITE_BED": case BlockID.WHITE_BED:
case "YELLOW_BED": return 0.5625; case BlockID.YELLOW_BED: return 0.5625;
case "BREWING_STAND": return 0.875; case BlockID.BREWING_STAND: return 0.875;
case "CAKE": return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375; case BlockID.CAKE: return (block.getState(PropertyKey.BITES) == (Integer) 6) ? 0 : 0.4375;
case "CAULDRON": return 0.3125; case BlockID.CAULDRON: return 0.3125;
case "COCOA": return 0.750; case BlockID.COCOA: return 0.750;
case "ENCHANTING_TABLE": return 0.75; case BlockID.ENCHANTING_TABLE: return 0.75;
case "END_PORTAL_FRAME": return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125; case BlockID.END_PORTAL_FRAME: return block.getState(PropertyKey.EYE) == Boolean.TRUE ? 1 : 0.8125;
case "CREEPER_HEAD": case BlockID.CREEPER_HEAD:
case "DRAGON_HEAD": case BlockID.DRAGON_HEAD:
case "PISTON_HEAD": case BlockID.PISTON_HEAD:
case "PLAYER_HEAD": case BlockID.PLAYER_HEAD:
case "ZOMBIE_HEAD": return 0.5; case BlockID.ZOMBIE_HEAD: return 0.5;
case "CREEPER_WALL_HEAD": case BlockID.CREEPER_WALL_HEAD:
case "DRAGON_WALL_HEAD": case BlockID.DRAGON_WALL_HEAD:
case "PLAYER_WALL_HEAD": case BlockID.PLAYER_WALL_HEAD:
case "ZOMBIE_WALL_HEAD": return 0.75; case BlockID.ZOMBIE_WALL_HEAD: return 0.75;
case "ACACIA_FENCE": case BlockID.ACACIA_FENCE:
case "BIRCH_FENCE": case BlockID.BIRCH_FENCE:
case "DARK_OAK_FENCE": case BlockID.DARK_OAK_FENCE:
case "JUNGLE_FENCE": case BlockID.JUNGLE_FENCE:
case "NETHER_BRICK_FENCE": case BlockID.NETHER_BRICK_FENCE:
case "OAK_FENCE": case BlockID.OAK_FENCE:
case "SPRUCE_FENCE": return 1.5; case BlockID.SPRUCE_FENCE: return 1.5;
case "ACACIA_SLAB": case BlockID.ACACIA_SLAB:
case "BIRCH_SLAB": case BlockID.BIRCH_SLAB:
case "BRICK_SLAB": case BlockID.BRICK_SLAB:
case "COBBLESTONE_SLAB": case BlockID.COBBLESTONE_SLAB:
case "DARK_OAK_SLAB": case BlockID.DARK_OAK_SLAB:
case "DARK_PRISMARINE_SLAB": case BlockID.DARK_PRISMARINE_SLAB:
case "JUNGLE_SLAB": case BlockID.JUNGLE_SLAB:
case "NETHER_BRICK_SLAB": case BlockID.NETHER_BRICK_SLAB:
case "OAK_SLAB": case BlockID.OAK_SLAB:
case "PETRIFIED_OAK_SLAB": case BlockID.PETRIFIED_OAK_SLAB:
case "PRISMARINE_BRICK_SLAB": case BlockID.PRISMARINE_BRICK_SLAB:
case "PRISMARINE_SLAB": case BlockID.PRISMARINE_SLAB:
case "PURPUR_SLAB": case BlockID.PURPUR_SLAB:
case "QUARTZ_SLAB": case BlockID.QUARTZ_SLAB:
case "RED_SANDSTONE_SLAB": case BlockID.RED_SANDSTONE_SLAB:
case "SANDSTONE_SLAB": case BlockID.SANDSTONE_SLAB:
case "SPRUCE_SLAB": case BlockID.SPRUCE_SLAB:
case "STONE_BRICK_SLAB": case BlockID.STONE_BRICK_SLAB:
case "STONE_SLAB": { case BlockID.STONE_SLAB: {
String state = (String) block.getState(PropertyKey.TYPE); String state = (String) block.getState(PropertyKey.TYPE);
if (state == null) return 0.5; if (state == null) return 0.5;
switch (state) { switch (state) {
@ -173,22 +173,22 @@ public class BlockTypeUtil {
return 1; return 1;
} }
} }
case "LILY_PAD": return 0.015625; case BlockID.LILY_PAD: return 0.015625;
case "REPEATER": return 0.125; case BlockID.REPEATER: return 0.125;
case "SOUL_SAND": return 0.875; case BlockID.SOUL_SAND: return 0.875;
case "COBBLESTONE_WALL": case BlockID.COBBLESTONE_WALL:
case "MOSSY_COBBLESTONE_WALL": return 1.5; case BlockID.MOSSY_COBBLESTONE_WALL: return 1.5;
case "FLOWER_POT": return 0.375; case BlockID.FLOWER_POT: return 0.375;
case "COMPARATOR": return 0.125; case BlockID.COMPARATOR: return 0.125;
case "DAYLIGHT_DETECTOR": return 0.375; case BlockID.DAYLIGHT_DETECTOR: return 0.375;
case "HOPPER": return 0.625; case BlockID.HOPPER: return 0.625;
case "ACACIA_TRAPDOOR": case BlockID.ACACIA_TRAPDOOR:
case "BIRCH_TRAPDOOR": case BlockID.BIRCH_TRAPDOOR:
case "DARK_OAK_TRAPDOOR": case BlockID.DARK_OAK_TRAPDOOR:
case "IRON_TRAPDOOR": case BlockID.IRON_TRAPDOOR:
case "JUNGLE_TRAPDOOR": case BlockID.JUNGLE_TRAPDOOR:
case "OAK_TRAPDOOR": case BlockID.OAK_TRAPDOOR:
case "SPRUCE_TRAPDOOR": case BlockID.SPRUCE_TRAPDOOR:
if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) { if (block.getState(PropertyKey.OPEN) == Boolean.TRUE) {
return 0; return 0;
} else if ("top".equals(block.getState(PropertyKey.HALF))) { } else if ("top".equals(block.getState(PropertyKey.HALF))) {
@ -196,12 +196,12 @@ public class BlockTypeUtil {
} else { } else {
return 0.1875; return 0.1875;
} }
case "ACACIA_FENCE_GATE": case BlockID.ACACIA_FENCE_GATE:
case "BIRCH_FENCE_GATE": case BlockID.BIRCH_FENCE_GATE:
case "DARK_OAK_FENCE_GATE": case BlockID.DARK_OAK_FENCE_GATE:
case "JUNGLE_FENCE_GATE": case BlockID.JUNGLE_FENCE_GATE:
case "OAK_FENCE_GATE": case BlockID.OAK_FENCE_GATE:
case "SPRUCE_FENCE_GATE": return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5; case BlockID.SPRUCE_FENCE_GATE: return block.getState(PropertyKey.OPEN) == Boolean.TRUE ? 0 : 1.5;
default: default:
if (type.hasProperty(PropertyKey.LAYERS)) { if (type.hasProperty(PropertyKey.LAYERS)) {
return PropertyGroup.LEVEL.get(block) * 0.0625; return PropertyGroup.LEVEL.get(block) * 0.0625;