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);
}
}
}
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);
}
}
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++;
}
}
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())));
}
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();
}
Aggregations