/**
* 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));
}
}
NetHandlerPlayClient.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:ExpandedRailsMod
作者:
评论列表
文章目录