mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Further work on BlockState transition
This commit is contained in:
@ -26,6 +26,8 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockType;
|
||||
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
@ -33,6 +35,7 @@ import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.util.Direction;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -51,7 +54,7 @@ public abstract class AbstractWorld implements World {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean setBlock(Vector pt, BaseBlock block) throws WorldEditException {
|
||||
public final boolean setBlock(Vector pt, BlockStateHolder block) throws WorldEditException {
|
||||
return setBlock(pt, block, true);
|
||||
}
|
||||
|
||||
@ -63,10 +66,10 @@ public abstract class AbstractWorld implements World {
|
||||
@Override
|
||||
public Mask createLiquidMask() {
|
||||
return new BlockMask(this,
|
||||
new BaseBlock(BlockTypes.LAVA),
|
||||
new BaseBlock(BlockTypes.FLOWING_LAVA),
|
||||
new BaseBlock(BlockTypes.WATER),
|
||||
new BaseBlock(BlockTypes.FLOWING_WATER));
|
||||
new BlockState(BlockTypes.LAVA, new HashMap<>()),
|
||||
new BlockState(BlockTypes.FLOWING_LAVA, new HashMap<>()),
|
||||
new BlockState(BlockTypes.WATER, new HashMap<>()),
|
||||
new BlockState(BlockTypes.FLOWING_WATER, new HashMap<>()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,6 +26,9 @@ import com.sk89q.worldedit.Vector2D;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.LazyBlock;
|
||||
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
@ -57,7 +60,7 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException {
|
||||
public boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -101,13 +104,18 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBlock(Vector position) {
|
||||
return new BaseBlock(BlockTypes.AIR);
|
||||
public BlockState getBlock(Vector position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getLazyBlock(Vector position) {
|
||||
return new BaseBlock(BlockTypes.AIR);
|
||||
public LazyBlock getLazyBlock(Vector position) {
|
||||
return new LazyBlock(getBlock(position), this, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(Vector position) {
|
||||
return new BaseBlock(getBlock(position));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,6 +27,7 @@ import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||
import com.sk89q.worldedit.extension.platform.Platform;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -75,7 +76,7 @@ public interface World extends Extent {
|
||||
boolean useItem(Vector position, BaseItem item, Direction face);
|
||||
|
||||
/**
|
||||
* Similar to {@link Extent#setBlock(Vector, BaseBlock)} but a
|
||||
* Similar to {@link Extent#setBlock(Vector, BlockStateHolder)} but a
|
||||
* {@code notifyAndLight} parameter indicates whether adjacent blocks
|
||||
* should be notified that changes have been made and lighting operations
|
||||
* should be executed.
|
||||
@ -92,7 +93,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) throws WorldEditException;
|
||||
boolean setBlock(Vector position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException;
|
||||
|
||||
/**
|
||||
* Get the light level at the given block.
|
||||
@ -165,7 +166,7 @@ public interface World extends Extent {
|
||||
/**
|
||||
* Fix the given chunks after fast mode was used.
|
||||
*
|
||||
* <p>Fast mode makes calls to {@link #setBlock(Vector, BaseBlock, boolean)}
|
||||
* <p>Fast mode makes calls to {@link #setBlock(Vector, BlockStateHolder, boolean)}
|
||||
* with {@code false} for the {@code notifyAndLight} parameter, which
|
||||
* may causes lighting errors to accumulate. Use of this method, if
|
||||
* it is implemented by the underlying world, corrects those lighting
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.state.State;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -38,7 +40,7 @@ public interface BlockRegistry {
|
||||
* @return the block, which may be null if no block exists
|
||||
*/
|
||||
@Nullable
|
||||
BaseBlock createFromId(String id);
|
||||
BlockState createFromId(String id);
|
||||
|
||||
/**
|
||||
* Create a new block using its legacy numeric ID.
|
||||
@ -48,7 +50,7 @@ public interface BlockRegistry {
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated
|
||||
BaseBlock createFromId(int id);
|
||||
BlockState createFromId(int id);
|
||||
|
||||
/**
|
||||
* Get the material for the given block.
|
||||
@ -66,6 +68,6 @@ public interface BlockRegistry {
|
||||
* @return a map of states where the key is the state's ID
|
||||
*/
|
||||
@Nullable
|
||||
Map<String, ? extends State> getStates(BaseBlock block);
|
||||
Map<String, ? extends State> getStates(BlockStateHolder block);
|
||||
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ package com.sk89q.worldedit.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||
import com.sk89q.worldedit.blocks.BlockMaterial;
|
||||
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||
import com.sk89q.worldedit.world.registry.state.State;
|
||||
|
||||
@ -35,13 +37,13 @@ public class BundledBlockRegistry implements BlockRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBlock createFromId(String id) {
|
||||
return new BaseBlock(BlockTypes.getBlockType(id));
|
||||
public BlockState createFromId(String id) {
|
||||
return BlockTypes.getBlockType(id).getDefaultState();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseBlock createFromId(int legacyId) {
|
||||
public BlockState createFromId(int legacyId) {
|
||||
String id = BundledBlockData.getInstance().fromLegacyId(legacyId);
|
||||
if (id != null) {
|
||||
return createFromId(id);
|
||||
@ -58,7 +60,7 @@ public class BundledBlockRegistry implements BlockRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Map<String, ? extends State> getStates(BaseBlock block) {
|
||||
public Map<String, ? extends State> getStates(BlockStateHolder block) {
|
||||
return BundledBlockData.getInstance().getStatesById(block.getBlockType().getId());
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user