本文整理匯總了Java中cpw.mods.fml.common.network.internal.FMLProxyPacket.payload方法的典型用法代碼示例。如果您正苦於以下問題:Java FMLProxyPacket.payload方法的具體用法?Java FMLProxyPacket.payload怎麽用?Java FMLProxyPacket.payload使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cpw.mods.fml.common.network.internal.FMLProxyPacket
的用法示例。
在下文中一共展示了FMLProxyPacket.payload方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected final void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
testMessageValidity(msg);
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends A> clazz = discriminators.get(discriminator);
if(clazz == null)
{
throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
}
A newMsg = clazz.newInstance();
ctx.attr(INBOUNDPACKETTRACKER).get().set(new WeakReference<FMLProxyPacket>(msg));
decodeInto(ctx, payload.slice(), newMsg);
out.add(newMsg);
}
示例2: handlePacket
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
protected void handlePacket(FMLProxyPacket proxyPacket, EntityPlayerMP player) {
final ByteBuf payload = proxyPacket.payload();
if( payload.readableBytes() > 0 ) {
final PacketBuffer buf = new PacketBuffer(payload);
final byte id = buf.readByte();
final PacketType type = PacketType.get(id);
if( type == null ) {
FairyFactions.LOGGER.error("Got unknown packet type "+id);
return;
}
final FairyPacket packet;
try {
packet = type.packet_class.newInstance();
} catch (Exception e) {
// ERROR, unable to actually process
e.printStackTrace();
return;
}
packet.init(buf);
packet.handle(proxyPacket.getOrigin());
}
}
示例3: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket packet) throws Exception
{
if (packet.channel().equals(TheMod.RESOURCE_PREFIX + "Network"))
{
ByteBuf payload = packet.payload();
final PacketBuffer packetBuffer = new PacketBuffer(payload);
final PacketType[] values = PacketType.values();
final int packetTypeValue = packetBuffer.readInt();
if (packetTypeValue >= values.length)
{
Logger.warning("Unknown Packet type: %d", packetTypeValue);
return;
}
PacketType packetType = values[packetTypeValue];
switch (packetType)
{
case SET_SCHEMATIC_NAME:
setSchematicName(packetBuffer);
break;
}
}
}
示例4: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
AbstractPacket pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
pkt.handleClientSide(this.getClientPlayer());
break;
case SERVER:
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
pkt.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity);
break;
default:
break;
}
out.add(pkt);
}
示例5: onFMLProxyPacketData
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
public void onFMLProxyPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player)
{
try {
if ((packet == null) || (packet.payload() == null)) throw new RuntimeException("Empty packet sent to Galacticraft channel");
ByteBuf data = packet.payload();
this.handle(data, player);
} catch (Exception e) {
GCLog.severe("GC login packet handler: Failed to read packet");
GCLog.severe(e.toString());
e.printStackTrace();
}
}
示例6: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
ByteBuf buf = msg.payload();
int x = buf.readInt();
int y = buf.readInt();
int z = buf.readInt();
TileEntity te = FCMiner.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
if(te instanceof GenericTile) {
((GenericTile)te).readFromPacket(buf);
}
}
示例7: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
protected void decode(final ChannelHandlerContext ctx, final FMLProxyPacket msg, final List<Object> out) throws Exception {
((ThreadLocal)ctx.attr((AttributeKey)ImaginePacketCodec.PACKET_TRACKER).get()).set(new WeakReference<FMLProxyPacket>(msg));
final ImaginePacketRegistry packetRegistry = (ImaginePacketRegistry)ctx.attr((AttributeKey)ImaginePacketCodec.PACKET_REGISTRY).get();
final ByteBuf payload = msg.payload();
final boolean newPacketClass = payload.readBoolean();
final int packetClassId = payload.readInt();
Class<? extends ImaginePacket> packetClass;
if (newPacketClass) {
final int classNameLength = payload.readInt();
if (classNameLength <= 0) {
new IllegalArgumentException("Too short class name: " + classNameLength).printStackTrace();
ctx.close();
}
if (classNameLength > 1024) {
new IllegalArgumentException("Too long class name: " + classNameLength).printStackTrace();
ctx.close();
}
final byte[] classNameBytes = new byte[classNameLength];
payload.readBytes(classNameBytes, 0, classNameLength);
final String className = new String(classNameBytes, 0, classNameLength, ImaginePacketCodec.UTF_8);
packetClass = (Class<? extends ImaginePacket>)Class.forName(className);
if (!ImaginePacket.class.isAssignableFrom(packetClass)) {
new IllegalArgumentException("Provided class isn't imagine packet: " + packetClass).printStackTrace();
ctx.close();
}
packetRegistry.register(packetClassId, packetClass);
}
else {
packetClass = packetRegistry.get(packetClassId);
}
if (packetClass == null) {
new NullPointerException("Undefined message in channel " + msg.channel()).printStackTrace();
ctx.close();
}
final ImaginePacket packet = ImagineNetwork.obtainPacket(packetClass);
packet.readPacket(ctx, new WritableBuf(payload.slice()));
out.add(packet);
}
示例8: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception
{
ByteBuf buf = msg.payload();
int x = buf.readInt();
int y = buf.readInt();
int z = buf.readInt();
TileEntity te = Network.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
if (te instanceof TileEntityNetwork)
{
((TileEntityNetwork) te).readFromPacket(buf);
}
}
示例9: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
ByteBuf buf = msg.payload();
int x = buf.readInt();
int y = buf.readInt();
int z = buf.readInt();
TileEntity te = RainbowElectricity.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
if(te instanceof TileEntityRainbowElectricity) {
((TileEntityRainbowElectricity)te).readFromPacket(buf);
}
}
示例10: onFMLProxyPacketData
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
public void onFMLProxyPacketData(NetworkManager manager, FMLProxyPacket packet, EntityPlayer player)
{
try {
if ((packet == null) || (packet.payload() == null)) throw new RuntimeException("Empty packet sent to Amunra channel");
ByteBuf data = packet.payload();
this.handle(data, player);
} catch (Exception e) {
GCLog.severe("Amunra login packet handler: Failed to read packet");
GCLog.severe(e.toString());
e.printStackTrace();
}
}
示例11: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends MMMessage> clazz = packets.get(discriminator);
if (clazz == null) {
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
}
MMMessage pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
player = getClientPlayer();
pkt.handleClientSide(player);
break;
case SERVER:
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.handleServerSide(player);
break;
default:
}
out.add(pkt);
}
示例12: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception {
World world = DynamicLib.proxy.getClientWorld();
ByteBuf payload = msg.payload();
DataInputStream input = new DataInputStream(new ByteBufInputStream(payload));
ISyncMapProvider provider = SyncMap.findSyncMap(world, input);
try {
if (provider != null) provider.getSyncMap().readFromStream(input);
} catch (Throwable e) {
throw new SyncException(e, provider);
}
}
示例13: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
testMessageValidity(msg);
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends Packet> clazz = discriminators.get(discriminator);
if (clazz == null) {
throw new NullPointerException("Undefined message for discriminator " + discriminator + " in channel " + msg.channel());
}
Packet newMsg = clazz.newInstance();
ctx.attr(INBOUNDPACKETTRACKER).get().set(new WeakReference<FMLProxyPacket>(msg));
newMsg.readData(payload.slice());
out.add(newMsg);
}
示例14: decode
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
ByteBuf payload = msg.payload();
byte discriminator = payload.readByte();
Class<? extends AbstractPacket> clazz = this.packets.get(discriminator);
if (clazz == null) {
throw new NullPointerException("This packet has never been registered" + clazz.getCanonicalName());
}
AbstractPacket abstractPacket = clazz.newInstance();
abstractPacket.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
player = this.getClientPlayer();
abstractPacket.handleClientSide(player);
break;
case SERVER:
INetHandler iNetHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) iNetHandler).playerEntity;
abstractPacket.handleServerSide(player);
break;
default:
}
//out.add(abstractPacket);
}
示例15: channelRead0
import cpw.mods.fml.common.network.internal.FMLProxyPacket; //導入方法依賴的package包/類
@Override
protected void channelRead0(ChannelHandlerContext ctx, FMLProxyPacket msg) throws Exception{
ByteBuf buf = msg.payload();
int x = buf.readInt();
int y = buf.readInt();
int z = buf.readInt();
TileEntity te = RandomThoughtsMod.proxy.getClientPlayer().worldObj.getTileEntity(x, y, z);
if(te instanceof TileEntity_RandomThoughtsMod) {
((TileEntity_RandomThoughtsMod)te).readFromPacket(buf);
}
}