本文整理汇总了Java中net.minecraftforge.fml.common.network.internal.FMLProxyPacket.payload方法的典型用法代码示例。如果您正苦于以下问题:Java FMLProxyPacket.payload方法的具体用法?Java FMLProxyPacket.payload怎么用?Java FMLProxyPacket.payload使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fml.common.network.internal.FMLProxyPacket
的用法示例。
在下文中一共展示了FMLProxyPacket.payload方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPacketData
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
public void onPacketData(
final FMLProxyPacket packet,
final INetHandler handler,
final EntityPlayerMP playerEntity )
{
if ( playerEntity == null )
{
return;
}
final PacketBuffer buffer = new PacketBuffer( packet.payload() );
final ModPacket innerPacket = parsePacket( buffer );
innerPacket.serverEntity = playerEntity;
PacketThreadUtil.checkThreadAndEnqueue( innerPacket, handler, playerEntity.getServer() );
innerPacket.server( playerEntity );
}
示例2: decode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception
{
ByteBuf buf = msg.payload();
int packetId = buf.readByte();
Class pktCls = packets.get(packetId);
SasaPacketBase pkt = (SasaPacketBase)pktCls.newInstance();
pkt.fromByteBuf(ctx, buf);
if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
{
pkt.receiveClient(getClientPlayer());
}
else if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{
INetHandler localINetHandler = (INetHandler)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
EntityPlayer ep = ((NetHandlerPlayServer)localINetHandler).playerEntity;
pkt.receiveServer(ep);
}
}
示例3: decode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
ByteBuf packetPayload = msg.payload();
byte indexOfClass = packetPayload.readByte();
ByteBufInputStream bbis = new ByteBufInputStream(packetPayload.slice());
Class<? extends CLLPacket> packetClass = registeredPackets.get(indexOfClass);
if(packetClass != null){
CLLPacket packetCLL = packetClass.newInstance();
packetCLL.readDataFrom(bbis);
switch(FMLCommonHandler.instance().getEffectiveSide()){
case CLIENT:
handleClient(packetCLL);
break;
case SERVER:
packetCLL.handleServerSide(((NetHandlerPlayServer)ctx.channel().attr(NetworkRegistry.NET_HANDLER).get()).player);
break;
}
bbis.close();
out.add(packetCLL);
}
}
示例4: decode
import net.minecraftforge.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 ARKMessage> clazz = packets.get(discriminator);
if (clazz == null) { throw new NullPointerException("No packet registered for discriminator: "
+ discriminator); }
ARKMessage 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);
}
示例5: decode
import net.minecraftforge.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("No packet registered for discriminator: " + discriminator);
}
AbstractPacket pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide())
{
case CLIENT:
player = this.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:
}
}
示例6: decode
import net.minecraftforge.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 PacketAbstract> clazz = this.packets.get(discriminator);
if (clazz == null) {
throw new NullPointerException(
"No packet registered for discriminator: " + discriminator);
}
PacketAbstract pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
player = this.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);
}
示例7: decode
import net.minecraftforge.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 ARKMessage> clazz = packets.get(discriminator);
if (clazz == null)
{
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
}
ARKMessage 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);
}
示例8: decode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
PacketBuffer payload = new PacketBuffer(msg.payload());
Packet packet = new AchSyncPacket();
packet.readPacketData(payload);
packet.processPacket(null);
}
示例9: decode
import net.minecraftforge.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 Packet> packetClass = this.packets.get(discriminator);
if (packetClass == null)
{
throw new NullPointerException("No packet registered for discriminator: " + discriminator);
}
Packet pkt = packetClass.newInstance();
pkt.decode(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide())
{
case CLIENT:
player = this.getClientPlayer();
pkt.onClientSide(player);
break;
case SERVER:
INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get();
player = ((NetHandlerPlayServer) netHandler).playerEntity;
pkt.onServerSide(player);
break;
default:
}
out.add(pkt);
}
示例10: decode
import net.minecraftforge.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("No packet registered for discriminator: " + discriminator);
}
AbstractPacket pkt = clazz.newInstance();
pkt.decodeInto(ctx, payload.slice());
EntityPlayer player;
switch (FMLCommonHandler.instance().getEffectiveSide()) {
case CLIENT:
player = this.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);
}
示例11: decode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
final PacketBuffer input = new PacketBuffer(msg.payload());
final Side side = ctx.channel().attr(NetworkRegistry.CHANNEL_SOURCE).get();
final IRpcTarget target;
final MethodEntry method;
final Object[] args;
{
final int targetId = input.readVarInt();
final BiMap<Integer, TargetTypeProvider> idToEntryMap = CommonRegistryCallbacks.getEntryIdMap(targetRegistry).inverse();
final TargetTypeProvider entry = idToEntryMap.get(targetId);
target = entry.createRpcTarget();
EntityPlayer player = getPlayer(msg);
target.readFromStreamStream(side, player, input);
}
{
final BiMap<MethodEntry, Integer> eventIdMap = CommonRegistryCallbacks.getEntryIdMap(methodRegistry);
final int methodId = input.readVarInt();
method = eventIdMap.inverse().get(methodId);
args = method.paramsCodec.readArgs(input);
}
int bufferJunkSize = input.readableBytes();
Preconditions.checkState(bufferJunkSize == 0, "%s junk bytes left in buffer, method = %s", bufferJunkSize, method);
out.add(new RpcCall(target, method, args));
}
示例12: decode
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket; //导入方法依赖的package包/类
@Override
protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception {
final Channel channel = ctx.channel();
final Side side = channel.attr(NetworkRegistry.CHANNEL_SOURCE).get();
final PacketBuffer payload = new PacketBuffer(msg.payload());
final int typeId = payload.readVarInt();
final NetworkEventEntry type = CommonRegistryCallbacks.getEntryIdMap(registry).inverse().get(typeId);
final EventDirection validator = type.getDirection();
Preconditions.checkState(validator != null && validator.validateReceive(side),
"Invalid direction: receiving packet %s on side %s", msg.getClass(), side);
final NetworkEvent event = type.createPacket();
event.readFromStream(payload);
event.dispatcher = msg.getDispatcher();
event.side = side;
final INetHandler handler = msg.handler();
if (handler != null) event.sender = OpenMods.proxy.getPlayerFromHandler(handler);
final int bufferJunkSize = payload.readableBytes();
if (bufferJunkSize > 0) Log.warn("%s junk bytes left in buffer, event %s", bufferJunkSize, event);
out.add(event);
}