Search in sources :

Example 1 with ModernPacket

use of logisticspipes.network.abstractpackets.ModernPacket in project LogisticsPipes by RS485.

the class GuiChassiPipe method actionPerformed.

@Override
protected void actionPerformed(GuiButton guibutton) {
    if (guibutton.id >= 0 && guibutton.id <= 7) {
        LogisticsModule module = _chassiPipe.getLogisticsModule().getSubModule(guibutton.id);
        if (module != null) {
            final ModernPacket packet = PacketHandler.getPacket(ChassisGUI.class).setButtonID(guibutton.id).setPosX(_chassiPipe.getX()).setPosY(_chassiPipe.getY()).setPosZ(_chassiPipe.getZ());
            MainProxy.sendPacketToServer(packet);
        }
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule)

Example 2 with ModernPacket

use of logisticspipes.network.abstractpackets.ModernPacket in project LogisticsPipes by RS485.

the class ModuleItemSink method setIgnoreData.

public void setIgnoreData(int slot, EntityPlayer player) {
    if (slot < 0 || slot >= 9) {
        return;
    }
    if (MainProxy.isClient(_world.getWorld())) {
        if (player == null) {
            MainProxy.sendPacketToServer(PacketHandler.getPacket(ItemSinkFuzzy.class).setPos(slot).setNBT(false).setModulePos(this));
        }
    } else {
        ignoreData.set(slot, !ignoreData.get(slot));
        ModernPacket pak = PacketHandler.getPacket(ItemSinkFuzzy.class).setIgnoreData(ignoreData).setIgnoreNBT(ignoreNBT).setModulePos(this);
        if (player != null) {
            MainProxy.sendPacketToPlayer(pak, player);
        }
        MainProxy.sendPacketToAllWatchingChunk(getX(), getZ(), MainProxy.getDimensionForWorld(_world.getWorld()), pak);
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) ItemSinkFuzzy(logisticspipes.network.packets.modules.ItemSinkFuzzy)

Example 3 with ModernPacket

use of logisticspipes.network.abstractpackets.ModernPacket in project LogisticsPipes by RS485.

the class PacketHandler method initialize.

/*
	 * enumerates all ModernPackets, sets their IDs and populate packetlist/packetmap
	 */
@SuppressWarnings("unchecked")
@SneakyThrows({ IOException.class, InvocationTargetException.class, IllegalAccessException.class, InstantiationException.class, IllegalArgumentException.class, NoSuchMethodException.class, SecurityException.class })
public static final // Suppression+sneakiness because these shouldn't ever fail, and if they do, it needs to fail.
void initialize() {
    final List<ClassInfo> classes = new ArrayList<>(ClassPath.from(PacketHandler.class.getClassLoader()).getTopLevelClassesRecursive("logisticspipes.network.packets"));
    Collections.sort(classes, (o1, o2) -> o1.getSimpleName().compareTo(o2.getSimpleName()));
    PacketHandler.packetlist = new ArrayList<>(classes.size());
    PacketHandler.packetmap = new HashMap<>(classes.size());
    int currentid = 0;
    for (ClassInfo c : classes) {
        final Class<?> cls = c.load();
        final ModernPacket instance = (ModernPacket) cls.getConstructor(int.class).newInstance(currentid);
        PacketHandler.packetlist.add(instance);
        PacketHandler.packetmap.put((Class<? extends ModernPacket>) cls, instance);
        currentid++;
    }
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) ArrayList(java.util.ArrayList) ClassInfo(com.google.common.reflect.ClassPath.ClassInfo) SneakyThrows(lombok.SneakyThrows)

Example 4 with ModernPacket

use of logisticspipes.network.abstractpackets.ModernPacket in project LogisticsPipes by RS485.

the class PacketHandler method decode.

@Override
protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
    ByteBuf payload = msg.payload();
    int packetID = payload.readShort();
    final ModernPacket packet = PacketHandler.packetlist.get(packetID).template();
    packet.setDebugId(payload.readInt());
    ctx.attr(PacketHandler.INBOUNDPACKETTRACKER).get().set(msg);
    LPDataIOWrapper.provideData(payload.slice(), packet::readData);
    out.add(new InboundModernPacketWrapper(packet, MainProxy.proxy.getEntityPlayerFromNetHandler(msg.handler())));
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) ByteBuf(io.netty.buffer.ByteBuf)

Example 5 with ModernPacket

use of logisticspipes.network.abstractpackets.ModernPacket in project LogisticsPipes by RS485.

the class PipeItemsSatelliteLogistics method setPrevId.

public void setPrevId(EntityPlayer player) {
    satelliteId = findId(-1);
    ensureAllSatelliteStatus();
    if (MainProxy.isClient(player.worldObj)) {
        final ModernPacket packet = PacketHandler.getPacket(SatPipePrev.class).setPosX(getX()).setPosY(getY()).setPosZ(getZ());
        MainProxy.sendPacketToServer(packet);
    } else {
        final ModernPacket packet = PacketHandler.getPacket(SatPipeSetID.class).setSatID(satelliteId).setPosX(getX()).setPosY(getY()).setPosZ(getZ());
        MainProxy.sendPacketToPlayer(packet, player);
    }
    updateWatchers();
}
Also used : ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) SatPipePrev(logisticspipes.network.packets.satpipe.SatPipePrev)

Aggregations

ModernPacket (logisticspipes.network.abstractpackets.ModernPacket)16 ArrayList (java.util.ArrayList)2 ItemSinkFuzzy (logisticspipes.network.packets.modules.ItemSinkFuzzy)2 SatPipeNext (logisticspipes.network.packets.satpipe.SatPipeNext)2 SatPipePrev (logisticspipes.network.packets.satpipe.SatPipePrev)2 ClassInfo (com.google.common.reflect.ClassPath.ClassInfo)1 ByteBuf (io.netty.buffer.ByteBuf)1 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)1 IPipeSign (logisticspipes.pipes.signs.IPipeSign)1 SneakyThrows (lombok.SneakyThrows)1