use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class SendQueueContent method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
if (pipe == null) {
return;
}
if (pipe.pipe instanceof ISendQueueContentRecieiver) {
ISendQueueContentRecieiver receiver = (ISendQueueContentRecieiver) pipe.pipe;
receiver.handleSendQueueItemIdentifierList(getIdentList());
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class SlotFinderOpenGuiPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
// hack to avoid wrenching blocks
int savedEquipped = player.inventory.currentItem;
boolean foundSlot = false;
// try to find a empty slot
for (int i = 0; i < 9; i++) {
if (player.inventory.getStackInSlot(i).isEmpty()) {
foundSlot = true;
player.inventory.currentItem = i;
break;
}
}
// okay, anything that's a block?
if (!foundSlot) {
for (int i = 0; i < 9; i++) {
ItemStack is = player.inventory.getStackInSlot(i);
if (!is.isEmpty() && is.getItem() instanceof ItemBlock) {
foundSlot = true;
player.inventory.currentItem = i;
break;
}
}
}
// give up and select whatever is right of the current slot
if (!foundSlot) {
player.inventory.currentItem = (player.inventory.currentItem + 1) % 9;
}
boolean openedGui = false;
final LogisticsTileGenericPipe genericPipe = getPipe(player.world, LTGPCompletionCheck.PIPE);
if (genericPipe.isRoutingPipe()) {
openedGui = genericPipe.getRoutingPipe().getAvailableAdjacent().inventories().stream().filter(neighbor -> LPNeighborTileEntityKt.getInventoryUtil(neighbor) instanceof ISpecialInsertion).anyMatch(neighbor -> {
for (ICraftingRecipeProvider provider : SimpleServiceLocator.craftingRecipeProviders) {
if (provider.canOpenGui(neighbor.getTileEntity())) {
return true;
}
}
Block block = neighbor.getTileEntity().getBlockType();
final BlockPos blockPos = neighbor.getTileEntity().getPos();
final IBlockState blockState = player.world.getBlockState(blockPos);
if (!block.isAir(blockState, player.world, blockPos)) {
int xCoord = blockPos.getX();
int yCoord = blockPos.getY();
int zCoord = blockPos.getZ();
if (SimpleServiceLocator.enderStorageProxy.isEnderChestBlock(block)) {
SimpleServiceLocator.enderStorageProxy.openEnderChest(player.world, xCoord, yCoord, zCoord, player);
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
return true;
}
if (block.onBlockActivated(player.world, blockPos, blockState, player, EnumHand.MAIN_HAND, EnumFacing.UP, 0, 0, 0)) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SlotFinderActivatePacket.class).setTagetPosX(xCoord).setTagetPosY(yCoord).setTagetPosZ(zCoord).setSlot(getSlot()).setPacketPos(this), player);
return true;
}
}
return false;
});
}
if (!openedGui) {
LogisticsPipes.log.warn("Ignored SlotFinderOpenGuiPacket from " + player.toString() + ", because of failing preconditions");
}
player.inventory.currentItem = savedEquipped;
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class SatelliteSetNamePacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld(), LTGPCompletionCheck.PIPE);
if (pipe == null || pipe.pipe == null) {
return;
}
String newName = getString();
SatelliteNamingResult result = null;
if (newName.trim().isEmpty()) {
result = SatelliteNamingResult.BLANK_NAME;
} else if (pipe.pipe instanceof SatellitePipe) {
final SatellitePipe satellitePipe = (SatellitePipe) pipe.pipe;
if (satellitePipe.getSatellitesOfType().stream().anyMatch(it -> it.getSatellitePipeName().equals(newName))) {
result = SatelliteNamingResult.DUPLICATE_NAME;
} else {
result = SatelliteNamingResult.SUCCESS;
satellitePipe.setSatellitePipeName(newName);
satellitePipe.updateWatchers();
satellitePipe.ensureAllSatelliteStatus();
}
}
if (result != null) {
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(SetNameResult.class).setResult(result).setNewName(getString()), player);
}
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class OrdererRefreshRequestPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
int dimension = (getInteger() - (getInteger() % 10)) / 10;
final LogisticsTileGenericPipe pipe = MainProxy.proxy.getPipeInDimensionAt(dimension, getPosX(), getPosY(), getPosZ(), player);
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
return;
}
RequestHandler.DisplayOptions option;
switch(getInteger() % 10) {
case 0:
option = RequestHandler.DisplayOptions.Both;
break;
case 1:
option = RequestHandler.DisplayOptions.SupplyOnly;
break;
case 2:
option = RequestHandler.DisplayOptions.CraftOnly;
break;
default:
option = RequestHandler.DisplayOptions.Both;
break;
}
RequestHandler.refresh(player, (CoreRoutedPipe) pipe.pipe, option);
}
use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.
the class RequestSubmitListPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
final LogisticsTileGenericPipe pipe = this.getPipe(player.world);
if (pipe == null) {
return;
}
if (!(pipe.pipe instanceof PipeBlockRequestTable)) {
return;
}
RequestHandler.requestList(player, getIdentList(), (CoreRoutedPipe) pipe.pipe);
}
Aggregations