use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class LogisticsPowerProviderTileEntity method sendPowerLaserPackets.
private void sendPowerLaserPackets(IRouter sourceRouter, IRouter destinationRouter, ForgeDirection exitOrientation, boolean addBall) {
if (sourceRouter == destinationRouter) {
return;
}
LinkedList<Triplet<IRouter, ForgeDirection, Boolean>> todo = new LinkedList<>();
todo.add(new Triplet<>(sourceRouter, exitOrientation, addBall));
while (!todo.isEmpty()) {
Triplet<IRouter, ForgeDirection, Boolean> part = todo.pollFirst();
List<ExitRoute> exits = part.getValue1().getRoutersOnSide(part.getValue2());
for (ExitRoute exit : exits) {
if (exit.containsFlag(PipeRoutingConnectionType.canPowerSubSystemFrom)) {
// Find only result (caused by only straight connections)
int distance = part.getValue1().getDistanceToNextPowerPipe(exit.exitOrientation);
CoreRoutedPipe pipe = part.getValue1().getPipe();
if (pipe != null && pipe.isInitialized()) {
pipe.container.addLaser(exit.exitOrientation, distance, getLaserColor(), false, part.getValue3());
}
// Use new sourceRouter
IRouter nextRouter = exit.destination;
if (nextRouter == destinationRouter) {
return;
}
outerRouters: for (ExitRoute newExit : nextRouter.getDistanceTo(destinationRouter)) {
if (newExit.containsFlag(PipeRoutingConnectionType.canPowerSubSystemFrom)) {
for (IFilter filter : newExit.filters) {
if (filter.blockPower()) {
continue outerRouters;
}
}
todo.addLast(new Triplet<>(nextRouter, newExit.exitOrientation, newExit.exitOrientation != exit.exitOrientation));
}
}
}
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class HUDAdvancedExtractor method renderContent.
@Override
public void renderContent(boolean shifted) {
if (selected == 0) {
Minecraft mc = FMLClientHandler.instance().getClient();
ForgeDirection d = module.getSneakyDirection();
mc.fontRenderer.drawString("Extract", -22, -22, 0);
mc.fontRenderer.drawString("from:", -22, -9, 0);
mc.fontRenderer.drawString(((d == ForgeDirection.UNKNOWN) ? "DEFAULT" : d.name()), -22, 18, 0);
} else {
Minecraft mc = FMLClientHandler.instance().getClient();
GL11.glScalef(1.0F, 1.0F, -0.00001F);
ItemStackRenderer.renderItemIdentifierStackListIntoGui(ItemIdentifierStack.getListFromInventory(module.getFilterInventory()), null, 0, -25, -32, 3, 9, 18, 18, 100.0F, DisplayAmount.NEVER, true, false, shifted);
GL11.glScalef(1.0F, 1.0F, 1 / -0.00001F);
if (module.areItemsIncluded()) {
mc.fontRenderer.drawString("Included", -22, 25, 0);
} else {
mc.fontRenderer.drawString("Excluded", -22, 25, 0);
}
}
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class ChassiTransportLayer method stillWantItem.
@Override
public boolean stillWantItem(IRoutedItem item) {
LogisticsModule module = _chassiPipe.getLogisticsModule();
if (module == null) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (!_chassiPipe.isEnabled()) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
SinkReply reply = module.sinksItem(item.getItemIdentifierStack().getItem(), -1, 0, true, false);
if (reply == null || reply.maxNumberOfItems < 0) {
_chassiPipe.notifyOfItemArival(item.getInfo());
return false;
}
if (reply.maxNumberOfItems > 0 && item.getItemIdentifierStack().getStackSize() > reply.maxNumberOfItems) {
ForgeDirection o = _chassiPipe.getPointedOrientation();
if (o == null || o == ForgeDirection.UNKNOWN) {
o = ForgeDirection.UP;
}
item.split(reply.maxNumberOfItems, o);
}
return true;
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class PipeTransportLayer method itemArrived.
@Override
public ForgeDirection itemArrived(IRoutedItem item, ForgeDirection denyed) {
if (item.getItemIdentifierStack() != null) {
_trackStatistics.recievedItem(item.getItemIdentifierStack().getStackSize());
}
List<AdjacentTileEntity> adjacentEntities = new WorldCoordinatesWrapper(routedPipe.container).getConnectedAdjacentTileEntities(IPipeInformationProvider.ConnectionPipeType.ITEM).collect(Collectors.toList());
LinkedList<ForgeDirection> possibleForgeDirection = new LinkedList<>();
for (AdjacentTileEntity adjacent : adjacentEntities) {
if (SimpleServiceLocator.pipeInformationManager.isItemPipe(adjacent.tileEntity)) {
continue;
}
if (_router.isRoutedExit(adjacent.direction)) {
continue;
}
if (denyed != null && denyed.equals(adjacent.direction)) {
continue;
}
CoreRoutedPipe pipe = _router.getPipe();
if (pipe != null) {
if (pipe.isLockedExit(adjacent.direction)) {
continue;
}
}
possibleForgeDirection.add(adjacent.direction);
}
if (possibleForgeDirection.size() != 0) {
return possibleForgeDirection.get(routedPipe.getWorld().rand.nextInt(possibleForgeDirection.size()));
}
// 2nd prio, deliver to non-routed exit
for (AdjacentTileEntity adjacent : adjacentEntities) {
if (_router.isRoutedExit(adjacent.direction)) {
continue;
}
CoreRoutedPipe pipe = _router.getPipe();
if (pipe != null) {
if (pipe.isLockedExit(adjacent.direction)) {
continue;
}
}
possibleForgeDirection.add(adjacent.direction);
}
if (possibleForgeDirection.size() == 0) {
return null;
}
return possibleForgeDirection.get(routedPipe.getWorld().rand.nextInt(possibleForgeDirection.size()));
}
use of net.minecraftforge.common.util.ForgeDirection in project LogisticsPipes by RS485.
the class ModuleCrafterMK3 method tick.
@Override
public void tick() {
super.tick();
if (inv.isEmpty()) {
return;
}
if (!_service.isNthTick(6)) {
return;
}
//Add from internal buffer
List<AdjacentTileEntity> crafters = locateCrafters();
boolean change = false;
for (AdjacentTileEntity adjacent : crafters) {
for (int i = inv.getSizeInventory() - 1; i >= 0; i--) {
ItemIdentifierStack slot = inv.getIDStackInSlot(i);
if (slot == null) {
continue;
}
ForgeDirection insertion = adjacent.direction.getOpposite();
if (getUpgradeManager().hasSneakyUpgrade()) {
insertion = getUpgradeManager().getSneakyOrientation();
}
ItemIdentifierStack toadd = slot.clone();
toadd.setStackSize(Math.min(toadd.getStackSize(), toadd.getItem().getMaxStackSize()));
if (_service.getItemOrderManager().hasOrders(ResourceType.CRAFTING)) {
toadd.setStackSize(Math.min(toadd.getStackSize(), ((IInventory) adjacent.tileEntity).getInventoryStackLimit()));
ItemStack added = InventoryHelper.getTransactorFor(adjacent.tileEntity, adjacent.direction.getOpposite()).add(toadd.makeNormalStack(), insertion, true);
slot.setStackSize(slot.getStackSize() - added.stackSize);
if (added.stackSize != 0) {
change = true;
}
} else {
_service.queueRoutedItem(SimpleServiceLocator.routedItemHelper.createNewTravelItem(toadd), adjacent.direction.getOpposite());
slot.setStackSize(slot.getStackSize() - toadd.getStackSize());
change = true;
}
if (slot.getStackSize() <= 0) {
inv.clearInventorySlotContents(i);
} else {
inv.setInventorySlotContents(i, slot);
}
}
}
if (change) {
inv.markDirty();
_service.getCacheHolder().trigger(CacheTypes.Inventory);
}
}
Aggregations