Added more rituals
Includes the Green Grove, Regen, Animal Growth, and a fix to the Feathered Knife ritual so that it... doesn't cause the damage animation.
This commit is contained in:
parent
e312e3d854
commit
06faa916c3
15 changed files with 1365 additions and 45 deletions
|
@ -0,0 +1,258 @@
|
|||
package wayoftime.bloodmagic.ritual.types;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
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.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
||||
import wayoftime.bloodmagic.ritual.AreaDescriptor;
|
||||
import wayoftime.bloodmagic.ritual.EnumRuneType;
|
||||
import wayoftime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import wayoftime.bloodmagic.ritual.Ritual;
|
||||
import wayoftime.bloodmagic.ritual.RitualComponent;
|
||||
import wayoftime.bloodmagic.ritual.RitualRegister;
|
||||
import wayoftime.bloodmagic.util.Utils;
|
||||
|
||||
@RitualRegister("animal_growth")
|
||||
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 static int defaultRefreshTime = 20;
|
||||
public int refreshTime = 20;
|
||||
|
||||
public RitualAnimalGrowth()
|
||||
{
|
||||
super("ritualAnimalGrowth", 0, 10000, "ritual." + BloodMagic.MODID + ".animalGrowthRitual");
|
||||
addBlockRange(GROWTH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-2, 1, -2), 5, 2, 5));
|
||||
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
|
||||
public void performRitual(IMasterRitualStone masterRitualStone)
|
||||
{
|
||||
World world = masterRitualStone.getWorldObj();
|
||||
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
|
||||
|
||||
if (currentEssence < getRefreshCost())
|
||||
{
|
||||
masterRitualStone.getOwnerNetwork().causeNausea();
|
||||
return;
|
||||
}
|
||||
|
||||
int maxGrowths = currentEssence / getRefreshCost();
|
||||
int totalGrowths = 0;
|
||||
BlockPos pos = masterRitualStone.getBlockPos();
|
||||
|
||||
AreaDescriptor chestRange = masterRitualStone.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 = masterRitualStone.getBlockRange(GROWTH_RANGE);
|
||||
AxisAlignedBB axis = growingRange.getAABB(masterRitualStone.getBlockPos());
|
||||
List<AnimalEntity> animalList = world.getEntitiesWithinAABB(AnimalEntity.class, axis);
|
||||
|
||||
boolean performedEffect = false;
|
||||
|
||||
for (AnimalEntity animal : animalList)
|
||||
{
|
||||
if (animal.getGrowingAge() < 0)
|
||||
{
|
||||
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(BloodMagicPotions.SACRIFICIAL_LAMB))
|
||||
{
|
||||
animal.addPotionEffect(new EffectInstance(BloodMagicPotions.SACRIFICIAL_LAMB, 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)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (performedEffect && consumeRawWill)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawWillDrain, true);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalGrowths * getRefreshCost()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshCost()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherComponents(Consumer<RitualComponent> components)
|
||||
{
|
||||
|
||||
addParallelRunes(components, 2, 0, EnumRuneType.DUSK);
|
||||
addParallelRunes(components, 1, 0, EnumRuneType.WATER);
|
||||
components.accept(new RitualComponent(new BlockPos(1, 0, 2), EnumRuneType.EARTH));
|
||||
components.accept(new RitualComponent(new BlockPos(1, 0, -2), EnumRuneType.EARTH));
|
||||
components.accept(new RitualComponent(new BlockPos(-1, 0, 2), EnumRuneType.EARTH));
|
||||
components.accept(new RitualComponent(new BlockPos(-1, 0, -2), EnumRuneType.EARTH));
|
||||
components.accept(new RitualComponent(new BlockPos(2, 0, 1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(2, 0, -1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(-2, 0, 1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(-2, 0, -1), EnumRuneType.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ritual getNewCopy()
|
||||
{
|
||||
return new RitualAnimalGrowth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent[] provideInformationOfRitualToPlayer(PlayerEntity player)
|
||||
{
|
||||
return new ITextComponent[] { new TranslationTextComponent(this.getTranslationKey() + ".info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".default.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".corrosive.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".steadfast.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".destructive.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".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;
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ import java.util.List;
|
|||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
@ -14,7 +15,9 @@ import net.minecraft.world.World;
|
|||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.ConfigHandler;
|
||||
import wayoftime.bloodmagic.altar.IBloodAltar;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.network.SetClientHealthPacket;
|
||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
||||
import wayoftime.bloodmagic.ritual.AreaDescriptor;
|
||||
import wayoftime.bloodmagic.ritual.EnumRuneType;
|
||||
|
@ -23,7 +26,6 @@ import wayoftime.bloodmagic.ritual.Ritual;
|
|||
import wayoftime.bloodmagic.ritual.RitualComponent;
|
||||
import wayoftime.bloodmagic.ritual.RitualRegister;
|
||||
import wayoftime.bloodmagic.util.helper.PlayerSacrificeHelper;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
|
||||
@RitualRegister("feathered_knife")
|
||||
public class RitualFeatheredKnife extends Ritual
|
||||
|
@ -54,6 +56,10 @@ public class RitualFeatheredKnife extends Ritual
|
|||
public void performRitual(IMasterRitualStone masterRitualStone)
|
||||
{
|
||||
World world = masterRitualStone.getWorldObj();
|
||||
// if (world.isRemote)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
|
||||
|
||||
if (currentEssence < getRefreshCost())
|
||||
|
@ -118,8 +124,7 @@ public class RitualFeatheredKnife extends Ritual
|
|||
{
|
||||
float healthThreshold = steadfastWill >= steadfastWillThreshold ? 0.7f : 0.3f;
|
||||
|
||||
if (vengefulWill >= vengefulWillThreshold
|
||||
&& !player.getGameProfile().getId().equals(masterRitualStone.getOwner()))
|
||||
if (vengefulWill >= vengefulWillThreshold && !player.getGameProfile().getId().equals(masterRitualStone.getOwner()))
|
||||
{
|
||||
healthThreshold = 0.1f;
|
||||
}
|
||||
|
@ -130,8 +135,7 @@ public class RitualFeatheredKnife extends Ritual
|
|||
float sacrificedHealth = 1;
|
||||
double lpModifier = 1;
|
||||
|
||||
if ((health / player.getMaxHealth() > healthThreshold)
|
||||
&& (!useIncense || !player.isPotionActive(BloodMagicPotions.SOUL_FRAY)))
|
||||
if ((health / player.getMaxHealth() > healthThreshold) && (!useIncense || !player.isPotionActive(BloodMagicPotions.SOUL_FRAY)))
|
||||
{
|
||||
if (useIncense)
|
||||
{
|
||||
|
@ -169,9 +173,9 @@ public class RitualFeatheredKnife extends Ritual
|
|||
// }
|
||||
|
||||
player.setHealth(health - sacrificedHealth);
|
||||
BloodMagic.packetHandler.sendTo(new SetClientHealthPacket(health - sacrificedHealth), (ServerPlayerEntity) player);
|
||||
|
||||
tileAltar.sacrificialDaggerCall((int) (ConfigHandler.values.sacrificialDaggerConversion * lpModifier
|
||||
* sacrificedHealth), false);
|
||||
tileAltar.sacrificialDaggerCall((int) (ConfigHandler.values.sacrificialDaggerConversion * lpModifier * sacrificedHealth), false);
|
||||
|
||||
totalEffects++;
|
||||
|
||||
|
@ -229,8 +233,7 @@ public class RitualFeatheredKnife extends Ritual
|
|||
@Override
|
||||
public ITextComponent[] provideInformationOfRitualToPlayer(PlayerEntity player)
|
||||
{
|
||||
return new ITextComponent[]
|
||||
{ new TranslationTextComponent(this.getTranslationKey() + ".info"),
|
||||
return new ITextComponent[] { new TranslationTextComponent(this.getTranslationKey() + ".info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".default.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".corrosive.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".steadfast.info"),
|
||||
|
|
|
@ -0,0 +1,345 @@
|
|||
package wayoftime.bloodmagic.ritual.types;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.CactusBlock;
|
||||
import net.minecraft.block.FarmlandBlock;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.SugarCaneBlock;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.impl.BloodMagicAPI;
|
||||
import wayoftime.bloodmagic.potion.BloodMagicPotions;
|
||||
import wayoftime.bloodmagic.ritual.AreaDescriptor;
|
||||
import wayoftime.bloodmagic.ritual.EnumRuneType;
|
||||
import wayoftime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import wayoftime.bloodmagic.ritual.Ritual;
|
||||
import wayoftime.bloodmagic.ritual.RitualComponent;
|
||||
import wayoftime.bloodmagic.ritual.RitualRegister;
|
||||
import wayoftime.bloodmagic.util.Utils;
|
||||
import wayoftime.bloodmagic.will.DemonWillHolder;
|
||||
|
||||
@RitualRegister("green_grove")
|
||||
public class RitualGreenGrove extends Ritual
|
||||
{
|
||||
public static final String GROW_RANGE = "growing";
|
||||
public static final String LEECH_RANGE = "leech";
|
||||
public static final String HYDRATE_RANGE = "hydrate";
|
||||
|
||||
public static double corrosiveWillDrain = 0.2;
|
||||
public static double rawWillDrain = 0.05;
|
||||
public static double vengefulWillDrain = 0.05;
|
||||
public static double steadfastWillDrain = 0.05;
|
||||
public static int defaultRefreshTime = 20;
|
||||
public static double defaultGrowthChance = 0.3;
|
||||
public static BlockState farmlandState = Blocks.FARMLAND.getDefaultState().with(FarmlandBlock.MOISTURE, 7);
|
||||
public int refreshTime = 20;
|
||||
|
||||
public RitualGreenGrove()
|
||||
{
|
||||
super("ritualGreenGrove", 0, 5000, "ritual." + BloodMagic.MODID + ".greenGroveRitual");
|
||||
addBlockRange(GROW_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 2, -1), 3, 1, 3));
|
||||
addBlockRange(LEECH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 1));
|
||||
addBlockRange(HYDRATE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 1));
|
||||
setMaximumVolumeAndDistanceOfRange(GROW_RANGE, 81, 4, 4);
|
||||
setMaximumVolumeAndDistanceOfRange(LEECH_RANGE, 0, 15, 15);
|
||||
setMaximumVolumeAndDistanceOfRange(HYDRATE_RANGE, 0, 15, 15);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRitual(IMasterRitualStone masterRitualStone)
|
||||
{
|
||||
World world = masterRitualStone.getWorldObj();
|
||||
if (!(world instanceof ServerWorld))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ServerWorld serverWorld = (ServerWorld) world;
|
||||
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 = masterRitualStone.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))
|
||||
{
|
||||
BlockState state = world.getBlockState(newPos);
|
||||
|
||||
if (!BloodMagicAPI.INSTANCE.getBlacklist().getGreenGrove().contains(state))
|
||||
{
|
||||
boolean flag = state.getBlock() instanceof IGrowable || state.getBlock() instanceof CactusBlock || state.getBlock() instanceof SugarCaneBlock;
|
||||
if (flag)
|
||||
{
|
||||
if (world.rand.nextDouble() < growthChance)
|
||||
{
|
||||
state.getBlock().randomTick(state, serverWorld, newPos, new Random());
|
||||
BlockState newState = world.getBlockState(newPos);
|
||||
if (!newState.equals(state))
|
||||
{
|
||||
world.playEvent(2005, newPos, 0);
|
||||
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 = masterRitualStone.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;
|
||||
}
|
||||
|
||||
BlockState 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 = state.get(FarmlandBlock.MOISTURE);
|
||||
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 = masterRitualStone.getBlockRange(LEECH_RANGE);
|
||||
AxisAlignedBB mobArea = leechRange.getAABB(pos);
|
||||
List<LivingEntity> entityList = world.getEntitiesWithinAABB(LivingEntity.class, mobArea);
|
||||
for (LivingEntity entityLiving : entityList)
|
||||
{
|
||||
if (corrosiveWill < corrosiveWillDrain)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (entityLiving instanceof PlayerEntity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entityLiving.isPotionActive(BloodMagicPotions.PLANT_LEECH) || !entityLiving.isPotionApplicable(new EffectInstance(BloodMagicPotions.PLANT_LEECH)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
entityLiving.addPotionEffect(new EffectInstance(BloodMagicPotions.PLANT_LEECH, 200, 0));
|
||||
|
||||
corrosiveWill -= corrosiveWillDrain;
|
||||
corrosiveDrain += corrosiveWillDrain;
|
||||
}
|
||||
|
||||
if (corrosiveDrain > 0)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
|
||||
}
|
||||
}
|
||||
|
||||
masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalGrowths * getRefreshCost()));
|
||||
}
|
||||
|
||||
public double getPlantGrowthChanceForWill(double will)
|
||||
{
|
||||
if (will > 0)
|
||||
{
|
||||
return 0.3 + will / 200;
|
||||
}
|
||||
|
||||
return defaultGrowthChance;
|
||||
}
|
||||
|
||||
public int getRefreshTimeForRawWill(double rawWill)
|
||||
{
|
||||
if (rawWill > 0)
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
return defaultRefreshTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return refreshTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
||||
{
|
||||
if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE))
|
||||
{
|
||||
double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE);
|
||||
if (destructiveWill > 0)
|
||||
{
|
||||
return 81 + (int) Math.pow(destructiveWill / 4, 1.5);
|
||||
}
|
||||
}
|
||||
|
||||
return volumeRangeMap.get(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
||||
{
|
||||
if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE))
|
||||
{
|
||||
double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE);
|
||||
if (destructiveWill > 0)
|
||||
{
|
||||
return (int) (4 + destructiveWill / 10d);
|
||||
}
|
||||
}
|
||||
|
||||
return verticalRangeMap.get(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes, DemonWillHolder holder)
|
||||
{
|
||||
if (GROW_RANGE.equals(range) && activeTypes.contains(EnumDemonWillType.DESTRUCTIVE))
|
||||
{
|
||||
double destructiveWill = holder.getWill(EnumDemonWillType.DESTRUCTIVE);
|
||||
if (destructiveWill > 0)
|
||||
{
|
||||
return (int) (4 + destructiveWill / 10d);
|
||||
}
|
||||
}
|
||||
|
||||
return horizontalRangeMap.get(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshCost()
|
||||
{
|
||||
return 20; // TODO: Need to find a way to balance this
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherComponents(Consumer<RitualComponent> components)
|
||||
{
|
||||
addCornerRunes(components, 1, 0, EnumRuneType.EARTH);
|
||||
addParallelRunes(components, 1, 0, EnumRuneType.WATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent[] provideInformationOfRitualToPlayer(PlayerEntity player)
|
||||
{
|
||||
return new ITextComponent[] { new TranslationTextComponent(this.getTranslationKey() + ".info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".default.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".corrosive.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".steadfast.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".destructive.info"),
|
||||
new TranslationTextComponent(this.getTranslationKey() + ".vengeful.info") };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ritual getNewCopy()
|
||||
{
|
||||
return new RitualGreenGrove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,214 @@
|
|||
package wayoftime.bloodmagic.ritual.types;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.potion.EffectInstance;
|
||||
import net.minecraft.potion.Effects;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import wayoftime.bloodmagic.BloodMagic;
|
||||
import wayoftime.bloodmagic.api.compat.EnumDemonWillType;
|
||||
import wayoftime.bloodmagic.demonaura.WorldDemonWillHandler;
|
||||
import wayoftime.bloodmagic.ritual.AreaDescriptor;
|
||||
import wayoftime.bloodmagic.ritual.EnumRuneType;
|
||||
import wayoftime.bloodmagic.ritual.IMasterRitualStone;
|
||||
import wayoftime.bloodmagic.ritual.Ritual;
|
||||
import wayoftime.bloodmagic.ritual.RitualComponent;
|
||||
import wayoftime.bloodmagic.ritual.RitualRegister;
|
||||
import wayoftime.bloodmagic.util.DamageSourceBloodMagic;
|
||||
import wayoftime.bloodmagic.util.Utils;
|
||||
|
||||
@RitualRegister("regeneration")
|
||||
public class RitualRegeneration extends Ritual
|
||||
{
|
||||
public static final String HEAL_RANGE = "heal";
|
||||
public static final String VAMPIRE_RANGE = "vampire";
|
||||
|
||||
public static final int SACRIFICE_AMOUNT = 100;
|
||||
|
||||
public static final double corrosiveWillDrain = 0.04;
|
||||
|
||||
public RitualRegeneration()
|
||||
{
|
||||
super("ritualRegeneration", 0, 25000, "ritual." + BloodMagic.MODID + ".regenerationRitual");
|
||||
addBlockRange(HEAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -15, -15), 31));
|
||||
addBlockRange(VAMPIRE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -15, -15), 31));
|
||||
|
||||
setMaximumVolumeAndDistanceOfRange(HEAL_RANGE, 0, 20, 20);
|
||||
setMaximumVolumeAndDistanceOfRange(VAMPIRE_RANGE, 0, 20, 20);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performRitual(IMasterRitualStone masterRitualStone)
|
||||
{
|
||||
World world = masterRitualStone.getWorldObj();
|
||||
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
|
||||
|
||||
if (currentEssence < getRefreshCost())
|
||||
{
|
||||
masterRitualStone.getOwnerNetwork().causeNausea();
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPos pos = masterRitualStone.getBlockPos();
|
||||
|
||||
int maxEffects = currentEssence / getRefreshCost();
|
||||
int totalEffects = 0;
|
||||
|
||||
int totalCost = 0;
|
||||
|
||||
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);
|
||||
|
||||
double vengefulDrain = 0;
|
||||
double steadfastDrain = 0;
|
||||
double destructiveDrain = 0;
|
||||
double corrosiveDrain = 0;
|
||||
|
||||
boolean syphonHealth = corrosiveWill >= corrosiveWillDrain;
|
||||
boolean applyAbsorption = false;
|
||||
float absorptionRate = 1;
|
||||
int maxAbsorption = 20;
|
||||
|
||||
AreaDescriptor healArea = masterRitualStone.getBlockRange(HEAL_RANGE);
|
||||
AxisAlignedBB healRange = healArea.getAABB(pos);
|
||||
|
||||
AreaDescriptor damageArea = masterRitualStone.getBlockRange(VAMPIRE_RANGE);
|
||||
AxisAlignedBB damageRange = damageArea.getAABB(pos);
|
||||
|
||||
List<LivingEntity> entities = world.getEntitiesWithinAABB(LivingEntity.class, healRange);
|
||||
List<PlayerEntity> players = world.getEntitiesWithinAABB(PlayerEntity.class, healRange);
|
||||
List<LivingEntity> damagedEntities = world.getEntitiesWithinAABB(LivingEntity.class, damageRange);
|
||||
|
||||
if (syphonHealth)
|
||||
{
|
||||
for (PlayerEntity player : players)
|
||||
{
|
||||
if (player.getHealth() <= player.getMaxHealth() - 1)
|
||||
{
|
||||
float syphonedHealthAmount = getSyphonAmountForWill(corrosiveWill);
|
||||
Collections.shuffle(damagedEntities);
|
||||
for (LivingEntity damagedEntity : damagedEntities)
|
||||
{
|
||||
if (damagedEntity instanceof PlayerEntity)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float currentHealth = damagedEntity.getHealth();
|
||||
|
||||
damagedEntity.attackEntityFrom(DamageSourceBloodMagic.INSTANCE, Math.min(player.getMaxHealth() - player.getHealth(), syphonedHealthAmount));
|
||||
|
||||
float healthDifference = currentHealth - damagedEntity.getHealth();
|
||||
if (healthDifference > 0)
|
||||
{
|
||||
corrosiveDrain += corrosiveWillDrain;
|
||||
corrosiveWill -= corrosiveWillDrain;
|
||||
player.heal(healthDifference);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (LivingEntity entity : entities)
|
||||
{
|
||||
float health = entity.getHealth();
|
||||
if (health <= entity.getMaxHealth() - 1)
|
||||
{
|
||||
if (entity.isPotionApplicable(new EffectInstance(Effects.REGENERATION)))
|
||||
{
|
||||
if (entity instanceof PlayerEntity)
|
||||
{
|
||||
totalCost += getRefreshCost();
|
||||
currentEssence -= getRefreshCost();
|
||||
} else
|
||||
{
|
||||
totalCost += getRefreshCost() / 10;
|
||||
currentEssence -= getRefreshCost() / 10;
|
||||
}
|
||||
|
||||
entity.addPotionEffect(new EffectInstance(Effects.REGENERATION, 50, 0, false, false));
|
||||
|
||||
totalEffects++;
|
||||
|
||||
if (totalEffects >= maxEffects)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (applyAbsorption && entity instanceof PlayerEntity)
|
||||
{
|
||||
if (applyAbsorption)
|
||||
{
|
||||
float added = Utils.addAbsorptionToMaximum(entity, absorptionRate, maxAbsorption, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (corrosiveDrain > 0)
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
|
||||
}
|
||||
|
||||
masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(totalCost));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshTime()
|
||||
{
|
||||
return 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRefreshCost()
|
||||
{
|
||||
return SACRIFICE_AMOUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gatherComponents(Consumer<RitualComponent> components)
|
||||
{
|
||||
components.accept(new RitualComponent(new BlockPos(4, 0, 0), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(5, 0, -1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(5, 0, 1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(-4, 0, 0), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(-5, 0, -1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(-5, 0, 1), EnumRuneType.AIR));
|
||||
components.accept(new RitualComponent(new BlockPos(0, 0, 4), EnumRuneType.FIRE));
|
||||
components.accept(new RitualComponent(new BlockPos(1, 0, 5), EnumRuneType.FIRE));
|
||||
components.accept(new RitualComponent(new BlockPos(-1, 0, 5), EnumRuneType.FIRE));
|
||||
components.accept(new RitualComponent(new BlockPos(0, 0, -4), EnumRuneType.FIRE));
|
||||
components.accept(new RitualComponent(new BlockPos(1, 0, -5), EnumRuneType.FIRE));
|
||||
components.accept(new RitualComponent(new BlockPos(-1, 0, -5), EnumRuneType.FIRE));
|
||||
addOffsetRunes(components, 3, 5, 0, EnumRuneType.WATER);
|
||||
addCornerRunes(components, 3, 0, EnumRuneType.DUSK);
|
||||
addOffsetRunes(components, 4, 5, 0, EnumRuneType.EARTH);
|
||||
addOffsetRunes(components, 4, 5, -1, EnumRuneType.EARTH);
|
||||
addCornerRunes(components, 5, 0, EnumRuneType.EARTH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Ritual getNewCopy()
|
||||
{
|
||||
return new RitualRegeneration();
|
||||
}
|
||||
|
||||
public float getSyphonAmountForWill(double corrosiveWill)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue