本文整理汇总了Java中com.flowpowered.math.vector.Vector2i.getX方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2i.getX方法的具体用法?Java Vector2i.getX怎么用?Java Vector2i.getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.flowpowered.math.vector.Vector2i
的用法示例。
在下文中一共展示了Vector2i.getX方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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));
}
}
示例3: 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);
}
示例4: slot
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
@Builder(
builderMethodName = "slotBuilder",
builderClassName = "SimpleCustomInventoryDefinitionBuilderSlotBuilder"
)
public SimpleCustomInventoryDefinitionBuilder slot(String slotId, Vector2i position, boolean persistent, AffectCustomSlotListener affectCustomSlotListener, @NonNull GUIFeature defaultFeature, GUIFeature... additionalFeatures) {
Preconditions.checkNotNull(highPrioritySlots, "The height must be set first.");
highPrioritySlots[position.getY()][position.getX()] =
CustomSlotDefinition.create(position, slotId, persistent, affectCustomSlotListener, defaultFeature, Arrays.asList(additionalFeatures));
return this;
}
示例5: emptySlot
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
@Builder(
builderMethodName = "emptySlotBuilder",
builderClassName = "SimpleCustomInventoryDefinitionBuilderEmptySlotBuilder"
)
public SimpleCustomInventoryDefinitionBuilder emptySlot(String slotId, Vector2i position, boolean persistent, AffectCustomSlotListener affectCustomSlotListener) {
highPrioritySlots[position.getY()][position.getX()] =
CustomSlotDefinition.createEmpty(position, slotId, persistent, affectCustomSlotListener != null ? affectCustomSlotListener
: (customSlot, slotTransaction, affectSlotEvent) -> {});
return this;
}
示例6: getForced
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
/**
* Gets a map with all the forced chunk and the assigned tickets.
*
* @return the tickets
*/
public ImmutableSetMultimap<Vector3i, LoadingTicket> getForced() {
final ImmutableSetMultimap.Builder<Vector3i, LoadingTicket> builder =
ImmutableSetMultimap.builder();
for (Entry<Vector2i, Set<ChunkLoadingTicket>> en : this.ticketsByPos.entrySet()) {
final Vector2i pos0 = en.getKey();
final Vector3i pos = new Vector3i(pos0.getX(), 0, pos0.getY());
for (ChunkLoadingTicket ticket : en.getValue()) {
builder.put(pos, ticket);
}
}
return builder.build();
}
示例7: force
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
/**
* Forces the specified chunk coordinates for a specific ticket.
*
* @param ticket the ticket
* @param coords the coordinates
* @param callEvents whether the force chunk events should be called
*/
void force(LanternLoadingTicket ticket, Vector2i coords, boolean callEvents) {
final LanternChunk chunk = getChunk(coords, false);
// The chunk at this coords is already loaded,
// wa can call the event directly
lockInternally(coords, ticket);
// Remove from unload through loadChunk
this.pendingForUnload.removeIf(e -> e.coords.equals(coords));
// Whether the chunk should be queued for loading
boolean queueLoad = false;
if (chunk != null) {
if (chunk.lock.isLocked() && chunk.lockState == LanternChunk.LockState.UNLOADING) {
queueLoad = true;
}
// Queue the chunk to load
} else {
queueLoad = true;
}
if (queueLoad) {
LanternChunkQueueTask task = this.chunkQueueTasks.get(coords);
if (task == null || !(task.runnable instanceof LanternChunkLoadTask)) {
this.chunkQueueTasks.computeIfAbsent(coords, coords1 ->
queueTask(coords1, new LanternChunkLoadTask(coords1)));
}
}
if (callEvents) {
final Vector3i coords0 = new Vector3i(coords.getX(), 0, coords.getY());
final CauseStack causeStack = CauseStack.currentOrNull();
if (causeStack != null) {
postForcedChunkEvent(causeStack, ticket, coords0);
} else {
Lantern.getScheduler().callSync(() -> postForcedChunkEvent(CauseStack.current(), ticket, coords0));
}
}
}
示例8: chopBuffer
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
/**
* Chops a buffer to the specified width, height, and possibly an extra
* dimension.
*
* The returned buffer is rewinded.
*
* @param buf
* - the buffer to shrink
* @param oldWidthHeight
* - the old width and height (should multiply with
* extraDimensions to equal buf.capacity())
* @param choppedWidth
* - the new (smaller) width
* @param choppedHeight
* - the new (smaller) height
* @param extraDimensions
* - any extra dimensions, like bytes of color that should be
* kept together. Should be 1 if there is none.
* @return the chopped buffer
*/
public static ByteBuffer
chopBuffer(ByteBuffer buf, Vector2i oldWidthHeight, int choppedWidth, int choppedHeight, int extraDimensions) {
if (buf.capacity() < choppedWidth * choppedHeight * extraDimensions || oldWidthHeight.getX() < choppedHeight
|| oldWidthHeight.getY() < choppedWidth || extraDimensions < 1) {
throw new IndexOutOfBoundsException("One of the dimensions is breaking the bounds of the buffer!");
}
if (buf.capacity() > buf.remaining()) {
buf.rewind();
}
ByteBuffer newBuf = ByteBuffer.allocateDirect(choppedWidth * choppedHeight * extraDimensions);
byte[][][] arrayOfStuff = new byte[choppedWidth][choppedHeight][extraDimensions];
for (int i = 0; i < oldWidthHeight.getX() * oldWidthHeight.getY() * extraDimensions; i += extraDimensions) {
int x = i / extraDimensions / oldWidthHeight.getX();
int y = i / extraDimensions % oldWidthHeight.getY();
LUtils.print("x/y=" + String.format("%s/%s", x, y));
if (x >= choppedWidth || y >= choppedHeight) {
continue;
}
for (int extra = 0; extra < extraDimensions; extra++) {
arrayOfStuff[x][y][extra] = buf.get(i + extra);
}
}
for (byte[][] b2d : arrayOfStuff) {
for (byte[] b1d : b2d) {
for (byte b : b1d) {
newBuf.put(b);
}
}
}
newBuf.rewind();
return newBuf;
}
示例9: Rect
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
public Rect(UUID world, Vector2i point)
{
this(world, point.getX(), point.getX(), point.getY(), point.getY());
}
示例10: isInside
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
public boolean isInside(Vector2i point)
{
return minX <= point.getX() && point.getX() <= maxX && minY <= point.getY() && point.getY() <= maxY;
}
示例11: isAdjacent
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
public boolean isAdjacent(Vector2i point)
{
return this.minX - 1 <= point.getX() && point.getX() <= this.maxX + 1 && this.minY - 1 <= point.getY() && point.getY() <= this.maxY + 1;
}
示例12: inBounds
import com.flowpowered.math.vector.Vector2i; //导入方法依赖的package包/类
public static boolean inBounds(int x, int y, Vector2i min, Vector2i max) {
return x >= min.getX() && x <= max.getX() && y >= min.getY() && y <= max.getY();
}