Finished most of the Augments for the Ritual of the Shepherd.
This commit is contained in:
parent
d1e6076cca
commit
0419800a86
7 changed files with 245 additions and 21 deletions
|
@ -1,26 +1,53 @@
|
|||
package WayofTime.bloodmagic.ritual;
|
||||
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.*;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import net.minecraft.entity.EntityAgeable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.api.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
||||
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.registry.ModPotions;
|
||||
import WayofTime.bloodmagic.util.Utils;
|
||||
|
||||
public class RitualAnimalGrowth extends Ritual
|
||||
{
|
||||
public static final double rawWillDrain = 0.05;
|
||||
public static final double vengefulWillDrain = 0.02;
|
||||
public static final double steadfastWillDrain = 0.1;
|
||||
public static final double destructiveWillDrain = 1;
|
||||
|
||||
public static final String GROWTH_RANGE = "growing";
|
||||
public static final String CHEST_RANGE = "chest";
|
||||
|
||||
public int refreshTime = 20;
|
||||
public static int defaultRefreshTime = 20;
|
||||
|
||||
public RitualAnimalGrowth()
|
||||
{
|
||||
super("ritualAnimalGrowth", 0, 10000, "ritual." + Constants.Mod.MODID + ".animalGrowthRitual");
|
||||
addBlockRange(GROWTH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 1, -2), 5, 2, 5));
|
||||
setMaximumVolumeAndDistanceOfRange(GROWTH_RANGE, 0, 3, 3);
|
||||
addBlockRange(CHEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1));
|
||||
|
||||
setMaximumVolumeAndDistanceOfRange(GROWTH_RANGE, 0, 7, 7);
|
||||
setMaximumVolumeAndDistanceOfRange(CHEST_RANGE, 1, 3, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -38,17 +65,108 @@ public class RitualAnimalGrowth extends Ritual
|
|||
|
||||
int maxGrowths = currentEssence / getRefreshCost();
|
||||
int totalGrowths = 0;
|
||||
BlockPos pos = masterRitualStone.getBlockPos();
|
||||
|
||||
AreaDescriptor chestRange = getBlockRange(CHEST_RANGE);
|
||||
TileEntity chest = world.getTileEntity(chestRange.getContainedPositions(pos).get(0));
|
||||
IItemHandler itemHandler = null;
|
||||
if (chest != null)
|
||||
{
|
||||
itemHandler = Utils.getInventory(chest, null);
|
||||
}
|
||||
|
||||
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
|
||||
|
||||
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
|
||||
double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig);
|
||||
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
|
||||
double destructiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DESTRUCTIVE, willConfig);
|
||||
double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig);
|
||||
|
||||
refreshTime = getRefreshTimeForRawWill(rawWill);
|
||||
|
||||
boolean consumeRawWill = rawWill >= rawWillDrain && refreshTime != defaultRefreshTime;
|
||||
|
||||
double vengefulDrain = 0;
|
||||
double steadfastDrain = 0;
|
||||
double destructiveDrain = 0;
|
||||
|
||||
boolean decreaseBreedTimer = vengefulWill >= vengefulWillDrain;
|
||||
boolean breedAnimals = steadfastWill >= steadfastWillDrain && itemHandler != null;
|
||||
boolean kamikaze = destructiveWill >= destructiveWillDrain;
|
||||
|
||||
AreaDescriptor growingRange = getBlockRange(GROWTH_RANGE);
|
||||
AxisAlignedBB axis = growingRange.getAABB(masterRitualStone.getBlockPos());
|
||||
List<EntityAgeable> animalList = world.getEntitiesWithinAABB(EntityAgeable.class, axis);
|
||||
List<EntityAnimal> animalList = world.getEntitiesWithinAABB(EntityAnimal.class, axis);
|
||||
|
||||
for (EntityAgeable entity : animalList)
|
||||
boolean performedEffect = false;
|
||||
|
||||
for (EntityAnimal animal : animalList)
|
||||
{
|
||||
if (entity.getGrowingAge() < 0)
|
||||
if (animal.getGrowingAge() < 0)
|
||||
{
|
||||
entity.addGrowth(5);
|
||||
animal.addGrowth(5);
|
||||
totalGrowths++;
|
||||
performedEffect = true;
|
||||
} else if (animal.getGrowingAge() > 0)
|
||||
{
|
||||
if (decreaseBreedTimer)
|
||||
{
|
||||
if (vengefulWill >= vengefulWillDrain)
|
||||
{
|
||||
animal.setGrowingAge(Math.max(0, animal.getGrowingAge() - getBreedingDecreaseForWill(vengefulWill)));
|
||||
vengefulDrain += vengefulWillDrain;
|
||||
vengefulWill -= vengefulWillDrain;
|
||||
performedEffect = true;
|
||||
} else
|
||||
{
|
||||
decreaseBreedTimer = false;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (kamikaze)
|
||||
{
|
||||
if (destructiveWill >= destructiveWillDrain)
|
||||
{
|
||||
if (!animal.isPotionActive(ModPotions.sacrificialLamb))
|
||||
{
|
||||
animal.addPotionEffect(new PotionEffect(ModPotions.sacrificialLamb, 1200));
|
||||
destructiveDrain += destructiveWillDrain;
|
||||
destructiveWill -= destructiveWillDrain;
|
||||
performedEffect = true;
|
||||
}
|
||||
} else
|
||||
{
|
||||
kamikaze = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (breedAnimals)
|
||||
{
|
||||
if (steadfastWill >= steadfastWillDrain)
|
||||
{
|
||||
if (!animal.isInLove())
|
||||
{
|
||||
for (int slot = 0; slot < itemHandler.getSlots(); slot++)
|
||||
{
|
||||
ItemStack foodStack = itemHandler.getStackInSlot(slot);
|
||||
if (foodStack != null && animal.isBreedingItem(foodStack) && itemHandler.extractItem(slot, 1, true) != null)
|
||||
{
|
||||
animal.setInLove(null);
|
||||
itemHandler.extractItem(slot, 1, false);
|
||||
steadfastDrain += steadfastWillDrain;
|
||||
steadfastWill -= steadfastWillDrain;
|
||||
performedEffect = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
breedAnimals = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (totalGrowths >= maxGrowths)
|
||||
|
@ -57,13 +175,27 @@ public class RitualAnimalGrowth extends Ritual
|
|||
}
|
||||
}
|
||||
|
||||
network.syphon(totalGrowths * getRefreshCost());
|
||||
}
|
||||
if (performedEffect && consumeRawWill)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return 20;
|
||||
if (vengefulDrain > 0)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true);
|
||||
}
|
||||
|
||||
if (steadfastDrain > 0)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.STEADFAST, steadfastDrain, true);
|
||||
}
|
||||
|
||||
if (destructiveDrain > 0)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveDrain, true);
|
||||
}
|
||||
|
||||
network.syphon(totalGrowths * getRefreshCost());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,4 +228,31 @@ public class RitualAnimalGrowth extends Ritual
|
|||
{
|
||||
return new RitualAnimalGrowth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player)
|
||||
{
|
||||
return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info"), new TextComponentTranslation(this.getUnlocalizedName() + ".default.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".vengeful.info") };
|
||||
}
|
||||
|
||||
public int getBreedingDecreaseForWill(double vengefulWill)
|
||||
{
|
||||
return (int) (10 + vengefulWill / 5);
|
||||
}
|
||||
|
||||
public int getRefreshTimeForRawWill(double rawWill)
|
||||
{
|
||||
if (rawWill >= rawWillDrain)
|
||||
{
|
||||
return (int) Math.max(defaultRefreshTime - rawWill / 10, 1);
|
||||
}
|
||||
|
||||
return defaultRefreshTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return refreshTime;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue