Search in sources :

Example 1 with ICapability

use of mdc.voodoocraft.capability.ICapability in project VoodooCraft by Mod-DevCafeTeam.

the class CapabilityHandler method onClonePlayer.

@SuppressWarnings("all")
@SubscribeEvent
public static void onClonePlayer(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
    //Copy capability on player death to new player
    if (event.isWasDeath() && (event.getEntityPlayer() instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) event.getEntityPlayer();
        for (Capability<? extends ICapability> cap : VCCapabilities.getCapabilities()) {
            ICapability oldicap = event.getOriginal().getCapability(cap, null);
            ICapability icap = player.getCapability(cap, null);
            if (oldicap == null || icap == null)
                continue;
            icap.deserializeNBT(oldicap.serializeNBT());
            icap.dataChanged(player);
        }
    }
}
Also used : ICapability(mdc.voodoocraft.capability.ICapability) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ICapability (mdc.voodoocraft.capability.ICapability)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1