本文整理汇总了Java中cpw.mods.fml.common.network.PacketDispatcher.sendPacketToAllAround方法的典型用法代码示例。如果您正苦于以下问题:Java PacketDispatcher.sendPacketToAllAround方法的具体用法?Java PacketDispatcher.sendPacketToAllAround怎么用?Java PacketDispatcher.sendPacketToAllAround使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cpw.mods.fml.common.network.PacketDispatcher
的用法示例。
在下文中一共展示了PacketDispatcher.sendPacketToAllAround方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAmount
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
private void updateAmount() {
int amount = item == null ? 0 : item.stackSize;
if (prevAmount != amount || prevMaxSize != maxSize) {
World world = turtle.getWorld();
Vec3 pos = turtle.getPosition();
int x = (int)Math.floor(pos.xCoord);
int y = (int)Math.floor(pos.yCoord);
int z = (int)Math.floor(pos.zCoord);
ByteArrayDataOutput os = ByteStreams.newDataOutput();
os.writeInt(x);
os.writeInt(y);
os.writeInt(z);
os.writeInt(amount);
os.writeInt(maxSize);
PacketDispatcher.sendPacketToAllAround(pos.xCoord + 0.5D, pos.yCoord + 0.5D, pos.zCoord + 0.5D, 64.0D, world.provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)5, os.toByteArray()));
}
}
示例2: rotate
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void rotate() {
if (!worldObj.isRemote) {
if (forwardDirection == ForgeDirection.DOWN) {
forwardDirection = ForgeDirection.EAST;
} else if (forwardDirection == ForgeDirection.EAST) {
forwardDirection = ForgeDirection.SOUTH;
} else if (forwardDirection == ForgeDirection.SOUTH) {
forwardDirection = ForgeDirection.WEST;
} else if (forwardDirection == ForgeDirection.WEST){
forwardDirection = ForgeDirection.NORTH;
} else if (forwardDirection == ForgeDirection.NORTH) {
forwardDirection = ForgeDirection.UP;
} else if (forwardDirection == ForgeDirection.UP) {
forwardDirection = ForgeDirection.DOWN;
} else {
forwardDirection = ForgeDirection.NORTH;
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 50, worldObj.provider.dimensionId, getDescriptionPacket());
}
}
示例3: sendUpdatePacket
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
/**
* Sends base update packet for MadTileEntity containing position, progress, energy, fluids, textures, etc.
*/
private void sendUpdatePacket()
{
// Send update to clients that require it.
PacketDispatcher.sendPacketToAllAround( this.xCoord,
this.yCoord,
this.zCoord,
ModLoader.PACKET_SEND_RADIUS,
worldObj.provider.dimensionId,
new TileTemplatePacket( this ).makePacket() );
}
示例4: loadArrow
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
/**
* Adds an arrow to an item for rendering arrow = null when taking it off
* @param bow the bow used
* @param arrow the arrow applied
*/
public static void loadArrow(EntityPlayer player, ItemStack bow, ItemStack arrow, boolean sendPacket)
{
NBTTagCompound nbt = getOrApplyNBT(bow);
if(arrow == null)
{
nbt.removeTag("arrowID");
nbt.removeTag("arrowSub");
}
else
{
nbt.setInteger("arrowID", arrow.itemID);
nbt.setInteger("arrowSub", arrow.getItemDamage());
if(sendPacket)
{
try
{
Packet packet = PacketManagerMF.getArrowItemPacket(player, arrow.itemID, arrow.getItemDamage());
PacketDispatcher.sendPacketToAllAround(player.posX, player.posY, player.posZ, 16D, player.dimension, packet);
}
catch(Exception e)
{
System.err.println("MineFantasy: Failed to send arrow render packet to bow");
}
}
}
}
示例5: updateLiquid
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
private void updateLiquid() {
if (!areLiquidsEqual(liquid, prevLiquid)) {
World world = turtle.getWorld();
Vec3 pos = turtle.getPosition();
int x = (int)Math.floor(pos.xCoord);
int y = (int)Math.floor(pos.yCoord);
int z = (int)Math.floor(pos.zCoord);
world.markBlockForUpdate(x, y, z); // update for lava lighting
prevLiquid = liquid == null ? null : liquid.copy();
ByteArrayDataOutput os = ByteStreams.newDataOutput();
os.writeInt(x);
os.writeInt(y);
os.writeInt(z);
if (liquid == null) {
os.writeShort(Short.MIN_VALUE);
os.writeShort(Short.MIN_VALUE);
os.writeInt(Integer.MIN_VALUE);
} else {
os.writeShort(liquid.itemID);
os.writeShort(liquid.itemMeta);
os.writeInt(liquid.amount);
}
PacketDispatcher.sendPacketToAllAround(pos.xCoord + 0.5D, pos.yCoord + 0.5D, pos.zCoord + 0.5D, 64.0D, world.provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)2, os.toByteArray()));
}
}
示例6: callMethod
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception {
switch (method) {
case 0: {
if (arguments.length < 1) throw new Exception("too few arguments");
else if (!(arguments[0] instanceof String)) throw new Exception("bad argument #1 (expected string)");
else if (arguments.length > 1 && !(arguments[1] instanceof Double)) throw new Exception("bad argument #2 (expected number)");
String text = (String) arguments[0];
if (text.length() > 255) text = text.substring(0, 255);
double speed = arguments.length > 1 ? (Double)arguments[1] : 0.0D;
if (speed < -1.0D || speed > 1.0D) throw new Exception("bad speed " + speed + " (expected -1..1)");
if (++reqs > MAX_REQS) throw new Exception("too many requests (over "+MAX_REQS+" per second)");
Vec3 pos = positionable.getPosition();
ByteArrayDataOutput os = ByteStreams.newDataOutput();
os.writeDouble(pos.xCoord);
os.writeDouble(pos.yCoord);
os.writeDouble(pos.zCoord);
os.writeUTF(text);
os.writeDouble(speed);
PacketDispatcher.sendPacketToAllAround(pos.xCoord, pos.yCoord, pos.zCoord, 64.0D, positionable.getWorld().provider.dimensionId, PacketDispatcher.getTinyPacket(MiscPeripherals.instance, (short)8, os.toByteArray()));
return new Object[0];
}
}
return new Object[0];
}
示例7: setHeatLevel
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
@Override
public void setHeatLevel(float heatLevel)
{
m_HeatLevel = heatLevel;
// TODO: Limit sync packets sent?
if (!worldObj.isRemote)
{
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 64, worldObj.provider.dimensionId, PacketHeatLevelSync.from(this).wrap());
}
}
示例8: sendLidAngle
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void sendLidAngle(TileEntitySC tileEntitySC) {
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
DataOutputStream dataStream = new DataOutputStream(byteStream);
try {
dataStream.writeByte((byte)0);
dataStream.writeInt(tileEntitySC.numUsingPlayers);
dataStream.writeFloat(tileEntitySC.lidAngle);
PacketDispatcher.sendPacketToAllAround(tileEntitySC.xCoord, tileEntitySC.yCoord, tileEntitySC.zCoord, 66, tileEntitySC.getWorldObj().provider.dimensionId, PacketDispatcher.getPacket(Reference.CHANNEL, byteStream.toByteArray()));
}catch (IOException e){
System.err.append("Error sending Lid Angle Packet");
}
}
示例9: setTier
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void setTier(int tier) {
if (worldObj != null && !worldObj.isRemote && this.tier != tier) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 50, worldObj.provider.dimensionId, getDescriptionPacket());
this.tier = tier;
}
}
示例10: sendPacket
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void sendPacket()
{
final ByteArrayOutputStream bos = new ByteArrayOutputStream(140);
final DataOutputStream dos = new DataOutputStream(bos);
try
{
dos.writeShort(0);
dos.writeInt(xCoord);
dos.writeInt(yCoord);
dos.writeInt(zCoord);
dos.writeByte(direction);
dos.writeInt(fuelRemaining);
dos.writeInt(temp);
dos.writeInt(maxTemp);
}
catch (final IOException e)
{
System.out.println(e);
}
final Packet250CustomPayload packet = new Packet250CustomPayload();
packet.channel = Agriculture.MODID;
packet.data = bos.toByteArray();
packet.length = bos.size();
packet.isChunkDataPacket = true;
if (packet != null)
{
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
{
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 16, worldObj.provider.dimensionId, packet);
}
else
{
PacketDispatcher.sendPacketToServer(packet);
}
}
}
示例11: deploy
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void deploy()
{
if (worldObj.isRemote)
{
return;
}
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 64D,
worldObj.provider.dimensionId, PacketTypeHandler
.populatePacket(new PacketSoundEvent(Resources.MOD_ID
+ ":ambience", xCoord, yCoord, zCoord, 1.0F,
1.0F)));
startDeploy = true;
}
示例12: EntityRocket2
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public EntityRocket2(World par1World, Rocket rLogic, double x, double y, double z, int controlX, int controlY, int controlZ)
{
this(par1World);
this.setPosition(x, y, z);
ControlPos[0] = controlX;
ControlPos[1] = controlY;
ControlPos[2] = controlZ;
PacketDispatcher.sendPacketToAllAround(controlX, controlY, controlZ, 10, 0, new Packet3Chat(ChatMessageComponent.createFromText("[" + StringUtils.localize("strings.Title") + "] Rocket entity initialized!")));
}
示例13: sendTilePacket
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void sendTilePacket(TileEntity tile)
{
Packet packet = tile.getDescriptionPacket();
PacketDispatcher.sendPacketToAllAround(tile.xCoord, tile.yCoord,
tile.zCoord, 32, tile.worldObj.provider.dimensionId, packet);
}
示例14: sendToAllAround
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public static void sendToAllAround(World world, int x, int y, int z,
Packet packet)
{
PacketDispatcher.sendPacketToAllAround(x, y, z, 32,
world.provider.dimensionId, packet);
}
示例15: invalidateMultiblock
import cpw.mods.fml.common.network.PacketDispatcher; //导入方法依赖的package包/类
public void invalidateMultiblock() {
setIsMultiPart(false);
PacketDispatcher.sendPacketToAllAround(xCoord, yCoord, zCoord, 32,
worldObj.provider.dimensionId, getDescriptionPacket());
}