Cleaned up ForgeWorld, AbstractWorld.

Change block setting method in Forge to a more proper one.
This commit is contained in:
sk89q
2014-04-06 15:06:38 -07:00
parent b6ee2c570a
commit 4a6614f34f
10 changed files with 378 additions and 301 deletions

View File

@ -135,7 +135,7 @@ public abstract class LocalWorld extends AbstractWorld {
}
@Override
public boolean setBlock(Vector pt, BaseBlock block, boolean notifyAdjacent) {
public boolean setBlock(Vector pt, BaseBlock block, boolean notifyAdjacent) throws WorldEditException {
boolean successful;
// Default implementation will call the old deprecated methods
@ -164,7 +164,7 @@ public abstract class LocalWorld extends AbstractWorld {
public abstract boolean copyToWorld(Vector position, BaseBlock block);
@Override
public boolean setBlock(Vector pt, BaseBlock block) {
public boolean setBlock(Vector pt, BaseBlock block) throws WorldEditException {
return setBlock(pt, block, true);
}

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.extent;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.pattern.Pattern;

View File

@ -82,7 +82,7 @@ public class LocalWorldAdapter extends LocalWorld {
}
@Override
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) {
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
return world.setBlock(position, block, notifyAndLight);
}

View File

@ -44,7 +44,7 @@ public abstract class AbstractWorld implements World {
@Override
public int getMaxY() {
return 255;
return getMaximumPoint().getBlockY();
}
@Override
@ -67,6 +67,44 @@ public abstract class AbstractWorld implements World {
new BaseBlock(BlockID.WATER, -1));
}
@Override
public int getBlockType(Vector pt) {
return getLazyBlock(pt).getType();
}
@Override
public int getBlockData(Vector pt) {
return getLazyBlock(pt).getData();
}
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
return setBlock(position, block, true);
}
@Override
public boolean setBlockType(Vector position, int type) {
try {
return setBlock(position, new BaseBlock(type));
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
@Override
public void setBlockData(Vector position, int data) {
try {
setBlock(position, new BaseBlock(getLazyBlock(position).getId(), data));
} catch (WorldEditException e) {
throw new RuntimeException(e);
}
}
@Override
public void setBlockDataFast(Vector position, int data) {
setBlockData(position, data);
}
@SuppressWarnings("deprecation")
@Override
public boolean setBlockTypeFast(Vector pt, int type) {
@ -132,11 +170,6 @@ public abstract class AbstractWorld implements World {
return killMobs(origin, radius, killPets ? KillFlags.PETS : 0);
}
@Override
public int killMobs(Vector origin, double radius, int flags) {
return killMobs(origin, (int) radius, (flags & KillFlags.PETS) != 0);
}
@Override
public boolean generateTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
return generateTree(TreeType.TREE, editSession, pt);
@ -212,7 +245,7 @@ public abstract class AbstractWorld implements World {
@Override
public Vector getMaximumPoint() {
return new Vector(30000000, getMaxY(), 30000000);
return new Vector(30000000, 255, 30000000);
}
@Override

View File

@ -103,7 +103,7 @@ public interface World extends Extent {
* @param notifyAndLight true to to notify and light
* @return true if the block was successfully set (return value may not be accurate)
*/
boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight);
boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException;
/**
* @deprecated Use {@link #setBlock(Vector, BaseBlock)}