本文整理汇总了Java中cpw.mods.fml.common.network.PacketDispatcher.sendPacketToAllPlayers方法的典型用法代码示例。如果您正苦于以下问题:Java PacketDispatcher.sendPacketToAllPlayers方法的具体用法?Java PacketDispatcher.sendPacketToAllPlayers怎么用?Java PacketDispatcher.sendPacketToAllPlayers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpw.mods.fml.common.network.PacketDispatcher
的用法示例。
在下文中一共展示了PacketDispatcher.sendPacketToAllPlayers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dispatchPackage
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void dispatchPackage() { //packet server-to-player
Packet250CustomPayload packet = new Packet250CustomPayload();
ByteArrayOutputStream stream = new ByteArrayOutputStream(21);
DataOutputStream outputStream = new DataOutputStream(stream);
try {
outputStream.writeInt(coinSum);
outputStream.writeInt(xCoord);
outputStream.writeInt(yCoord);
outputStream.writeInt(zCoord);
outputStream.writeInt(this.worldObj.getWorldInfo().getVanillaDimension());
outputStream.writeBoolean(bypassActive);
} catch (Exception ex) {
ex.printStackTrace();
}
packet.channel = "UCTS_TileEntity";
packet.data = stream.toByteArray();
packet.length = stream.size();
PacketDispatcher.sendPacketToAllPlayers(packet);
}
示例2: BlockVisibilitySender
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void BlockVisibilitySender(boolean result) {
ByteArrayOutputStream bos = new ByteArrayOutputStream(8);
DataOutputStream outputStream = new DataOutputStream(bos);
try {
outputStream.writeBoolean(result);
} catch (Exception ex) {
ex.printStackTrace();
}
Packet250CustomPayload packet_sender = new Packet250CustomPayload();
packet_sender.channel = "Apocalyptic-bv";
packet_sender.data = bos.toByteArray();
packet_sender.length = bos.size();
if (side == Side.SERVER) {
PacketDispatcher.sendPacketToAllPlayers(packet_sender);
}
}
示例3: onNetworkPatternChange
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@ForgeSubscribe
public void onNetworkPatternChange(GridPatternUpdateEvent e)
{
if (grid != null)
{
IMEInventoryHandler inventoryHandler = grid.getCraftableArray();
if (inventoryHandler != null)
{
craftableFluidsInNetwork = new ArrayList<Fluid>();
for (IAEItemStack stack : inventoryHandler.getAvailableItems())
{
if (stack.getItem() == FLUIDDISPLAY.getItemInstance())
{
craftableFluidsInNetwork.add(FluidRegistry.getFluid(stack.getItemDamage()));
}
}
}
}
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
}
示例4: onItemRightClick
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
MinecraftForge.EVENT_BUS.post(new UseItemEvent(player, this));
itemStack.stackSize--;
EntityStats stats = Dota2Items.stats.getOrCreateEntityStats(player);
long startTime = world.getTotalWorldTime();
long endTime = startTime + (long) (duration * MCConstants.TICKS_PER_SECOND);
BuffInstance buffInst = new BuffInstance(Buff.clarity, player, startTime, endTime, true);
boolean buffAdded = stats.addBuff(buffInst);
PacketDispatcher.sendPacketToAllPlayers(new BuffForcePacket(buffInst).makePacket());
player.playSound(Sound.CLARITY.getName(), 0.7f, 1);
if (!player.worldObj.isRemote && buffAdded) {
EffectClarity effect = new EffectClarity(player);
player.worldObj.spawnEntityInWorld(effect);
}
return itemStack;
}
示例5: doSpellTargetEffect
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit)
{
for (int i = 0; i < 3; i++)
{
final double nextX = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;
final double nextZ = SpellboundCore.modRandom.nextBoolean() ? SpellboundCore.modRandom.nextInt(15) + 10 : SpellboundCore.modRandom.nextInt(15) + 10 * -1;
worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, posX + nextX, posY, posZ + nextZ));
PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createLightningPacket(posX + nextX, posY, posZ + nextZ));
}
final EntityMeteor meteor = new EntityMeteor(caster, this);
meteor.setPosition(posX + SpellboundCore.modRandom.nextGaussian(), 255, posZ + SpellboundCore.modRandom.nextGaussian());
worldObj.spawnEntityInWorld(meteor);
}
示例6: onNeighborBlockChange
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighborID)
{
super.onNeighborBlockChange(world, x, y, z, neighborID);
if (!world.isRemote)
{
if (world.getBlockTileEntity(x, y, z) instanceof TileEntityBusFluidExport)
PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket());
((TileEntityBusFluidExport) world.getBlockTileEntity(x, y, z)).setRedstoneStatus(world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockIndirectlyGettingPowered(x, y + 1, z));
}
ForgeDirection blockOrientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z));
TileEntity blockTE = world.getBlockTileEntity(x, y, z);
if (blockTE instanceof TileEntityBusFluidExport)
{
TileEntity fluidHandler = world.getBlockTileEntity(x + blockOrientation.offsetX, y + blockOrientation.offsetY, z + blockOrientation.offsetZ);
((TileEntityBusFluidExport) blockTE).setFluidHandler(fluidHandler instanceof IFluidHandler ? (IFluidHandler) fluidHandler : null);
}
}
示例7: syncSpear
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void syncSpear()
{
if(!worldObj.isRemote)
{
try
{
Packet packet = PacketManagerMF.getPacketItemStackArray(this, 0, getSpear());
PacketDispatcher.sendPacketToAllPlayers(packet);
}catch(Exception e){}
}
}
示例8: syncItems
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void syncItems()
{
if(!worldObj.isRemote)
{
try
{
for(int a = 0; a < this.getSizeInventory(); a ++)
{
Packet packet = PacketManagerMF.getPacketItemStackArray(this, a, getStackInSlot(a));
PacketDispatcher.sendPacketToAllPlayers(packet);
}
}catch(Exception e){}
}
}
示例9: onNeighborBlockChange
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int neighbourID)
{
if (!world.isRemote)
{
PacketDispatcher.sendPacketToAllPlayers(world.getBlockTileEntity(x, y, z).getDescriptionPacket());
}
}
示例10: setPowerStatus
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void setPowerStatus(boolean hasPower)
{
powerStatus = hasPower;
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord);
}
示例11: playerLoggedIn
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
//SERVER SIDE
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
PacketDispatcher.sendPacketToPlayer(getSkillAllUpdatePacket(), player);
PacketDispatcher.sendPacketToAllPlayers(getAllSkillsUpdatePacket(netHandler.getPlayer().username));
SCLog.info("Send all skills to " + netHandler.getPlayer().username);
}
示例12: drain
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
if (from == ForgeDirection.UNKNOWN)
return null;
FluidStack drained = tanks[from.ordinal()].drain(maxDrain, doDrain);
if (drained != null)
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
return drained;
}
示例13: fill
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
{
if (from == ForgeDirection.UNKNOWN || resource == null)
return 0;
int filled = 0;
filled += fillToNetwork(resource, doFill);
if (filled < resource.amount)
filled += tanks[from.ordinal()].fill(new FluidStack(resource.fluidID, resource.amount - filled), doFill);
if (filled > 0)
PacketDispatcher.sendPacketToAllPlayers(getDescriptionPacket());
return filled;
}
示例14: sendCapeUpdate
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void sendCapeUpdate(String player, String capeUrl) {
if (capeUrl == null) {
capeUrl = "";
}
Object[] data = new Object[] { player, capeUrl };
PacketDispatcher.sendPacketToAllPlayers(PacketWrapper.createPacket(HexxitGear.modNetworkChannel, Packets.CapeChange, data));
}
示例15: doSpellTargetEffect
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void doSpellTargetEffect(World worldObj, int posX, int posY, int posZ, EntityLivingBase entityHit)
{
if (entityHit != null)
{
PacketDispatcher.sendPacketToAllPlayers(PacketHandler.createColdGFXPacket(2, 0, entityHit.posX, entityHit.posY, entityHit.posZ));
for (final Point3D point : Logic.getNearbyBlocks(worldObj, (int)entityHit.posX, (int)entityHit.posY, (int)entityHit.posZ, 3, Constants.SNOW_SUPPORTERS))
{
if (worldObj.getBlockId(point.posX, point.posY + 1, point.posZ) == 0)
{
worldObj.setBlock(point.posX, point.posY + 1, point.posZ, Block.snow.blockID);
}
}
if (entityHit instanceof EntityPlayer)
{
if (!SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellShieldOfInvulnerability.class) && !SpellboundCore.getInstance().entityHasActiveSpell((EntityPlayer)entityHit, SpellColdShield.class))
{
entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
entityHit.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200));
entityHit.extinguish();
}
}
else
{
entityHit.attackEntityFrom(DamageSource.magic, 5.0F);
entityHit.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 1200));
entityHit.extinguish();
}
}
}