本文整理汇总了Java中net.minecraft.network.play.client.CPacketCustomPayload类的典型用法代码示例。如果您正苦于以下问题:Java CPacketCustomPayload类的具体用法?Java CPacketCustomPayload怎么用?Java CPacketCustomPayload使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CPacketCustomPayload类属于net.minecraft.network.play.client包,在下文中一共展示了CPacketCustomPayload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sendBook
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
private void sendBook(ItemStack stack) {
NBTTagList pages = new NBTTagList(); // page tag list
// copy pages into NBT
for(int i = 0; i < MAX_PAGES && parser.hasNext(); i++) {
pages.appendTag(new NBTTagString(parser.next().trim()));
page++;
}
// set our client side book
if(stack.hasTagCompound())
stack.getTagCompound().setTag("pages", pages);
else
stack.setTagInfo("pages", pages);
// publish the book
stack.setTagInfo("author", new NBTTagString(getLocalPlayer().getName()));
stack.setTagInfo("title", new NBTTagString(parent.name.get().replaceAll(NUMBER_TOKEN, "" + getBook()).trim()));
PacketBuffer buff = new PacketBuffer(Unpooled.buffer());
buff.writeItemStack(stack);
MC.getConnection().sendPacket(new CPacketCustomPayload("MC|BSign", buff));
}
示例2: handleJoinGame
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
/**
* Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new
* WorldClient and sets the player initial dimension
*/
public void handleJoinGame(SPacketJoinGame packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
this.gameController.playerController = new PlayerControllerMP(this.gameController, this);
this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), packetIn.getDimension(), packetIn.getDifficulty(), this.gameController.mcProfiler);
this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
this.gameController.loadWorld(this.clientWorldController);
this.gameController.player.dimension = packetIn.getDimension();
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
this.gameController.player.setEntityId(packetIn.getPlayerId());
this.currentServerMaxPlayers = packetIn.getMaxPlayers();
this.gameController.player.setReducedDebug(packetIn.isReducedDebugInfo());
this.gameController.playerController.setGameType(packetIn.getGameType());
this.gameController.gameSettings.sendSettingsToServer();
this.netManager.sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
}
示例3: channelRead0
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet<?> msg) throws Exception
{
boolean handled = false;
if (msg instanceof CPacketCustomPayload)
{
handled = handleServerSideCustomPacket((CPacketCustomPayload) msg, ctx);
}
else if (msg instanceof SPacketCustomPayload)
{
handled = handleClientSideCustomPacket((SPacketCustomPayload)msg, ctx);
}
else if (state != ConnectionState.CONNECTED && state != ConnectionState.HANDSHAKECOMPLETE)
{
handled = handleVanilla(msg);
}
if (!handled)
{
ctx.fireChannelRead(msg);
}
}
示例4: handleJoinGame
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
/**
* Registers some server properties (gametype,hardcore-mode,terraintype,difficulty,player limit), creates a new
* WorldClient and sets the player initial dimension
*/
public void handleJoinGame(SPacketJoinGame packetIn)
{
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
this.gameController.playerController = new PlayerControllerMP(this.gameController, this);
this.clientWorldController = new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.get(getNetworkManager()).getOverrideDimension(packetIn), packetIn.getDifficulty(), this.gameController.mcProfiler);
this.gameController.gameSettings.difficulty = packetIn.getDifficulty();
this.gameController.loadWorld(this.clientWorldController);
this.gameController.thePlayer.dimension = packetIn.getDimension();
this.gameController.displayGuiScreen(new GuiDownloadTerrain(this));
this.gameController.thePlayer.setEntityId(packetIn.getPlayerId());
this.currentServerMaxPlayers = packetIn.getMaxPlayers();
this.gameController.thePlayer.setReducedDebug(packetIn.isReducedDebugInfo());
this.gameController.playerController.setGameType(packetIn.getGameType());
this.gameController.gameSettings.sendSettingsToServer();
this.netManager.sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
}
示例5: sendToServer
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void sendToServer(Message message) {
Optional<MessageRegistration<?>> registration = (Optional) this.messageRegistry.getRegistration(message.getClass());
if (registration.isPresent()) {
PacketBuffer content = new PacketBuffer(Unpooled.buffer());
try {
message.writeTo(content);
} catch (IOException e) {
this.logger.error("Unable to serialize the message of type {}", registration.get().getType().getName(), e);
return;
}
PacketBuffer buf = new PacketBuffer(Unpooled.buffer(content.array().length + 1));
buf.writeByte(registration.get().getOpcode());
buf.writeBytes(content);
CPacketCustomPayload packet = new CPacketCustomPayload(this.channel, buf);
Minecraft.getMinecraft().thePlayer.connection.sendPacket(packet);
} else {
this.logger.warn("Attempted to send a message type {} that wasn't registered", registration.get().getType().getName());
}
}
示例6: sendBookToServer
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
private void sendBookToServer() throws IOException {
if (!this.bookIsModified || this.bookPages == null) {
return;
}
while (this.bookPages.tagCount() > 1) {
String s = this.bookPages.getStringTagAt(this.bookPages.tagCount() - 1);
if (!s.trim().isEmpty()) {
break;
}
this.bookPages.removeTag(this.bookPages.tagCount() - 1);
}
this.bookObj.setTagInfo("pages", this.bookPages);
String title = this.bookTitle;
if (title.equals(TITLE_PLACEHOLDER)) title = "";
this.bookObj.setTagInfo("title", new NBTTagString(title));
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeItemStackToBuffer(this.bookObj);
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|BEdit", packetbuffer));
}
示例7: handleJoinGame
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
@Override
public void handleJoinGame(SPacketJoinGame packetIn) {
PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.mc);
if (clientWorldController == null) super.handleJoinGame(packetIn);
this.mc.playerController = new PlayerControllerMP(this.mc, this); //Replaces the playerController with my own patched PlayerControllerMP
ReflectionHelper.set(ObfuscatedField.NetHandlerPlayClient_clientWorldController, clientWorldController, this, new WorldClient(this, new WorldSettings(0L, packetIn.getGameType(), false, packetIn.isHardcoreMode(), packetIn.getWorldType()), net.minecraftforge.fml.common.network.handshake.NetworkDispatcher.get(getNetworkManager()).getOverrideDimension(packetIn), packetIn.getDifficulty(), this.mc.mcProfiler));
this.mc.gameSettings.difficulty = packetIn.getDifficulty();
this.mc.loadWorld(ReflectionHelper.get(ObfuscatedField.NetHandlerPlayClient_clientWorldController, clientWorldController, this));
this.mc.player.dimension = packetIn.getDimension();
this.mc.displayGuiScreen(new GuiDownloadTerrain());
this.mc.player.setEntityId(packetIn.getPlayerId());
this.currentServerMaxPlayers = packetIn.getMaxPlayers();
this.mc.player.setReducedDebug(packetIn.isReducedDebugInfo());
this.mc.playerController.setGameType(packetIn.getGameType());
this.mc.gameSettings.sendSettingsToServer();
this.getNetworkManager().sendPacket(new CPacketCustomPayload("MC|Brand", (new PacketBuffer(Unpooled.buffer())).writeString(ClientBrandRetriever.getClientModName())));
}
示例8: onOutgoingPacket
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onOutgoingPacket(PacketEvent.Outgoing.Pre event) {
if(event.getPacket() instanceof CPacketCustomPayload) {
String channel = ((CPacketCustomPayload) event.getPacket()).getChannelName();
PacketBuffer packetBuffer = ((CPacketCustomPayload) event.getPacket()).getBufferData();
if(isBlockedPacket(channel, packetBuffer)) event.setCanceled(true);
}
}
示例9: onUpdate
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
@Override
public void onUpdate()
{
updateMS();
if(hasTimePassedM(100))
{
WConnection.sendPacket(new CPacketCustomPayload(
vulnerableChannels[random.nextInt(vulnerableChannels.length)],
payload));
updateLastMS();
}
}
示例10: renameItem
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
private void renameItem()
{
String s = this.nameField.getText();
Slot slot = this.anvil.getSlot(0);
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
{
s = "";
}
this.anvil.updateItemName(s);
this.mc.player.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
示例11: actionPerformed
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
boolean flag = false;
if (button == this.nextButton)
{
++this.selectedMerchantRecipe;
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.player);
if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size())
{
this.selectedMerchantRecipe = merchantrecipelist.size() - 1;
}
flag = true;
}
else if (button == this.previousButton)
{
--this.selectedMerchantRecipe;
if (this.selectedMerchantRecipe < 0)
{
this.selectedMerchantRecipe = 0;
}
flag = true;
}
if (flag)
{
((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe);
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.selectedMerchantRecipe);
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|TrSel", packetbuffer));
}
}
示例12: sendToServer
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
private boolean sendToServer(int p_189820_1_)
{
try
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
this.tileStructure.writeCoordinates(packetbuffer);
packetbuffer.writeByte(p_189820_1_);
packetbuffer.writeString(this.tileStructure.getMode().toString());
packetbuffer.writeString(this.nameEdit.getText());
packetbuffer.writeInt(this.parseCoordinate(this.posXEdit.getText()));
packetbuffer.writeInt(this.parseCoordinate(this.posYEdit.getText()));
packetbuffer.writeInt(this.parseCoordinate(this.posZEdit.getText()));
packetbuffer.writeInt(this.parseCoordinate(this.sizeXEdit.getText()));
packetbuffer.writeInt(this.parseCoordinate(this.sizeYEdit.getText()));
packetbuffer.writeInt(this.parseCoordinate(this.sizeZEdit.getText()));
packetbuffer.writeString(this.tileStructure.getMirror().toString());
packetbuffer.writeString(this.tileStructure.getRotation().toString());
packetbuffer.writeString(this.dataEdit.getText());
packetbuffer.writeBoolean(this.tileStructure.ignoresEntities());
packetbuffer.writeBoolean(this.tileStructure.showsAir());
packetbuffer.writeBoolean(this.tileStructure.showsBoundingBox());
packetbuffer.writeFloat(this.parseIntegrity(this.integrityEdit.getText()));
packetbuffer.writeVarLong(this.parseSeed(this.seedEdit.getText()));
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|Struct", packetbuffer));
return true;
}
catch (Exception exception)
{
LOGGER.warn((String)"Could not send structure block info", (Throwable)exception);
return false;
}
}
示例13: actionPerformed
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
if (button.enabled)
{
if (button.id == 1)
{
this.commandBlockLogic.setTrackOutput(this.trackOutput);
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (button.id == 0)
{
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeByte(this.commandBlockLogic.getCommandBlockType());
this.commandBlockLogic.fillInInfo(packetbuffer);
packetbuffer.writeString(this.commandField.getText());
packetbuffer.writeBoolean(this.commandBlockLogic.shouldTrackOutput());
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|AdvCmd", packetbuffer));
if (!this.commandBlockLogic.shouldTrackOutput())
{
this.commandBlockLogic.setLastOutput((ITextComponent)null);
}
this.mc.displayGuiScreen((GuiScreen)null);
}
else if (button.id == 4)
{
this.commandBlockLogic.setTrackOutput(!this.commandBlockLogic.shouldTrackOutput());
this.updateCommandOutput();
}
}
}
示例14: renameItem
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
private void renameItem()
{
String s = this.nameField.getText();
Slot slot = this.anvil.getSlot(0);
if (slot != null && slot.getHasStack() && !slot.getStack().hasDisplayName() && s.equals(slot.getStack().getDisplayName()))
{
s = "";
}
this.anvil.updateItemName(s);
this.mc.thePlayer.connection.sendPacket(new CPacketCustomPayload("MC|ItemName", (new PacketBuffer(Unpooled.buffer())).writeString(s)));
}
示例15: actionPerformed
import net.minecraft.network.play.client.CPacketCustomPayload; //导入依赖的package包/类
/**
* Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
*/
protected void actionPerformed(GuiButton button) throws IOException
{
boolean flag = false;
if (button == this.nextButton)
{
++this.selectedMerchantRecipe;
MerchantRecipeList merchantrecipelist = this.merchant.getRecipes(this.mc.thePlayer);
if (merchantrecipelist != null && this.selectedMerchantRecipe >= merchantrecipelist.size())
{
this.selectedMerchantRecipe = merchantrecipelist.size() - 1;
}
flag = true;
}
else if (button == this.previousButton)
{
--this.selectedMerchantRecipe;
if (this.selectedMerchantRecipe < 0)
{
this.selectedMerchantRecipe = 0;
}
flag = true;
}
if (flag)
{
((ContainerMerchant)this.inventorySlots).setCurrentRecipeIndex(this.selectedMerchantRecipe);
PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
packetbuffer.writeInt(this.selectedMerchantRecipe);
this.mc.getConnection().sendPacket(new CPacketCustomPayload("MC|TrSel", packetbuffer));
}
}