Search in sources :

Example 1 with PacketShuntingAura

use of mods.railcraft.common.util.network.PacketShuntingAura in project Railcraft by Railcraft.

the class ShuntingAuraTickHandler method tick.

@SubscribeEvent
public void tick(PlayerEvent.LivingUpdateEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    if (Game.isClient(entity.worldObj))
        return;
    clock++;
    if (clock % 16 != 0)
        return;
    if (entity instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) entity;
        if (ItemGoggles.isPlayerWearing(player)) {
            ItemStack goggles = ItemGoggles.getGoggles(player);
            ItemGoggles.GoggleAura aura = ItemGoggles.getCurrentAura(goggles);
            if (aura == ItemGoggles.GoggleAura.SHUNTING) {
                List<EntityMinecart> carts = EntitySearcher.findMinecarts().around(player, 32F).at(player.worldObj);
                PacketShuntingAura pkt = new PacketShuntingAura(carts);
                PacketDispatcher.sendToPlayer(pkt.getPacket(), player);
            }
        }
    }
}
Also used : ItemGoggles(mods.railcraft.common.items.ItemGoggles) PacketShuntingAura(mods.railcraft.common.util.network.PacketShuntingAura) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ItemGoggles (mods.railcraft.common.items.ItemGoggles)1 PacketShuntingAura (mods.railcraft.common.util.network.PacketShuntingAura)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityMinecart (net.minecraft.entity.item.EntityMinecart)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1