本文整理汇总了Java中cpw.mods.fml.common.network.PacketDispatcher.sendPacketToServer方法的典型用法代码示例。如果您正苦于以下问题:Java PacketDispatcher.sendPacketToServer方法的具体用法?Java PacketDispatcher.sendPacketToServer怎么用?Java PacketDispatcher.sendPacketToServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpw.mods.fml.common.network.PacketDispatcher
的用法示例。
在下文中一共展示了PacketDispatcher.sendPacketToServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: requestCoinSumPackage
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
void requestCoinSumPackage(){
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream stream = new ByteArrayOutputStream(16);
DataOutputStream outputStream = new DataOutputStream(stream);
try {
outputStream.writeInt(xCoord);
outputStream.writeInt(yCoord);
outputStream.writeInt(zCoord);
outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
} catch (Exception ex) {
ex.printStackTrace();
}
packet.channel = "UCTS_TE_Request";
packet.data = stream.toByteArray();
packet.length = stream.size();
PacketDispatcher.sendPacketToServer(packet);
}
示例2: onBlockActivated
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2)
{
TileEntityAnvil tile = (TileEntityAnvil) world.getBlockTileEntity(x, y, z);
if(tile == null)
{
return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
}
if(world.isRemote)
{
int slot = tile.getSlotFor(f, f2);
this.useInventory(world, x, y, z, tile, player, i, slot);
Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
try
{
PacketDispatcher.sendPacketToServer(packet);
} catch(NullPointerException e)
{
System.out.println("MineFantasy: Client connection lost");
}
}
return true;
}
示例3: onBlockActivated
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2)
{
TileEntityTailor tile = (TileEntityTailor) world.getBlockTileEntity(x, y, z);
if(tile == null)
{
return super.onBlockActivated(world, x, y, z, player, i, f, f1, f2);
}
if(world.isRemote)
{
int slot = tile.getSlotFor(f, f2);
this.useInventory(world, x, y, z, tile, player, i, slot);
Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
try
{
PacketDispatcher.sendPacketToServer(packet);
} catch(NullPointerException e)
{
System.out.println("MineFantasy: Client connection lost");
}
}
return true;
}
示例4: onBlockActivated
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float f1, float f2)
{
TileEntityWeaponRack tile = (TileEntityWeaponRack)world.getBlockTileEntity(x, y, z);
if(world.isRemote)
{
int slot = tile.getSlotFor(f, f2);
if(slot >= 0 && slot < 4)
{
tryPlaceItem(slot, world, tile, player);
}
Packet packet = PacketManagerMF.getPacketIntegerArray(tile, new int[]{1, player.entityId, i, slot});
try
{
PacketDispatcher.sendPacketToServer(packet);
} catch(NullPointerException e)
{
System.out.println("MineFantasy: Client connection lost");
}
}
return true;
}
示例5: onMouseClick
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Subscribe
public void onMouseClick(MouseClickEvent event)
{
if (event.getComponent().getAction().equals(btnSit.getAction()))
{
bot.setSitting(!bot.isSitting());
PacketDispatcher.sendPacketToServer(new PacketBuddyBotSit(bot.entityId).makePacket());
btnSit.setText(bot.isSitting() ? LangHelper.translate("gui", "button.stand") : LangHelper.translate("gui", "button.sit"));
}
if (event.getComponent().getAction().equals(btnNext.getAction()))
{
if (currentPage < pages.size() - 1)
setCurrentPage(currentPage + 1);
}
if (event.getComponent().getAction().equals(btnPrev.getAction()))
{
if (currentPage > 0)
setCurrentPage(currentPage - 1);
}
}
示例6: mousePressed
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public boolean mousePressed(Minecraft minecraft, int par2, int par3)
{
if (renderID != 0)
return super.mousePressed(minecraft, par2, par3);
this.enabled = !super.mousePressed(minecraft, par2, par3);
if (!this.enabled && this.renderID == 0)
{
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.length = 1;
packet.data = new byte[] { 0 };
packet.channel = Reference.CHANNEL;
PacketDispatcher.sendPacketToServer(packet);
}
return !this.enabled;
}
示例7: overlayRecipe
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift)
{
List<PositionedStack> ingredients = recipe.getIngredientStacks(recipeIndex);
NBTTagCompound root = new NBTTagCompound();
for (PositionedStack stack : ingredients)
{
int x = (stack.relx - 25) / 18;
int y = (stack.rely - 6) / 18;
root.setCompoundTag(String.valueOf((x + y * 3)), stack.item.writeToNBT(new NBTTagCompound()));
}
PacketDispatcher.sendPacketToServer(NetworkHelper.makeNBTPacket(CHANNEL_NEI, root));
((AutoCrafterGui) firstGui).inventorySlots.getSlot(0).putStack(recipe.getResultStack(recipeIndex).item);
}
示例8: order
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
private void order()
{
if( !m_ordered )
{
// Send our orders to the server
for( int i=0; i<NUM_SETS; ++i )
{
if( m_orders[i] )
{
BillundPacket packet = new BillundPacket();
packet.packetType = BillundPacket.OrderSet;
packet.dataInt = new int[] { i };
PacketDispatcher.sendPacketToServer( packet.toPacket() );
}
}
// Ensure we don't order again
m_ordered = true;
}
}
示例9: mouseClicked
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
protected void mouseClicked(int par1, int par2, int par3) {
super.mouseClicked(par1, par2, par3);
if (drawButtonReady(par1, par2) && selected >= 0) {
if (ClientTradingManager.tradeTarget != null) {
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
ClientTradingManager.player1Ready = !ClientTradingManager.player1Ready;
PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.SetTradingReady, ClientTradingManager.player1Ready ? 1 : 0));
}
}
if (drawButtonTrade(par1, par2)) {
if (ClientTradingManager.player1Ready && ClientTradingManager.player2Ready) {
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.Trade, 0));
}
}
if (drawPokemonSelection(par1, par2) != -1) {
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
this.selected = drawPokemonSelection(par1, par2);
PacketDispatcher.sendPacketToServer(PacketCreator.createPacket(EnumPackets.SelectPokemonForTrade, selected));
}
if(drawButtonClose(par1, par2)){
this.mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
mc.thePlayer.closeScreen();
}
}
示例10: drawGuiContainerForegroundLayer
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
protected void drawGuiContainerForegroundLayer(int sizeX, int sizeY)
{
PacketDispatcher.sendPacketToServer(new PacketBusFluidImport(world, tileentity.xCoord, tileentity.yCoord, tileentity.zCoord, 0, player.username).makePacket());
Minecraft.getMinecraft().renderEngine.bindTexture(guiTexture);
if (tileentity != null)
{
WidgetRedstoneModes redstoneSwitch = (WidgetRedstoneModes) buttonList.get(0);
redstoneSwitch.setRedstoneMode(tileentity.getRedstoneMode());
WidgetFluidModes fluidSwitch = (WidgetFluidModes) buttonList.get(1);
fluidSwitch.setFluidMode(tileentity.getFluidMode());
}
this.fontRenderer.drawString(BlockEnum.FLUIDIMPORT.getStatName(), 5, 0, 0x000000);
}
示例11: sendGuiExpBookPacket
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void sendGuiExpBookPacket(int data) {
if (FMLCommonHandler.instance().getSide().equals(Side.CLIENT)) {
log("Side is Client, creating packet.");
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
DataOutputStream dataStream = new DataOutputStream(bytes);
try {
dataStream.writeInt(0);
dataStream.writeInt(data);
} catch (IOException e) {
e.printStackTrace();
}
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "EnhancedBooks"; // CHANNEL MAX 16 CHARS
packet.data = bytes.toByteArray();
packet.length = packet.data.length;
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
log("Sending Packet 250 (Channel:" + packet.channel + " Data:" + packet.data + " Length:" + packet.length + ")");
PacketDispatcher.sendPacketToServer(packet);
}
}
}
示例12: sendReloaderPacket
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void sendReloaderPacket() {
try {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(baout);
out.writeByte(reloadPacketID);
out.close();
Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = "bl2";
packet.isChunkDataPacket = false;
packet.data = baout.toByteArray();
packet.length = baout.size();
PacketDispatcher.sendPacketToServer(packet);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例13: actionPerformed
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
protected void actionPerformed(GuiButton button)
{
if (button.id == ID_REDSTONE)
{
AutoCrafterTile tile = ((AutoCrafterContainer) this.inventorySlots).tile;
redstonebutton.item = tile.redstoneMode = (tile.redstoneMode + 1) % 3;
PacketDispatcher.sendPacketToServer(PacketDispatcher.getPacket(CHANNEL_RMU, Joiner.on(";").join(tile.xCoord, tile.yCoord, tile.zCoord, tile.redstoneMode).getBytes()));
}
}
示例14: commandFromClient
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public void commandFromClient(int id)
{
try {
Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{2, id});
PacketDispatcher.sendPacketToServer(packet);
FMLCommonHandler.instance().getMinecraftServerInstance()
.getConfigurationManager()
.sendPacketToAllPlayers(packet);
} catch (NullPointerException e) {
;
}
}
示例15: usePower
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
public void usePower(int id)
{
try {
Packet packet = PacketManagerMF.getEntityPacketIntegerArray(this, new int[]{3, id});
PacketDispatcher.sendPacketToServer(packet);
FMLCommonHandler.instance().getMinecraftServerInstance()
.getConfigurationManager()
.sendPacketToAllPlayers(packet);
} catch (NullPointerException e) {
;
}
}