本文整理汇总了Java中net.minecraft.network.PacketBuffer.release方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.release方法的具体用法?Java PacketBuffer.release怎么用?Java PacketBuffer.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.network.PacketBuffer
的用法示例。
在下文中一共展示了PacketBuffer.release方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleCustomPayload
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla
* implemented channels are "MC|TrList" to acquire a MerchantRecipeList trades
* for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate
* the identifier of the default server resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName())) {
PacketBuffer packetbuffer = packetIn.getBufferData();
try {
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant
&& i == this.gameController.thePlayer.openContainer.windowId) {
IMerchant imerchant = ((GuiMerchant) guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
} catch (IOException ioexception) {
logger.error((String) "Couldn\'t load trade info", (Throwable) ioexception);
} finally {
packetbuffer.release();
}
} else if ("MC|Brand".equals(packetIn.getChannelName())) {
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
} else if ("MC|BOpen".equals(packetIn.getChannelName())) {
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book) {
this.gameController
.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例2: decode
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws Exception
{
p_decode_2_.markReaderIndex();
byte[] abyte = new byte[3];
for (int i = 0; i < abyte.length; ++i)
{
if (!p_decode_2_.isReadable())
{
p_decode_2_.resetReaderIndex();
return;
}
abyte[i] = p_decode_2_.readByte();
if (abyte[i] >= 0)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(abyte));
try
{
int j = packetbuffer.readVarIntFromBuffer();
if (p_decode_2_.readableBytes() >= j)
{
p_decode_3_.add(p_decode_2_.readBytes(j));
return;
}
p_decode_2_.resetReaderIndex();
}
finally
{
packetbuffer.release();
}
return;
}
}
throw new CorruptedFrameException("length wider than 21-bit");
}
示例3: handleCustomPayload
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(S3FPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
logger.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.thePlayer.setClientBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
ItemStack itemstack = this.gameController.thePlayer.getCurrentEquippedItem();
if (itemstack != null && itemstack.getItem() == Items.written_book)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
}
示例4: handleCustomPayload
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();
if (itemstack.getItem() == Items.WRITTEN_BOOK)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
}
}
else if ("MC|DebugPath".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer1 = packetIn.getBufferData();
int j = packetbuffer1.readInt();
float f = packetbuffer1.readFloat();
Path path = Path.read(packetbuffer1);
((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
}
else if ("MC|StopSound".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer2 = packetIn.getBufferData();
String s = packetbuffer2.readStringFromBuffer(32767);
String s1 = packetbuffer2.readStringFromBuffer(256);
this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
}
}
示例5: handleCustomPayload
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();
if (itemstack.getItem() == Items.WRITTEN_BOOK)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
}
}
else if ("MC|DebugPath".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer1 = packetIn.getBufferData();
int j = packetbuffer1.readInt();
float f = packetbuffer1.readFloat();
Path path = Path.read(packetbuffer1);
((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
}
else if ("MC|DebugNeighborsUpdate".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer2 = packetIn.getBufferData();
long k = packetbuffer2.readVarLong();
BlockPos blockpos = packetbuffer2.readBlockPos();
((DebugRendererNeighborsUpdate)this.gameController.debugRenderer.field_191557_f).func_191553_a(k, blockpos);
}
else if ("MC|StopSound".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer3 = packetIn.getBufferData();
String s = packetbuffer3.readStringFromBuffer(32767);
String s1 = packetbuffer3.readStringFromBuffer(256);
this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
}
}
示例6: handleCustomPayload
import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
* Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
* acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
* player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
* resourcepack for the client to load.
*/
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
if ("MC|TrList".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer = packetIn.getBufferData();
try
{
int i = packetbuffer.readInt();
GuiScreen guiscreen = this.gameController.currentScreen;
if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
{
IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
imerchant.setRecipes(merchantrecipelist);
}
}
catch (IOException ioexception)
{
LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
}
finally
{
packetbuffer.release();
}
}
else if ("MC|Brand".equals(packetIn.getChannelName()))
{
this.gameController.thePlayer.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
}
else if ("MC|BOpen".equals(packetIn.getChannelName()))
{
EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.thePlayer.getHeldItemOffhand() : this.gameController.thePlayer.getHeldItemMainhand();
if (itemstack != null && itemstack.getItem() == Items.WRITTEN_BOOK)
{
this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
}
}
else if ("MC|DebugPath".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer1 = packetIn.getBufferData();
int j = packetbuffer1.readInt();
float f = packetbuffer1.readFloat();
Path path = Path.read(packetbuffer1);
((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
}
else if ("MC|StopSound".equals(packetIn.getChannelName()))
{
PacketBuffer packetbuffer2 = packetIn.getBufferData();
String s = packetbuffer2.readStringFromBuffer(32767);
String s1 = packetbuffer2.readStringFromBuffer(256);
this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
}
}