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


Java Vector3i類代碼示例

本文整理匯總了Java中com.flowpowered.math.vector.Vector3i的典型用法代碼示例。如果您正苦於以下問題:Java Vector3i類的具體用法?Java Vector3i怎麽用?Java Vector3i使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: vecForDirection

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
/**
 * Find out which vector is more towards the given direction relative to the
 * other.
 */
public static Vector3i vecForDirection(EnumFacing direction, Vector3i pos1, Vector3i pos2) {
    int pos1ToPos2 = pos1.distanceSquared(pos2);
    if (pos1ToPos2 == 0) {
        // same vector!
        return pos1;
    }
    int moved1ToPos2 = pos1.add(toFlow(direction.getDirectionVec())).distanceSquared(pos2);
    if (pos1ToPos2 >= moved1ToPos2) {
        // it moved closer to pos2, therefore pos2 is more
        return pos2;
    } else {
        // it moved away from pos2, therefore pos1 is more
        return pos1;
    }
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:20,代碼來源:VecBridge.java

示例2: getRCCreator

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
private RCCreator getRCCreator(REGION region) {
    int minX = region.getMinimum().getX();
    int maxX = region.getMaximum().getX();
    int minY = region.getMinimum().getY();
    int maxY = region.getMaximum().getY();
    int minZ = region.getMinimum().getZ();
    int maxZ = region.getMaximum().getZ();
    int yDiff = maxY - minY + 1;
    return (cx, cz) -> BRC.fromStream(cx, cz,
            chunkAxis(cx, minX, maxX).mapToObj(x -> {
                return chunkAxis(cz, minZ, maxZ).mapToObj(z -> {
                    return IntStream.iterate(maxY, y -> y - 1)
                            .limit(yDiff)
                            .mapToObj(y -> {
                                if (isInWorld(x, y, z) && isInRegion(region, x, y, z)) {
                                    return new Vector3i(x, y, z);
                                }
                                return null;
                            });
                }).flatMap(Function.identity());
            }).flatMap(Function.identity()).filter(Objects::nonNull));
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:23,代碼來源:BaseRegionChunker.java

示例3: expandRegion

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
@Override
public String expandRegion(EnumFacing direction, int amount) {
    if (amount == 0) {
        return "";
    }
    ExpandOp op = expandOp(amount);
    final String partialDesc = " the selection " + op.directionName(direction) + " by " + op.amount(amount) + " block(s)";
    if (op == ExpandOp.CONTRACT) {
        // verify this won't move too far
        int pos1Axis = VecBridge.getAxisValue(direction.getAxis(), region.getPos1());
        int pos2Axis = VecBridge.getAxisValue(direction.getAxis(), region.getPos2());
        if (Math.abs(pos1Axis - pos2Axis) < Math.abs(amount)) {
            // this will move one past the other, not allowed!
            throw new IllegalArgumentException("Cannot " + op.presentTense + partialDesc + ", it is too small in that direction.");
        }
    }
    Vector3i moveVec = VecBridge.toFlow(direction.getDirectionVec()).mul(amount);
    if (VecBridge.vecForDirection(direction, region.getPos1(), region.getPos2()) == region.getPos1()) {
        // move pos1
        region.setPos1(region.getPos1().add(moveVec));
    } else {
        // move pos1
        region.setPos2(region.getPos2().add(moveVec));
    }
    return op.pastTense + partialDesc + ".";
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:27,代碼來源:BoxRegionSelector.java

示例4: dueProcess

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
private void dueProcess(PlayerInteractEvent event, BiFunction<RegionSelector<?, ?>, Vector3i, String> selector) {
    if (event.getWorld().isRemote) {
        // don't process on client
        // perhaps we can cancel on client if we do config sync
        return;
    }

    if (event.getItemStack().getItem() == HardVoxConfig.getSelectionWand()) {
        // cancel event, fire selection
        event.setCanceled(true);

        WorldServer ws = (WorldServer) event.getWorld();
        SessionManager.getInstance()
                .getSession(ws.getMinecraftServer(), event.getEntityPlayer())
                .performRegionCommand(sel -> selector.apply(sel, VecBridge.toFlow(event.getPos())));
        // send an update to the player so the block re-appears?
        ws.getPlayerChunkMap().markBlockForUpdate(event.getPos());
    }
}
 
開發者ID:kenzierocks,項目名稱:HardVox,代碼行數:20,代碼來源:SelectionListener.java

示例5: setPlayerChunkPosition

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public static void setPlayerChunkPosition(UUID playerUUID, Vector3i chunk)
{
    Path playerFile = Paths.get(EagleFactions.getEagleFactions ().getConfigDir().resolve("players") +  "/" + playerUUID.toString() + ".conf");

    try
    {
        ConfigurationLoader<CommentedConfigurationNode> configLoader = HoconConfigurationLoader.builder().setPath(playerFile).build();

        CommentedConfigurationNode playerNode = configLoader.load();

        if(chunk != null)
        {
            playerNode.getNode("chunkPosition").setValue(chunk.toString());
        }
        else
        {
            playerNode.getNode("chunkPosition").setValue(null);
        }

        configLoader.save(playerNode);
    }
    catch (Exception exception)
    {
        exception.printStackTrace();
    }
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:27,代碼來源:PlayerService.java

示例6: isClaimed

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public static boolean isClaimed(UUID worldUUID, Vector3i chunk)
{
    for (String factionName: getFactionsNames())
    {
        List<String> factionClaims = getClaims(factionName);

        if(!factionClaims.isEmpty() && factionClaims != null)
        {
            for (String claim: factionClaims)
            {
                if(claim.equalsIgnoreCase(worldUUID.toString() + "|" + chunk.toString()))
                {
                    return true;
                }
            }
        }
    }
    return false;
}
 
開發者ID:Aquerr,項目名稱:EagleFactions,代碼行數:20,代碼來源:FactionLogic.java

示例7: inspect

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public synchronized void inspect(Player p, UUID world, Vector3i pos) {		
	Connection c = db.getConnection();
	LookupResult lookup = null;
	
	try {			
		PreparedStatement ps = c.prepareStatement(QueryHelper.INSPECT_BLOCK_QUERY);
		ps.setInt(1, pos.getX());
		ps.setInt(2, pos.getY());
		ps.setInt(3, pos.getZ());
		ps.setString(4, world.toString());
		ResultSet result = ps.executeQuery();
		
		lookup = new BlockLookupResult(result);
		LookupResultManager.instance().setLookupResult(p, lookup);
		
		result.close();
		c.close();
	} catch (SQLException e) {
		e.printStackTrace();
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AC] ", TextColors.RED, "A database error has occurred! Contact your server administrator!"));
		return;
	}

	lookup.showPage(p, 1);
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:26,代碼來源:InspectManager.java

示例8: inspectContainer

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public synchronized void inspectContainer(Player p, UUID world, Vector3i pos) {
	Connection c = db.getConnection();
	ContainerLookupResult lookup = null;
	
	try {
		PreparedStatement ps = c.prepareStatement(QueryHelper.INSPECT_CONTAINER_QUERY);
		ps.setInt(1, pos.getX());
		ps.setInt(2, pos.getY());
		ps.setInt(3, pos.getZ());
		ps.setString(4, world.toString());
		ResultSet result = ps.executeQuery();
		
		lookup = new ContainerLookupResult(result);
		LookupResultManager.instance().setLookupResult(p, lookup);
		
		result.close();
		c.close();
	} catch (SQLException e) {
		e.printStackTrace();
		p.sendMessage(Text.of(TextColors.DARK_AQUA, "[AC] ", TextColors.RED, "A database error has occurred! Contact your server administrator!"));
		return;
	}
	
	lookup.showPage(p, 1);
}
 
開發者ID:Karanum,項目名稱:AdamantineShield,代碼行數:26,代碼來源:InspectManager.java

示例9: fireDropItemEvent

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
private void fireDropItemEvent(World world, Vector3i pos) {
    List<ItemStack> stacks = getDroppedItems();
    if (stacks.isEmpty()) {
        return;
    }
    List<Entity> entities = Lists.newArrayList();
    for (ItemStack stack : stacks) {
        Entity drop = createItemDrop(world, pos, stack);
        entities.add(drop);
    }
    Cause cause = Cause.source(BlockSpawnCause.builder()
            .type(SpawnTypes.DROPPED_ITEM)
            .block(world.createSnapshot(pos))
            .build())
            .build();
    DropItemEvent.Destruct harvestEvent = SpongeEventFactory.createDropItemEventDestruct(cause, entities);
    if (Sponge.getEventManager().post(harvestEvent)) {
        return;
    }
    for (Entity entity : harvestEvent.getEntities()) {
        world.spawnEntity(entity, cause);
    }
}
 
開發者ID:simon816,項目名稱:Industrialization,代碼行數:24,代碼來源:PipeBlock.java

示例10: onTick

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public void onTick() {
    // Grab the first 50 (or all entries) in the queue
    List<Vector3i> willTick = new ArrayList<>();
    Vector3i location;
    while (willTick.size() < MAXIMUM_BLOCKS_TICKED_PER_TICK && ((location = blocksToTick.poll()) != null)) {
        willTick.add(location);
    }

    // Try to tick all blocks.
    for (Vector3i vector3i : willTick) {
        // Make sure the relevant chunk is loaded.
        Optional<Block> blockOptional = level.getBlockIfChunkLoaded(vector3i);
        if (!blockOptional.isPresent()) {
            // Can't tick because chunk isn't loaded, continue.
            blocksToTick.add(vector3i);
            continue;
        }

        Block block = blockOptional.get();
        BlockBehavior behavior = BlockBehaviors.getBlockBehavior(block.getBlockState().getBlockType());
        if (!behavior.handleBlockTick(level.getServer(), block)) {
            blocksToTick.add(vector3i);
        }
    }
}
 
開發者ID:voxelwind,項目名稱:voxelwind,代碼行數:26,代碼來源:LevelBlockManager.java

示例11: addTarget

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
public void addTarget(BlockSnapshot pistonBlock, EnhancedCustomBlock block, BlockData blockData,
        Vector3i blockPos) {
    Direction pistonFacing = pistonBlock.getState().get(Keys.DIRECTION).get();
    boolean isRetracting;
    if (pistonBlock.getState().getType() == BlockTypes.PISTON_EXTENSION) {
        // Followed up from sticky piston - retraction has cause of the piston extension
        // See CustomBlockEventListeners#getPistonCause
        isRetracting = true;
    } else {
        isRetracting = pistonBlock.getState().get(Keys.EXTENDED).get();
    }
    Vector3i destPos;
    if (isRetracting) {
        destPos = blockPos.sub(pistonFacing.asBlockOffset());
    } else {
        destPos = blockPos.add(pistonFacing.asBlockOffset());
    }
    this.locations.put(destPos, new Tuple<>(blockPos, new ImmutablePair<>(block, blockData)));
}
 
開發者ID:simon816,項目名稱:Industrialization,代碼行數:20,代碼來源:WorldManager.java

示例12: writeTo

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
@Override
public void writeTo(DataView data) {
    DataList<DataView> blockList = Utils.createListView();
    for (Entry<Vector3i, BlockNature> entry : this.trackedBlocks.entrySet()) {
        DataView blockDataView = blockList.next();
        Vector3i pos = entry.getKey();
        BlockNature block = entry.getValue();
        blockDataView.set(of("position"), pos);
        DataView blockView = blockDataView.createView(of("block"));
        blockView.set(of("id"), block.getId());
        block.writeDataAt(this, pos, blockView);
        BlockData blockData = this.trackedBlockData.get(pos);
        if (blockData != null) {
            blockDataView.set(of("blockData"), blockData);
        }
    }
    data.set(of("blocks"), blockList.getList());
    DataList<DataView> entityList = Utils.createListView();
    for (CustomEntity customEntity : this.trackedCustomEntities) {
        customEntity.writeTo(entityList.next());
    }
    data.set(of("entities"), entityList.getList());
}
 
開發者ID:simon816,項目名稱:Industrialization,代碼行數:24,代碼來源:WorldManager.java

示例13: commandTree

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
private CompletableFuture<Boolean> commandTree(final EPlayer player, PopulatorObject generator) throws CommandException {
	Optional<Vector3i> block = player.getViewBlock();
	
	// Aucun block
	if (!block.isPresent()) {
		EAMessages.PLAYER_NO_LOOK_BLOCK.sender()
			.prefix(EEMessages.PREFIX)
			.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	Vector3i location = block.get().add(0, 1, 0);
	
	// Impossible de le placer
	if (!generator.canPlaceAt(player.getWorld(), location.getX(), location.getY(), location.getZ())) {
		if (!generator.equals(PopulatorObjects.DESERT_WELL)) {
			EEMessages.TREE_NO_CAN_DIRT.sendTo(player);
		} else {
			EEMessages.TREE_NO_CAN_SAND.sendTo(player);
		}
	}
		
	generator.placeObject(player.getWorld(), player.getRandom(), location.getX(), location.getY(), location.getZ());
	return CompletableFuture.completedFuture(true);
}
 
開發者ID:EverCraft,項目名稱:EverEssentials,代碼行數:26,代碼來源:EETree.java

示例14: onInteract

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
/** protect playershop crates */
	
	@Listener
	public void onInteract(InteractBlockEvent event) {
		Optional<Player> source = event.getCause().first(Player.class);
		if (!source.isPresent()) return;
		if (!event.getTargetBlock().getLocation().isPresent()) return;
		Extent tex = event.getTargetBlock().getLocation().get().getExtent();
		Vector3i tv3 = event.getTargetBlock().getPosition(); 
		for (NPCguard g : VillagerShops.npcs)
			if (g.playershopcontainer != null && 
					g.playershopcontainer.getExtent().equals(tex) &&
					g.playershopcontainer.getBlockPosition().equals(tv3)) {
//				VillagerShops.l("Is Stock Container");
				if (	( g.playershopholder!=null && !g.playershopholder.equals(source.get().getUniqueId()) ) &&
						( !source.get().hasPermission("vshop.edit.admin")) ) {
//					VillagerShops.l("But not yours!");
					event.setCancelled(true);
					return;
				}
			}
	}
 
開發者ID:DosMike,項目名稱:VillagerShops,代碼行數:23,代碼來源:EventListeners.java

示例15: commandJump

import com.flowpowered.math.vector.Vector3i; //導入依賴的package包/類
private CompletableFuture<Boolean> commandJump(final EPlayer player) {
	Optional<Vector3i> block = player.getViewBlock();
	
	if (!block.isPresent()) {
		EAMessages.PLAYER_NO_LOOK_BLOCK.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}	
	
	if (!player.teleportSafe(player.getWorld().getLocation(block.get().add(0, 1, 0)), false)) {
		EEMessages.JUMP_TELEPORT_ERROR.sendTo(player);
		return CompletableFuture.completedFuture(false);
	}
	
	EEMessages.JUMP_TELEPORT.sendTo(player);
	return CompletableFuture.completedFuture(true);
}
 
開發者ID:EverCraft,項目名稱:EverEssentials,代碼行數:17,代碼來源:EEJump.java


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