use of logisticspipes.pipes.PipeLogisticsChassi in project LogisticsPipes by RS485.
the class RequestChassiOrientationPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
LogisticsTileGenericPipe pipe = this.getPipe(player.worldObj);
if (pipe == null || !(pipe.pipe instanceof PipeLogisticsChassi)) {
return;
}
MainProxy.sendPacketToPlayer(PacketHandler.getPacket(ChassiOrientationPacket.class).setDir(((PipeLogisticsChassi) pipe.pipe).getPointedOrientation()).setPosX(getPosX()).setPosY(getPosY()).setPosZ(getPosZ()), player);
}
use of logisticspipes.pipes.PipeLogisticsChassi in project LogisticsPipes by RS485.
the class ChassiOrientationPacket method processPacket.
@Override
public void processPacket(EntityPlayer player) {
LogisticsTileGenericPipe pipe = this.getPipe(player.worldObj);
if (pipe == null || !(pipe.pipe instanceof PipeLogisticsChassi)) {
return;
}
((PipeLogisticsChassi) pipe.pipe).setClientOrientation(dir);
}
use of logisticspipes.pipes.PipeLogisticsChassi in project LogisticsPipes by RS485.
the class LogisticsEventListener method onPlayerInteract.
@SubscribeEvent
public void onPlayerInteract(final PlayerInteractEvent event) {
if (MainProxy.isServer(event.entityPlayer.worldObj)) {
if (event.action == Action.LEFT_CLICK_BLOCK) {
final TileEntity tile = event.entityPlayer.worldObj.getTileEntity(event.x, event.y, event.z);
if (tile instanceof LogisticsTileGenericPipe) {
if (((LogisticsTileGenericPipe) tile).pipe instanceof CoreRoutedPipe) {
if (!((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).canBeDestroyedByPlayer(event.entityPlayer)) {
event.setCanceled(true);
event.entityPlayer.addChatComponentMessage(new ChatComponentTranslation("lp.chat.permissiondenied"));
((LogisticsTileGenericPipe) tile).scheduleNeighborChange();
event.entityPlayer.worldObj.markBlockForUpdate(tile.xCoord, tile.yCoord, tile.zCoord);
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).delayTo = System.currentTimeMillis() + 200;
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).repeatFor = 10;
} else {
((CoreRoutedPipe) ((LogisticsTileGenericPipe) tile).pipe).setDestroyByPlayer();
}
}
}
}
if (event.action == Action.RIGHT_CLICK_BLOCK) {
WorldCoordinatesWrapper worldCoordinates = new WorldCoordinatesWrapper(event.entityPlayer.worldObj, event.x, event.y, event.z);
TileEntity tileEntity = worldCoordinates.getTileEntity();
if (tileEntity instanceof TileEntityChest || SimpleServiceLocator.ironChestProxy.isIronChest(tileEntity)) {
//@formatter:off
List<WeakReference<ModuleQuickSort>> list = worldCoordinates.getAdjacentTileEntities().filter(adjacent -> adjacent.tileEntity instanceof LogisticsTileGenericPipe).filter(adjacent -> ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe instanceof PipeLogisticsChassi).filter(adjacent -> ((PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).getPointedOrientation() == adjacent.direction.getOpposite()).map(adjacent -> (PipeLogisticsChassi) ((LogisticsTileGenericPipe) adjacent.tileEntity).pipe).flatMap(pipeLogisticsChassi -> Arrays.stream(pipeLogisticsChassi.getModules().getModules())).filter(logisticsModule -> logisticsModule instanceof ModuleQuickSort).map(logisticsModule -> new WeakReference<>((ModuleQuickSort) logisticsModule)).collect(Collectors.toList());
if (!list.isEmpty()) {
LogisticsEventListener.chestQuickSortConnection.put(event.entityPlayer, list);
}
}
}
}
}
use of logisticspipes.pipes.PipeLogisticsChassi in project LogisticsPipes by RS485.
the class ModuleCoordinatesPacket method getLogisticsModule.
@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(EntityPlayer player, Class<T> clazz) {
LogisticsModule module = null;
if (type == ModulePositionType.IN_PIPE) {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
moduleBased = false;
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
targetNotFound("Couldn't find " + clazz.getName() + ", pipe didn't exsist");
return null;
}
module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
} else if (type == ModulePositionType.IN_HAND) {
if (MainProxy.isServer(player.getEntityWorld())) {
if (player.openContainer instanceof DummyModuleContainer) {
DummyModuleContainer dummy = (DummyModuleContainer) player.openContainer;
module = dummy.getModule();
} else {
targetNotFound("Couldn't find " + clazz.getName() + ", container wasn't a DummyModule Container");
return null;
}
} else {
module = MainProxy.proxy.getModuleFromGui();
if (module == null) {
targetNotFound("Couldn't find " + clazz.getName() + ", GUI didn't provide the module");
return null;
}
}
} else {
moduleBased = true;
LogisticsTileGenericPipe pipe = this.getPipe(player.getEntityWorld());
moduleBased = false;
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
targetNotFound("Couldn't find " + clazz.getName() + ", pipe didn't exsist");
return null;
} else if (!pipe.isInitialized()) {
return null;
}
if (!(pipe.pipe instanceof PipeLogisticsChassi)) {
targetNotFound("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe");
return null;
}
module = ((PipeLogisticsChassi) pipe.pipe).getLogisticsModule().getSubModule(positionInt);
}
if (module != null) {
if (!(clazz.isAssignableFrom(module.getClass()))) {
targetNotFound("Couldn't find " + clazz.getName() + ", found " + module.getClass());
return null;
}
} else {
targetNotFound("Couldn't find " + clazz.getName());
}
return (T) module;
}
use of logisticspipes.pipes.PipeLogisticsChassi in project LogisticsPipes by RS485.
the class ModuleCoordinatesGuiProvider method getLogisticsModule.
@SuppressWarnings("unchecked")
public <T> T getLogisticsModule(World world, Class<T> clazz) {
LogisticsTileGenericPipe pipe = getPipe(world);
if (pipe == null || !(pipe.pipe instanceof CoreRoutedPipe)) {
if (LPConstants.DEBUG && (pipe == null || pipe.isInitialized())) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe didn't exsist").printStackTrace();
}
return null;
}
LogisticsModule module = null;
if (slot == ModulePositionType.IN_PIPE) {
module = ((CoreRoutedPipe) pipe.pipe).getLogisticsModule();
} else if (slot == ModulePositionType.IN_HAND) {
throw new UnsupportedOperationException("NO IN_HAND FOR THIS PACKET TYPE");
} else {
if (!(pipe.pipe instanceof PipeLogisticsChassi)) {
if (LPConstants.DEBUG) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", pipe wasn't a chassi pipe").printStackTrace();
}
return null;
}
module = ((PipeLogisticsChassi) pipe.pipe).getLogisticsModule().getSubModule(positionInt);
}
if (module != null) {
if (!(clazz.isAssignableFrom(module.getClass()))) {
if (LPConstants.DEBUG) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName() + ", found " + module.getClass()).printStackTrace();
}
return null;
}
} else {
if (LPConstants.DEBUG) {
LogisticsPipes.log.fatal(toString());
new RuntimeException("Couldn't find " + clazz.getName()).printStackTrace();
}
}
return (T) module;
}
Aggregations