本文整理匯總了Java中org.bukkit.Chunk.getTileEntities方法的典型用法代碼示例。如果您正苦於以下問題:Java Chunk.getTileEntities方法的具體用法?Java Chunk.getTileEntities怎麽用?Java Chunk.getTileEntities使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.Chunk
的用法示例。
在下文中一共展示了Chunk.getTileEntities方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleChunkLoadSync
import org.bukkit.Chunk; //導入方法依賴的package包/類
public void handleChunkLoadSync(Chunk loadedChunk) {
if (loadedChunk.getTileEntities() != null) {
for (BlockState bs : loadedChunk.getTileEntities()) {
if (isIdContainerBlock(bs.getTypeId())) {
updateDuctNeighborBlockSync(bs.getBlock(), true);
Map<BlockLoc, TransportPipesContainer> containerMap = TransportPipes.instance.getContainerMap(loadedChunk.getWorld());
synchronized (containerMap) {
BlockLoc bl = BlockLoc.convertBlockLoc(bs.getLocation());
TransportPipesContainer tpc = containerMap.get(bl);
if (tpc instanceof BlockContainer) {
((BlockContainer) tpc).updateBlock();
}
}
}
}
}
}
示例2: autoClean
import org.bukkit.Chunk; //導入方法依賴的package包/類
private void autoClean(Chunk chunk) {
if (chunk == null) {
return;
}
for (BlockState tiles : chunk.getTileEntities()) {
if (tiles instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner) tiles;
// 非法類型檢測
if (cm.illegalSpawnerType.contains(spawner.getCreatureTypeName().toLowerCase())) {
switch (cm.illegalTypeSpawnerCleanMode) {
case 0:
spawner.getBlock().setType(Material.AIR);
break;
case 1:
spawner.setCreatureType(RND_ENTITYTYPE[(int) (Math.random() * RND_ENTITYTYPE.length)]);
break;
default:
break;
}
}
}
}
}
示例3: checkChunk
import org.bukkit.Chunk; //導入方法依賴的package包/類
private void checkChunk(ChunkPosition pos, @Nullable Chunk chunk) {
if(repairedChunks.add(pos)) {
if(chunk == null) {
chunk = pos.getChunk(match.getWorld());
}
for(BlockState state : chunk.getTileEntities()) {
if(state instanceof Skull) {
if(!NMSHacks.isSkullCached((Skull) state)) {
Location loc = state.getLocation();
broadcastDeveloperWarning("Uncached skull \"" + ((Skull) state).getOwner() + "\" at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ());
}
}
}
// Replace formerly invisible half-iron-door blocks with barriers
for(Block ironDoor : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) {
BlockFace half = (ironDoor.getData() & 8) == 0 ? BlockFace.DOWN : BlockFace.UP;
if(ironDoor.getRelative(half.getOppositeFace()).getType() != Material.IRON_DOOR_BLOCK) {
ironDoor.setType(Material.BARRIER, false);
}
}
// Remove all block 36 and remember the ones at y=0 so VoidFilter can check them
for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) {
if(block36.getY() == 0) {
block36Locations.add(block36.getX(), block36.getY(), block36.getZ());
}
block36.setType(Material.AIR, false);
}
}
}
示例4: load
import org.bukkit.Chunk; //導入方法依賴的package包/類
void load(Chunk chunk) {
if(chunks.add(ChunkLocation.of(chunk))) {
for(BlockState blockState : chunk.getTileEntities()) {
if(blockState instanceof Sign) {
final SignHandle sign = createSign((Sign) blockState);
if(sign != null) {
signs.put(blockState.getLocation(), sign);
}
}
}
logger.fine(() -> "Loaded chunk " + chunk.getX() + "," + chunk.getZ() +" with " + signs.size());
}
}
示例5: WorldInfo
import org.bukkit.Chunk; //導入方法依賴的package包/類
public WorldInfo(World world) {
this.worldName = world.getName();
this.totalOnline = world.getPlayers().size();
for (Entity entity : world.getEntities()) {
this.totalEntity++;
if (entity instanceof Animals) {
this.totalAnimals++;
} else if (entity instanceof Monster) {
this.totalMonsters++;
} else if (entity instanceof Item) {
this.totalDropItem++;
}
}
for (Chunk loadedChunk : world.getLoadedChunks()) {
this.totalChunk++;
for (BlockState tiles : loadedChunk.getTileEntities()) {
this.totalTiles++;
if (tiles instanceof Hopper) {
this.totalHopper++;
} else if (tiles instanceof Chest) {
this.totalChest++;
} else if (tiles instanceof Dispenser) {
this.totalDispenser++;
} else if (tiles instanceof Dropper) {
this.totalDropper++;
} else if (tiles instanceof BrewingStand) {
this.totalBrewingStand++;
}
}
}
}
示例6: searchForMarkers
import org.bukkit.Chunk; //導入方法依賴的package包/類
/**
* Searches the map for "markers". Most of the time these are implemented as tile entities (skulls)
*
* @param map the map to scan
* @param center the center location
* @param range the range in where to scan
*/
public void searchForMarkers(@Nonnull Map map, @Nonnull Vector3D center, int range, @Nonnull UUID gameid) {
World world = Bukkit.getWorld(map.getLoadedName(gameid));
if (world == null) {
throw new MapException("Could not find world " + map.getLoadedName(gameid) + "(" + map.getInfo().getName() + ")" + ". Is it loaded?");
}
List<Marker> markers = new ArrayList<>();
List<ChestMarker> chestMarkers = new ArrayList<>();
int startX = (int) center.getX();
int startY = (int) center.getZ();
int minX = Math.min(startX - range, startX + range);
int minZ = Math.min(startY - range, startY + range);
int maxX = Math.max(startX - range, startX + range);
int maxZ = Math.max(startY - range, startY + range);
for (int x = minX; x <= maxX; x += 16) {
for (int z = minZ; z <= maxZ; z += 16) {
Chunk chunk = world.getChunkAt(x >> 4, z >> 4);
for (BlockState te : chunk.getTileEntities()) {
if (te.getType() == Material.SKULL) {
Skull skull = (Skull) te;
if (skull.getSkullType() == SkullType.PLAYER) {
String markerData = getMarkerData(skull);
if (markerData == null) continue;
MarkerDefinition markerDefinition = mapHandler.createMarkerDefinition(markerData);
markers.add(new Marker(new Vector3D(skull.getX(), skull.getY(), skull.getZ()),
DirectionUtil.directionToYaw(skull.getRotation()),
markerData, markerDefinition));
}
} else if (te.getType() == Material.CHEST) {
Chest chest = (Chest) te;
String name = chest.getBlockInventory().getName();
ItemStack[] items = new ItemStack[chest.getBlockInventory()
.getStorageContents().length];
for (int i = 0; i < items.length; i++) {
ItemStack is = chest.getBlockInventory().getItem(i);
if (is == null) {
items[i] = new ItemStack(Material.AIR);
} else {
items[i] = is;
}
}
chestMarkers
.add(new ChestMarker(new Vector3D(chest.getX(), chest.getY(), chest.getZ()), name,
items));
}
}
}
}
map.setMarkers(markers);
map.setChestMarkers(chestMarkers);
}