Java 类net.minecraftforge.event.entity.player.PlayerEvent.StartTracking 实例源码

项目:blockbuster    文件:CapabilityHandler.java   
/**
 * When player starts tracking an actor, server has to send actor's record
 * frames to the player
 */
@SubscribeEvent
public void playerStartsTracking(StartTracking event)
{
    Entity target = event.getTarget();
    EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();

    if (target instanceof EntityActor)
    {
        EntityActor actor = (EntityActor) target;

        if (actor.isPlaying())
        {
            Utils.sendRequestedRecord(actor.getEntityId(), actor.playback.record.filename, player);
        }
    }
}
项目:Bewitchment    文件:BrewEvents.java   
@SubscribeEvent
public void onEntityStartTracking(StartTracking event) {
    Entity entity = event.getTarget();
    EntityPlayer player = event.getEntityPlayer();
    if (!entity.world.isRemote && entity != player && entity instanceof EntityLivingBase && player instanceof EntityPlayerMP) {
        Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage((EntityLivingBase) entity);
        if (optional.isPresent()) {
            IBrewStorage storage = optional.get();
            storage.syncTo((EntityPlayerMP) event.getEntityPlayer());
        }
    }
}
项目:metamorph    文件:CapabilityHandler.java   
/**
 * When player starts tracking another player, server has to send its
 * morphing values.
 */
@SubscribeEvent
public void playerStartsTracking(StartTracking event)
{
    if (event.getTarget() instanceof EntityPlayer)
    {
        Entity target = event.getTarget();
        EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();
        IMorphing cap = target.getCapability(MorphingProvider.MORPHING_CAP, null);

        Dispatcher.sendTo(new PacketMorphPlayer(target.getEntityId(), cap.getCurrentMorph()), player);
    }
}