本文整理匯總了Java中org.bukkit.entity.ItemFrame.getFacing方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame.getFacing方法的具體用法?Java ItemFrame.getFacing怎麽用?Java ItemFrame.getFacing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.entity.ItemFrame
的用法示例。
在下文中一共展示了ItemFrame.getFacing方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public Frame addFrame(String pictureURL, ItemFrame entity) {
Frame frame = new Frame(this.getNewFrameID(), pictureURL, entity.getLocation(), entity.getFacing());
frame.setEntity(entity);
if (frame.getBufferImage() == null) {
return null;
}
Chunk chunk = entity.getLocation().getChunk();
List<Frame> frameList = this.getFramesInChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
frameList.add(frame);
this.setFramesInChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ(), frameList);
Utils.setFrameItemWithoutSending(entity, new ItemStack(Material.AIR));
this.sendFrame(frame);
this.saveFrames();
return frame;
}
示例2: addMultiFrames
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public List<Frame> addMultiFrames(BufferedImage img, ItemFrame[] frames, int vertical, int horizontal) {
if (frames.length == 0 || horizontal <= 0) return null;
img = Utils.scaleImage(img, img.getWidth() * vertical, img.getHeight() * horizontal);
int width = img.getWidth() / vertical;
int height = img.getHeight() / horizontal;
List<Frame> frameList = new ArrayList<Frame>();
int globalId = this.getNewFrameID();
int id = globalId;
//y = Horizontal
for (int y = 0; y < horizontal; y++) {
//x = Vertical
for (int x = 0; x < vertical; x++) {
BufferedImage frameImg = Utils.cutImage(img, x * width, y * height, width, height);
frameImg = Utils.scaleImage(frameImg, 128, 128, false);
File file = this.pictureDB.writeImage(frameImg, String.format("Frame%s_%s-%s", globalId, x, y));
ItemFrame entity = frames[vertical * y + x];
Utils.setFrameItemWithoutSending(entity, new ItemStack(Material.AIR));
Frame frame = this.getFrame(entity);
if (frame != null)
this.removeFrame(frame);
frame = new Frame(globalId, file.getName(), entity.getLocation(), entity.getFacing());
frame.setEntity(entity);
Chunk chunk = frame.getLocation().getChunk();
List<Frame> chunkFrames = this.getFramesInChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ());
chunkFrames.add(frame);
this.setFramesInChunk(chunk.getWorld().getName(), chunk.getX(), chunk.getZ(), chunkFrames);
globalId++;
frameList.add(frame);
this.sendFrame(frame);
}
}
this.saveFrames();
return frameList;
}
示例3: getItemFrameFromChunk
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public static ItemFrame getItemFrameFromChunk(Chunk chunk, Location loc, BlockFace face) {
for (Entity entity : chunk.getEntities()) {
if ((entity.getType() == EntityType.ITEM_FRAME) && isSameLocation(entity.getLocation(), loc)) {
ItemFrame frameEntity = (ItemFrame)entity;
if ((face == null) || (frameEntity.getFacing() == face)) {
return frameEntity;
}
}
}
return null;
}
示例4: selectFrame
import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public void selectFrame(ItemFrame start) {
Location pos1 = start.getLocation().clone();
Location pos2 = start.getLocation().clone();
BlockFace facing = start.getFacing();
int planeX = facing.getModX() == 0 ? 1 : 0;
int planeY = facing.getModY() == 0 ? 1 : 0;
int planeZ = facing.getModZ() == 0 ? 1 : 0;
ItemFrame[][] res = find(pos1, pos2, facing);
Location tmp;
while (true) {
if (res != null) {
frames = res;
}
tmp = pos1.clone().subtract(planeX, planeY, planeZ);
if ((res = find(tmp, pos2, facing)) != null) {
pos1 = tmp;
continue;
}
tmp = pos2.clone().add(planeX, planeY, planeZ);
if ((res = find(pos1, tmp, facing)) != null) {
pos2 = tmp;
continue;
}
tmp = pos1.clone().subtract(planeX, 0, planeZ);
if ((res = find(tmp, pos2, facing)) != null) {
pos1 = tmp;
continue;
}
tmp = pos2.clone().add(planeX, 0, planeZ);
if ((res = find(pos1, tmp, facing)) != null) {
pos2 = tmp;
continue;
}
tmp = pos1.clone().subtract(0, 1, 0);
if ((res = find(tmp, pos2, facing)) != null) {
pos1 = tmp;
continue;
}
tmp = pos2.clone().add(0, 1, 0);
if ((res = find(pos1, tmp, facing)) != null) {
pos2 = tmp;
continue;
}
break;
}
}