2011-01-01 18:33:18 +00:00
|
|
|
// $Id$
|
|
|
|
/*
|
|
|
|
* WorldEdit
|
2012-01-05 21:38:23 +00:00
|
|
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
2011-01-01 18:33:18 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
2011-02-18 23:49:50 +00:00
|
|
|
*/
|
2011-01-01 18:33:18 +00:00
|
|
|
|
|
|
|
package com.sk89q.worldedit;
|
|
|
|
|
2011-11-29 08:09:32 +00:00
|
|
|
import java.util.PriorityQueue;
|
2011-01-11 18:21:26 +00:00
|
|
|
import java.util.Random;
|
2011-01-23 08:36:26 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
2011-01-08 19:26:27 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2011-09-14 23:19:19 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BlockType;
|
2011-03-13 00:37:07 +00:00
|
|
|
import com.sk89q.worldedit.regions.Region;
|
2012-03-17 22:24:30 +00:00
|
|
|
import com.sk89q.worldedit.util.TreeGenerator;
|
2011-01-08 19:26:27 +00:00
|
|
|
|
2011-01-01 18:33:18 +00:00
|
|
|
/**
|
|
|
|
* Represents a world.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-01 18:33:18 +00:00
|
|
|
* @author sk89q
|
|
|
|
*/
|
|
|
|
public abstract class LocalWorld {
|
2011-12-06 05:26:12 +00:00
|
|
|
/**
|
2012-03-17 22:24:30 +00:00
|
|
|
* Named flags to use as parameters to {@link LocalWorld#killMobs(Vector, double, int)}
|
2011-12-06 05:26:12 +00:00
|
|
|
*/
|
|
|
|
public class KillFlags {
|
|
|
|
public static final int PETS = 1 << 0;
|
|
|
|
public static final int NPCS = 1 << 1;
|
2011-12-06 06:08:32 +00:00
|
|
|
public static final int ANIMALS = 1 << 2;
|
2012-03-16 19:02:56 +00:00
|
|
|
public static final int GOLEMS = 1 << 3;
|
2012-03-17 08:09:31 +00:00
|
|
|
public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS;
|
2011-12-21 17:10:34 +00:00
|
|
|
public static final int WITH_LIGHTNING = 1 << 20;
|
2011-12-06 05:26:12 +00:00
|
|
|
}
|
|
|
|
|
2011-01-11 18:21:26 +00:00
|
|
|
/**
|
|
|
|
* Random generator.
|
|
|
|
*/
|
|
|
|
protected Random random = new Random();
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-07-07 17:23:12 +00:00
|
|
|
/**
|
|
|
|
* Get the name of the world.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-07-07 17:23:12 +00:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract String getName();
|
2011-02-18 23:49:50 +00:00
|
|
|
|
2011-01-08 19:26:27 +00:00
|
|
|
/**
|
|
|
|
* Set block type.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
* @param type
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract boolean setBlockType(Vector pt, int type);
|
|
|
|
|
2011-06-04 17:30:45 +00:00
|
|
|
/**
|
|
|
|
* Set block type.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-06-04 17:30:45 +00:00
|
|
|
* @param pt
|
|
|
|
* @param type
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public boolean setBlockTypeFast(Vector pt, int type) {
|
|
|
|
return setBlockType(pt, type);
|
|
|
|
}
|
|
|
|
|
2011-01-08 19:26:27 +00:00
|
|
|
/**
|
|
|
|
* Get block type.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract int getBlockType(Vector pt);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set block data.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
* @param data
|
|
|
|
*/
|
2011-07-15 07:00:48 +00:00
|
|
|
|
2011-01-08 19:26:27 +00:00
|
|
|
public abstract void setBlockData(Vector pt, int data);
|
|
|
|
|
2011-06-04 17:30:45 +00:00
|
|
|
/**
|
|
|
|
* Set block data.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-06-04 17:30:45 +00:00
|
|
|
* @param pt
|
|
|
|
* @param data
|
|
|
|
*/
|
2011-07-15 07:00:48 +00:00
|
|
|
public abstract void setBlockDataFast(Vector pt, int data);
|
2011-06-04 17:30:45 +00:00
|
|
|
|
2012-03-17 15:35:29 +00:00
|
|
|
/**
|
|
|
|
* Get biome type
|
|
|
|
*
|
|
|
|
* @param pt
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract BiomeType getBiome(Vector2D pt);
|
|
|
|
|
2011-07-15 07:00:48 +00:00
|
|
|
/**
|
|
|
|
* set block type & data
|
|
|
|
* @param pt
|
|
|
|
* @param type
|
|
|
|
* @param data
|
|
|
|
* @return
|
|
|
|
*/
|
2011-08-14 07:48:18 +00:00
|
|
|
public boolean setTypeIdAndData(Vector pt, int type, int data) {
|
|
|
|
boolean ret = setBlockType(pt, type);
|
|
|
|
setBlockData(pt, data);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-10-26 20:50:46 +00:00
|
|
|
|
2011-07-15 07:00:48 +00:00
|
|
|
/**
|
|
|
|
* set block type & data
|
|
|
|
* @param pt
|
|
|
|
* @param type
|
|
|
|
* @param data
|
2012-03-02 04:47:19 +00:00
|
|
|
* @return
|
2011-07-15 07:00:48 +00:00
|
|
|
*/
|
2011-08-14 07:48:18 +00:00
|
|
|
public boolean setTypeIdAndDataFast(Vector pt, int type, int data) {
|
|
|
|
boolean ret = setBlockTypeFast(pt, type);
|
|
|
|
setBlockDataFast(pt, data);
|
|
|
|
return ret;
|
|
|
|
}
|
2011-10-26 20:50:46 +00:00
|
|
|
|
2011-01-08 19:26:27 +00:00
|
|
|
/**
|
|
|
|
* Get block data.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract int getBlockData(Vector pt);
|
2011-04-30 06:15:09 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get block light level.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-04-30 06:15:09 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract int getBlockLightLevel(Vector pt);
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-03-13 00:37:07 +00:00
|
|
|
/**
|
|
|
|
* Regenerate an area.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-03-13 00:37:07 +00:00
|
|
|
* @param region
|
|
|
|
* @param editSession
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract boolean regenerate(Region region, EditSession editSession);
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
2011-01-23 08:36:26 +00:00
|
|
|
* Attempts to accurately copy a BaseBlock's extra data to the world.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
2011-01-23 08:36:26 +00:00
|
|
|
* @param block
|
2011-01-08 19:26:27 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-01-23 08:36:26 +00:00
|
|
|
public abstract boolean copyToWorld(Vector pt, BaseBlock block);
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
2011-01-23 08:36:26 +00:00
|
|
|
* Attempts to read a BaseBlock's extra data from the world.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
2011-01-23 08:36:26 +00:00
|
|
|
* @param block
|
2011-01-08 19:26:27 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-01-23 08:36:26 +00:00
|
|
|
public abstract boolean copyFromWorld(Vector pt, BaseBlock block);
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Clear a chest's contents.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
2011-02-18 23:49:50 +00:00
|
|
|
* @return
|
2011-01-08 19:26:27 +00:00
|
|
|
*/
|
2011-01-23 08:36:26 +00:00
|
|
|
public abstract boolean clearContainerBlockContents(Vector pt);
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a tree at a location.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-02-18 23:49:50 +00:00
|
|
|
* @param editSession
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
2011-02-18 23:49:50 +00:00
|
|
|
* @throws MaxChangedBlocksException
|
2012-03-17 22:24:30 +00:00
|
|
|
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
2011-01-08 19:26:27 +00:00
|
|
|
*/
|
2012-03-17 22:24:30 +00:00
|
|
|
@Deprecated
|
|
|
|
public boolean generateTree(EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-08 19:26:27 +00:00
|
|
|
|
2011-01-09 18:22:01 +00:00
|
|
|
/**
|
|
|
|
* Generate a big tree at a location.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-02-18 23:49:50 +00:00
|
|
|
* @param editSession
|
2011-01-09 18:22:01 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
2011-02-18 23:49:50 +00:00
|
|
|
* @throws MaxChangedBlocksException
|
2012-03-17 22:24:30 +00:00
|
|
|
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
2011-01-09 18:22:01 +00:00
|
|
|
*/
|
2012-03-17 22:24:30 +00:00
|
|
|
@Deprecated
|
|
|
|
public boolean generateBigTree(EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 22:54:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a birch tree at a location.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-02-18 23:49:50 +00:00
|
|
|
* @param editSession
|
2011-01-30 22:54:42 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
2011-02-18 23:49:50 +00:00
|
|
|
* @throws MaxChangedBlocksException
|
2012-03-17 22:24:30 +00:00
|
|
|
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
2011-01-30 22:54:42 +00:00
|
|
|
*/
|
2012-03-17 22:24:30 +00:00
|
|
|
@Deprecated
|
|
|
|
public boolean generateBirchTree(EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 22:54:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a redwood tree at a location.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-02-18 23:49:50 +00:00
|
|
|
* @param editSession
|
2011-01-30 22:54:42 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
2011-02-18 23:49:50 +00:00
|
|
|
* @throws MaxChangedBlocksException
|
2012-03-17 22:24:30 +00:00
|
|
|
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
2011-01-30 22:54:42 +00:00
|
|
|
*/
|
2012-03-17 22:24:30 +00:00
|
|
|
@Deprecated
|
|
|
|
public boolean generateRedwoodTree(EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
return false;
|
|
|
|
}
|
2011-01-30 22:54:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generate a tall redwood tree at a location.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
|
|
|
* @param editSession
|
2011-01-30 22:54:42 +00:00
|
|
|
* @param pt
|
|
|
|
* @return
|
2012-03-02 04:47:19 +00:00
|
|
|
* @throws MaxChangedBlocksException
|
2012-03-17 22:24:30 +00:00
|
|
|
* @deprecated use {@link #generateTree(com.sk89q.worldedit.util.TreeGenerator.TreeType, EditSession, Vector)} instead
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public boolean generateTallRedwoodTree(EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates a tree
|
|
|
|
* @param type The type of tree to generate
|
|
|
|
* @param editSession The EditSession to pass block changes through
|
|
|
|
* @param pt The point where the base of the tree should be located
|
|
|
|
* @return Whether the tree generation was successful
|
|
|
|
* @throws MaxChangedBlocksException if too many blocks were changed by the EditSession
|
2011-01-30 22:54:42 +00:00
|
|
|
*/
|
2012-03-17 22:24:30 +00:00
|
|
|
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, Vector pt)
|
|
|
|
throws MaxChangedBlocksException {
|
|
|
|
switch (type) {
|
|
|
|
case BIG_TREE:
|
|
|
|
return generateBigTree(editSession, pt);
|
|
|
|
case BIRCH:
|
|
|
|
return generateBirchTree(editSession, pt);
|
|
|
|
case REDWOOD:
|
|
|
|
return generateRedwoodTree(editSession, pt);
|
|
|
|
case TALL_REDWOOD:
|
|
|
|
return generateTallRedwoodTree(editSession, pt);
|
|
|
|
default:
|
|
|
|
case TREE:
|
|
|
|
return generateTree(editSession, pt);
|
|
|
|
}
|
|
|
|
}
|
2011-01-09 18:22:01 +00:00
|
|
|
|
2011-01-08 19:26:27 +00:00
|
|
|
/**
|
|
|
|
* Drop an item.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
2012-03-02 04:47:19 +00:00
|
|
|
* @param item
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param times
|
|
|
|
*/
|
2011-02-18 23:49:50 +00:00
|
|
|
public void dropItem(Vector pt, BaseItemStack item, int times) {
|
2011-07-15 07:00:48 +00:00
|
|
|
for (int i = 0; i < times; ++i) {
|
2011-01-18 04:30:54 +00:00
|
|
|
dropItem(pt, item);
|
2011-01-11 18:21:26 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop an item.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
2011-01-18 04:30:54 +00:00
|
|
|
* @param item
|
2011-01-08 19:26:27 +00:00
|
|
|
*/
|
2011-01-18 04:30:54 +00:00
|
|
|
public abstract void dropItem(Vector pt, BaseItemStack item);
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Simulate a block being mined.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-08 19:26:27 +00:00
|
|
|
* @param pt
|
|
|
|
*/
|
2011-01-11 18:21:26 +00:00
|
|
|
public void simulateBlockMine(Vector pt) {
|
2011-09-18 04:52:12 +00:00
|
|
|
BaseItemStack stack = BlockType.getBlockDrop(getBlockType(pt), (short) getBlockData(pt));
|
2011-11-23 01:29:48 +00:00
|
|
|
if (stack == null) {
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 23:49:50 +00:00
|
|
|
|
2011-11-23 01:29:48 +00:00
|
|
|
final int amount = stack.getAmount();
|
|
|
|
if (amount > 1) {
|
|
|
|
dropItem(pt, new BaseItemStack(stack.getType(), 1, stack.getDamage()), amount);
|
|
|
|
} else {
|
|
|
|
dropItem(pt, stack, amount);
|
|
|
|
}
|
2011-01-11 18:21:26 +00:00
|
|
|
}
|
2011-01-08 19:26:27 +00:00
|
|
|
|
|
|
|
/**
|
2011-05-24 22:19:11 +00:00
|
|
|
* Kill mobs in an area, excluding pet wolves.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2012-03-17 22:24:30 +00:00
|
|
|
* @param origin -1 for the whole world
|
2011-01-08 19:26:27 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-12-06 05:26:12 +00:00
|
|
|
@Deprecated
|
|
|
|
public int killMobs(Vector origin, int radius) {
|
|
|
|
return killMobs(origin, radius, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Kill mobs in an area.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2012-03-17 22:24:30 +00:00
|
|
|
* @param origin The center of the area to kill mobs in
|
2011-12-06 05:26:12 +00:00
|
|
|
* @param radius -1 for all mobs
|
2012-03-17 22:24:30 +00:00
|
|
|
* @param killPets whether to kill pets
|
2011-12-06 05:26:12 +00:00
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public int killMobs(Vector origin, int radius, boolean killPets) {
|
|
|
|
return killMobs(origin, radius, killPets ? KillFlags.PETS : 0);
|
|
|
|
}
|
2011-02-18 23:49:50 +00:00
|
|
|
|
2011-05-24 22:19:11 +00:00
|
|
|
/**
|
|
|
|
* Kill mobs in an area.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-05-24 22:19:11 +00:00
|
|
|
* @param origin
|
|
|
|
* @param radius
|
2012-03-17 22:24:30 +00:00
|
|
|
* @param flags
|
2011-05-24 22:19:11 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-12-06 05:26:12 +00:00
|
|
|
public int killMobs(Vector origin, double radius, int flags) {
|
|
|
|
return killMobs(origin, (int) radius, (flags & KillFlags.PETS) != 0);
|
|
|
|
}
|
2011-05-24 22:19:11 +00:00
|
|
|
|
2011-02-19 04:31:49 +00:00
|
|
|
/**
|
|
|
|
* Remove entities in an area.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
|
|
|
* @param type
|
2011-02-19 04:31:49 +00:00
|
|
|
* @param origin
|
|
|
|
* @param radius
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public abstract int removeEntities(EntityType type, Vector origin, int radius);
|
2011-11-23 01:29:48 +00:00
|
|
|
|
2011-06-05 05:22:23 +00:00
|
|
|
/**
|
|
|
|
* Returns whether a block has a valid ID.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-06-05 05:22:23 +00:00
|
|
|
* @param type
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public boolean isValidBlockType(int type) {
|
2011-09-14 23:19:19 +00:00
|
|
|
return BlockType.fromID(type) != null;
|
2011-06-05 05:22:23 +00:00
|
|
|
}
|
2012-03-02 04:47:19 +00:00
|
|
|
|
2012-02-06 01:46:26 +00:00
|
|
|
/**
|
|
|
|
* Returns whether a block uses its data value.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2012-02-06 01:46:26 +00:00
|
|
|
* @param type block ID type
|
|
|
|
* @return true if the block uses data value
|
|
|
|
*/
|
|
|
|
public boolean usesBlockData(int type) {
|
|
|
|
// We future proof here by assuming all unknown blocks use data
|
|
|
|
return BlockType.usesData(type) || BlockType.fromID(type) == null;
|
|
|
|
}
|
2011-02-19 04:31:49 +00:00
|
|
|
|
2011-08-30 00:31:08 +00:00
|
|
|
/**
|
|
|
|
* Checks if the chunk pt is in is loaded. if not, loads the chunk
|
|
|
|
*
|
|
|
|
* @param pt Position to check
|
|
|
|
*/
|
2011-11-23 01:29:48 +00:00
|
|
|
public void checkLoadedChunk(Vector pt) {
|
|
|
|
}
|
2011-08-30 00:31:08 +00:00
|
|
|
|
2011-01-01 18:33:18 +00:00
|
|
|
/**
|
|
|
|
* Compare if the other world is equal.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-01 18:33:18 +00:00
|
|
|
* @param other
|
|
|
|
* @return
|
|
|
|
*/
|
2011-02-18 23:49:50 +00:00
|
|
|
@Override
|
2011-01-01 18:33:18 +00:00
|
|
|
public abstract boolean equals(Object other);
|
2011-02-18 23:49:50 +00:00
|
|
|
|
2011-01-01 18:33:18 +00:00
|
|
|
/**
|
|
|
|
* Hash code.
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-01-01 18:33:18 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-02-18 23:49:50 +00:00
|
|
|
@Override
|
2011-01-01 18:33:18 +00:00
|
|
|
public abstract int hashCode();
|
2011-09-24 22:44:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the world's height
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-09-24 22:44:54 +00:00
|
|
|
* @return
|
|
|
|
*/
|
2011-12-13 03:20:31 +00:00
|
|
|
public int getMaxY() {
|
2012-03-02 04:47:19 +00:00
|
|
|
return 255;
|
2011-09-24 22:44:54 +00:00
|
|
|
}
|
2011-10-17 03:57:08 +00:00
|
|
|
|
2011-10-25 16:29:37 +00:00
|
|
|
/**
|
|
|
|
* Does some post-processing. Should be called after using fast mode
|
2012-03-02 04:47:19 +00:00
|
|
|
*
|
2011-10-25 16:29:37 +00:00
|
|
|
* @param chunks the chunks to fix
|
|
|
|
*/
|
2011-11-23 01:29:48 +00:00
|
|
|
public void fixAfterFastMode(Iterable<BlockVector2D> chunks) {
|
|
|
|
}
|
2011-10-25 16:29:37 +00:00
|
|
|
|
2011-11-23 01:29:48 +00:00
|
|
|
public void fixLighting(Iterable<BlockVector2D> chunks) {
|
|
|
|
}
|
2011-11-28 06:13:19 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays the minecraft effect with the given type and data at the given position.
|
|
|
|
*
|
|
|
|
* @param position
|
|
|
|
* @param type
|
|
|
|
* @param data
|
|
|
|
*/
|
|
|
|
public boolean playEffect(Vector position, int type, int data) {
|
|
|
|
return false;
|
|
|
|
}
|
2011-11-29 08:09:32 +00:00
|
|
|
|
2011-12-04 19:01:08 +00:00
|
|
|
private class QueuedEffect implements Comparable<QueuedEffect> {
|
2011-11-29 08:09:32 +00:00
|
|
|
private final Vector position;
|
|
|
|
private final int blockId;
|
|
|
|
private final double priority;
|
|
|
|
public QueuedEffect(Vector position, int blockId, double priority) {
|
|
|
|
this.position = position;
|
|
|
|
this.blockId = blockId;
|
|
|
|
this.priority = priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void play() {
|
|
|
|
playEffect(position, 2001, blockId);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(QueuedEffect other) {
|
|
|
|
return Double.compare(priority, other.priority);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final PriorityQueue<QueuedEffect> effectQueue = new PriorityQueue<QueuedEffect>();
|
|
|
|
private int taskId = -1;
|
|
|
|
public boolean queueBlockBreakEffect(ServerInterface server, Vector position, int blockId, double priority) {
|
|
|
|
if (taskId == -1) {
|
2012-03-02 04:47:19 +00:00
|
|
|
taskId = server.schedule(0, 1, new Runnable() {
|
2011-11-29 08:09:32 +00:00
|
|
|
public void run() {
|
|
|
|
int max = Math.max(1, Math.min(30, effectQueue.size() / 3));
|
|
|
|
for (int i = 0; i < max; ++i) {
|
|
|
|
if (effectQueue.isEmpty()) return;
|
|
|
|
|
|
|
|
effectQueue.poll().play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (taskId == -1) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
effectQueue.offer(new QueuedEffect(position, blockId, priority));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-01 18:33:18 +00:00
|
|
|
}
|