當前位置: 首頁>>代碼示例>>Java>>正文


Java ItemFrame.getLocation方法代碼示例

本文整理匯總了Java中org.bukkit.entity.ItemFrame.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java ItemFrame.getLocation方法的具體用法?Java ItemFrame.getLocation怎麽用?Java ItemFrame.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.ItemFrame的用法示例。


在下文中一共展示了ItemFrame.getLocation方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ItemFrameStorage

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public ItemFrameStorage(ItemFrame frame, Location attachedLoc) throws CivException {
		if (frame != null) {
			this.frameID = frame.getUniqueId();
			this.location = frame.getLocation();
			this.attachedBlock = new BlockCoord(attachedLoc);
			CivGlobal.addProtectedItemFrame(this);
		} else {
			throw new CivException("Passed a null item frame to storage constructor.");
		}
		
//		this.frame = frame;
//		if (this.frame != null) {
//			CivGlobal.addProtectedItemFrame(this);
//		} else {
//			CivLog.error("Passed a null item frame!!!");
//			throw new CivException("Passed a null item frame.");
//		}
	}
 
開發者ID:netizen539,項目名稱:civcraft,代碼行數:19,代碼來源:ItemFrameStorage.java

示例2: 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;
}
 
開發者ID:Howaner,項目名稱:FramePicture,代碼行數:19,代碼來源:FrameManager.java

示例3: FrameInfo

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
public FrameInfo(Frame type, ItemFrame frame) {
    this.type = type;
    id = frame.getUniqueId();

    Location loc = frame.getLocation();
    Chunk chunk = loc.getChunk();

    worldId = chunk.getWorld().getUID();
    chunk_x = chunk.getX();
    chunk_z = chunk.getZ();

    instance = new WeakReference<ItemFrame>(frame);
}
 
開發者ID:stendec,項目名稱:Abyss,代碼行數:14,代碼來源:FrameInfo.java

示例4: 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;
}
 
開發者ID:Howaner,項目名稱:FramePicture,代碼行數:42,代碼來源:FrameManager.java

示例5: onPlayerInteract

import org.bukkit.entity.ItemFrame; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.useItemInHand() == Event.Result.DENY) return;

    Player player = event.getPlayer();
    FawePlayer<Object> fp = FawePlayer.wrap(player);
    if (fp.getMeta("CFISettings") == null) return;
    try {
        if (event.getHand() == EquipmentSlot.OFF_HAND) return;
    } catch (NoSuchFieldError | NoSuchMethodError ignored) {}

    List<Block> target = player.getLastTwoTargetBlocks((Set<Material>) null, 100);
    if (target.isEmpty()) return;

    Block targetBlock = target.get(0);
    World world = player.getWorld();
    mutable.setWorld(world);
    mutable.setX(targetBlock.getX() + 0.5);
    mutable.setY(targetBlock.getY() + 0.5);
    mutable.setZ(targetBlock.getZ() + 0.5);
    Collection<Entity> entities = world.getNearbyEntities(mutable, 0.46875, 0, 0.46875);

    if (!entities.isEmpty()) {
        Action action = event.getAction();
        boolean primary = action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;

        double minDist = Integer.MAX_VALUE;
        ItemFrame minItemFrame = null;

        for (Entity entity : entities) {
            if (entity instanceof ItemFrame) {
                ItemFrame itemFrame = (ItemFrame) entity;
                Location loc = itemFrame.getLocation();
                double dx = loc.getX() - mutable.getX();
                double dy = loc.getY() - mutable.getY();
                double dz = loc.getZ() - mutable.getZ();
                double dist = dx * dx + dy * dy + dz * dz;
                if (dist < minDist) {
                    minItemFrame = itemFrame;
                    minDist = dist;
                }
            }
        }
        if (minItemFrame != null) {
            handleInteract(event, minItemFrame, primary);
            if (event.isCancelled()) return;
        }
    }
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:50,代碼來源:BukkitImageListener.java


注:本文中的org.bukkit.entity.ItemFrame.getLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。