Search in sources :

Example 1 with IFortuneValueSystem

use of team.covertdragon.springfestival.module.fortune.fortunevaluesystem.capability.IFortuneValueSystem in project SpringFestival by TeamCovertDragon.

the class FortuneValueManager method updatePlayerFortuneValue.

private void updatePlayerFortuneValue(EntityPlayerMP player) {
    IFortuneValueSystem system = player.getCapability(CapabilityLoader.fortuneValue, null);
    if (system != null) {
        // Update player fortune level
        system.addFortune(system.getIncreasingPoint());
        system.setBufPoint(0);
        // Tick FV machines
        for (AbstractTileFVMachine machine : system.getFVMachines()) {
            if (machine.getWorld().getTileEntity(machine.getPos()) == null) {
                TASKS.add(new FortuneManagerActions.ActionDeleteMachine(machine, system));
                continue;
            }
            if (system.shrinkFortune(machine.getRequiredFV())) {
                machine.onFVProvided();
            }
        }
    } else {
        throw new RuntimeException("Unable to read fv system info for player " + player.getGameProfile().getName());
    }
}
Also used : AbstractTileFVMachine(team.covertdragon.springfestival.module.fortune.fortunevaluesystem.machines.AbstractTileFVMachine) IFortuneValueSystem(team.covertdragon.springfestival.module.fortune.fortunevaluesystem.capability.IFortuneValueSystem)

Example 2 with IFortuneValueSystem

use of team.covertdragon.springfestival.module.fortune.fortunevaluesystem.capability.IFortuneValueSystem in project SpringFestival by TeamCovertDragon.

the class ModuleFortune method onPlayerClone.

@SubscribeEvent
public void onPlayerClone(net.minecraftforge.event.entity.player.PlayerEvent.Clone event) {
    Capability<IFortuneValueSystem> capability = CapabilityLoader.fortuneValue;
    Capability.IStorage<IFortuneValueSystem> storage = capability.getStorage();
    if (event.getOriginal().hasCapability(capability, null) && event.getEntityPlayer().hasCapability(capability, null)) {
        NBTBase nbt = storage.writeNBT(capability, event.getOriginal().getCapability(capability, null), null);
        storage.readNBT(capability, event.getEntityPlayer().getCapability(capability, null), null, nbt);
    }
}
Also used : IFortuneValueSystem(team.covertdragon.springfestival.module.fortune.fortunevaluesystem.capability.IFortuneValueSystem) Capability(net.minecraftforge.common.capabilities.Capability) NBTBase(net.minecraft.nbt.NBTBase) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

IFortuneValueSystem (team.covertdragon.springfestival.module.fortune.fortunevaluesystem.capability.IFortuneValueSystem)2 NBTBase (net.minecraft.nbt.NBTBase)1 Capability (net.minecraftforge.common.capabilities.Capability)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 AbstractTileFVMachine (team.covertdragon.springfestival.module.fortune.fortunevaluesystem.machines.AbstractTileFVMachine)1