Search in sources :

Example 1 with TargetPoint

use of cpw.mods.fml.common.network.NetworkRegistry.TargetPoint in project Armourers-Workshop by RiskyKen.

the class ExPropsPlayerSkinData method updateEquipmentDataToPlayersAround.

public void updateEquipmentDataToPlayersAround() {
    if (!allowNetworkUpdates) {
        return;
    }
    TargetPoint p = new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 512);
    PlayerPointer playerPointer = new PlayerPointer(player);
    PacketHandler.networkWrapper.sendToAllAround(new MessageServerSkinInfoUpdate(playerPointer, equipmentData), p);
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MessageServerSkinInfoUpdate(riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinInfoUpdate) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 2 with TargetPoint

use of cpw.mods.fml.common.network.NetworkRegistry.TargetPoint in project SimplyJetpacks by Tonius.

the class LivingTickHandler method onLivingTick.

@SubscribeEvent
public void onLivingTick(LivingUpdateEvent evt) {
    if (!evt.entityLiving.worldObj.isRemote) {
        ParticleType jetpackState = null;
        ItemStack armor = evt.entityLiving.getEquipmentInSlot(3);
        Jetpack jetpack = null;
        if (armor != null && armor.getItem() instanceof ItemJetpack) {
            jetpack = ((ItemJetpack) armor.getItem()).getPack(armor);
            if (jetpack != null) {
                jetpackState = jetpack.getDisplayParticleType(armor, (ItemJetpack) armor.getItem(), evt.entityLiving);
            }
        }
        if (jetpackState != lastJetpackState.get(evt.entityLiving.getEntityId())) {
            if (jetpackState == null) {
                lastJetpackState.remove(evt.entityLiving.getEntityId());
            } else {
                lastJetpackState.put(evt.entityLiving.getEntityId(), jetpackState);
            }
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        } else if (jetpack != null && evt.entityLiving.worldObj.getTotalWorldTime() % 160L == 0) {
            PacketHandler.instance.sendToAllAround(new MessageJetpackSync(evt.entityLiving.getEntityId(), jetpackState != null ? jetpackState.ordinal() : -1), new TargetPoint(evt.entityLiving.dimension, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, 256));
        }
        if (evt.entityLiving.worldObj.getTotalWorldTime() % 200L == 0) {
            Iterator<Integer> itr = lastJetpackState.keySet().iterator();
            while (itr.hasNext()) {
                int entityId = itr.next();
                if (evt.entityLiving.worldObj.getEntityByID(entityId) == null) {
                    itr.remove();
                }
            }
        }
    }
}
Also used : MessageJetpackSync(tonius.simplyjetpacks.network.message.MessageJetpackSync) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) ParticleType(tonius.simplyjetpacks.setup.ParticleType) ItemStack(net.minecraft.item.ItemStack) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) Jetpack(tonius.simplyjetpacks.item.meta.Jetpack) ItemJetpack(tonius.simplyjetpacks.item.ItemPack.ItemJetpack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 3 with TargetPoint

use of cpw.mods.fml.common.network.NetworkRegistry.TargetPoint in project ArsMagica2 by Mithion.

the class AMNetHandler method sendPacketToAllClientsNear.

public void sendPacketToAllClientsNear(int dimension, double ox, double oy, double oz, double radius, byte packetID, byte[] data) {
    // first byte is ID, followed by data
    byte[] pkt_data = new byte[data.length + 1];
    pkt_data[0] = packetID;
    // copy the data
    for (int i = 0; i < data.length; ++i) {
        pkt_data[i + 1] = data[i];
    }
    FMLProxyPacket packet = new FMLProxyPacket(Unpooled.copiedBuffer(pkt_data), ChannelLabel);
    packet.setTarget(Side.CLIENT);
    Channel.sendToAllAround(packet, new TargetPoint(dimension, ox, oy, oz, radius));
}
Also used : FMLProxyPacket(cpw.mods.fml.common.network.internal.FMLProxyPacket) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 4 with TargetPoint

use of cpw.mods.fml.common.network.NetworkRegistry.TargetPoint in project Armourers-Workshop by RiskyKen.

the class ExPropsPlayerSkinData method sendSkinData.

private void sendSkinData() {
    TargetPoint p = new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 512);
    PlayerPointer playerPointer = new PlayerPointer(player);
    PacketHandler.networkWrapper.sendToAllAround(new MessageServerSkinWardrobeUpdate(playerPointer, this.equipmentWardrobeData), p);
}
Also used : PlayerPointer(riskyken.armourersWorkshop.common.data.PlayerPointer) MessageServerSkinWardrobeUpdate(riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinWardrobeUpdate) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Example 5 with TargetPoint

use of cpw.mods.fml.common.network.NetworkRegistry.TargetPoint in project Armourers-Workshop by RiskyKen.

the class ExPropsEntityEquipmentData method sendEquipmentDataToPlayerToAllPlayersAround.

private void sendEquipmentDataToPlayerToAllPlayersAround() {
    if (!allowNetworkUpdates) {
        return;
    }
    TargetPoint p = new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 512);
    PacketHandler.networkWrapper.sendToAllAround(new MessageServerEntitySkinData(equipmentData, entity.getEntityId()), p);
}
Also used : MessageServerEntitySkinData(riskyken.armourersWorkshop.common.network.messages.server.MessageServerEntitySkinData) TargetPoint(cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)

Aggregations

TargetPoint (cpw.mods.fml.common.network.NetworkRegistry.TargetPoint)6 PlayerPointer (riskyken.armourersWorkshop.common.data.PlayerPointer)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 FMLProxyPacket (cpw.mods.fml.common.network.internal.FMLProxyPacket)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 EntityFireball (net.minecraft.entity.projectile.EntityFireball)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 PacketPlaySound (pneumaticCraft.common.network.PacketPlaySound)1 PacketSetEntityMotion (pneumaticCraft.common.network.PacketSetEntityMotion)1 PacketSpawnParticle (pneumaticCraft.common.network.PacketSpawnParticle)1 MessageServerEntitySkinData (riskyken.armourersWorkshop.common.network.messages.server.MessageServerEntitySkinData)1 MessageServerSkinInfoUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinInfoUpdate)1 MessageServerSkinWardrobeUpdate (riskyken.armourersWorkshop.common.network.messages.server.MessageServerSkinWardrobeUpdate)1 ItemJetpack (tonius.simplyjetpacks.item.ItemPack.ItemJetpack)1 Jetpack (tonius.simplyjetpacks.item.meta.Jetpack)1