mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-06 20:56:41 +00:00
Get rid of the string equality and convert a few more ID uses over.
This commit is contained in:
@ -104,7 +104,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
||||
|
||||
builder.putByte("Rot", (byte) MCDirections.toRotation(newDirection));
|
||||
|
||||
return new BaseBlock(state.getId(), state.getData(), builder.build());
|
||||
return new BaseBlock(state.getType(), state.getData(), builder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.LayerFunction;
|
||||
import com.sk89q.worldedit.masks.BlockMask;
|
||||
import com.sk89q.worldedit.masks.Mask;
|
||||
@ -38,9 +38,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class Naturalizer implements LayerFunction {
|
||||
|
||||
private final EditSession editSession;
|
||||
private final BaseBlock grass = new BaseBlock(BlockID.GRASS);
|
||||
private final BaseBlock dirt = new BaseBlock(BlockID.DIRT);
|
||||
private final BaseBlock stone = new BaseBlock(BlockID.STONE);
|
||||
private final BaseBlock grass = new BaseBlock(BlockTypes.GRASS_BLOCK);
|
||||
private final BaseBlock dirt = new BaseBlock(BlockTypes.DIRT);
|
||||
private final BaseBlock stone = new BaseBlock(BlockTypes.STONE);
|
||||
private final Mask mask = new BlockMask(grass, dirt, stone);
|
||||
private int affected = 0;
|
||||
|
||||
|
@ -84,9 +84,9 @@ public class FloraGenerator implements RegionFunction {
|
||||
*/
|
||||
public static Pattern getDesertPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.DEAD_BUSH)), 30);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.CACTUS)), 20);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.AIR)), 300);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.DEAD_BUSH)), 30);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.CACTUS)), 20);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.AIR)), 300);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@ -97,9 +97,9 @@ public class FloraGenerator implements RegionFunction {
|
||||
*/
|
||||
public static Pattern getTemperatePattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.LONG_GRASS, 1)), 300);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.RED_FLOWER)), 5);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.YELLOW_FLOWER)), 5);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.TALL_GRASS, 1)), 300);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.POPPY)), 5);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.DANDELION)), 5);
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@ -107,10 +107,10 @@ public class FloraGenerator implements RegionFunction {
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
BaseBlock block = editSession.getBlock(position);
|
||||
|
||||
if (block.getType().getId().equals(BlockTypes.GRASS)) {
|
||||
if (block.getType() == BlockTypes.GRASS) {
|
||||
editSession.setBlock(position.add(0, 1, 0), temperatePattern.apply(position));
|
||||
return true;
|
||||
} else if (block.getType().getLegacyId() == BlockID.SAND) {
|
||||
} else if (block.getType() == BlockTypes.SAND) {
|
||||
editSession.setBlock(position.add(0, 1, 0), desertPattern.apply(position));
|
||||
return true;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.util.TreeGenerator;
|
||||
|
||||
@ -50,17 +52,17 @@ public class ForestGenerator implements RegionFunction {
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
BaseBlock block = editSession.getBlock(position);
|
||||
int t = block.getType().getLegacyId();
|
||||
BlockType t = block.getType();
|
||||
|
||||
if (t == BlockID.GRASS || t == BlockID.DIRT) {
|
||||
if (t == BlockTypes.GRASS || t == BlockTypes.DIRT) {
|
||||
treeGenerator.generate(editSession, position.add(0, 1, 0));
|
||||
return true;
|
||||
} else if (t == BlockID.LONG_GRASS || t == BlockID.DEAD_BUSH || t == BlockID.RED_FLOWER || t == BlockID.YELLOW_FLOWER) { // TODO: This list needs to be moved
|
||||
editSession.setBlock(position, new BaseBlock(0));
|
||||
} else if (t == BlockTypes.TALL_GRASS || t == BlockTypes.DEAD_BUSH || t == BlockTypes.POPPY || t == BlockTypes.DANDELION) { // TODO: This list needs to be moved
|
||||
editSession.setBlock(position, new BaseBlock(BlockTypes.AIR));
|
||||
treeGenerator.generate(editSession, position);
|
||||
return true;
|
||||
} else if (t == BlockID.SNOW) {
|
||||
editSession.setBlock(position, new BaseBlock(BlockID.AIR));
|
||||
} else if (t == BlockTypes.SNOW) {
|
||||
editSession.setBlock(position, new BaseBlock(BlockTypes.AIR));
|
||||
return false;
|
||||
} else { // Trees won't grow on this!
|
||||
return false;
|
||||
|
@ -87,25 +87,25 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
*/
|
||||
private void placeVine(Vector basePos, Vector pos) throws MaxChangedBlocksException {
|
||||
if (pos.distance(basePos) > 4) return;
|
||||
if (editSession.getBlockType(pos) != 0) return;
|
||||
if (!editSession.getBlock(pos).isAir()) return;
|
||||
|
||||
for (int i = -1; i > -3; --i) {
|
||||
Vector testPos = pos.add(0, i, 0);
|
||||
if (editSession.getBlockType(testPos) == BlockID.AIR) {
|
||||
if (editSession.getBlock(testPos).isAir()) {
|
||||
pos = testPos;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
editSession.setBlockIfAir(pos, new BaseBlock(BlockID.LEAVES));
|
||||
editSession.setBlockIfAir(pos, new BaseBlock(BlockTypes.OAK_LEAVES));
|
||||
affected++;
|
||||
|
||||
int t = random.nextInt(4);
|
||||
int h = random.nextInt(3) - 1;
|
||||
Vector p;
|
||||
|
||||
BaseBlock log = new BaseBlock(BlockID.LOG);
|
||||
BaseBlock log = new BaseBlock(BlockTypes.OAK_LOG);
|
||||
|
||||
switch (t) {
|
||||
case 0:
|
||||
@ -160,17 +160,19 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
|
||||
@Override
|
||||
public boolean apply(Vector position) throws WorldEditException {
|
||||
if (!editSession.getBlock(position).getType().getId().equals(BlockTypes.AIR)) {
|
||||
if (!editSession.getBlock(position).isAir()) {
|
||||
position = position.add(0, 1, 0);
|
||||
}
|
||||
|
||||
if (!editSession.getBlock(position.add(0, -1, 0)).getType().getId().equals(BlockTypes.GRASS)) {
|
||||
if (editSession.getBlock(position.add(0, -1, 0)).getType() != BlockTypes.GRASS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
BaseBlock leavesBlock = new BaseBlock(BlockID.LEAVES);
|
||||
BaseBlock leavesBlock = new BaseBlock(BlockTypes.OAK_LEAVES);
|
||||
|
||||
editSession.setBlockIfAir(position, leavesBlock);
|
||||
if (editSession.getBlock(position).isAir()) {
|
||||
editSession.setBlock(position, leavesBlock);
|
||||
}
|
||||
|
||||
placeVine(position, position.add(0, 0, 1));
|
||||
placeVine(position, position.add(0, 0, -1));
|
||||
@ -188,7 +190,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
public static Pattern getPumpkinPattern() {
|
||||
RandomPattern pattern = new RandomPattern();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockID.PUMPKIN, i)), 100);
|
||||
pattern.add(new BlockPattern(new BaseBlock(BlockTypes.PUMPKIN, i)), 100);
|
||||
}
|
||||
return pattern;
|
||||
}
|
||||
@ -199,6 +201,6 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* @return a melon pattern
|
||||
*/
|
||||
public static Pattern getMelonPattern() {
|
||||
return new BlockPattern(new BaseBlock(BlockID.MELON_BLOCK));
|
||||
return new BlockPattern(new BaseBlock(BlockTypes.MELON_BLOCK));
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
||||
|
||||
@Override
|
||||
public boolean test(Vector vector) {
|
||||
return getExtent().getLazyBlock(vector).getType().getLegacyId() != BlockID.AIR;
|
||||
return !getExtent().getLazyBlock(vector).isAir();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
Reference in New Issue
Block a user