Search in sources :

Example 1 with EnergyMessage

use of com.witchworks.common.core.net.EnergyMessage in project Witchworks by Um-Mitternacht.

the class EnergyEvents method onWorldJoin.

@SubscribeEvent
public void onWorldJoin(EntityJoinWorldEvent event) {
    if (event.getEntity() instanceof EntityPlayerMP) {
        EntityPlayerMP entity = (EntityPlayerMP) event.getEntity();
        Optional<IEnergy> optional = EnergyHandler.getEnergy(entity);
        if (optional.isPresent()) {
            PacketHandler.sendTo(entity, new EnergyMessage(optional.get(), entity.getUniqueID()));
        }
    }
}
Also used : EnergyMessage(com.witchworks.common.core.net.EnergyMessage) IEnergy(com.witchworks.common.core.capability.energy.IEnergy) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IEnergy (com.witchworks.common.core.capability.energy.IEnergy)1 EnergyMessage (com.witchworks.common.core.net.EnergyMessage)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1