net.minecraft.util.math.BlockPos.compareTo()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.0k)|赞(0)|评价(0)|浏览(75)

本文整理了Java中net.minecraft.util.math.BlockPos.compareTo()方法的一些代码示例,展示了BlockPos.compareTo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockPos.compareTo()方法的具体详情如下:
包路径:net.minecraft.util.math.BlockPos
类名称:BlockPos
方法名:compareTo

BlockPos.compareTo介绍

暂无

代码示例

代码示例来源:origin: McJtyMods/XNet

@Override
  public int compareTo(SidedPos o) {
    int result = pos.compareTo(o.pos);
    if(result == 0) result = side.compareTo(o.side);
    return result;
  }
}

代码示例来源:origin: amadornes/MCMultiPart

public void sort() {
  // group by same position and same slot id
  changes.sort((a1, a2) -> {
    int i = a1.pos.compareTo(a2.pos);
    if (i != 0) {
      return i;
    } else {
      return SlotRegistry.INSTANCE.getSlotID(a2.slot) - SlotRegistry.INSTANCE.getSlotID(a1.slot);
    }
  });
}

代码示例来源:origin: ForestryMC/ForestryMC

private int _shouldConsume(IMultiblockControllerInternal otherController) {
  BlockPos myCoord = getReferenceCoord();
  BlockPos theirCoord = otherController.getReferenceCoord();
  // Always consume other controllers if their reference coordinate is null - this means they're empty and can be assimilated on the cheap
  if (theirCoord == null || myCoord == null) {
    return -1;
  } else {
    return myCoord.compareTo(theirCoord);
  }
}

代码示例来源:origin: raoulvdberge/refinedstorage

@Override
public void rebuild() {
  this.patterns.clear();
  this.containerInventories.clear();
  List<ICraftingPatternContainer> containers = new ArrayList<>();
  for (INetworkNode node : network.getNodeGraph().all()) {
    if (node instanceof ICraftingPatternContainer && node.canUpdate()) {
      containers.add((ICraftingPatternContainer) node);
    }
  }
  containers.sort((a, b) -> b.getPosition().compareTo(a.getPosition()));
  for (ICraftingPatternContainer container : containers) {
    this.patterns.addAll(container.getPatterns());
    IItemHandlerModifiable handler = container.getPatternInventory();
    if (handler != null) {
      this.containerInventories.computeIfAbsent(container.getName(), k -> new ArrayList<>()).add(handler);
    }
  }
}

代码示例来源:origin: ForestryMC/ForestryMC

@Override
public void assimilate(IMultiblockControllerInternal other) {
  BlockPos otherReferenceCoord = other.getReferenceCoord();
  BlockPos referenceCoord = getReferenceCoord();
  if (otherReferenceCoord != null && referenceCoord != null && referenceCoord.compareTo(otherReferenceCoord) >= 0) {
    throw new IllegalArgumentException("The controller with the lowest minimum-coord value must consume the one with the higher coords");
  }
  Set<IMultiblockComponent> partsToAcquire = new HashSet<>(other.getComponents());
  // releases all blocks and references gently so they can be incorporated into another multiblock
  other._onAssimilated(this);
  for (IMultiblockComponent acquiredPart : partsToAcquire) {
    // By definition, none of these can be the minimum block.
    if (isInvalid(acquiredPart)) {
      continue;
    }
    connectedParts.add(acquiredPart);
    MultiblockLogic logic = (MultiblockLogic) acquiredPart.getMultiblockLogic();
    logic.setController(this);
    this.onBlockAdded(acquiredPart);
  }
  this.onAssimilate(other);
  other.onAssimilated(this);
}

代码示例来源:origin: ForestryMC/ForestryMC

referenceCoord = c;
  referencePart = part;
} else if (c.compareTo(referenceCoord) < 0) {
  referenceCoord = c;
  referencePart = part;

代码示例来源:origin: ForestryMC/ForestryMC

@Nullable
private BlockPos selectNewReferenceCoord() {
  IChunkProvider chunkProvider = world.getChunkProvider();
  IMultiblockComponent theChosenOne = null;
  referenceCoord = null;
  for (IMultiblockComponent part : connectedParts) {
    BlockPos partCoord = part.getCoordinates();
    if (isInvalid(part) || chunkProvider.getLoadedChunk(partCoord.getX() >> 4, partCoord.getZ() >> 4) == null) {
      // Chunk is unloading, skip this coord to prevent chunk thrashing
      continue;
    }
    if (referenceCoord == null || referenceCoord.compareTo(partCoord) > 0) {
      referenceCoord = part.getCoordinates();
      theChosenOne = part;
    }
  }
  if (theChosenOne != null) {
    MultiblockLogic logic = (MultiblockLogic) theChosenOne.getMultiblockLogic();
    logic.becomeMultiblockSaveDelegate();
  }
  return referenceCoord;
}

代码示例来源:origin: ForestryMC/ForestryMC

referenceCoord = coord;
  logic.becomeMultiblockSaveDelegate();
} else if (coord.compareTo(referenceCoord) < 0) {
  TileUtil.actOnTile(world, referenceCoord, IMultiblockComponent.class, tile -> {
    MultiblockLogic teLogic = (MultiblockLogic) tile.getMultiblockLogic();

相关文章