mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
Re-implement /remove and /butcher with the new entity API.
This commit is contained in:
@ -21,8 +21,6 @@ package com.sk89q.worldedit.world;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
@ -141,21 +139,6 @@ public abstract class AbstractWorld implements World {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int killEntities(LocalEntity... entities) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int killMobs(Vector origin, int radius) {
|
||||
return killMobs(origin, radius, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int killMobs(Vector origin, int radius, boolean killPets) {
|
||||
return killMobs(origin, radius, killPets ? KillFlags.PETS : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(EditSession editSession, Vector pt) throws MaxChangedBlocksException {
|
||||
return generateTree(TreeType.TREE, editSession, pt);
|
||||
|
@ -74,16 +74,6 @@ public class NullWorld extends AbstractWorld {
|
||||
public void dropItem(Vector position, BaseItemStack item) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int killMobs(Vector origin, double radius, int flags) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int removeEntities(EntityType type, Vector origin, int radius) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean regenerate(Region region, EditSession editSession) {
|
||||
return false;
|
||||
|
@ -22,9 +22,6 @@ package com.sk89q.worldedit.world;
|
||||
import com.sk89q.worldedit.BiomeType;
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.EntityType;
|
||||
import com.sk89q.worldedit.LocalEntity;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.Vector2D;
|
||||
@ -191,46 +188,6 @@ public interface World extends Extent {
|
||||
*/
|
||||
void simulateBlockMine(Vector position);
|
||||
|
||||
/**
|
||||
* Kill the entities listed in the provided array.
|
||||
*
|
||||
* @param entity an array of entities
|
||||
* @return the number of entities that were removed
|
||||
*/
|
||||
int killEntities(LocalEntity... entity);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #killMobs(Vector, double, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
int killMobs(Vector origin, int radius);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #killMobs(Vector, double, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
int killMobs(Vector origin, int radius, boolean killPets);
|
||||
|
||||
/**
|
||||
* Kill mobs at the given location with the given radius.
|
||||
*
|
||||
* @param origin the origin
|
||||
* @param radius the radius
|
||||
* @param flags kill flags (see {@link LocalWorld.KillFlags})
|
||||
* @return the number of mobs that were killed
|
||||
*/
|
||||
int killMobs(Vector origin, double radius, int flags);
|
||||
|
||||
/**
|
||||
* Remove entities in an area.
|
||||
*
|
||||
* @param type the type of entity
|
||||
* @param origin the origin
|
||||
* @param radius the radius
|
||||
* @return the number of mobs that were killed
|
||||
*/
|
||||
int removeEntities(EntityType type, Vector origin, int radius);
|
||||
|
||||
/**
|
||||
* Regenerate an area.
|
||||
*
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.entity.metadata.EntityType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Provides information on entities.
|
||||
*/
|
||||
public interface EntityRegistry {
|
||||
|
||||
/**
|
||||
* Create a new entity using its ID.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the entity, which may be null if the entity does not exist
|
||||
*/
|
||||
@Nullable
|
||||
BaseEntity createFromId(String id);
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ public final class LegacyWorldData implements WorldData {
|
||||
|
||||
private static final LegacyWorldData INSTANCE = new LegacyWorldData();
|
||||
private final LegacyBlockRegistry blockRegistry = new LegacyBlockRegistry();
|
||||
private final NullEntityRegistry entityRegistry = new NullEntityRegistry();
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -39,6 +40,11 @@ public final class LegacyWorldData implements WorldData {
|
||||
return blockRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityRegistry getEntityRegistry() {
|
||||
return entityRegistry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a singleton instance.
|
||||
*
|
||||
|
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.world.registry;
|
||||
|
||||
import com.sk89q.worldedit.entity.BaseEntity;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* An implementation of an entity registry that knows nothing.
|
||||
*/
|
||||
public class NullEntityRegistry implements EntityRegistry {
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BaseEntity createFromId(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -32,4 +32,11 @@ public interface WorldData {
|
||||
*/
|
||||
BlockRegistry getBlockRegistry();
|
||||
|
||||
/**
|
||||
* Get the entity registry.
|
||||
*
|
||||
* @return the entity registry
|
||||
*/
|
||||
EntityRegistry getEntityRegistry();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user