use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSoulGem method getRGBDurabilityForDisplay.
@Override
public int getRGBDurabilityForDisplay(ItemStack stack) {
EnumDemonWillType type = this.getCurrentType(stack);
double maxWill = getMaxWill(type, stack);
if (maxWill <= 0) {
return 1;
}
return MathHelper.hsvToRGB(Math.max(0.0F, (float) (getWill(type, stack)) / (float) maxWill) / 3.0F, 1.0F, 1.0F);
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSoulGem method drainWill.
@Override
public double drainWill(EnumDemonWillType type, ItemStack soulGemStack, double drainAmount, boolean doDrain) {
EnumDemonWillType currentType = this.getCurrentType(soulGemStack);
if (currentType != type) {
return 0;
}
double souls = getWill(type, soulGemStack);
double soulsDrained = Math.min(drainAmount, souls);
if (doDrain) {
setWill(type, soulGemStack, souls - soulsDrained);
}
return soulsDrained;
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSoulGem method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
if (!stack.hasTagCompound())
return;
EnumDemonWillType type = this.getCurrentType(stack);
tooltip.add(TextHelper.localize("tooltip.bloodmagic.soulGem." + names[stack.getItemDamage()]));
tooltip.add(TextHelper.localize("tooltip.bloodmagic.will", getWill(type, stack)));
tooltip.add(TextHelper.localizeEffect("tooltip.bloodmagic.currentType." + getCurrentType(stack).getName().toLowerCase()));
super.addInformation(stack, world, tooltip, flag);
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class ItemSoulGem method getSubItems.
@Override
public void getSubItems(CreativeTabs creativeTab, NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTab))
return;
for (int i = 0; i < names.length; i++) {
ItemStack emptyStack = new ItemStack(this, 1, i);
list.add(emptyStack);
}
for (EnumDemonWillType type : EnumDemonWillType.values()) {
for (int i = 0; i < names.length; i++) {
ItemStack fullStack = new ItemStack(this, 1, i);
setWill(type, fullStack, getMaxWill(EnumDemonWillType.DEFAULT, fullStack));
list.add(fullStack);
}
}
}
use of WayofTime.bloodmagic.soul.EnumDemonWillType in project BloodMagic by WayofTime.
the class RitualGreenGrove method performRitual.
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorldObj();
BlockPos pos = masterRitualStone.getBlockPos();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
if (currentEssence < getRefreshCost()) {
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
int maxGrowths = currentEssence / getRefreshCost();
int totalGrowths = 0;
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
refreshTime = getRefreshTimeForRawWill(rawWill);
double growthChance = getPlantGrowthChanceForWill(vengefulWill);
boolean consumeRawWill = rawWill >= rawWillDrain && refreshTime != defaultRefreshTime;
boolean consumeVengefulWill = vengefulWill >= vengefulWillDrain && growthChance != defaultGrowthChance;
double rawDrain = 0;
double vengefulDrain = 0;
AreaDescriptor growingRange = getBlockRange(GROW_RANGE);
int maxGrowthVolume = getMaxVolumeForRange(GROW_RANGE, willConfig, holder);
if (!growingRange.isWithinRange(getMaxVerticalRadiusForRange(GROW_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(GROW_RANGE, willConfig, holder)) || (maxGrowthVolume != 0 && growingRange.getVolume() > maxGrowthVolume)) {
return;
}
for (BlockPos newPos : growingRange.getContainedPositions(pos)) {
IBlockState state = world.getBlockState(newPos);
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state)) {
if (state.getBlock() instanceof IGrowable) {
if (world.rand.nextDouble() < growthChance) {
state.getBlock().updateTick(world, newPos, state, new Random());
IBlockState newState = world.getBlockState(newPos);
if (!newState.equals(state)) {
totalGrowths++;
if (consumeRawWill) {
rawWill -= rawWillDrain;
rawDrain += rawWillDrain;
}
if (consumeVengefulWill) {
vengefulWill -= vengefulWillDrain;
vengefulDrain += vengefulWillDrain;
}
}
}
}
}
if (totalGrowths >= maxGrowths || (consumeRawWill && rawWill < rawWillDrain) || (consumeVengefulWill && vengefulWill < vengefulWillDrain)) {
break;
}
}
if (rawDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrain, true);
}
if (vengefulDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true);
}
AreaDescriptor hydrateRange = getBlockRange(HYDRATE_RANGE);
double steadfastDrain = 0;
if (steadfastWill > steadfastWillDrain) {
AxisAlignedBB aabb = hydrateRange.getAABB(pos);
steadfastDrain += steadfastWillDrain * Utils.plantSeedsInArea(world, aabb, 2, 1);
steadfastWill -= steadfastDrain;
for (BlockPos newPos : hydrateRange.getContainedPositions(pos)) {
if (steadfastWill < steadfastWillDrain) {
break;
}
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
boolean hydratedBlock = false;
if (block == Blocks.DIRT || block == Blocks.GRASS) {
world.setBlockState(newPos, farmlandState);
hydratedBlock = true;
} else if (block == Blocks.FARMLAND) {
int meta = block.getMetaFromState(state);
if (meta < 7) {
world.setBlockState(newPos, farmlandState);
hydratedBlock = true;
}
}
if (hydratedBlock) {
steadfastWill -= steadfastWillDrain;
steadfastDrain += steadfastWillDrain;
}
}
}
if (steadfastDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrain, true);
}
double corrosiveDrain = 0;
if (corrosiveWill > corrosiveWillDrain) {
AreaDescriptor leechRange = getBlockRange(LEECH_RANGE);
AxisAlignedBB mobArea = leechRange.getAABB(pos);
List<EntityLivingBase> entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, mobArea);
for (EntityLivingBase entityLiving : entityList) {
if (corrosiveWill < corrosiveWillDrain) {
break;
}
if (entityLiving instanceof EntityPlayer) {
continue;
}
if (entityLiving.isPotionActive(RegistrarBloodMagic.PLANT_LEECH) || !entityLiving.isPotionApplicable(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH))) {
continue;
}
entityLiving.addPotionEffect(new PotionEffect(RegistrarBloodMagic.PLANT_LEECH, 200, 0));
corrosiveWill -= corrosiveWillDrain;
corrosiveDrain += corrosiveWillDrain;
}
if (corrosiveDrain > 0) {
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
}
}
masterRitualStone.getOwnerNetwork().syphon(totalGrowths * getRefreshCost());
}
Aggregations