3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-27 03:12:37 +01:00

Added support for Extent interface.

Dieser Commit ist enthalten in:
sk89q 2014-03-29 21:05:09 -07:00
Ursprung 3c5c257a41
Commit 70f409975e
3 geänderte Dateien mit 98 neuen und 22 gelöschten Zeilen

Datei anzeigen

@ -27,17 +27,18 @@ import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.expression.Expression;
import com.sk89q.worldedit.expression.ExpressionException;
import com.sk89q.worldedit.expression.runtime.RValue;
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
import com.sk89q.worldedit.function.GroundFunction;
import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockCount;
import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.ForestGenerator;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.operation.OperationHelper;
import com.sk89q.worldedit.function.util.RegionOffset;
import com.sk89q.worldedit.function.visitor.*;
import com.sk89q.worldedit.function.visitor.DownwardVisitor;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
import com.sk89q.worldedit.function.visitor.RecursiveVisitor;
import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.interpolation.Interpolation;
import com.sk89q.worldedit.interpolation.KochanekBartelsInterpolation;
import com.sk89q.worldedit.interpolation.Node;
@ -56,9 +57,7 @@ import java.util.*;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
import static com.sk89q.worldedit.regions.Regions.*;
/**
* This class can wrap all block editing operations into one "edit session" that
@ -70,7 +69,7 @@ import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
*
* @author sk89q
*/
public class EditSession {
public class EditSession implements Extent {
/**
* Random number generator.
@ -248,6 +247,11 @@ public class EditSession {
return result;
}
@Override
public boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent) {
return setBlock(location, block, true);
}
/**
* Sets the block at position x, y, z with a block type. If queue mode is
* enabled, blocks may not be actually set in world until flushQueue() is

Datei anzeigen

@ -0,0 +1,77 @@
/*
* 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 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.sk89q.worldedit;
import com.sk89q.worldedit.blocks.BaseBlock;
/**
* A world, portion of a world, clipboard, or other object that can have blocks set or
* entities placed.
*/
public interface Extent {
/**
* Get a copy of the block at the given location. May return null if the location
* given is out of bounds. The returned block must not be tied to any real block
* in the world, so changes to the returned {@link BaseBlock} have no effect until
* {@link #setBlock(Vector, BaseBlock)} is called.
*
* @param location location of the block
* @return the block, or null if the block does not exist
*/
BaseBlock getBlock(Vector location);
/**
* Get the block ID at the given location.
*
* @param location location of the block
* @return the block ID
*/
int getBlockType(Vector location);
/**
* Get the data value of the block at the given location.
*
* @param location the location of the block
* @return the block data value
*/
int getBlockData(Vector location);
/**
* Change the block at the given location to the given block. The operation may
* not tie the given {@link BaseBlock} to the world, so future changes to the
* {@link BaseBlock} do not affect the world until this method is called again.
*
* <p>The return value of this method indicates whether the change "went through," as
* in the block was changed in the world in any way. If the new block is no different
* than the block already at the position in the world, 'false' would be returned.
* If the position is invalid (out of bounds, for example), then nothing should
* occur and 'false' should be returned. If possible, the return value should be
* accurate as possible, but implementations may choose to not provide an accurate
* value if it is not possible to know.</p>
*
* @param location location of the block
* @param block block to set
* @param notifyAdjacent true to notify adjacent blocks of changes
* @return true if the block was successfully set (return value may not be accurate)
*/
boolean setBlock(Vector location, BaseBlock block, boolean notifyAdjacent);
}

Datei anzeigen

@ -19,31 +19,21 @@
package com.sk89q.worldedit;
import java.util.PriorityQueue;
import java.util.Random;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.blocks.BlockType;
import com.sk89q.worldedit.blocks.ChestBlock;
import com.sk89q.worldedit.blocks.DispenserBlock;
import com.sk89q.worldedit.blocks.FurnaceBlock;
import com.sk89q.worldedit.blocks.MobSpawnerBlock;
import com.sk89q.worldedit.blocks.NoteBlock;
import com.sk89q.worldedit.blocks.SignBlock;
import com.sk89q.worldedit.blocks.SkullBlock;
import com.sk89q.worldedit.blocks.*;
import com.sk89q.worldedit.foundation.Block;
import com.sk89q.worldedit.foundation.World;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.TreeGenerator;
import java.util.PriorityQueue;
import java.util.Random;
/**
* Represents a world.
*
* @author sk89q
*/
public abstract class LocalWorld implements World {
public abstract class LocalWorld implements World, Extent {
/**
* Named flags to use as parameters to {@link LocalWorld#killMobs(Vector, double, int)}
*/
@ -528,6 +518,11 @@ public abstract class LocalWorld implements World {
public int killEntities(LocalEntity... entities) {
return 0;
}
@Override
public boolean setBlock(Vector pt, BaseBlock block, boolean notifyAdjacent) {
return setBlock(pt, (Block) block, notifyAdjacent);
}
@Override
public boolean setBlock(Vector pt, Block block, boolean notifyAdjacent) {