Search in sources :

Example 1 with PipeLogisticsChassi

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);
}
Also used : PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 2 with PipeLogisticsChassi

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);
}
Also used : PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 3 with PipeLogisticsChassi

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);
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) Action(net.minecraftforge.event.entity.player.PlayerInteractEvent.Action) Arrays(java.util.Arrays) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) MainProxy(logisticspipes.proxy.MainProxy) VersionChecker(logisticspipes.ticks.VersionChecker) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) Configs(logisticspipes.config.Configs) ChestGuiOpened(logisticspipes.network.packets.chassis.ChestGuiOpened) ChatComponentText(net.minecraft.util.ChatComponentText) LogisticsHUDRenderer(logisticspipes.renderer.LogisticsHUDRenderer) LogisticsGuiOverrenderer(logisticspipes.renderer.LogisticsGuiOverrenderer) Map(java.util.Map) FMLClientHandler(cpw.mods.fml.client.FMLClientHandler) PlayerLoggedInEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent) PlayerLoggedOutEvent(cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent) ClientConnectedToServerEvent(cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent) EntityItem(net.minecraft.entity.item.EntityItem) ChestGuiClosed(logisticspipes.network.packets.chassis.ChestGuiClosed) Side(cpw.mods.fml.relauncher.Side) SideOnly(cpw.mods.fml.relauncher.SideOnly) UnWatch(net.minecraftforge.event.world.ChunkWatchEvent.UnWatch) WorldEvent(net.minecraftforge.event.world.WorldEvent) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PacketHandler(logisticspipes.network.PacketHandler) Collectors(java.util.stream.Collectors) List(java.util.List) EntityJoinWorldEvent(net.minecraftforge.event.entity.EntityJoinWorldEvent) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) PlayerIdentifier(logisticspipes.utils.PlayerIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Queue(java.util.Queue) PlayerConfig(logisticspipes.config.PlayerConfig) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) GuiReopenPacket(logisticspipes.network.packets.gui.GuiReopenPacket) HashMap(java.util.HashMap) PlayerConfigToClientPacket(logisticspipes.network.packets.PlayerConfigToClientPacket) Watch(net.minecraftforge.event.world.ChunkWatchEvent.Watch) TileEntityChest(net.minecraft.tileentity.TileEntityChest) ItemStack(net.minecraft.item.ItemStack) IItemAdvancedExistance(logisticspipes.interfaces.IItemAdvancedExistance) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) PlayerInteractEvent(net.minecraftforge.event.entity.player.PlayerInteractEvent) WeakHashMap(java.util.WeakHashMap) IOException(java.io.IOException) GuiChest(net.minecraft.client.gui.inventory.GuiChest) GuiOpenEvent(net.minecraftforge.client.event.GuiOpenEvent) QuickSortChestMarkerStorage(logisticspipes.utils.QuickSortChestMarkerStorage) TileEntity(net.minecraft.tileentity.TileEntity) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) AllArgsConstructor(lombok.AllArgsConstructor) TileEntityChest(net.minecraft.tileentity.TileEntityChest) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) WeakReference(java.lang.ref.WeakReference) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ModuleQuickSort(logisticspipes.modules.ModuleQuickSort) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) WorldCoordinatesWrapper(network.rs485.logisticspipes.world.WorldCoordinatesWrapper) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with PipeLogisticsChassi

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;
}
Also used : DummyModuleContainer(logisticspipes.utils.gui.DummyModuleContainer) PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 5 with PipeLogisticsChassi

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;
}
Also used : PipeLogisticsChassi(logisticspipes.pipes.PipeLogisticsChassi) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Aggregations

PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)9 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)8 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)3 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)2 IInventory (net.minecraft.inventory.IInventory)2 ItemStack (net.minecraft.item.ItemStack)2 FMLClientHandler (cpw.mods.fml.client.FMLClientHandler)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 PlayerLoggedInEvent (cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent)1 PlayerLoggedOutEvent (cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent)1 ClientConnectedToServerEvent (cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent)1 Side (cpw.mods.fml.relauncher.Side)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 IOException (java.io.IOException)1 WeakReference (java.lang.ref.WeakReference)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1