本文整理汇总了Java中org.bukkit.util.BlockVector类的典型用法代码示例。如果您正苦于以下问题:Java BlockVector类的具体用法?Java BlockVector怎么用?Java BlockVector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockVector类属于org.bukkit.util包,在下文中一共展示了BlockVector类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderBlocks
import org.bukkit.util.BlockVector; //导入依赖的package包/类
private void renderBlocks(MatchTeam matchTeam) {
byte color1 = progressingTowardsTeam != null ? ColorConverter.convertChatColorToDyeColor(progressingTowardsTeam.getColor()).getWoolData() : -1;
byte color2 = controller != null && matchTeam == controller ? ColorConverter.convertChatColorToDyeColor(controller.getColor()).getWoolData() : -1;
Location center = region.getCenter();
double x = center.getX();
double z = center.getZ();
double percent = Math.toRadians(getPercent() * 3.6);
for(Block block : region.getBlocks()) {
if(!Blocks.isVisualMaterial(block.getType())) continue;
double dx = block.getX() - x;
double dz = block.getZ() - z;
double angle = Math.atan2(dz, dx);
if(angle < 0) angle += 2 * Math.PI;
byte color = angle < percent ? color1 : color2;
if (color == -1) {
Pair<Material,Byte> oldBlock = regionSave.getBlockAt(new BlockVector(block.getLocation().toVector()));
if (oldBlock.getLeft().equals(block.getType())) color = oldBlock.getRight();
}
if (color != -1) {
block.setData(color);
// Bukkit.broadcastMessage("set to " + color);
} else {
// Bukkit.broadcastMessage("color = -1");
}
}
}
示例2: parseBlockVector
import org.bukkit.util.BlockVector; //导入依赖的package包/类
public static BlockVector parseBlockVector(Node node, BlockVector def) throws InvalidXMLException {
if(node == null) return def;
String[] components = node.getValue().trim().split("\\s*,\\s*");
if(components.length != 3) {
throw new InvalidXMLException("Invalid block location", node);
}
try {
return new BlockVector(Integer.parseInt(components[0]),
Integer.parseInt(components[1]),
Integer.parseInt(components[2]));
}
catch(NumberFormatException e) {
throw new InvalidXMLException("Invalid block location", node);
}
}
示例3: FiniteBlockRegion
import org.bukkit.util.BlockVector; //导入依赖的package包/类
public FiniteBlockRegion(Collection<BlockVector> positions) {
this.positions = BlockVectorSet.of(positions);
// calculate AABB
final Vector min = new Vector(Double.MAX_VALUE);
final Vector max = new Vector(-Double.MAX_VALUE);
for(BlockVector pos : this.positions) {
min.setX(Math.min(min.getX(), pos.getBlockX()));
min.setY(Math.min(min.getY(), pos.getBlockY()));
min.setZ(Math.min(min.getZ(), pos.getBlockZ()));
max.setX(Math.max(max.getX(), pos.getBlockX() + 1));
max.setY(Math.max(max.getY(), pos.getBlockY() + 1));
max.setZ(Math.max(max.getZ(), pos.getBlockZ() + 1));
}
this.bounds = Cuboid.between(min, max);
}
示例4: setController
import org.bukkit.util.BlockVector; //导入依赖的package包/类
/**
* Change the controller display to the given team's color, or reset the display if team is null
*/
@SuppressWarnings("deprecation")
public void setController(Competitor controllingTeam) {
if(!Objects.equals(this.controllingTeam, controllingTeam) && this.controllerDisplayRegion != null) {
if(controllingTeam == null) {
for(BlockVector block : this.controllerDisplayRegion.getBlockVectors()) {
this.controllerDisplayImage.restore(block);
}
} else {
byte blockData = BukkitUtils.chatColorToDyeColor(controllingTeam.getColor()).getWoolData();
for(BlockVector pos : this.controllerDisplayRegion.getBlockVectors()) {
BlockUtils.blockAt(match.getWorld(), pos).setData(blockData);
}
}
this.controllingTeam = controllingTeam;
}
}
示例5: setProgress
import org.bukkit.util.BlockVector; //导入依赖的package包/类
protected void setProgress(Competitor controllingTeam, Competitor capturingTeam, double capturingProgress) {
if(this.progressDisplayRegion != null) {
Vector center = this.progressDisplayRegion.getBounds().center();
// capturingProgress can be zero, but it can never be one, so invert it to avoid
// a zero-area SectorRegion that can cause glitchy rendering
SectorRegion sectorRegion = new SectorRegion(center.getX(), center.getZ(), 0, (1 - capturingProgress) * 2 * Math.PI);
for(BlockVector pos : this.progressDisplayRegion.getBlockVectors()) {
if(sectorRegion.contains(pos)) {
this.setBlock(pos, controllingTeam);
} else {
this.setBlock(pos, capturingTeam);
}
}
}
}
示例6: renew
import org.bukkit.util.BlockVector; //导入依赖的package包/类
boolean renew(BlockVector pos) {
MaterialData material;
if(isOriginalShuffleable(pos)) {
// If position is shuffled, first try to find a nearby shuffleable block to swap with.
// This helps to make shuffling less predictable when the material deficit is small or
// out of proportion to the original distribution of materials.
material = sampleShuffledMaterial(pos);
// If that fails, choose a random material, weighted by the current material deficits.
if(material == null) material = chooseShuffledMaterial();
} else {
material = snapshot().getOriginalMaterial(pos);
}
if(material != null) {
return renew(pos, material);
}
return false;
}
示例7: iterator
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@Override
public Iterator<BlockVector> iterator() {
final TLongIterator iter = this.set.iterator();
return new Iterator<BlockVector>() {
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public BlockVector next() {
return decodePos(iter.next());
}
@Override
public void remove() {
iter.remove();
}
};
}
示例8: mutableIterator
import org.bukkit.util.BlockVector; //导入依赖的package包/类
/**
* Return an iterator that reuses a single BlockVector instance,
* mutating it for each iteration.
*/
public Iterator<BlockVector> mutableIterator() {
final TLongIterator iter = set.iterator();
return new Iterator<BlockVector>() {
final BlockVector value = new BlockVector();
@Override
public boolean hasNext() {
return iter.hasNext();
}
@Override
public BlockVector next() {
return decodePos(iter.next(), value);
}
};
}
示例9: iterator
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@Override
public Iterator<BlockVector> iterator() {
int spacing = 20;
List<BlockVector> result = new ArrayList<>(spacing);
double PI2 = Math.PI * 2.0;
for (int i = 0; i <= spacing; i++) {
double angle = ((double) i / spacing) * PI2;
double dX = Math.cos(angle) * this.radius + this.base.getX();
double dZ = Math.sin(angle) * this.radius + this.base.getZ();
// TODO Height 1 currently counts two separate heights, should it stay like that?
for (int j = 0; j <= (int) this.height; j++) {
result.add(new BlockVector(dX, this.base.getY() + j, dZ));
}
}
return result.iterator();
}
示例10: next
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@Override
public BlockVector next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
BlockVector answer = new BlockVector(nextX, nextY, nextZ);
if (++nextX > max.getBlockX()) {
nextX = min.getBlockX();
if (++nextY > max.getBlockY()) {
nextY = min.getBlockY();
if (++nextZ > max.getBlockZ()) {
nextX = Integer.MIN_VALUE;
}
}
}
return answer;
}
示例11: iterator
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@Override
public Iterator<BlockVector> iterator() {
return new Iterator<BlockVector>() {
boolean done;
@Override
public boolean hasNext() {
return !done;
}
@Override
public BlockVector next() {
if (this.done) {
throw new NoSuchElementException();
}
this.done = true;
return BlockExtent.this.vector.toBlockVector();
}
};
}
示例12: enable
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@Override
public void enable() {
Runnable runnable = () -> {
for (Extent extent : data.extents) {
for (BlockVector bv : extent) {
bv.toLocation(getSession().getWorld()).getBlock().setTypeIdAndData(data.blockData.getItemTypeId(), data.blockData.getData(), data.physics);
}
}
};
// If a delay or interval has been set, create a future task
if (data.delay != null || data.interval != null) {
newTask().run(runnable).delay(data.delay).interval(data.interval).build();
} else { // Otherwise, just run this module now
runnable.run();
}
}
示例13: contain
import org.bukkit.util.BlockVector; //导入依赖的package包/类
public boolean contain(BlockData blockData)
{
// First do a sanity check with the map
// Currently, we don't replace blocks!
if (contains(blockData)) return false;
// Check the world name
if (worldName != null && !worldName.equals(blockData.getWorldName())) return false;
// Set a world name if this block list doesn't have one yet
if (worldName == null || worldName.length() == 0) worldName = blockData.getWorldName();
BlockVector blockLocation = blockData.getPosition();
contain(blockLocation);
return true;
}
示例14: onBlockBreak
import org.bukkit.util.BlockVector; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
final Player player = event.getPlayer();
long time = timer.getTicks();
// Start tracking this broken block
final BrokenBlock brokenBlock = new BrokenBlock(event.getBlock(), player, time);
final BlockVector bv = new BlockVector(brokenBlock.block.getLocation().toVector());
brokenBlocks.put(bv, brokenBlock);
// Schedule the tracking to end after MAX_SPLEEF_TIME
new SchedulerUtil() {
public void runnable() {
if (brokenBlocks.containsKey(bv) && brokenBlocks.get(bv) == brokenBlock) {
brokenBlocks.remove(bv);
}
}
}.laterAsync(MAX_SPLEEF_TIME + 1);
}
示例15: RegionSave
import org.bukkit.util.BlockVector; //导入依赖的package包/类
public RegionSave(RegionModule region) {
BlockVector min = blockAlign(region.getMin());
BlockVector max = blockAlign(region.getMax());
BlockVector size = max.minus(min).toBlockVector();
this.min = min;
this.size = size;
List<Pair<Material,Byte>> blocks = new ArrayList<>();
for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) {
for (int y = min.getBlockY(); y < max.getBlockY(); y++) {
for (int x = min.getBlockX(); x < max.getBlockX(); x++) {
Block block = new Location(GameHandler.getGameHandler().getMatchWorld(), x, y, z).getBlock();
blocks.add(new ImmutablePair<>(block.getType(), block.getData()));
}
}
}
this.blocks = blocks;
}