Added a new preliminary mapping + metadata framework.

The eventual goal is to add:

1. Support for mapping block, etc. names (minecraft:stone, etc.)
2. Proper support for entities in WorldEdit
3. Support for querying for metadata about a block, entity, etc.
4. Extent support to biomes, structures, and so on
This commit is contained in:
sk89q
2014-04-26 21:57:45 -07:00
parent 19c43a2834
commit 354d819872
16 changed files with 777 additions and 188 deletions

View File

@@ -22,11 +22,14 @@ package com.sk89q.worldedit.internal;
import com.sk89q.worldedit.*;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.mapping.Resolver;
import javax.annotation.Nullable;
@@ -308,6 +311,33 @@ public class LocalWorldAdapter extends LocalWorld {
public Operation commit() {
return world.commit();
}
@Override
public Resolver<BaseBlock> getBlockMapping() {
return world.getBlockMapping();
}
@Override
public Resolver<BaseEntity> getEntityMapping() {
return world.getEntityMapping();
}
@Override
@Nullable
public <T> T getMetaData(BaseBlock block, Class<T> metaDataClass) {
return world.getMetaData(block, metaDataClass);
}
@Override
@Nullable
public <T> T getMetaData(Entity entity, Class<T> metaDataClass) {
return world.getMetaData(entity, metaDataClass);
}
@Override
@Nullable
public <T> T getMetaData(BaseEntity entity, Class<T> metaDataClass) {
return world.getMetaData(entity, metaDataClass);
}
public static LocalWorldAdapter wrap(World world) {
return new LocalWorldAdapter(world);

View File

@@ -0,0 +1,52 @@
/*
* 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.internal.util;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Abstract class for adapters.
*
* @param <E> class of adapted objects
*/
public abstract class AbstractAdapter<E> {
private final E object;
/**
* Create a new instance.
*
* @param object the object to adapt
*/
public AbstractAdapter(E object) {
checkNotNull(object);
this.object = object;
}
/**
* Get the object.
*
* @return the object
*/
public E getHandle() {
return object;
}
}