本文整理汇总了Java中com.flowpowered.math.vector.Vector2i类的典型用法代码示例。如果您正苦于以下问题:Java Vector2i类的具体用法?Java Vector2i怎么用?Java Vector2i使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector2i类属于com.flowpowered.math.vector包,在下文中一共展示了Vector2i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isInside
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public boolean isInside(Location<World> loc)
{
Rect extr = extrema.get(loc.getExtent().getUniqueId());
Vector2i p = new Vector2i(loc.getBlockX(), loc.getBlockZ());
if (p.getX() < extr.getMinX() || p.getX() > extr.getMaxX() || p.getY() < extr.getMinY() || p.getY() > extr.getMaxY())
{
return false;
}
for (Rect r : rects)
{
if (r.isInside(p))
{
return true;
}
}
return false;
}
示例2: pointsInside
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public ArrayList<Vector2i> pointsInside(Rect rect)
{
ArrayList<Vector2i> points = new ArrayList<Vector2i>();
Vector2i A = new Vector2i(minX, minY);
if (rect.isInside(A))
points.add(A);
Vector2i B = new Vector2i(minX, maxY);
if (rect.isInside(B))
points.add(B);
Vector2i C = new Vector2i(maxX, minY);
if (rect.isInside(C))
points.add(C);
Vector2i D = new Vector2i(maxX, maxY);
if (rect.isInside(D))
points.add(D);
return points;
}
示例3: addToWorldChunks
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public static void addToWorldChunks(Nation nation)
{
for (Rect r : nation.getRegion().getRects())
{
if (!worldChunks.containsKey(r.getWorld()))
{
worldChunks.put(r.getWorld(), new Hashtable<Vector2i, ArrayList<Nation>>());
}
Hashtable<Vector2i, ArrayList<Nation>> chunks = worldChunks.get(r.getWorld());
for (int i = IntMath.divide(r.getMinX(), 16, RoundingMode.FLOOR); i < IntMath.divide(r.getMaxX(), 16, RoundingMode.FLOOR) + 1; i++)
{
for (int j = IntMath.divide(r.getMinY(), 16, RoundingMode.FLOOR); j < IntMath.divide(r.getMaxY(), 16, RoundingMode.FLOOR) + 1; j++)
{
Vector2i vect = new Vector2i(i, j);
if (!chunks.containsKey(vect))
{
chunks.put(vect, new ArrayList<Nation>());
}
if (!chunks.get(vect).contains(nation))
{
chunks.get(vect).add(nation);
}
}
}
}
}
示例4: unforce
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
/**
* Unforces the specified chunk coordinates for a specific ticket.
*
* @param ticket the ticket
* @param coords the coordinates
*/
void unforce(LanternLoadingTicket ticket, Vector2i coords, @Nullable CauseStack causeStack) {
if (unlockInternally(coords, ticket)) {
final LanternChunk chunk = getChunk(coords, false);
// Try to cancel any queued chunk loadings
if (chunk != null && chunk.lock.isLocked() && chunk.lockState == LanternChunk.LockState.LOADING) {
final LanternChunkQueueTask task = this.chunkQueueTasks.get(coords);
if (task != null && task.runnable instanceof LanternChunkLoadTask) {
task.cancel();
}
// Queue the chunk for unload, will be some ticks later
} else {
final UnloadingChunkEntry entry = new UnloadingChunkEntry(coords);
if (!this.pendingForUnload.contains(entry)) {
this.pendingForUnload.offer(entry);
}
}
}
if (causeStack != null) {
final Vector3i coords0 = new Vector3i(coords.getX(), 0, coords.getY());
Sponge.getEventManager().post(SpongeEventFactory.createUnforcedChunkEvent(causeStack.getCurrentCause(), coords0, ticket));
}
}
示例5: forceChunk
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
@Override
public boolean forceChunk(Vector2i chunk) {
checkNotNull(chunk, "chunk");
synchronized (this.queue) {
if (this.released) {
Lantern.getLogger().warn("The plugin {} attempted to force load a chunk with an invalid ticket. "
+ "This is not permitted.", this.plugin);
return false;
}
// Only force if not done before
if (!this.queue.contains(chunk)) {
// Remove the oldest chunk if necessary
if (this.queue.size() >= this.numChunks) {
this.chunkManager.unforce(this, this.queue.poll(), CauseStack.currentOrEmpty());
}
this.queue.add(chunk);
this.chunkManager.force(this, chunk);
return true;
}
}
return false;
}
示例6: registerSerializers
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public static void registerSerializers(DataManager dataManager) {
dataManager.registerTranslator(UUID.class, UUID_DATA_SERIALIZER);
dataManager.registerTranslator(Vector2d.class, VECTOR_2_D_DATA_SERIALIZER);
dataManager.registerTranslator(Vector2f.class, VECTOR_2_F_DATA_SERIALIZER);
dataManager.registerTranslator(Vector2i.class, VECTOR_2_I_DATA_SERIALIZER);
dataManager.registerTranslator(Vector2l.class, VECTOR_2_L_DATA_SERIALIZER);
dataManager.registerTranslator(Vector3d.class, VECTOR_3_D_DATA_SERIALIZER);
dataManager.registerTranslator(Vector3f.class, VECTOR_3_F_DATA_SERIALIZER);
dataManager.registerTranslator(Vector3i.class, VECTOR_3_I_DATA_SERIALIZER);
dataManager.registerTranslator(Vector3l.class, VECTOR_3_L_DATA_SERIALIZER);
dataManager.registerTranslator(Vector4d.class, VECTOR_4_D_DATA_SERIALIZER);
dataManager.registerTranslator(Vector4f.class, VECTOR_4_F_DATA_SERIALIZER);
dataManager.registerTranslator(Vector4i.class, VECTOR_4_I_DATA_SERIALIZER);
dataManager.registerTranslator(Vector4l.class, VECTOR_4_L_DATA_SERIALIZER);
dataManager.registerTranslator(Complexd.class, COMPLEXD_DATA_SERIALIZER);
dataManager.registerTranslator(Complexf.class, COMPLEXF_DATA_SERIALIZER);
dataManager.registerTranslator(Quaterniond.class, QUATERNIOND_DATA_SERIALIZER);
dataManager.registerTranslator(Quaternionf.class, QUATERNIONF_DATA_SERIALIZER);
dataManager.registerTranslator(LocalTime.class, LOCAL_TIME_DATA_SERIALIZER);
dataManager.registerTranslator(LocalDate.class, LOCAL_DATE_DATA_SERIALIZER);
dataManager.registerTranslator(LocalDateTime.class, LOCAL_DATE_TIME_DATA_SERIALIZER);
dataManager.registerTranslator(ZonedDateTime.class, ZONED_DATE_TIME_DATA_SERIALIZER);
dataManager.registerTranslator(Instant.class, INSTANT_DATA_SERIALIZER);
dataManager.registerTranslator(Month.class, MONTH_DATA_SERIALIZER);
}
示例7: getLastMarkedPoint
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public Vector2i getLastMarkedPoint() throws IllegalStateException {
if (globalBoxList.isEmpty()) {
return new Vector2i(0, 0);
}
globalBoxList.sort((a, b) -> {
Vector3i aMax = a.getMaximumPoint();
Vector3i bMax = b.getMaximumPoint();
if (aMax.getX() < bMax.getX() || aMax.getZ() < bMax.getZ()) {
return -1;
}
return 1;
});
Vector3i lastMax = globalBoxList.get(globalBoxList.size() - 1).getMaximumPoint();
return new Vector2i(lastMax.getX() + 1, lastMax.getZ() + 1);
}
示例8: loadRegion
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
private Region loadRegion(Region region)
{
World world = region.getWorld();
if (world == null) {
logger.warn("Region {} was not loaded: Could not find world {}.", region.getName(), region.getWorldName());
return region;
}
byName.computeIfAbsent(world.getUniqueId(), k -> new HashMap<>()).put(region.getName().toLowerCase(), region);
Vector3d max = region.getCuboid().getMaximumPoint();
Vector3d min = region.getCuboid().getMinimumPoint();
Map<Vector2i, List<Region>> chunkMap = byChunk.computeIfAbsent(region.getWorld().getUniqueId(), k -> new HashMap<>());
for (Vector2i chunkLoc : getChunks(min.toInt(), max.toInt()))
{
chunkMap.computeIfAbsent(chunkLoc, k -> new ArrayList<>()).add(region);
}
return region;
}
示例9: updateOnTick
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
@Override
public void updateOnTick(float delta) {
// For test entities, we can assume there's no other windows for now.
DisplayLayer layer = DisplayLayer.CREATED.values().iterator().next();
Vector2i size = DrawableUtils.getWindowSize(layer);
if (this.pos.x > size.getX() || this.pos.x < 0) {
setXPos(!(this.pos.x > size.getX()) ? size.getX() : 0);
}
if (this.pos.y > size.getY() || this.pos.y < 0) {
setYPos(!(this.pos.y > size.getY()) ? size.getY() : 0);
}
if (Math.sqrt(this.vel.y * this.vel.y + this.vel.x * this.vel.x) < 0.5) {
setTex(BetterArrays.randomArray(TestEntity.texmix)[0]);
}
super.updateOnTick(delta);
doRandomVelocityChange();
setYaw(getYaw() + 1);
}
示例10: isAdjacent
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public boolean isAdjacent(Vector2i point)
{
for (Rect r : rects)
{
if (r.isAdjacent(point))
{
return true;
}
}
return false;
}
示例11: distance
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public float distance(Location<World> loc)
{
float dist = Float.MAX_VALUE;
for (Rect r : rects)
{
if (loc.getExtent().getUniqueId().equals(r.getWorld()))
{
dist = Math.min(dist, r.distance(new Vector2i(loc.getBlockX(), loc.getBlockZ())));
}
}
return dist;
}
示例12: getZone
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public Zone getZone(Location<World> loc)
{
Vector2i p = new Vector2i(loc.getBlockX(), loc.getBlockZ());
for (Zone zone : zones.values())
{
if (zone.getRect().isInside(p))
{
return zone;
}
}
return null;
}
示例13: distance
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public float distance(Vector2i point)
{
if (isInside(point))
{
return 0;
}
return Math.min(
Math.min(
point.distance(new Vector2i(minX, minY)),
point.distance(new Vector2i(minX, maxY))),
Math.min(
point.distance(new Vector2i(maxX, minY)),
point.distance(new Vector2i(maxX, maxY))));
}
示例14: getNation
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public static Nation getNation(Location<World> loc)
{
if (!worldChunks.containsKey(loc.getExtent().getUniqueId()))
{
return null;
}
Vector2i area = new Vector2i(IntMath.divide(loc.getBlockX(), 16, RoundingMode.FLOOR), IntMath.divide(loc.getBlockZ(), 16, RoundingMode.FLOOR));
if (!worldChunks.get(loc.getExtent().getUniqueId()).containsKey(area))
{
return null;
}
for (Nation nation : worldChunks.get(loc.getExtent().getUniqueId()).get(area))
{
if (nation.getRegion().isInside(loc))
{
return nation;
}
}
// for (Entry<Vector2i, ArrayList<Nation>> e : worldChunks.get(loc.getExtent().getUniqueId()).entrySet())
// {
// if (e.getKey().equals(new Vector2i(IntMath.divide(loc.getBlockX(), 16, RoundingMode.FLOOR), IntMath.divide(loc.getBlockZ(), 16, RoundingMode.FLOOR))))
// {
// for (Nation nation : e.getValue())
// {
// if (nation.getRegion().isInside(loc))
// {
// return nation;
// }
// }
// return null;
// }
// }
return null;
}
示例15: calculateWorldChunks
import com.flowpowered.math.vector.Vector2i; //导入依赖的package包/类
public static void calculateWorldChunks()
{
worldChunks = new Hashtable<UUID, Hashtable<Vector2i, ArrayList<Nation>>>();
for (Nation nation : nations.values())
{
addToWorldChunks(nation);
}
}