Search in sources :

Example 1 with Clone

use of net.minecraftforge.event.entity.player.PlayerEvent.Clone in project Bewitchment by Um-Mitternacht.

the class BrewEvents method onPlayerClone.

@SubscribeEvent
public void onPlayerClone(Clone event) {
    if (!event.isWasDeath()) {
        final EntityPlayer oldPlayer = event.getOriginal();
        final EntityPlayer newPlayer = event.getEntityPlayer();
        Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(oldPlayer);
        optional.ifPresent(oldStorage -> BrewStorageHandler.getBrewStorage(newPlayer).ifPresent(newStorage -> {
            newStorage.setBrewMap(oldStorage.getBrewMap());
            newStorage.syncToNear(newPlayer);
        }));
    }
}
Also used : BrewEffect(com.bewitchment.common.brew.BrewEffect) Entity(net.minecraft.entity.Entity) com.bewitchment.api.cauldron.brew.special(com.bewitchment.api.cauldron.brew.special) Collection(java.util.Collection) IBrew(com.bewitchment.api.cauldron.brew.IBrew) PlayerEvent(net.minecraftforge.fml.common.gameevent.PlayerEvent) HashMap(java.util.HashMap) Clone(net.minecraftforge.event.entity.player.PlayerEvent.Clone) AttachCapabilitiesEvent(net.minecraftforge.event.AttachCapabilitiesEvent) StartTracking(net.minecraftforge.event.entity.player.PlayerEvent.StartTracking) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BrewStorageHandler(com.bewitchment.common.core.capability.brew.BrewStorageHandler) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Map(java.util.Map) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) IBrewStorage(com.bewitchment.api.capability.IBrewStorage) Optional(java.util.Optional) LibMod(com.bewitchment.common.lib.LibMod) BrewStorageProvider(com.bewitchment.common.core.capability.brew.BrewStorageProvider) net.minecraftforge.event.entity.living(net.minecraftforge.event.entity.living) IBrewStorage(com.bewitchment.api.capability.IBrewStorage) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IBrewStorage (com.bewitchment.api.capability.IBrewStorage)1 IBrew (com.bewitchment.api.cauldron.brew.IBrew)1 com.bewitchment.api.cauldron.brew.special (com.bewitchment.api.cauldron.brew.special)1 BrewEffect (com.bewitchment.common.brew.BrewEffect)1 BrewStorageHandler (com.bewitchment.common.core.capability.brew.BrewStorageHandler)1 BrewStorageProvider (com.bewitchment.common.core.capability.brew.BrewStorageProvider)1 LibMod (com.bewitchment.common.lib.LibMod)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Entity (net.minecraft.entity.Entity)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 AttachCapabilitiesEvent (net.minecraftforge.event.AttachCapabilitiesEvent)1 net.minecraftforge.event.entity.living (net.minecraftforge.event.entity.living)1 Clone (net.minecraftforge.event.entity.player.PlayerEvent.Clone)1 StartTracking (net.minecraftforge.event.entity.player.PlayerEvent.StartTracking)1