Further BaseBlock modernisation

This commit is contained in:
Matthew Miller
2018-06-18 17:53:33 +10:00
parent 811f1d4433
commit e99190225e
61 changed files with 344 additions and 787 deletions

View File

@ -34,7 +34,7 @@ import java.util.Map;
public class SignCompatibilityHandler implements NBTCompatibilityHandler {
@Override
public boolean isAffectedBlock(BaseBlock block) {
return block.getType() == BlockTypes.SIGN || block.getType() == BlockTypes.WALL_SIGN;
return block.getBlockType() == BlockTypes.SIGN || block.getBlockType() == BlockTypes.WALL_SIGN;
}
@Override

View File

@ -82,8 +82,8 @@ public class BlockBagExtent extends AbstractDelegateExtent {
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
if (blockBag != null) {
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
int existing = lazyBlock.getType().getLegacyId();
final int type = block.getType().getLegacyId();
int existing = lazyBlock.getBlockType().getLegacyId();
final int type = block.getBlockType().getLegacyId();
if (type > 0) {
try {

View File

@ -19,28 +19,30 @@
package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.blocks.type.ItemType;
/**
* Thrown when the target inventory of a block bag is full.
*/
public class OutOfSpaceException extends BlockBagException {
private int id;
private ItemType type;
/**
* Construct the object.
*
* @param id the ID of the block
* @param type the type of the block
*/
public OutOfSpaceException(int id) {
this.id = id;
public OutOfSpaceException(ItemType type) {
this.type = type;
}
/**
* Get the ID of the block
* Get the type of the block
*
* @return the id
* @return the type
*/
public int getID() {
return id;
public ItemType getType() {
return this.type;
}
}

View File

@ -94,21 +94,21 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
return super.setBlock(location, block);
}
if (BlockType.shouldPlaceLast(block.getType().getLegacyId())) {
if (BlockType.shouldPlaceLast(block.getBlockType().getLegacyId())) {
// Place torches, etc. last
stage2.put(location.toBlockVector(), block);
return !(lazyBlock.getType() == block.getType() && lazyBlock.getData() == block.getData());
} else if (BlockType.shouldPlaceFinal(block.getType().getLegacyId())) {
return !(lazyBlock.getBlockType() == block.getBlockType() && lazyBlock.getData() == block.getData());
} else if (BlockType.shouldPlaceFinal(block.getBlockType().getLegacyId())) {
// Place signs, reed, etc even later
stage3.put(location.toBlockVector(), block);
return !(lazyBlock.getType() == block.getType() && lazyBlock.getData() == block.getData());
} else if (BlockType.shouldPlaceLast(lazyBlock.getType().getLegacyId())) {
return !(lazyBlock.getBlockType() == block.getBlockType() && lazyBlock.getData() == block.getData());
} else if (BlockType.shouldPlaceLast(lazyBlock.getBlockType().getLegacyId())) {
// Destroy torches, etc. first
super.setBlock(location, new BaseBlock(BlockTypes.AIR));
return super.setBlock(location, block);
} else {
stage1.put(location.toBlockVector(), block);
return !(lazyBlock.getType() == block.getType() && lazyBlock.getData() == block.getData());
return !(lazyBlock.getBlockType() == block.getBlockType() && lazyBlock.getData() == block.getData());
}
}
@ -150,7 +150,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
final BaseBlock baseBlock = blockTypes.get(current);
final int type = baseBlock.getType().getLegacyId();
final int type = baseBlock.getBlockType().getLegacyId();
final int data = baseBlock.getData();
switch (type) {

View File

@ -138,7 +138,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
if (value != null && value.getData() != null) {
DirectionalStateValue newValue = getNewStateValue((DirectionalState) state, transform, value.getDirection());
if (newValue != null) {
changedBlock.setState(state, newValue);
changedBlock.with(state, newValue);
}
}
}

View File

@ -51,7 +51,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
final int y = location.getBlockY();
final BlockType type = block.getType();
final BlockType type = block.getBlockType();
if (y < 0 || y > world.getMaxY()) {
return false;
}

View File

@ -54,7 +54,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
@Override
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
int existing = lazyBlock.getType().getLegacyId();
int existing = lazyBlock.getBlockType().getLegacyId();
if (BlockType.isContainerBlock(existing)) {
world.clearContainerBlockContents(position); // Clear the container block so that it doesn't drop items