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());
}
}
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);
}
}
Aggregations