use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class TransformationEvents method onPlayerRespawn.
@SubscribeEvent
public void onPlayerRespawn(PlayerEvent.Clone event) {
ITransformationData data = event.getOriginal().getCapability(CapabilityTransformationData.CAPABILITY, null);
BewitchmentAPI.getAPI().setTypeAndLevel(event.getEntityPlayer(), data.getType(), data.getLevel(), false);
if (event.isWasDeath()) {
TransformationHelper.setVampireBlood(event.getEntityPlayer(), (int) (data.getMaxBlood() * 0.1));
} else {
TransformationHelper.setVampireBlood(event.getEntityPlayer(), data.getMaxBlood());
}
HotbarAction.refreshActions(event.getEntityPlayer(), event.getEntityPlayer().world);
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class TransformationHelper method drainBloodFromEntity.
public static void drainBloodFromEntity(EntityPlayer player, EntityLivingBase entity) {
IBloodReserve br = entity.getCapability(CapabilityBloodReserve.CAPABILITY, null);
ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
if (br.getBlood() > 0 && br.getMaxBlood() > 0) {
int transferred = (int) Math.min(br.getBlood(), br.getBlood() * 0.05 * data.getLevel());
if (transferred > 0 && (BewitchmentAPI.getAPI().addVampireBlood(player, transferred) || player.isSneaking())) {
br.setBlood(br.getBlood() - transferred);
NetworkHandler.HANDLER.sendToAllAround(new EntityInternalBloodChanged(entity), new TargetPoint(entity.dimension, entity.posX, entity.posY, entity.posZ, 32));
}
}
}
use of com.bewitchment.common.core.capability.transformation.ITransformationData in project Bewitchment by Um-Mitternacht.
the class TransformationHelper method setVampireBlood.
public static void setVampireBlood(EntityPlayer player, int amount) {
ITransformationData data = player.getCapability(CapabilityTransformationData.CAPABILITY, null);
data.setBlood(amount);
if (player instanceof EntityPlayerMP) {
NetworkHandler.HANDLER.sendTo(new PlayerVampireBloodChanged(player), (EntityPlayerMP) player);
}
}
Aggregations