Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-03 01:50:07 +01:00
Further BaseBlock modernisation
Dieser Commit ist enthalten in:
Ursprung
811f1d4433
Commit
e99190225e
@ -48,7 +48,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
|||||||
public List<BaseBiome> getBiomes() {
|
public List<BaseBiome> getBiomes() {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
List<BaseBiome> biomes = new ArrayList<BaseBiome>();
|
List<BaseBiome> biomes = new ArrayList<>();
|
||||||
for (Biome biome : Biome.values()) {
|
for (Biome biome : Biome.values()) {
|
||||||
int biomeId = adapter.getBiomeId(biome);
|
int biomeId = adapter.getBiomeId(biome);
|
||||||
biomes.add(new BaseBiome(biomeId));
|
biomes.add(new BaseBiome(biomeId));
|
||||||
@ -65,12 +65,7 @@ class BukkitBiomeRegistry implements BiomeRegistry {
|
|||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
if (adapter != null) {
|
if (adapter != null) {
|
||||||
final Biome bukkitBiome = adapter.getBiome(biome.getId());
|
final Biome bukkitBiome = adapter.getBiome(biome.getId());
|
||||||
return new BiomeData() {
|
return bukkitBiome::name;
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return bukkitBiome.name();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class BukkitEntity implements Entity {
|
|||||||
*/
|
*/
|
||||||
BukkitEntity(org.bukkit.entity.Entity entity) {
|
BukkitEntity(org.bukkit.entity.Entity entity) {
|
||||||
checkNotNull(entity);
|
checkNotNull(entity);
|
||||||
this.entityRef = new WeakReference<org.bukkit.entity.Entity>(entity);
|
this.entityRef = new WeakReference<>(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -78,8 +78,8 @@ public class BukkitPlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveItem(int type, int amt) {
|
public void giveItem(BaseItemStack itemStack) {
|
||||||
player.getInventory().addItem(new ItemStack(type, amt));
|
player.getInventory().addItem(new ItemStack(itemStack.getLegacyId(), itemStack.getAmount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,8 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||||
|
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||||
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
import com.sk89q.worldedit.extent.inventory.OutOfBlocksException;
|
||||||
@ -64,13 +65,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||||
final int id = item.getLegacyId();
|
final ItemType id = item.getType();
|
||||||
final int damage = item.getData();
|
|
||||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||||
assert(amount == 1);
|
assert(amount == 1);
|
||||||
boolean usesDamageValue = true;// TODO ItemType.usesDamageValue(id);
|
|
||||||
|
|
||||||
if (id == BlockID.AIR) {
|
if (id == ItemTypes.AIR) {
|
||||||
throw new IllegalArgumentException("Can't fetch air block");
|
throw new IllegalArgumentException("Can't fetch air block");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,16 +84,12 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bukkitItem.getTypeId() != id) {
|
if (bukkitItem.getTypeId() != id.getLegacyId()) {
|
||||||
|
// TODO Fix when bukkit gets not awful
|
||||||
// Type id doesn't fit
|
// Type id doesn't fit
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
|
||||||
// Damage value doesn't fit.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentAmount = bukkitItem.getAmount();
|
int currentAmount = bukkitItem.getAmount();
|
||||||
if (currentAmount < 0) {
|
if (currentAmount < 0) {
|
||||||
// Unlimited
|
// Unlimited
|
||||||
@ -119,13 +114,11 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeItem(BaseItem item) throws BlockBagException {
|
public void storeItem(BaseItem item) throws BlockBagException {
|
||||||
final int id = item.getLegacyId();
|
final ItemType id = item.getType();
|
||||||
final int damage = item.getData();
|
|
||||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||||
assert(amount <= 64);
|
assert(amount <= 64);
|
||||||
boolean usesDamageValue = true; //TODO ItemType.usesDamageValue(id);
|
|
||||||
|
|
||||||
if (id == BlockID.AIR) {
|
if (id == ItemTypes.AIR) {
|
||||||
throw new IllegalArgumentException("Can't store air block");
|
throw new IllegalArgumentException("Can't store air block");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,16 +139,12 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bukkitItem.getTypeId() != id) {
|
if (bukkitItem.getTypeId() != id.getLegacyId()) {
|
||||||
|
// TODO Fix when bukkit gets not terrible
|
||||||
// Type id doesn't fit
|
// Type id doesn't fit
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usesDamageValue && bukkitItem.getDurability() != damage) {
|
|
||||||
// Damage value doesn't fit.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentAmount = bukkitItem.getAmount();
|
int currentAmount = bukkitItem.getAmount();
|
||||||
if (currentAmount < 0) {
|
if (currentAmount < 0) {
|
||||||
// Unlimited
|
// Unlimited
|
||||||
@ -177,7 +166,7 @@ public class BukkitPlayerBlockBag extends BlockBag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (freeSlot > -1) {
|
if (freeSlot > -1) {
|
||||||
items[freeSlot] = new ItemStack(id, amount);
|
items[freeSlot] = new ItemStack(id.getLegacyId(), amount); // TODO Ditto
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,13 @@
|
|||||||
package com.sk89q.worldedit.bukkit;
|
package com.sk89q.worldedit.bukkit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
import com.sk89q.worldedit.blocks.ItemID;
|
import com.sk89q.worldedit.blocks.ItemID;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -131,7 +130,7 @@ public final class BukkitUtil {
|
|||||||
case ItemID.INK_SACK:
|
case ItemID.INK_SACK:
|
||||||
final Dye materialData = (Dye) itemStack.getData();
|
final Dye materialData = (Dye) itemStack.getData();
|
||||||
if (materialData.getColor() == DyeColor.BROWN) {
|
if (materialData.getColor() == DyeColor.BROWN) {
|
||||||
return new BaseBlock(BlockID.COCOA_PLANT, -1);
|
return new BaseBlock(BlockTypes.COCOA);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -143,11 +142,7 @@ public final class BukkitUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.isValidBlockType(typeId)) {
|
return new BaseBlock(typeId, -1);
|
||||||
return new BaseBlock(typeId, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new NotABlockException(typeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BaseItemStack toBaseItemStack(ItemStack itemStack) {
|
public static BaseItemStack toBaseItemStack(ItemStack itemStack) {
|
||||||
|
@ -248,36 +248,6 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateBigTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.BIG_TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateBirchTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.BIRCH, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) {
|
|
||||||
return generateTree(TreeGenerator.TreeType.TALL_REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
* An EnumMap that stores which WorldEdit TreeTypes apply to which Bukkit TreeTypes
|
||||||
*/
|
*/
|
||||||
@ -323,16 +293,10 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
@Override
|
@Override
|
||||||
public void dropItem(Vector pt, BaseItemStack item) {
|
public void dropItem(Vector pt, BaseItemStack item) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
ItemStack bukkitItem = new ItemStack(item.getLegacyId(), item.getAmount(),
|
ItemStack bukkitItem = new ItemStack(item.getLegacyId(), item.getAmount()); // TODO Add data.
|
||||||
item.getData());
|
|
||||||
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), bukkitItem);
|
world.dropItemNaturally(BukkitUtil.toLocation(world, pt), bukkitItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidBlockType(int type) {
|
|
||||||
return Material.getMaterial(type) != null && Material.getMaterial(type).isBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkLoadedChunk(Vector pt) {
|
public void checkLoadedChunk(Vector pt) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
@ -415,7 +379,7 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
return adapter.setBlock(BukkitAdapter.adapt(getWorld(), position), block, notifyAndLight);
|
||||||
} else {
|
} else {
|
||||||
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
return bukkitBlock.setTypeIdAndData(block.getType().getLegacyId(), (byte) block.getData(), notifyAndLight);
|
return bukkitBlock.setTypeIdAndData(block.getBlockType().getLegacyId(), (byte) block.getData(), notifyAndLight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
|
||||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.world.registry.state.State;
|
|
||||||
import com.sk89q.worldedit.world.registry.state.value.StateValue;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Map;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.Vector;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A implementation of a lazy block for {@link Extent#getLazyBlock(Vector)}
|
* A implementation of a lazy block for {@link Extent#getLazyBlock(Vector)}
|
||||||
@ -65,14 +62,13 @@ public class LazyBlock extends BaseBlock {
|
|||||||
/**
|
/**
|
||||||
* Create a new lazy block.
|
* Create a new lazy block.
|
||||||
*
|
*
|
||||||
* @param type the block type
|
* @param state the block state
|
||||||
* @param states the block states
|
|
||||||
* @param extent the extent to later load the full block data from
|
* @param extent the extent to later load the full block data from
|
||||||
* @param position the position to later load the full block data from
|
* @param position the position to later load the full block data from
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public LazyBlock(BlockType type, Map<State, StateValue> states, Extent extent, Vector position) {
|
public LazyBlock(BlockState state, Extent extent, Vector position) {
|
||||||
super(type, states);
|
super(state);
|
||||||
checkNotNull(extent);
|
checkNotNull(extent);
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
this.extent = extent;
|
this.extent = extent;
|
||||||
@ -96,31 +92,12 @@ public class LazyBlock extends BaseBlock {
|
|||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setId(int id) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setData(int data) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setType(BlockType type) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setState(State state, StateValue stateValue) {
|
|
||||||
throw new UnsupportedOperationException("This object is immutable");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
if (!loaded) {
|
if (!loaded) {
|
||||||
BaseBlock loadedBlock = extent.getBlock(position);
|
BaseBlock loadedBlock = extent.getBlock(position);
|
||||||
super.setNbtData(loadedBlock.getNbtData());
|
super.setNbtData(loadedBlock.getNbtData());
|
||||||
|
loaded = true;
|
||||||
}
|
}
|
||||||
return super.getNbtData();
|
return super.getNbtData();
|
||||||
}
|
}
|
||||||
|
@ -1063,7 +1063,7 @@ public class EditSession implements Extent {
|
|||||||
// Remove the original blocks
|
// Remove the original blocks
|
||||||
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
|
com.sk89q.worldedit.function.pattern.Pattern pattern = replacement != null ?
|
||||||
new BlockPattern(replacement) :
|
new BlockPattern(replacement) :
|
||||||
new BlockPattern(new BaseBlock(BlockID.AIR));
|
new BlockPattern(new BaseBlock(BlockTypes.AIR));
|
||||||
BlockReplace remove = new BlockReplace(this, pattern);
|
BlockReplace remove = new BlockReplace(this, pattern);
|
||||||
|
|
||||||
// Copy to a buffer so we don't destroy our original before we can copy all the blocks from it
|
// Copy to a buffer so we don't destroy our original before we can copy all the blocks from it
|
||||||
@ -1143,22 +1143,22 @@ public class EditSession implements Extent {
|
|||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||||
*/
|
*/
|
||||||
public int fixLiquid(Vector origin, double radius, int moving, int stationary) throws MaxChangedBlocksException {
|
public int fixLiquid(Vector origin, double radius, com.sk89q.worldedit.blocks.type.BlockType moving, com.sk89q.worldedit.blocks.type.BlockType stationary) throws MaxChangedBlocksException {
|
||||||
checkNotNull(origin);
|
checkNotNull(origin);
|
||||||
checkArgument(radius >= 0, "radius >= 0 required");
|
checkArgument(radius >= 0, "radius >= 0 required");
|
||||||
|
|
||||||
// Our origins can only be liquids
|
// Our origins can only be liquids
|
||||||
BlockMask liquidMask = new BlockMask(
|
BlockMask liquidMask = new BlockMask(
|
||||||
this,
|
this,
|
||||||
new BaseBlock(moving, -1),
|
new BaseBlock(moving),
|
||||||
new BaseBlock(stationary, -1));
|
new BaseBlock(stationary));
|
||||||
|
|
||||||
// But we will also visit air blocks
|
// But we will also visit air blocks
|
||||||
MaskIntersection blockMask =
|
MaskIntersection blockMask =
|
||||||
new MaskUnion(liquidMask,
|
new MaskUnion(liquidMask,
|
||||||
new BlockMask(
|
new BlockMask(
|
||||||
this,
|
this,
|
||||||
new BaseBlock(BlockID.AIR)));
|
new BaseBlock(BlockTypes.AIR)));
|
||||||
|
|
||||||
// There are boundaries that the routine needs to stay in
|
// There are boundaries that the routine needs to stay in
|
||||||
MaskIntersection mask = new MaskIntersection(
|
MaskIntersection mask = new MaskIntersection(
|
||||||
@ -1449,7 +1449,7 @@ public class EditSession implements Extent {
|
|||||||
|
|
||||||
for (int y = world.getMaxY(); y >= 1; --y) {
|
for (int y = world.getMaxY(); y >= 1; --y) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
com.sk89q.worldedit.blocks.type.BlockType id = getLazyBlock(pt).getType();
|
com.sk89q.worldedit.blocks.type.BlockType id = getLazyBlock(pt).getBlockType();
|
||||||
|
|
||||||
if (id == BlockTypes.ICE) {
|
if (id == BlockTypes.ICE) {
|
||||||
if (setBlock(pt, water)) {
|
if (setBlock(pt, water)) {
|
||||||
@ -1657,14 +1657,14 @@ public class EditSession implements Extent {
|
|||||||
|
|
||||||
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
|
for (int y = basePosition.getBlockY(); y >= basePosition.getBlockY() - 10; --y) {
|
||||||
// Check if we hit the ground
|
// Check if we hit the ground
|
||||||
int t = getBlock(new Vector(x, y, z)).getType().getLegacyId();
|
com.sk89q.worldedit.blocks.type.BlockType t = getBlock(new Vector(x, y, z)).getBlockType();
|
||||||
if (t == BlockID.GRASS || t == BlockID.DIRT) {
|
if (t == BlockTypes.GRASS_BLOCK || t == BlockTypes.DIRT) {
|
||||||
treeGenerator.generate(this, new Vector(x, y + 1, z));
|
treeGenerator.generate(this, new Vector(x, y + 1, z));
|
||||||
++affected;
|
++affected;
|
||||||
break;
|
break;
|
||||||
} else if (t == BlockID.SNOW) {
|
} else if (t == BlockTypes.SNOW) {
|
||||||
setBlock(new Vector(x, y, z), new BaseBlock(BlockID.AIR));
|
setBlock(new Vector(x, y, z), new BaseBlock(BlockTypes.AIR));
|
||||||
} else if (t != BlockID.AIR) { // Trees won't grow on this!
|
} else if (t != BlockTypes.AIR) { // Trees won't grow on this!
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1680,9 +1680,9 @@ public class EditSession implements Extent {
|
|||||||
* @param region a region
|
* @param region a region
|
||||||
* @return the results
|
* @return the results
|
||||||
*/
|
*/
|
||||||
public List<Countable<Integer>> getBlockDistribution(Region region) {
|
public List<Countable<com.sk89q.worldedit.blocks.type.BlockType>> getBlockDistribution(Region region) {
|
||||||
List<Countable<Integer>> distribution = new ArrayList<>();
|
List<Countable<com.sk89q.worldedit.blocks.type.BlockType>> distribution = new ArrayList<>();
|
||||||
Map<Integer, Countable<Integer>> map = new HashMap<>();
|
Map<com.sk89q.worldedit.blocks.type.BlockType, Countable<com.sk89q.worldedit.blocks.type.BlockType>> map = new HashMap<>();
|
||||||
|
|
||||||
if (region instanceof CuboidRegion) {
|
if (region instanceof CuboidRegion) {
|
||||||
// Doing this for speed
|
// Doing this for speed
|
||||||
@ -1701,13 +1701,13 @@ public class EditSession implements Extent {
|
|||||||
for (int z = minZ; z <= maxZ; ++z) {
|
for (int z = minZ; z <= maxZ; ++z) {
|
||||||
Vector pt = new Vector(x, y, z);
|
Vector pt = new Vector(x, y, z);
|
||||||
|
|
||||||
int id = getLazyBlock(pt).getId();
|
com.sk89q.worldedit.blocks.type.BlockType type = getLazyBlock(pt).getBlockType();
|
||||||
|
|
||||||
if (map.containsKey(id)) {
|
if (map.containsKey(type)) {
|
||||||
map.get(id).increment();
|
map.get(type).increment();
|
||||||
} else {
|
} else {
|
||||||
Countable<Integer> c = new Countable<>(id, 1);
|
Countable<com.sk89q.worldedit.blocks.type.BlockType> c = new Countable<>(type, 1);
|
||||||
map.put(id, c);
|
map.put(type, c);
|
||||||
distribution.add(c);
|
distribution.add(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1715,13 +1715,13 @@ public class EditSession implements Extent {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (Vector pt : region) {
|
for (Vector pt : region) {
|
||||||
int id = getLazyBlock(pt).getId();
|
com.sk89q.worldedit.blocks.type.BlockType type = getLazyBlock(pt).getBlockType();
|
||||||
|
|
||||||
if (map.containsKey(id)) {
|
if (map.containsKey(type)) {
|
||||||
map.get(id).increment();
|
map.get(type).increment();
|
||||||
} else {
|
} else {
|
||||||
Countable<Integer> c = new Countable<>(id, 1);
|
Countable<com.sk89q.worldedit.blocks.type.BlockType> c = new Countable<>(type, 1);
|
||||||
map.put(id, c);
|
map.put(type, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1809,7 +1809,7 @@ public class EditSession implements Extent {
|
|||||||
final Vector scaled = current.subtract(zero).divide(unit);
|
final Vector scaled = current.subtract(zero).divide(unit);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getType().getLegacyId(), defaultMaterial.getData()) <= 0) {
|
if (expression.evaluate(scaled.getX(), scaled.getY(), scaled.getZ(), defaultMaterial.getBlockType().getLegacyId(), defaultMaterial.getData()) <= 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,19 +24,18 @@ import com.sk89q.jnbt.StringTag;
|
|||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
||||||
import com.sk89q.worldedit.blocks.type.BlockState;
|
import com.sk89q.worldedit.blocks.type.BlockState;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.blocks.type.BlockType;
|
import com.sk89q.worldedit.blocks.type.BlockType;
|
||||||
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
|
||||||
import com.sk89q.worldedit.world.registry.state.State;
|
import com.sk89q.worldedit.world.registry.state.State;
|
||||||
import com.sk89q.worldedit.world.registry.state.value.StateValue;
|
import com.sk89q.worldedit.world.registry.state.value.StateValue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@ -54,13 +53,12 @@ import javax.annotation.Nullable;
|
|||||||
* as a "wildcard" block value, even though a {@link Mask} would be
|
* as a "wildcard" block value, even though a {@link Mask} would be
|
||||||
* more appropriate.</p>
|
* more appropriate.</p>
|
||||||
*/
|
*/
|
||||||
public class BaseBlock implements TileEntityBlock {
|
public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||||
|
|
||||||
// Instances of this class should be _as small as possible_ because there will
|
// Instances of this class should be _as small as possible_ because there will
|
||||||
// be millions of instances of this object.
|
// be millions of instances of this object.
|
||||||
|
|
||||||
private BlockType blockType;
|
private BlockState blockState;
|
||||||
private Map<State, StateValue> states;
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private CompoundTag nbtData;
|
private CompoundTag nbtData;
|
||||||
|
|
||||||
@ -68,18 +66,18 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* Construct a block with the given ID and a data value of 0.
|
* Construct a block with the given ID and a data value of 0.
|
||||||
*
|
*
|
||||||
* @param id ID value
|
* @param id ID value
|
||||||
* @see #setId(int)
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock(int id) {
|
public BaseBlock(int id) {
|
||||||
internalSetId(id);
|
|
||||||
internalSetData(0);
|
|
||||||
this.states = new HashMap<>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a block with a state.
|
||||||
|
*
|
||||||
|
* @param blockState The blockstate
|
||||||
|
*/
|
||||||
public BaseBlock(BlockState blockState) {
|
public BaseBlock(BlockState blockState) {
|
||||||
this.blockType = blockState.getBlockType();
|
this.blockState = blockState;
|
||||||
this.states = blockState.getStates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,8 +86,18 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @param blockType The block type
|
* @param blockType The block type
|
||||||
*/
|
*/
|
||||||
public BaseBlock(BlockType blockType) {
|
public BaseBlock(BlockType blockType) {
|
||||||
internalSetType(blockType);
|
this.blockState = blockType.getDefaultState();
|
||||||
this.states = new HashMap<>();
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a block with the given ID, data value and NBT data structure.
|
||||||
|
*
|
||||||
|
* @param state The block state
|
||||||
|
* @param nbtData NBT data, which may be null
|
||||||
|
*/
|
||||||
|
public BaseBlock(BlockState state, @Nullable CompoundTag nbtData) {
|
||||||
|
this.blockState = state;
|
||||||
|
setNbtData(nbtData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,27 +105,9 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*
|
*
|
||||||
* @param id ID value
|
* @param id ID value
|
||||||
* @param data data value
|
* @param data data value
|
||||||
* @see #setId(int)
|
|
||||||
* @see #setData(int)
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock(int id, int data) {
|
public BaseBlock(int id, int data) {
|
||||||
internalSetId(id);
|
|
||||||
internalSetData(data);
|
|
||||||
this.states = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a block with the given ID and data value.
|
|
||||||
*
|
|
||||||
* @param blockType The block type
|
|
||||||
* @param states The states
|
|
||||||
* @see #setId(int)
|
|
||||||
* @see #setData(int)
|
|
||||||
*/
|
|
||||||
public BaseBlock(BlockType blockType, Map<State, StateValue> states) {
|
|
||||||
internalSetType(blockType);
|
|
||||||
setStates(states);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -129,22 +119,6 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock(int id, int data, @Nullable CompoundTag nbtData) {
|
public BaseBlock(int id, int data, @Nullable CompoundTag nbtData) {
|
||||||
internalSetId(id);
|
|
||||||
setData(data);
|
|
||||||
setNbtData(nbtData);
|
|
||||||
this.states = new HashMap<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct a block with the given ID, data value and NBT data structure.
|
|
||||||
*
|
|
||||||
* @param blockType The block type
|
|
||||||
* @param states The states
|
|
||||||
* @param nbtData NBT data, which may be null
|
|
||||||
*/
|
|
||||||
public BaseBlock(BlockType blockType, Map<State, StateValue> states, @Nullable CompoundTag nbtData) {
|
|
||||||
setType(blockType);
|
|
||||||
setStates(states);
|
|
||||||
setNbtData(nbtData);
|
setNbtData(nbtData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +128,16 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @param other the other block
|
* @param other the other block
|
||||||
*/
|
*/
|
||||||
public BaseBlock(BaseBlock other) {
|
public BaseBlock(BaseBlock other) {
|
||||||
this(other.getType(), other.getStates(), other.getNbtData());
|
this(other.getState(), other.getNbtData());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block state
|
||||||
|
*
|
||||||
|
* @return The block state
|
||||||
|
*/
|
||||||
|
public BlockState getState() {
|
||||||
|
return this.blockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,45 +147,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return this.blockType.getLegacyId();
|
return this.blockState.getBlockType().getLegacyId();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the block ID.
|
|
||||||
*
|
|
||||||
* @param type block type
|
|
||||||
*/
|
|
||||||
protected final void internalSetType(BlockType type) {
|
|
||||||
if (type == null) {
|
|
||||||
throw new IllegalArgumentException("You must provide a BlockType");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.blockType = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the block ID.
|
|
||||||
*
|
|
||||||
* @param id block id
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setId(int id) {
|
|
||||||
internalSetId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
private void internalSetId(int id) {
|
|
||||||
BlockType type = BlockTypes.getBlockType(BundledBlockData.getInstance().fromLegacyId(id));
|
|
||||||
internalSetType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the block type.
|
|
||||||
*
|
|
||||||
* @param type block type
|
|
||||||
*/
|
|
||||||
public void setType(BlockType type) {
|
|
||||||
internalSetType(type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -223,16 +168,17 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @return The state map
|
* @return The state map
|
||||||
*/
|
*/
|
||||||
public Map<State, StateValue> getStates() {
|
public Map<State, StateValue> getStates() {
|
||||||
return Collections.unmodifiableMap(states);
|
return this.blockState.getStates();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Sets the states of this block.
|
public BlockType getBlockType() {
|
||||||
*
|
return this.blockState.getBlockType();
|
||||||
* @param states The states
|
}
|
||||||
*/
|
|
||||||
private void setStates(Map<State, StateValue> states) {
|
@Override
|
||||||
this.states = states;
|
public BaseBlock with(State state, StateValue value) {
|
||||||
|
return new BaseBlock(this.blockState.with(state, value), getNbtData());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,26 +188,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @return The state value
|
* @return The state value
|
||||||
*/
|
*/
|
||||||
public StateValue getState(State state) {
|
public StateValue getState(State state) {
|
||||||
return states.get(state);
|
return this.blockState.getState(state);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a state to a specific value
|
|
||||||
*
|
|
||||||
* @param state The state
|
|
||||||
* @param stateValue The value
|
|
||||||
*/
|
|
||||||
public void setState(State state, StateValue stateValue) {
|
|
||||||
this.states.put(state, stateValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the block's data value.
|
|
||||||
*
|
|
||||||
* @param data block data value
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
protected final void internalSetData(int data) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -271,34 +198,6 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setData(int data) {
|
public void setData(int data) {
|
||||||
internalSetData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set both the block's ID and data value.
|
|
||||||
*
|
|
||||||
* @param id ID value
|
|
||||||
* @param data data value
|
|
||||||
* @see #setId(int)
|
|
||||||
* @see #setData(int)
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setIdAndData(int id, int data) {
|
|
||||||
setId(id);
|
|
||||||
setData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether there are no matched states.
|
|
||||||
*
|
|
||||||
* @return true if there are no matched states
|
|
||||||
*/
|
|
||||||
public boolean hasWildcardData() {
|
|
||||||
return getStates().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasWildcardDataFor(State state) {
|
|
||||||
return getState(state) == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -323,21 +222,12 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
return nbtData;
|
return this.nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
this.nbtData = nbtData;
|
throw new UnsupportedOperationException("This class is immutable.");
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the type of block.
|
|
||||||
*
|
|
||||||
* @return the type
|
|
||||||
*/
|
|
||||||
public BlockType getType() {
|
|
||||||
return this.blockType;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -346,7 +236,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @return if air
|
* @return if air
|
||||||
*/
|
*/
|
||||||
public boolean isAir() {
|
public boolean isAir() {
|
||||||
return getType() == BlockTypes.AIR;
|
return getBlockType() == BlockTypes.AIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -357,7 +247,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int rotate90() {
|
public int rotate90() {
|
||||||
int newData = BlockData.rotate90(getType().getLegacyId(), getData());
|
int newData = BlockData.rotate90(getBlockType().getLegacyId(), getData());
|
||||||
setData(newData);
|
setData(newData);
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
@ -370,7 +260,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int rotate90Reverse() {
|
public int rotate90Reverse() {
|
||||||
int newData = BlockData.rotate90Reverse(getType().getLegacyId(), getData());
|
int newData = BlockData.rotate90Reverse(getBlockType().getLegacyId(), getData());
|
||||||
setData((short) newData);
|
setData((short) newData);
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
@ -384,7 +274,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public int cycleData(int increment) {
|
public int cycleData(int increment) {
|
||||||
int newData = BlockData.cycle(getType().getLegacyId(), getData(), increment);
|
int newData = BlockData.cycle(getBlockType().getLegacyId(), getData(), increment);
|
||||||
setData((short) newData);
|
setData((short) newData);
|
||||||
return newData;
|
return newData;
|
||||||
}
|
}
|
||||||
@ -397,7 +287,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock flip() {
|
public BaseBlock flip() {
|
||||||
setData((short) BlockData.flip(getType().getLegacyId(), getData()));
|
setData((short) BlockData.flip(getBlockType().getLegacyId(), getData()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -410,7 +300,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseBlock flip(FlipDirection direction) {
|
public BaseBlock flip(FlipDirection direction) {
|
||||||
setData((short) BlockData.flip(getType().getLegacyId(), getData(), direction));
|
setData((short) BlockData.flip(getBlockType().getLegacyId(), getData(), direction));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -425,7 +315,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
final BaseBlock otherBlock = (BaseBlock) o;
|
final BaseBlock otherBlock = (BaseBlock) o;
|
||||||
|
|
||||||
return getType() == otherBlock.getType() && getData() == otherBlock.getData();
|
return this.getState().equals(otherBlock.getState()) && Objects.equals(getNbtData(), otherBlock.getNbtData());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +326,7 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
* @return true if equal
|
* @return true if equal
|
||||||
*/
|
*/
|
||||||
public boolean equalsFuzzy(BaseBlock o) {
|
public boolean equalsFuzzy(BaseBlock o) {
|
||||||
if (!getType().equals(o.getType())) {
|
if (!getBlockType().equals(o.getBlockType())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,14 +374,16 @@ public class BaseBlock implements TileEntityBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int ret = getType().hashCode() << 3;
|
int ret = getState().hashCode() << 3;
|
||||||
ret += getStates().hashCode();
|
if (hasNbtData()) {
|
||||||
|
ret += getNbtData().hashCode();
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Block{Type:" + getType().getId() + ", States: " + getStates().toString() + "}";
|
return "Block{State: " + this.getState().toString() + ", NBT: " + String.valueOf(getNbtData()) + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,11 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||||
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
import com.sk89q.worldedit.world.NbtValued;
|
||||||
import com.sk89q.worldedit.world.registry.BundledItemData;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an item, without an amount value. See {@link BaseItemStack}
|
* Represents an item, without an amount value. See {@link BaseItemStack}
|
||||||
@ -32,11 +31,11 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
* <p>This class may be removed in the future.</p>
|
* <p>This class may be removed in the future.</p>
|
||||||
*/
|
*/
|
||||||
public class BaseItem {
|
public class BaseItem implements NbtValued {
|
||||||
|
|
||||||
private ItemType itemType;
|
private ItemType itemType;
|
||||||
private short damage;
|
@Nullable
|
||||||
private final Map<Integer, Integer> enchantments = new HashMap<>();
|
private CompoundTag nbtData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
@ -45,7 +44,6 @@ public class BaseItem {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseItem(int id) {
|
public BaseItem(int id) {
|
||||||
this(id, (short) 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,27 +55,15 @@ public class BaseItem {
|
|||||||
this.itemType = itemType;
|
this.itemType = itemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct the object.
|
|
||||||
*
|
|
||||||
* @param id ID of the item
|
|
||||||
* @param data data value of the item
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public BaseItem(int id, short data) {
|
|
||||||
setLegacyId(id);
|
|
||||||
this.damage = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param itemType Type of the item
|
* @param itemType Type of the item
|
||||||
* @param damage Damage value of the item
|
* @param tag NBT Compound tag
|
||||||
*/
|
*/
|
||||||
public BaseItem(ItemType itemType, short damage) {
|
public BaseItem(ItemType itemType, CompoundTag tag) {
|
||||||
this.itemType = itemType;
|
this.itemType = itemType;
|
||||||
this.damage = damage;
|
this.nbtData = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,17 +76,6 @@ public class BaseItem {
|
|||||||
return this.itemType.getLegacyId();
|
return this.itemType.getLegacyId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the type of item.
|
|
||||||
*
|
|
||||||
* @param id the id to set
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setLegacyId(int id) {
|
|
||||||
ItemType type = ItemTypes.getItemType(BundledItemData.getInstance().fromLegacyId(id));
|
|
||||||
setType(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the type of item.
|
* Get the type of item.
|
||||||
*
|
*
|
||||||
@ -119,50 +94,19 @@ public class BaseItem {
|
|||||||
this.itemType = itemType;
|
this.itemType = itemType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Get the damage value.
|
public boolean hasNbtData() {
|
||||||
*
|
return this.nbtData != null;
|
||||||
* @return the damage
|
|
||||||
*/
|
|
||||||
public short getDamage() {
|
|
||||||
return this.damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Nullable
|
||||||
* Get the data value.
|
@Override
|
||||||
*
|
public CompoundTag getNbtData() {
|
||||||
* @return the data
|
return this.nbtData;
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public short getData() {
|
|
||||||
return this.damage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Set the data value.
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
*
|
this.nbtData = nbtData;
|
||||||
* @param damage the damage to set
|
|
||||||
*/
|
|
||||||
public void setDamage(short damage) {
|
|
||||||
this.damage = damage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the data value.
|
|
||||||
*
|
|
||||||
* @param data the damage to set
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public void setData(short data) {
|
|
||||||
this.damage = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the map of enchantments.
|
|
||||||
*
|
|
||||||
* @return map of enchantments
|
|
||||||
*/
|
|
||||||
public Map<Integer, Integer> getEnchantments() {
|
|
||||||
return enchantments;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +82,7 @@ public class BaseItemStack extends BaseItem {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BaseItemStack(int id, int amount, short data) {
|
public BaseItemStack(int id, int amount, short data) {
|
||||||
super(id, data);
|
super(id);
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +90,11 @@ public class BaseItemStack extends BaseItem {
|
|||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param id The item type
|
* @param id The item type
|
||||||
|
* @param tag Tag value
|
||||||
* @param amount amount in the stack
|
* @param amount amount in the stack
|
||||||
* @param damage Damage value
|
|
||||||
*/
|
*/
|
||||||
public BaseItemStack(ItemType id, int amount, short damage) {
|
public BaseItemStack(ItemType id, CompoundTag tag, int amount) {
|
||||||
super(id, damage);
|
super(id, tag);
|
||||||
this.amount = amount;
|
this.amount = amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1540,7 +1540,7 @@ public enum BlockType {
|
|||||||
|
|
||||||
addIdentities(BlockID.DOUBLE_WOODEN_STEP, 7); // rule 3
|
addIdentities(BlockID.DOUBLE_WOODEN_STEP, 7); // rule 3
|
||||||
addIdentities(BlockID.WOODEN_STEP, 7); // rule 1
|
addIdentities(BlockID.WOODEN_STEP, 7); // rule 1
|
||||||
nonDataBlockBagItems.put(BlockID.COCOA_PLANT, new BaseItem(ItemID.INK_SACK, (short) (15 - ClothColor.ID.BROWN))); // rule 3
|
nonDataBlockBagItems.put(BlockID.COCOA_PLANT, new BaseItem(ItemID.INK_SACK)); // rule 3 TODO data removed
|
||||||
addIdentity(BlockID.SANDSTONE_STAIRS); // rule 1
|
addIdentity(BlockID.SANDSTONE_STAIRS); // rule 1
|
||||||
nonDataBlockBagItems.put(BlockID.EMERALD_ORE, new BaseItem(ItemID.EMERALD)); // rule 5
|
nonDataBlockBagItems.put(BlockID.EMERALD_ORE, new BaseItem(ItemID.EMERALD)); // rule 5
|
||||||
addIdentity(BlockID.ENDER_CHEST); // rule 3
|
addIdentity(BlockID.ENDER_CHEST); // rule 3
|
||||||
@ -1569,7 +1569,8 @@ public enum BlockType {
|
|||||||
addIdentity(BlockID.HOPPER); // rule 1
|
addIdentity(BlockID.HOPPER); // rule 1
|
||||||
addIdentities(BlockID.QUARTZ_BLOCK, 1); // rule 4
|
addIdentities(BlockID.QUARTZ_BLOCK, 1); // rule 4
|
||||||
for (int i = 2; i <= 4; i++) {
|
for (int i = 2; i <= 4; i++) {
|
||||||
dataBlockBagItems.put(typeDataKey(BlockID.QUARTZ_BLOCK, i), new BaseItem(BlockID.QUARTZ_BLOCK, (short) 2)); // rule 4, quartz pillars
|
dataBlockBagItems.put(typeDataKey(BlockID.QUARTZ_BLOCK, i), new BaseItem(BlockID.QUARTZ_BLOCK)); // rule 4, quartz pillars TODO data
|
||||||
|
// removed
|
||||||
}
|
}
|
||||||
addIdentity(BlockID.QUARTZ_STAIRS); // rule 1
|
addIdentity(BlockID.QUARTZ_STAIRS); // rule 1
|
||||||
addIdentity(BlockID.ACTIVATOR_RAIL); // rule 1
|
addIdentity(BlockID.ACTIVATOR_RAIL); // rule 1
|
||||||
@ -1629,7 +1630,7 @@ public enum BlockType {
|
|||||||
|
|
||||||
private static void addIdentities(int type, int maxData) {
|
private static void addIdentities(int type, int maxData) {
|
||||||
for (int data = 0; data < maxData; ++data) {
|
for (int data = 0; data < maxData; ++data) {
|
||||||
dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(type, (short) data));
|
dataBlockBagItems.put(typeDataKey(type, data), new BaseItem(type)); // TODO data removed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ import java.util.Map;
|
|||||||
* An immutable class that represents the state a block can be in.
|
* An immutable class that represents the state a block can be in.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class BlockState {
|
public class BlockState implements BlockStateHolder<BlockState> {
|
||||||
|
|
||||||
private final BlockType blockType;
|
private final BlockType blockType;
|
||||||
private final Map<State, StateValue> values;
|
private final Map<State, StateValue> values;
|
||||||
@ -67,7 +67,7 @@ public class BlockState {
|
|||||||
for(final Map.Entry<State, StateValue> entry : this.values.entrySet()) {
|
for(final Map.Entry<State, StateValue> entry : this.values.entrySet()) {
|
||||||
final State state = entry.getKey();
|
final State state = entry.getKey();
|
||||||
|
|
||||||
state.getValues().stream().forEach(value -> {
|
state.getValues().forEach(value -> {
|
||||||
if(value != entry.getValue()) {
|
if(value != entry.getValue()) {
|
||||||
states.put(state, (StateValue) value, stateMap.get(this.withValue(state, (StateValue) value)));
|
states.put(state, (StateValue) value, stateMap.get(this.withValue(state, (StateValue) value)));
|
||||||
}
|
}
|
||||||
@ -83,22 +83,12 @@ public class BlockState {
|
|||||||
return values;
|
return values;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Get the block type
|
|
||||||
*
|
|
||||||
* @return The type
|
|
||||||
*/
|
|
||||||
public BlockType getBlockType() {
|
public BlockType getBlockType() {
|
||||||
return this.blockType;
|
return this.blockType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Returns a BlockState with the given state and value applied.
|
|
||||||
*
|
|
||||||
* @param state The state
|
|
||||||
* @param value The value
|
|
||||||
* @return The modified state, or same if could not be applied
|
|
||||||
*/
|
|
||||||
public BlockState with(State state, StateValue value) {
|
public BlockState with(State state, StateValue value) {
|
||||||
if (fuzzy) {
|
if (fuzzy) {
|
||||||
return setState(state, value);
|
return setState(state, value);
|
||||||
@ -108,21 +98,12 @@ public class BlockState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets the value at the given state
|
|
||||||
*
|
|
||||||
* @param state The state
|
|
||||||
* @return The value
|
|
||||||
*/
|
|
||||||
public StateValue getState(State state) {
|
public StateValue getState(State state) {
|
||||||
return this.values.get(state);
|
return this.values.get(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* Gets an immutable collection of the states.
|
|
||||||
*
|
|
||||||
* @return The states
|
|
||||||
*/
|
|
||||||
public Map<State, StateValue> getStates() {
|
public Map<State, StateValue> getStates() {
|
||||||
return Collections.unmodifiableMap(this.values);
|
return Collections.unmodifiableMap(this.values);
|
||||||
}
|
}
|
||||||
@ -136,7 +117,7 @@ public class BlockState {
|
|||||||
* @param value The value
|
* @param value The value
|
||||||
* @return The blockstate, for chaining
|
* @return The blockstate, for chaining
|
||||||
*/
|
*/
|
||||||
BlockState setState(State state, StateValue value) {
|
private BlockState setState(State state, StateValue value) {
|
||||||
this.values.put(state, value);
|
this.values.put(state, value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU Lesser General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.blocks.type;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.world.registry.state.State;
|
||||||
|
import com.sk89q.worldedit.world.registry.state.value.StateValue;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface BlockStateHolder<T extends BlockStateHolder> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the block type
|
||||||
|
*
|
||||||
|
* @return The type
|
||||||
|
*/
|
||||||
|
BlockType getBlockType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a BlockState with the given state and value applied.
|
||||||
|
*
|
||||||
|
* @param state The state
|
||||||
|
* @param value The value
|
||||||
|
* @return The modified state, or same if could not be applied
|
||||||
|
*/
|
||||||
|
T with(State state, StateValue value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value at the given state
|
||||||
|
*
|
||||||
|
* @param state The state
|
||||||
|
* @return The value
|
||||||
|
*/
|
||||||
|
StateValue getState(State state);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an immutable collection of the states.
|
||||||
|
*
|
||||||
|
* @return The states
|
||||||
|
*/
|
||||||
|
Map<State, StateValue> getStates();
|
||||||
|
}
|
@ -34,6 +34,7 @@ import com.sk89q.worldedit.Vector2D;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.extension.input.ParserContext;
|
import com.sk89q.worldedit.extension.input.ParserContext;
|
||||||
@ -277,7 +278,7 @@ public class SelectionCommands {
|
|||||||
@CommandPermissions("worldedit.wand")
|
@CommandPermissions("worldedit.wand")
|
||||||
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
public void wand(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException {
|
||||||
|
|
||||||
player.giveItem(ItemTypes.getItemType(we.getConfiguration().wandItem).getLegacyId(), 1);
|
player.giveItem(new BaseItemStack(ItemTypes.getItemType(we.getConfiguration().wandItem), 1));
|
||||||
player.print("Left click: select pos #1; Right click: select pos #2");
|
player.print("Left click: select pos #1; Right click: select pos #2");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -677,12 +678,12 @@ public class SelectionCommands {
|
|||||||
player.print("# total blocks: " + size);
|
player.print("# total blocks: " + size);
|
||||||
|
|
||||||
for (Countable<BaseBlock> c : distributionData) {
|
for (Countable<BaseBlock> c : distributionData) {
|
||||||
String name = c.getID().getType().getName();
|
String name = c.getID().getBlockType().getName();
|
||||||
String str = String.format("%-7s (%.3f%%) %s #%s%s",
|
String str = String.format("%-7s (%.3f%%) %s #%s%s",
|
||||||
String.valueOf(c.getAmount()),
|
String.valueOf(c.getAmount()),
|
||||||
c.getAmount() / (double) size * 100,
|
c.getAmount() / (double) size * 100,
|
||||||
name,
|
name,
|
||||||
c.getID().getType().getId(),
|
c.getID().getBlockType().getId(),
|
||||||
c.getID().getStates());
|
c.getID().getStates());
|
||||||
player.print(str);
|
player.print(str);
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ public class ToolCommands {
|
|||||||
|
|
||||||
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
|
session.setTool(itemStack.getType(), new LongRangeBuildTool(primary, secondary));
|
||||||
player.print("Long-range building tool bound to " + itemStack.getType().getName() + ".");
|
player.print("Long-range building tool bound to " + itemStack.getType().getName() + ".");
|
||||||
player.print("Left-click set to " + secondary.getType().getName() + "; right-click set to "
|
player.print("Left-click set to " + secondary.getBlockType().getName() + "; right-click set to "
|
||||||
+ primary.getType().getName() + ".");
|
+ primary.getBlockType().getName() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||||
import com.sk89q.worldedit.command.util.CreatureButcher;
|
import com.sk89q.worldedit.command.util.CreatureButcher;
|
||||||
import com.sk89q.worldedit.command.util.EntityRemover;
|
import com.sk89q.worldedit.command.util.EntityRemover;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -65,7 +66,6 @@ import com.sk89q.worldedit.util.formatting.component.CommandUsageBox;
|
|||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public class UtilityCommands {
|
|||||||
double radius = Math.max(0, args.getDouble(0));
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
int affected = editSession.fixLiquid(
|
int affected = editSession.fixLiquid(
|
||||||
session.getPlacementPosition(player), radius, 10, 11);
|
session.getPlacementPosition(player), radius, BlockTypes.FLOWING_LAVA, BlockTypes.LAVA);
|
||||||
player.print(affected + " block(s) have been changed.");
|
player.print(affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ public class UtilityCommands {
|
|||||||
double radius = Math.max(0, args.getDouble(0));
|
double radius = Math.max(0, args.getDouble(0));
|
||||||
we.checkMaxRadius(radius);
|
we.checkMaxRadius(radius);
|
||||||
int affected = editSession.fixLiquid(
|
int affected = editSession.fixLiquid(
|
||||||
session.getPlacementPosition(player), radius, 8, 9);
|
session.getPlacementPosition(player), radius, BlockTypes.FLOWING_WATER, BlockTypes.WATER);
|
||||||
player.print(affected + " block(s) have been changed.");
|
player.print(affected + " block(s) have been changed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ public class UtilityCommands {
|
|||||||
int size = Math.max(1, args.getInteger(1, 50));
|
int size = Math.max(1, args.getInteger(1, 50));
|
||||||
we.checkMaxRadius(size);
|
we.checkMaxRadius(size);
|
||||||
|
|
||||||
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getType().getLegacyId(), size);
|
int affected = editSession.removeNear(session.getPlacementPosition(player), block.getBlockType().getLegacyId(), size);
|
||||||
player.print(affected + " block(s) have been removed.");
|
player.print(affected + " block(s) have been removed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class ItemUseParser extends SimpleCommand<Contextual<RegionFunction>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "application of the item " + item.getType() + ":" + item.getData();
|
return "application of the item " + item.getType() + ":" + item.getNbtData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
int ox = clicked.getBlockX();
|
int ox = clicked.getBlockX();
|
||||||
int oy = clicked.getBlockY();
|
int oy = clicked.getBlockY();
|
||||||
int oz = clicked.getBlockZ();
|
int oz = clicked.getBlockZ();
|
||||||
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getType();
|
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector()).getBlockType();
|
||||||
|
|
||||||
if (initialType == BlockTypes.AIR) {
|
if (initialType == BlockTypes.AIR) {
|
||||||
return true;
|
return true;
|
||||||
@ -68,7 +68,7 @@ public class AreaPickaxe implements BlockTool {
|
|||||||
for (int y = oy - range; y <= oy + range; ++y) {
|
for (int y = oy - range; y <= oy + range; ++y) {
|
||||||
for (int z = oz - range; z <= oz + range; ++z) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
Vector pos = new Vector(x, y, z);
|
Vector pos = new Vector(x, y, z);
|
||||||
if (editSession.getBlock(pos).getType() != initialType) {
|
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class BlockReplacer implements DoubleActionBlockTool {
|
|||||||
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
targetBlock = (editSession).getBlock(clicked.toVector());
|
targetBlock = (editSession).getBlock(clicked.toVector());
|
||||||
BlockType type = targetBlock.getType().getLegacyType();
|
BlockType type = targetBlock.getBlockType().getLegacyType();
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
player.print("Replacer tool switched to: " + type.getName());
|
player.print("Replacer tool switched to: " + type.getName());
|
||||||
|
@ -81,7 +81,7 @@ public class FloatingTreeRemover implements BlockTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Vector blockVector : blockSet) {
|
for (Vector blockVector : blockSet) {
|
||||||
final int typeId = editSession.getBlock(blockVector).getType().getLegacyId();
|
final int typeId = editSession.getBlock(blockVector).getBlockType().getLegacyId();
|
||||||
switch (typeId) {
|
switch (typeId) {
|
||||||
case BlockID.LOG:
|
case BlockID.LOG:
|
||||||
case BlockID.LOG2:
|
case BlockID.LOG2:
|
||||||
|
@ -54,7 +54,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockType initialType = world.getLazyBlock(clicked.toVector()).getType();
|
BlockType initialType = world.getLazyBlock(clicked.toVector()).getBlockType();
|
||||||
|
|
||||||
if (initialType == BlockTypes.AIR) {
|
if (initialType == BlockTypes.AIR) {
|
||||||
return true;
|
return true;
|
||||||
@ -87,7 +87,7 @@ public class FloodFillTool implements BlockTool {
|
|||||||
|
|
||||||
visited.add(pos);
|
visited.add(pos);
|
||||||
|
|
||||||
if (editSession.getBlock(pos).getType() == initialType) {
|
if (editSession.getBlock(pos).getBlockType() == initialType) {
|
||||||
editSession.setBlock(pos, pattern.apply(pos));
|
editSession.setBlock(pos, pattern.apply(pos));
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
|
@ -55,7 +55,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
try {
|
try {
|
||||||
if (secondary.getType() == BlockTypes.AIR) {
|
if (secondary.getBlockType() == BlockTypes.AIR) {
|
||||||
eS.setBlock(pos.toVector(), secondary);
|
eS.setBlock(pos.toVector(), secondary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getDirection(), secondary);
|
eS.setBlock(pos.getDirection(), secondary);
|
||||||
@ -74,7 +74,7 @@ public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTo
|
|||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
try {
|
try {
|
||||||
if (primary.getType() == BlockTypes.AIR) {
|
if (primary.getBlockType() == BlockTypes.AIR) {
|
||||||
eS.setBlock(pos.toVector(), primary);
|
eS.setBlock(pos.toVector(), primary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getDirection(), primary);
|
eS.setBlock(pos.getDirection(), primary);
|
||||||
|
@ -48,8 +48,8 @@ public class QueryTool implements BlockTool {
|
|||||||
BaseBlock block = editSession.getBlock(clicked.toVector());
|
BaseBlock block = editSession.getBlock(clicked.toVector());
|
||||||
|
|
||||||
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
player.print("\u00A79@" + clicked.toVector() + ": " + "\u00A7e"
|
||||||
+ "#" + block.getType() + "\u00A77" + " ("
|
+ "#" + block.getBlockType() + "\u00A77" + " ("
|
||||||
+ block.getType().getId() + ") "
|
+ block.getBlockType().getId() + ") "
|
||||||
+ "\u00A7f"
|
+ "\u00A7f"
|
||||||
+ "[" + block.getStates().toString() + "]" + " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
|
+ "[" + block.getStates().toString() + "]" + " (" + world.getBlockLightLevel(clicked.toVector()) + "/" + world.getBlockLightLevel(clicked.toVector().add(0, 1, 0)) + ")");
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
|
|
||||||
BlockType initialType = world.getBlock(clicked.toVector()).getType();
|
BlockType initialType = world.getBlock(clicked.toVector()).getBlockType();
|
||||||
|
|
||||||
if (initialType == BlockTypes.AIR) {
|
if (initialType == BlockTypes.AIR) {
|
||||||
return true;
|
return true;
|
||||||
@ -89,7 +89,7 @@ public class RecursivePickaxe implements BlockTool {
|
|||||||
|
|
||||||
visited.add(pos);
|
visited.add(pos);
|
||||||
|
|
||||||
if (editSession.getBlock(pos).getType() != initialType) {
|
if (editSession.getBlock(pos).getBlockType() != initialType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class SinglePickaxe implements BlockTool {
|
|||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, com.sk89q.worldedit.util.Location clicked) {
|
||||||
World world = (World) clicked.getExtent();
|
World world = (World) clicked.getExtent();
|
||||||
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getType();
|
final BlockType blockType = world.getLazyBlock(clicked.toVector()).getBlockType();
|
||||||
if (blockType == BlockTypes.BEDROCK
|
if (blockType == BlockTypes.BEDROCK
|
||||||
&& !player.canDestroyBedrock()) {
|
&& !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -24,7 +24,6 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.type.ItemType;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
@ -75,10 +74,9 @@ public interface Player extends Entity, Actor {
|
|||||||
/**
|
/**
|
||||||
* Gives the player an item.
|
* Gives the player an item.
|
||||||
*
|
*
|
||||||
* @param type The item id of the item to be given to the player
|
* @param itemStack The item to give
|
||||||
* @param amount How many items in the stack
|
|
||||||
*/
|
*/
|
||||||
void giveItem(int type, int amount);
|
void giveItem(BaseItemStack itemStack);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get this actor's block bag.
|
* Get this actor's block bag.
|
||||||
|
@ -125,7 +125,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
return blockInHand;
|
return blockInHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockType = blockInHand.getType();
|
blockType = blockInHand.getBlockType();
|
||||||
blockStates = blockInHand.getStates();
|
blockStates = blockInHand.getStates();
|
||||||
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
} else if ("offhand".equalsIgnoreCase(typeString)) {
|
||||||
// Get the block type from the item in the user's off hand.
|
// Get the block type from the item in the user's off hand.
|
||||||
@ -134,7 +134,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
return blockInHand;
|
return blockInHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockType = blockInHand.getType();
|
blockType = blockInHand.getBlockType();
|
||||||
blockStates = blockInHand.getStates();
|
blockStates = blockInHand.getStates();
|
||||||
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
} else if ("pos1".equalsIgnoreCase(typeString)) {
|
||||||
// Get the block type from the "primary position"
|
// Get the block type from the "primary position"
|
||||||
@ -150,7 +150,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
return blockInHand;
|
return blockInHand;
|
||||||
}
|
}
|
||||||
|
|
||||||
blockType = blockInHand.getType();
|
blockType = blockInHand.getBlockType();
|
||||||
blockStates = blockInHand.getStates();
|
blockStates = blockInHand.getStates();
|
||||||
} else {
|
} else {
|
||||||
// Attempt to lookup a block from ID or name.
|
// Attempt to lookup a block from ID or name.
|
||||||
|
@ -33,45 +33,11 @@ public class DefaultItemParser extends InputParser<BaseItem> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseItem parseFromInput(String input, ParserContext context) throws InputParseException {
|
public BaseItem parseFromInput(String input, ParserContext context) throws InputParseException {
|
||||||
String[] tokens = input.split(":", 3);
|
BaseItem item = context.requireWorld().getWorldData().getItemRegistry().createFromId(input);
|
||||||
BaseItem item;
|
|
||||||
short damage = 0;
|
|
||||||
|
|
||||||
try {
|
|
||||||
int id = Integer.parseInt(tokens[0]);
|
|
||||||
|
|
||||||
// Parse metadata
|
|
||||||
if (tokens.length == 2) {
|
|
||||||
try {
|
|
||||||
damage = Short.parseShort(tokens[1]);
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
throw new InputParseException("Expected '" + tokens[1] + "' to be a damage value but it's not a number");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = context.requireWorld().getWorldData().getItemRegistry().createFromId(id);
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
String name = tokens[0];
|
|
||||||
if (input.length() >= 2) {
|
|
||||||
name += ":" + tokens[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse metadata
|
|
||||||
if (tokens.length == 3) {
|
|
||||||
try {
|
|
||||||
damage = Short.parseShort(tokens[2]);
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
throw new InputParseException("Expected '" + tokens[2] + "' to be a damage value but it's not a number");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
item = context.requireWorld().getWorldData().getItemRegistry().createFromId(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
throw new InputParseException("'" + input + "' did not match any item");
|
throw new InputParseException("'" + input + "' did not match any item");
|
||||||
} else {
|
} else {
|
||||||
item.setDamage(damage);
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extension.platform;
|
package com.sk89q.worldedit.extension.platform;
|
||||||
|
|
||||||
import com.sk89q.worldedit.NotABlockException;
|
|
||||||
import com.sk89q.worldedit.PlayerDirection;
|
import com.sk89q.worldedit.PlayerDirection;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -366,9 +365,6 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable {
|
|||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
public BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException {
|
||||||
final ItemType typeId = getItemInHand(handSide).getType();
|
final ItemType typeId = getItemInHand(handSide).getType();
|
||||||
if (!getWorld().isValidBlockType(typeId.getLegacyId())) {
|
|
||||||
throw new NotABlockException(typeId.getId());
|
|
||||||
}
|
|
||||||
return new BaseBlock(typeId.getLegacyId());
|
return new BaseBlock(typeId.getLegacyId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,8 @@ class PlayerProxy extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveItem(int type, int amount) {
|
public void giveItem(BaseItemStack itemStack) {
|
||||||
basePlayer.giveItem(type, amount);
|
basePlayer.giveItem(itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,7 +34,7 @@ import java.util.Map;
|
|||||||
public class SignCompatibilityHandler implements NBTCompatibilityHandler {
|
public class SignCompatibilityHandler implements NBTCompatibilityHandler {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAffectedBlock(BaseBlock block) {
|
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
|
@Override
|
||||||
|
@ -82,8 +82,8 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
|
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
|
||||||
if (blockBag != null) {
|
if (blockBag != null) {
|
||||||
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
|
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
|
||||||
int existing = lazyBlock.getType().getLegacyId();
|
int existing = lazyBlock.getBlockType().getLegacyId();
|
||||||
final int type = block.getType().getLegacyId();
|
final int type = block.getBlockType().getLegacyId();
|
||||||
|
|
||||||
if (type > 0) {
|
if (type > 0) {
|
||||||
try {
|
try {
|
||||||
|
@ -19,28 +19,30 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.blocks.type.ItemType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the target inventory of a block bag is full.
|
* Thrown when the target inventory of a block bag is full.
|
||||||
*/
|
*/
|
||||||
public class OutOfSpaceException extends BlockBagException {
|
public class OutOfSpaceException extends BlockBagException {
|
||||||
|
|
||||||
private int id;
|
private ItemType type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
*
|
*
|
||||||
* @param id the ID of the block
|
* @param type the type of the block
|
||||||
*/
|
*/
|
||||||
public OutOfSpaceException(int id) {
|
public OutOfSpaceException(ItemType type) {
|
||||||
this.id = id;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the ID of the block
|
* Get the type of the block
|
||||||
*
|
*
|
||||||
* @return the id
|
* @return the type
|
||||||
*/
|
*/
|
||||||
public int getID() {
|
public ItemType getType() {
|
||||||
return id;
|
return this.type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,21 +94,21 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BlockType.shouldPlaceLast(block.getType().getLegacyId())) {
|
if (BlockType.shouldPlaceLast(block.getBlockType().getLegacyId())) {
|
||||||
// Place torches, etc. last
|
// Place torches, etc. last
|
||||||
stage2.put(location.toBlockVector(), block);
|
stage2.put(location.toBlockVector(), block);
|
||||||
return !(lazyBlock.getType() == block.getType() && lazyBlock.getData() == block.getData());
|
return !(lazyBlock.getBlockType() == block.getBlockType() && lazyBlock.getData() == block.getData());
|
||||||
} else if (BlockType.shouldPlaceFinal(block.getType().getLegacyId())) {
|
} else if (BlockType.shouldPlaceFinal(block.getBlockType().getLegacyId())) {
|
||||||
// Place signs, reed, etc even later
|
// Place signs, reed, etc even later
|
||||||
stage3.put(location.toBlockVector(), block);
|
stage3.put(location.toBlockVector(), block);
|
||||||
return !(lazyBlock.getType() == block.getType() && lazyBlock.getData() == block.getData());
|
return !(lazyBlock.getBlockType() == block.getBlockType() && lazyBlock.getData() == block.getData());
|
||||||
} else if (BlockType.shouldPlaceLast(lazyBlock.getType().getLegacyId())) {
|
} else if (BlockType.shouldPlaceLast(lazyBlock.getBlockType().getLegacyId())) {
|
||||||
// Destroy torches, etc. first
|
// Destroy torches, etc. first
|
||||||
super.setBlock(location, new BaseBlock(BlockTypes.AIR));
|
super.setBlock(location, new BaseBlock(BlockTypes.AIR));
|
||||||
return super.setBlock(location, block);
|
return super.setBlock(location, block);
|
||||||
} else {
|
} else {
|
||||||
stage1.put(location.toBlockVector(), block);
|
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 BaseBlock baseBlock = blockTypes.get(current);
|
||||||
|
|
||||||
final int type = baseBlock.getType().getLegacyId();
|
final int type = baseBlock.getBlockType().getLegacyId();
|
||||||
final int data = baseBlock.getData();
|
final int data = baseBlock.getData();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -138,7 +138,7 @@ public class BlockTransformExtent extends AbstractDelegateExtent {
|
|||||||
if (value != null && value.getData() != null) {
|
if (value != null && value.getData() != null) {
|
||||||
DirectionalStateValue newValue = getNewStateValue((DirectionalState) state, transform, value.getDirection());
|
DirectionalStateValue newValue = getNewStateValue((DirectionalState) state, transform, value.getDirection());
|
||||||
if (newValue != null) {
|
if (newValue != null) {
|
||||||
changedBlock.setState(state, newValue);
|
changedBlock.with(state, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class DataValidatorExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
|
||||||
final int y = location.getBlockY();
|
final int y = location.getBlockY();
|
||||||
final BlockType type = block.getType();
|
final BlockType type = block.getBlockType();
|
||||||
if (y < 0 || y > world.getMaxY()) {
|
if (y < 0 || y > world.getMaxY()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ public class BlockQuirkExtent extends AbstractDelegateExtent {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
|
public boolean setBlock(Vector position, BaseBlock block) throws WorldEditException {
|
||||||
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
|
BaseBlock lazyBlock = getExtent().getLazyBlock(position);
|
||||||
int existing = lazyBlock.getType().getLegacyId();
|
int existing = lazyBlock.getBlockType().getLegacyId();
|
||||||
|
|
||||||
if (BlockType.isContainerBlock(existing)) {
|
if (BlockType.isContainerBlock(existing)) {
|
||||||
world.clearContainerBlockContents(position); // Clear the container block so that it doesn't drop items
|
world.clearContainerBlockContents(position); // Clear the container block so that it doesn't drop items
|
||||||
|
@ -104,7 +104,7 @@ public class ExtentBlockCopy implements RegionFunction {
|
|||||||
|
|
||||||
builder.putByte("Rot", (byte) MCDirections.toRotation(newDirection));
|
builder.putByte("Rot", (byte) MCDirections.toRotation(newDirection));
|
||||||
|
|
||||||
return new BaseBlock(state.getType(), state.getStates(), builder.build());
|
return new BaseBlock(state.getState(), builder.build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,10 +106,10 @@ public class FloraGenerator implements RegionFunction {
|
|||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
BaseBlock block = editSession.getBlock(position);
|
BaseBlock block = editSession.getBlock(position);
|
||||||
|
|
||||||
if (block.getType() == BlockTypes.GRASS) {
|
if (block.getBlockType() == BlockTypes.GRASS) {
|
||||||
editSession.setBlock(position.add(0, 1, 0), temperatePattern.apply(position));
|
editSession.setBlock(position.add(0, 1, 0), temperatePattern.apply(position));
|
||||||
return true;
|
return true;
|
||||||
} else if (block.getType() == BlockTypes.SAND) {
|
} else if (block.getBlockType() == BlockTypes.SAND) {
|
||||||
editSession.setBlock(position.add(0, 1, 0), desertPattern.apply(position));
|
editSession.setBlock(position.add(0, 1, 0), desertPattern.apply(position));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ public class ForestGenerator implements RegionFunction {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Vector position) throws WorldEditException {
|
public boolean apply(Vector position) throws WorldEditException {
|
||||||
BaseBlock block = editSession.getBlock(position);
|
BaseBlock block = editSession.getBlock(position);
|
||||||
BlockType t = block.getType();
|
BlockType t = block.getBlockType();
|
||||||
|
|
||||||
if (t == BlockTypes.GRASS || t == BlockTypes.DIRT) {
|
if (t == BlockTypes.GRASS || t == BlockTypes.DIRT) {
|
||||||
treeGenerator.generate(editSession, position.add(0, 1, 0));
|
treeGenerator.generate(editSession, position.add(0, 1, 0));
|
||||||
|
@ -163,7 +163,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
|||||||
position = position.add(0, 1, 0);
|
position = position.add(0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editSession.getBlock(position.add(0, -1, 0)).getType() != BlockTypes.GRASS) {
|
if (editSession.getBlock(position.add(0, -1, 0)).getBlockType() != BlockTypes.GRASS) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class BlockMask extends AbstractExtentMask {
|
|||||||
@Override
|
@Override
|
||||||
public boolean test(Vector vector) {
|
public boolean test(Vector vector) {
|
||||||
BaseBlock block = getExtent().getBlock(vector);
|
BaseBlock block = getExtent().getBlock(vector);
|
||||||
return blocks.contains(block) || blocks.contains(new BaseBlock(block.getType()));
|
return blocks.contains(block) || blocks.contains(new BaseBlock(block.getBlockType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -41,7 +41,7 @@ public class FuzzyBlockMask extends BlockMask {
|
|||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
Collection<BaseBlock> blocks = getBlocks();
|
Collection<BaseBlock> blocks = getBlocks();
|
||||||
BaseBlock lazyBlock = extent.getLazyBlock(vector);
|
BaseBlock lazyBlock = extent.getLazyBlock(vector);
|
||||||
BaseBlock compare = new BaseBlock(lazyBlock.getType(), lazyBlock.getStates());
|
BaseBlock compare = new BaseBlock(lazyBlock.getState());
|
||||||
return Blocks.containsFuzzy(blocks, compare);
|
return Blocks.containsFuzzy(blocks, compare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class SolidBlockMask extends AbstractExtentMask {
|
|||||||
public boolean test(Vector vector) {
|
public boolean test(Vector vector) {
|
||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
BaseBlock lazyBlock = extent.getLazyBlock(vector);
|
BaseBlock lazyBlock = extent.getLazyBlock(vector);
|
||||||
return !BlockType.canPassThrough(lazyBlock.getType().getLegacyId(), lazyBlock.getData());
|
return !BlockType.canPassThrough(lazyBlock.getBlockType().getLegacyId(), lazyBlock.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -148,8 +148,8 @@ public class HeightMap {
|
|||||||
BaseBlock existing = session.getBlock(new Vector(xr, curHeight, zr));
|
BaseBlock existing = session.getBlock(new Vector(xr, curHeight, zr));
|
||||||
|
|
||||||
// Skip water/lava
|
// Skip water/lava
|
||||||
if (existing.getType() != BlockTypes.WATER && existing.getType() != BlockTypes.FLOWING_WATER
|
if (existing.getBlockType() != BlockTypes.WATER && existing.getBlockType() != BlockTypes.FLOWING_WATER
|
||||||
&& existing.getType() != BlockTypes.LAVA && existing.getType() != BlockTypes.FLOWING_LAVA) {
|
&& existing.getBlockType() != BlockTypes.LAVA && existing.getBlockType() != BlockTypes.FLOWING_LAVA) {
|
||||||
session.setBlock(new Vector(xr, newHeight, zr), existing);
|
session.setBlock(new Vector(xr, newHeight, zr), existing);
|
||||||
++blocksChanged;
|
++blocksChanged;
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public abstract class ArbitraryShape {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
short newCacheEntry = (short) (material.getType().getLegacyId() | ((material.getData() + 1) << 8));
|
short newCacheEntry = (short) (material.getBlockType().getLegacyId() | ((material.getData() + 1) << 8));
|
||||||
if (newCacheEntry == 0) {
|
if (newCacheEntry == 0) {
|
||||||
// type and data 0
|
// type and data 0
|
||||||
newCacheEntry = -2;
|
newCacheEntry = -2;
|
||||||
|
@ -103,7 +103,7 @@ public class TargetBlock {
|
|||||||
boolean searchForLastBlock = true;
|
boolean searchForLastBlock = true;
|
||||||
Location lastBlock = null;
|
Location lastBlock = null;
|
||||||
while (getNextBlock() != null) {
|
while (getNextBlock() != null) {
|
||||||
if (world.getLazyBlock(getCurrentBlock().toVector()).getType() == BlockTypes.AIR) {
|
if (world.getLazyBlock(getCurrentBlock().toVector()).getBlockType() == BlockTypes.AIR) {
|
||||||
if (searchForLastBlock) {
|
if (searchForLastBlock) {
|
||||||
lastBlock = getCurrentBlock();
|
lastBlock = getCurrentBlock();
|
||||||
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
if (lastBlock.getBlockY() <= 0 || lastBlock.getBlockY() >= world.getMaxY()) {
|
||||||
@ -125,7 +125,7 @@ public class TargetBlock {
|
|||||||
* @return Block
|
* @return Block
|
||||||
*/
|
*/
|
||||||
public Location getTargetBlock() {
|
public Location getTargetBlock() {
|
||||||
while (getNextBlock() != null && world.getLazyBlock(getCurrentBlock().toVector()).getType() == BlockTypes.AIR) ;
|
while (getNextBlock() != null && world.getLazyBlock(getCurrentBlock().toVector()).getBlockType() == BlockTypes.AIR) ;
|
||||||
return getCurrentBlock();
|
return getCurrentBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,8 +20,6 @@
|
|||||||
package com.sk89q.worldedit.world;
|
package com.sk89q.worldedit.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.EditSession;
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
@ -34,7 +32,6 @@ import com.sk89q.worldedit.function.mask.BlockMask;
|
|||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
|
||||||
|
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
|
|
||||||
@ -53,32 +50,6 @@ public abstract class AbstractWorld implements World {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public final boolean setBlockType(Vector position, int type) {
|
|
||||||
try {
|
|
||||||
return setBlock(position, new BaseBlock(type));
|
|
||||||
} catch (WorldEditException ignored) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final void setBlockData(Vector position, int data) {
|
|
||||||
try {
|
|
||||||
setBlock(position, new BaseBlock(getLazyBlock(position).getType().getLegacyId(), data));
|
|
||||||
} catch (WorldEditException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public final boolean setTypeIdAndData(Vector position, int type, int data) {
|
|
||||||
try {
|
|
||||||
return setBlock(position, new BaseBlock(type, data));
|
|
||||||
} catch (WorldEditException ignored) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean setBlock(Vector pt, BaseBlock block) throws WorldEditException {
|
public final boolean setBlock(Vector pt, BaseBlock block) throws WorldEditException {
|
||||||
return setBlock(pt, block, true);
|
return setBlock(pt, block, true);
|
||||||
@ -89,17 +60,6 @@ public abstract class AbstractWorld implements World {
|
|||||||
return getMaximumPoint().getBlockY();
|
return getMaximumPoint().getBlockY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidBlockType(int type) {
|
|
||||||
return BlockType.fromID(type) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean usesBlockData(int type) {
|
|
||||||
// We future proof here by assuming all unknown blocks use data
|
|
||||||
return BlockType.usesData(type) || BlockType.fromID(type) == null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask createLiquidMask() {
|
public Mask createLiquidMask() {
|
||||||
return new BlockMask(this,
|
return new BlockMask(this,
|
||||||
@ -124,7 +84,7 @@ public abstract class AbstractWorld implements World {
|
|||||||
if (stack != null) {
|
if (stack != null) {
|
||||||
final int amount = stack.getAmount();
|
final int amount = stack.getAmount();
|
||||||
if (amount > 1) {
|
if (amount > 1) {
|
||||||
dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getData()), amount);
|
dropItem(pt, new BaseItemStack(stack.getType(), stack.getNbtData(), 1), amount);
|
||||||
} else {
|
} else {
|
||||||
dropItem(pt, stack, amount);
|
dropItem(pt, stack, amount);
|
||||||
}
|
}
|
||||||
@ -137,31 +97,6 @@ public abstract class AbstractWorld implements World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean generateTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
|
||||||
return generateTree(TreeType.TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean generateBigTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
|
||||||
return generateTree(TreeType.BIG_TREE, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean generateBirchTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
|
||||||
return generateTree(TreeType.BIRCH, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean generateRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
|
||||||
return generateTree(TreeType.REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
|
||||||
return generateTree(TreeType.TALL_REDWOOD, editSession, pt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void checkLoadedChunk(Vector pt) {
|
public void checkLoadedChunk(Vector pt) {
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,6 @@ import com.sk89q.worldedit.function.mask.Mask;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.util.Direction;
|
import com.sk89q.worldedit.util.Direction;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
|
||||||
import com.sk89q.worldedit.world.registry.WorldData;
|
import com.sk89q.worldedit.world.registry.WorldData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,24 +55,6 @@ public interface World extends Extent {
|
|||||||
*/
|
*/
|
||||||
int getMaxY();
|
int getMaxY();
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given block ID is a valid block ID.
|
|
||||||
*
|
|
||||||
* @param id the block ID
|
|
||||||
* @return true if the block ID is a valid one
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean isValidBlockType(int id);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether the given block ID uses data values for differentiating
|
|
||||||
* types of blocks.
|
|
||||||
*
|
|
||||||
* @param id the block ID
|
|
||||||
* @return true if the block uses data values
|
|
||||||
*/
|
|
||||||
boolean usesBlockData(int id);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a mask that matches all liquids.
|
* Create a mask that matches all liquids.
|
||||||
*
|
*
|
||||||
@ -113,24 +94,6 @@ public interface World extends Extent {
|
|||||||
*/
|
*/
|
||||||
boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException;
|
boolean setBlock(Vector position, BaseBlock block, boolean notifyAndLight) throws WorldEditException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setBlock(Vector, BaseBlock)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean setBlockType(Vector position, int type);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setBlock(Vector, BaseBlock)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
void setBlockData(Vector position, int data);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #setBlock(Vector, BaseBlock)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean setTypeIdAndData(Vector position, int type, int data);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the light level at the given block.
|
* Get the light level at the given block.
|
||||||
*
|
*
|
||||||
@ -192,36 +155,6 @@ public interface World extends Extent {
|
|||||||
*/
|
*/
|
||||||
boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #generateTree(TreeType, EditSession, Vector)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean generateTree(EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #generateTree(TreeType, EditSession, Vector)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean generateBigTree(EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #generateTree(TreeType, EditSession, Vector)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean generateBirchTree(EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #generateTree(TreeType, EditSession, Vector)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean generateRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link #generateTree(TreeType, EditSession, Vector)}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
boolean generateTallRedwoodTree(EditSession editSession, Vector position) throws MaxChangedBlocksException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the chunk at the given position if it isn't loaded.
|
* Load the chunk at the given position if it isn't loaded.
|
||||||
*
|
*
|
||||||
|
@ -118,8 +118,7 @@ public class AnvilChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private int getBlockID(Vector position) throws DataException {
|
||||||
public int getBlockID(Vector position) throws DataException {
|
|
||||||
int x = position.getBlockX() - rootX * 16;
|
int x = position.getBlockX() - rootX * 16;
|
||||||
int y = position.getBlockY();
|
int y = position.getBlockY();
|
||||||
int z = position.getBlockZ() - rootZ * 16;
|
int z = position.getBlockZ() - rootZ * 16;
|
||||||
@ -130,9 +129,6 @@ public class AnvilChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int yindex = y & 0x0F;
|
int yindex = y & 0x0F;
|
||||||
if (yindex < 0 || yindex >= 16) {
|
|
||||||
throw new DataException("Chunk does not contain position " + position);
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = x + (z * 16 + (yindex * 16 * 16));
|
int index = x + (z * 16 + (yindex * 16 * 16));
|
||||||
|
|
||||||
@ -155,8 +151,7 @@ public class AnvilChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private int getBlockData(Vector position) throws DataException {
|
||||||
public int getBlockData(Vector position) throws DataException {
|
|
||||||
int x = position.getBlockX() - rootX * 16;
|
int x = position.getBlockX() - rootX * 16;
|
||||||
int y = position.getBlockY();
|
int y = position.getBlockY();
|
||||||
int z = position.getBlockZ() - rootZ * 16;
|
int z = position.getBlockZ() - rootZ * 16;
|
||||||
@ -168,10 +163,6 @@ public class AnvilChunk implements Chunk {
|
|||||||
throw new DataException("Chunk does not contain position " + position);
|
throw new DataException("Chunk does not contain position " + position);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yIndex < 0 || yIndex >= 16) {
|
|
||||||
throw new DataException("Chunk does not contain position " + position);
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = x + (z * 16 + (yIndex * 16 * 16));
|
int index = x + (z * 16 + (yIndex * 16 * 16));
|
||||||
boolean shift = index % 2 == 0;
|
boolean shift = index % 2 == 0;
|
||||||
index /= 2;
|
index /= 2;
|
||||||
@ -200,8 +191,7 @@ public class AnvilChunk implements Chunk {
|
|||||||
|
|
||||||
for (Tag tag : tags) {
|
for (Tag tag : tags) {
|
||||||
if (!(tag instanceof CompoundTag)) {
|
if (!(tag instanceof CompoundTag)) {
|
||||||
throw new InvalidFormatException(
|
throw new InvalidFormatException("CompoundTag expected in TileEntities");
|
||||||
"CompoundTag expected in TileEntities");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompoundTag t = (CompoundTag) tag;
|
CompoundTag t = (CompoundTag) tag;
|
||||||
@ -268,21 +258,7 @@ public class AnvilChunk implements Chunk {
|
|||||||
int data = getBlockData(position);
|
int data = getBlockData(position);
|
||||||
BaseBlock block;
|
BaseBlock block;
|
||||||
|
|
||||||
/*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) {
|
block = new BaseBlock(id, data);
|
||||||
block = new SignBlock(id, data);
|
|
||||||
} else if (id == BlockID.CHEST) {
|
|
||||||
block = new ChestBlock(data);
|
|
||||||
} else if (id == BlockID.FURNACE || id == BlockID.BURNING_FURNACE) {
|
|
||||||
block = new FurnaceBlock(id, data);
|
|
||||||
} else if (id == BlockID.DISPENSER) {
|
|
||||||
block = new DispenserBlock(data);
|
|
||||||
} else if (id == BlockID.MOB_SPAWNER) {
|
|
||||||
block = new MobSpawnerBlock(data);
|
|
||||||
} else if (id == BlockID.NOTE_BLOCK) {
|
|
||||||
block = new NoteBlock(data);
|
|
||||||
} else {*/
|
|
||||||
block = new BaseBlock(id, data);
|
|
||||||
//}
|
|
||||||
|
|
||||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
|
@ -28,25 +28,6 @@ import com.sk89q.worldedit.world.DataException;
|
|||||||
*/
|
*/
|
||||||
public interface Chunk {
|
public interface Chunk {
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block ID of a block.
|
|
||||||
*
|
|
||||||
* @param position the position of the block
|
|
||||||
* @return the type ID of the block
|
|
||||||
* @throws DataException thrown on data error
|
|
||||||
*/
|
|
||||||
public int getBlockID(Vector position) throws DataException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the block data of a block.
|
|
||||||
*
|
|
||||||
* @param position the position of the block
|
|
||||||
* @return the data value of the block
|
|
||||||
* @throws DataException thrown on data error
|
|
||||||
*/
|
|
||||||
public int getBlockData(Vector position) throws DataException;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a block;
|
* Get a block;
|
||||||
*
|
*
|
||||||
@ -54,6 +35,6 @@ public interface Chunk {
|
|||||||
* @return block the block
|
* @return block the block
|
||||||
* @throws DataException thrown on data error
|
* @throws DataException thrown on data error
|
||||||
*/
|
*/
|
||||||
public BaseBlock getBlock(Vector position) throws DataException;
|
BaseBlock getBlock(Vector position) throws DataException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,7 @@ import com.sk89q.jnbt.Tag;
|
|||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.blocks.type.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
@ -76,43 +77,6 @@ public class OldChunk implements Chunk {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockID(Vector position) throws DataException {
|
|
||||||
if(position.getBlockY() >= 128) return 0;
|
|
||||||
|
|
||||||
int x = position.getBlockX() - rootX * 16;
|
|
||||||
int y = position.getBlockY();
|
|
||||||
int z = position.getBlockZ() - rootZ * 16;
|
|
||||||
int index = y + (z * 128 + (x * 128 * 16));
|
|
||||||
try {
|
|
||||||
return blocks[index];
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
throw new DataException("Chunk does not contain position " + position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBlockData(Vector position) throws DataException {
|
|
||||||
if(position.getBlockY() >= 128) return 0;
|
|
||||||
|
|
||||||
int x = position.getBlockX() - rootX * 16;
|
|
||||||
int y = position.getBlockY();
|
|
||||||
int z = position.getBlockZ() - rootZ * 16;
|
|
||||||
int index = y + (z * 128 + (x * 128 * 16));
|
|
||||||
boolean shift = index % 2 == 0;
|
|
||||||
index /= 2;
|
|
||||||
|
|
||||||
try {
|
|
||||||
if (!shift) {
|
|
||||||
return (data[index] & 0xF0) >> 4;
|
|
||||||
} else {
|
|
||||||
return data[index] & 0xF;
|
|
||||||
}
|
|
||||||
} catch (IndexOutOfBoundsException e) {
|
|
||||||
throw new DataException("Chunk does not contain position " + position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to load the tile entities.
|
* Used to load the tile entities.
|
||||||
*
|
*
|
||||||
@ -188,25 +152,33 @@ public class OldChunk implements Chunk {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Vector position) throws DataException {
|
public BaseBlock getBlock(Vector position) throws DataException {
|
||||||
int id = getBlockID(position);
|
if(position.getBlockY() >= 128) new BaseBlock(BlockTypes.AIR);
|
||||||
int data = getBlockData(position);
|
int id, dataVal;
|
||||||
BaseBlock block;
|
|
||||||
|
|
||||||
/*if (id == BlockID.WALL_SIGN || id == BlockID.SIGN_POST) {
|
int x = position.getBlockX() - rootX * 16;
|
||||||
block = new SignBlock(id, data);
|
int y = position.getBlockY();
|
||||||
} else if (id == BlockID.CHEST) {
|
int z = position.getBlockZ() - rootZ * 16;
|
||||||
block = new ChestBlock(data);
|
int index = y + (z * 128 + (x * 128 * 16));
|
||||||
} else if (id == BlockID.FURNACE || id == BlockID.BURNING_FURNACE) {
|
try {
|
||||||
block = new FurnaceBlock(id, data);
|
id = blocks[index];
|
||||||
} else if (id == BlockID.DISPENSER) {
|
} catch (IndexOutOfBoundsException e) {
|
||||||
block = new DispenserBlock(data);
|
throw new DataException("Chunk does not contain position " + position);
|
||||||
} else if (id == BlockID.MOB_SPAWNER) {
|
}
|
||||||
block = new MobSpawnerBlock(data);
|
|
||||||
} else if (id == BlockID.NOTE_BLOCK) {
|
boolean shift = index % 2 == 0;
|
||||||
block = new NoteBlock(data);
|
index /= 2;
|
||||||
} else {*/
|
|
||||||
block = new BaseBlock(id, data);
|
try {
|
||||||
//}
|
if (!shift) {
|
||||||
|
dataVal = (data[index] & 0xF0) >> 4;
|
||||||
|
} else {
|
||||||
|
dataVal = data[index] & 0xF;
|
||||||
|
}
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
throw new DataException("Chunk does not contain position " + position);
|
||||||
|
}
|
||||||
|
|
||||||
|
BaseBlock block = new BaseBlock(id, dataVal);
|
||||||
|
|
||||||
CompoundTag tileEntity = getBlockTileEntity(position);
|
CompoundTag tileEntity = getBlockTileEntity(position);
|
||||||
if (tileEntity != null) {
|
if (tileEntity != null) {
|
||||||
|
@ -53,13 +53,13 @@ public class BundledBlockRegistry implements BlockRegistry {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public BlockMaterial getMaterial(BaseBlock block) {
|
public BlockMaterial getMaterial(BaseBlock block) {
|
||||||
return BundledBlockData.getInstance().getMaterialById(block.getType().getId());
|
return BundledBlockData.getInstance().getMaterialById(block.getBlockType().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public Map<String, ? extends State> getStates(BaseBlock block) {
|
public Map<String, ? extends State> getStates(BaseBlock block) {
|
||||||
return BundledBlockData.getInstance().getStatesById(block.getType().getId());
|
return BundledBlockData.getInstance().getStatesById(block.getBlockType().getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ public class BlockTransformExtentTest {
|
|||||||
BaseBlock orig = new BaseBlock(type);
|
BaseBlock orig = new BaseBlock(type);
|
||||||
for (int i = 1; i < 4; i++) {
|
for (int i = 1; i < 4; i++) {
|
||||||
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_90, blockRegistry);
|
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_90, blockRegistry);
|
||||||
BaseBlock reference = new BaseBlock(orig.getType().getLegacyId(), BlockData.rotate90(orig.getType().getLegacyId(), orig.getData()));
|
BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90(orig.getBlockType().getLegacyId(), orig.getData()));
|
||||||
assertThat(type + "#" + type.getId() + " rotated " + (90 * i) + " degrees did not match BlockData.rotate90()'s expected result", rotated,
|
assertThat(type + "#" + type.getId() + " rotated " + (90 * i) + " degrees did not match BlockData.rotate90()'s expected result", rotated,
|
||||||
equalTo(reference));
|
equalTo(reference));
|
||||||
orig = rotated;
|
orig = rotated;
|
||||||
@ -81,7 +81,7 @@ public class BlockTransformExtentTest {
|
|||||||
orig = new BaseBlock(type);
|
orig = new BaseBlock(type);
|
||||||
for (int i = 0; i < 4; i++) {
|
for (int i = 0; i < 4; i++) {
|
||||||
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_NEG_90, blockRegistry);
|
BaseBlock rotated = BlockTransformExtent.transform(new BaseBlock(orig), ROTATE_NEG_90, blockRegistry);
|
||||||
BaseBlock reference = new BaseBlock(orig.getType().getLegacyId(), BlockData.rotate90Reverse(orig.getType().getLegacyId(), orig.getData()));
|
BaseBlock reference = new BaseBlock(orig.getBlockType().getLegacyId(), BlockData.rotate90Reverse(orig.getBlockType().getLegacyId(), orig.getData()));
|
||||||
assertThat(type + "#" + type.getId() + " rotated " + (-90 * i) + " degrees did not match BlockData.rotate90Reverse()'s expected result", rotated, equalTo(reference));
|
assertThat(type + "#" + type.getId() + " rotated " + (-90 * i) + " degrees did not match BlockData.rotate90Reverse()'s expected result", rotated, equalTo(reference));
|
||||||
orig = rotated;
|
orig = rotated;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
package com.sk89q.worldedit.forge;
|
package com.sk89q.worldedit.forge;
|
||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
|
import com.sk89q.worldedit.blocks.type.ItemTypes;
|
||||||
import com.sk89q.worldedit.world.registry.ItemRegistry;
|
import com.sk89q.worldedit.world.registry.ItemRegistry;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
@ -31,7 +32,7 @@ public class ForgeItemRegistry implements ItemRegistry {
|
|||||||
public BaseItem createFromId(String id) {
|
public BaseItem createFromId(String id) {
|
||||||
Item match = Item.REGISTRY.getObject(new ResourceLocation(id));
|
Item match = Item.REGISTRY.getObject(new ResourceLocation(id));
|
||||||
if (match != null) {
|
if (match != null) {
|
||||||
return new BaseItem(Item.REGISTRY.getIDForObject(match), (short) 0);
|
return new BaseItem(ItemTypes.getItemType(id));
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -41,7 +42,7 @@ public class ForgeItemRegistry implements ItemRegistry {
|
|||||||
@Override
|
@Override
|
||||||
public BaseItem createFromId(int id) {
|
public BaseItem createFromId(int id) {
|
||||||
if (Item.REGISTRY.getObjectById(id) != null) {
|
if (Item.REGISTRY.getObjectById(id) != null) {
|
||||||
return new BaseItem(id, (short) 0);
|
return new BaseItem(id);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,9 @@ public class ForgePlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveItem(int type, int amt) {
|
public void giveItem(BaseItemStack itemStack) {
|
||||||
this.player.inventory.addItemStackToInventory(new ItemStack(Item.getItemById(type), amt, 0));
|
this.player.inventory.addItemStackToInventory(
|
||||||
|
new ItemStack(Item.getByNameOrId(itemStack.getType().getId()), itemStack.getAmount(), 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -238,7 +238,12 @@ public class ForgeWorld extends AbstractWorld {
|
|||||||
@Override
|
@Override
|
||||||
public boolean useItem(Vector position, BaseItem item, Direction face) {
|
public boolean useItem(Vector position, BaseItem item, Direction face) {
|
||||||
Item nativeItem = Item.getByNameOrId(item.getType().getId());
|
Item nativeItem = Item.getByNameOrId(item.getType().getId());
|
||||||
ItemStack stack = new ItemStack(nativeItem, 1, item.getData());
|
ItemStack stack = null;
|
||||||
|
if (item.getNbtData() == null) {
|
||||||
|
stack = new ItemStack(nativeItem, 1, 0);
|
||||||
|
} else {
|
||||||
|
stack = new ItemStack(nativeItem, 1, 0, NBTConverter.toNative(item.getNbtData()));
|
||||||
|
}
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
EnumActionResult used = stack.onItemUse(new WorldEditFakePlayer((WorldServer) world), world, ForgeAdapter.toBlockPos(position),
|
EnumActionResult used = stack.onItemUse(new WorldEditFakePlayer((WorldServer) world), world, ForgeAdapter.toBlockPos(position),
|
||||||
EnumHand.MAIN_HAND, ForgeAdapter.adapt(face), 0, 0, 0);
|
EnumHand.MAIN_HAND, ForgeAdapter.adapt(face), 0, 0, 0);
|
||||||
@ -333,7 +338,7 @@ public class ForgeWorld extends AbstractWorld {
|
|||||||
@Override
|
@Override
|
||||||
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
|
public boolean generateTree(TreeType type, EditSession editSession, Vector position) throws MaxChangedBlocksException {
|
||||||
WorldGenerator generator = createWorldGenerator(type);
|
WorldGenerator generator = createWorldGenerator(type);
|
||||||
return generator != null ? generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position)) : false;
|
return generator != null && generator.generate(getWorld(), random, ForgeAdapter.toBlockPos(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -341,12 +346,6 @@ public class ForgeWorld extends AbstractWorld {
|
|||||||
return ForgeWorldData.getInstance();
|
return ForgeWorldData.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidBlockType(int id) {
|
|
||||||
Block block = Block.getBlockById(id);
|
|
||||||
return Block.getIdFromBlock(block) == id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBlock(Vector position) {
|
public BaseBlock getBlock(Vector position) {
|
||||||
World world = getWorld();
|
World world = getWorld();
|
||||||
|
@ -19,9 +19,8 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.forge;
|
package com.sk89q.worldedit.forge;
|
||||||
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import net.minecraft.block.Block;
|
import static net.minecraft.block.Block.REGISTRY;
|
||||||
import org.apache.logging.log4j.Logger;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
@ -30,12 +29,12 @@ import com.sk89q.worldedit.blocks.BaseItemStack;
|
|||||||
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
import com.sk89q.worldedit.event.platform.PlatformReadyEvent;
|
||||||
import com.sk89q.worldedit.extension.platform.Platform;
|
import com.sk89q.worldedit.extension.platform.Platform;
|
||||||
import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage;
|
import com.sk89q.worldedit.forge.net.LeftClickAirEventMessage;
|
||||||
|
import com.sk89q.worldedit.util.Location;
|
||||||
import java.io.File;
|
import net.minecraft.block.Block;
|
||||||
import java.util.Map;
|
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.CommandEvent;
|
import net.minecraftforge.event.CommandEvent;
|
||||||
@ -54,9 +53,9 @@ import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
|
|||||||
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
import net.minecraftforge.fml.common.event.FMLServerStoppingEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
import net.minecraftforge.fml.common.eventhandler.Event.Result;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import java.io.File;
|
||||||
import static net.minecraft.block.Block.REGISTRY;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Forge implementation of WorldEdit.
|
* The Forge implementation of WorldEdit.
|
||||||
@ -214,12 +213,11 @@ public class ForgeWorldEdit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack toForgeItemStack(BaseItemStack item) {
|
public static ItemStack toForgeItemStack(BaseItemStack item) {
|
||||||
ItemStack ret = new ItemStack(Item.getByNameOrId(item.getType().getId()), item.getAmount(), item.getData());
|
NBTTagCompound forgeCompound = null;
|
||||||
for (Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
|
if (item.getNbtData() != null) {
|
||||||
ret.addEnchantment(net.minecraft.enchantment.Enchantment.getEnchantmentByID(entry.getKey()), entry.getValue());
|
forgeCompound = NBTConverter.toNative(item.getNbtData());
|
||||||
}
|
}
|
||||||
|
return new ItemStack(Item.getByNameOrId(item.getType().getId()), item.getAmount(), 0, forgeCompound);
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,8 +31,10 @@ import com.sk89q.worldedit.internal.cui.CUIEvent;
|
|||||||
import com.sk89q.worldedit.session.SessionKey;
|
import com.sk89q.worldedit.session.SessionKey;
|
||||||
import com.sk89q.worldedit.util.HandSide;
|
import com.sk89q.worldedit.util.HandSide;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.data.type.HandTypes;
|
import org.spongepowered.api.data.type.HandTypes;
|
||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
|
import org.spongepowered.api.item.ItemType;
|
||||||
import org.spongepowered.api.item.inventory.ItemStack;
|
import org.spongepowered.api.item.inventory.ItemStack;
|
||||||
import org.spongepowered.api.text.Text;
|
import org.spongepowered.api.text.Text;
|
||||||
import org.spongepowered.api.text.format.TextColor;
|
import org.spongepowered.api.text.format.TextColor;
|
||||||
@ -91,8 +93,11 @@ public class SpongePlayer extends AbstractPlayerActor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void giveItem(int type, int amt) {
|
public void giveItem(BaseItemStack itemStack) {
|
||||||
this.player.getInventory().offer(ItemStack.of(SpongeWorldEdit.inst().getAdapter().resolveItem(type), amt));
|
this.player.getInventory().offer(
|
||||||
|
ItemStack.of(Sponge.getGame().getRegistry().getType(ItemType.class, itemStack.getType().getId()).get(),
|
||||||
|
itemStack.getAmount())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -202,11 +202,6 @@ public abstract class SpongeWorld extends AbstractWorld {
|
|||||||
return SpongeWorldData.getInstance();
|
return SpongeWorldData.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidBlockType(int id) {
|
|
||||||
return id == 0 || SpongeWorldEdit.inst().getAdapter().resolveBlock(id) != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return getWorld().hashCode();
|
return getWorld().hashCode();
|
||||||
@ -220,7 +215,7 @@ public abstract class SpongeWorld extends AbstractWorld {
|
|||||||
SpongeWorld other = ((SpongeWorld) o);
|
SpongeWorld other = ((SpongeWorld) o);
|
||||||
World otherWorld = other.worldRef.get();
|
World otherWorld = other.worldRef.get();
|
||||||
World thisWorld = worldRef.get();
|
World thisWorld = worldRef.get();
|
||||||
return otherWorld != null && thisWorld != null && otherWorld.equals(thisWorld);
|
return otherWorld != null && otherWorld.equals(thisWorld);
|
||||||
} else {
|
} else {
|
||||||
return o instanceof com.sk89q.worldedit.world.World
|
return o instanceof com.sk89q.worldedit.world.World
|
||||||
&& ((com.sk89q.worldedit.world.World) o).getName().equals(getName());
|
&& ((com.sk89q.worldedit.world.World) o).getName().equals(getName());
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren