2015-12-30 15:24:25 -05:00
|
|
|
package WayofTime.bloodmagic.ritual;
|
|
|
|
|
2016-08-10 17:24:36 -04:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2015-12-30 15:24:25 -05:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.IGrowable;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-08-10 17:24:36 -04:00
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-08-10 17:24:36 -04:00
|
|
|
import net.minecraft.util.text.ITextComponent;
|
|
|
|
import net.minecraft.util.text.TextComponentTranslation;
|
2015-12-30 15:24:25 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.common.IPlantable;
|
2016-08-10 17:24:36 -04:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
|
|
|
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;
|
2015-12-30 15:24:25 -05:00
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
public class RitualGreenGrove extends Ritual
|
|
|
|
{
|
|
|
|
public static final String GROW_RANGE = "growing";
|
2016-08-10 17:24:36 -04:00
|
|
|
public static final String LEECH_RANGE = "leech";
|
|
|
|
|
|
|
|
public static double corrosiveWillDrain = 0.2;
|
2015-12-30 15:34:40 -05:00
|
|
|
|
|
|
|
public RitualGreenGrove()
|
|
|
|
{
|
2016-01-02 17:15:33 -05:00
|
|
|
super("ritualGreenGrove", 0, 5000, "ritual." + Constants.Mod.MODID + ".greenGroveRitual");
|
2015-12-31 11:25:24 -05:00
|
|
|
addBlockRange(GROW_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 2, -1), 3, 1, 3));
|
2016-08-10 17:24:36 -04:00
|
|
|
addBlockRange(LEECH_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 0, 0), 1));
|
2016-04-11 15:36:27 -04:00
|
|
|
setMaximumVolumeAndDistanceOfRange(GROW_RANGE, 81, 4, 4);
|
2016-08-10 17:24:36 -04:00
|
|
|
setMaximumVolumeAndDistanceOfRange(LEECH_RANGE, 0, 15, 15);
|
2015-12-30 15:34:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void performRitual(IMasterRitualStone masterRitualStone)
|
|
|
|
{
|
2016-01-03 08:30:59 -05:00
|
|
|
World world = masterRitualStone.getWorldObj();
|
2016-08-10 17:24:36 -04:00
|
|
|
BlockPos pos = masterRitualStone.getBlockPos();
|
2015-12-31 20:10:57 -05:00
|
|
|
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
|
2015-12-30 15:34:40 -05:00
|
|
|
int currentEssence = network.getCurrentEssence();
|
|
|
|
|
|
|
|
if (currentEssence < getRefreshCost())
|
2015-12-31 20:47:01 -05:00
|
|
|
{
|
2016-06-12 13:41:02 -07:00
|
|
|
network.causeNausea();
|
2015-12-30 15:34:40 -05:00
|
|
|
return;
|
2015-12-31 20:47:01 -05:00
|
|
|
}
|
2015-12-30 15:34:40 -05:00
|
|
|
|
|
|
|
int maxGrowths = currentEssence / getRefreshCost();
|
|
|
|
int totalGrowths = 0;
|
|
|
|
|
2016-08-10 17:24:36 -04:00
|
|
|
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
|
|
|
|
|
|
|
|
double corrosiveWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.CORROSIVE, willConfig);
|
|
|
|
|
2015-12-30 16:19:50 -05:00
|
|
|
AreaDescriptor growingRange = getBlockRange(GROW_RANGE);
|
2015-12-30 15:34:40 -05:00
|
|
|
|
2016-01-03 08:30:59 -05:00
|
|
|
for (BlockPos newPos : growingRange.getContainedPositions(masterRitualStone.getBlockPos()))
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2015-12-30 16:19:50 -05:00
|
|
|
IBlockState state = world.getBlockState(newPos);
|
|
|
|
Block block = state.getBlock();
|
2016-01-23 00:32:10 -08:00
|
|
|
|
2016-02-16 11:46:47 -05:00
|
|
|
if (!BloodMagicAPI.getGreenGroveBlacklist().contains(block))
|
2015-12-30 15:34:40 -05:00
|
|
|
{
|
2016-01-23 00:32:10 -08:00
|
|
|
if (block instanceof IPlantable || block instanceof IGrowable)
|
|
|
|
{
|
|
|
|
block.updateTick(world, newPos, state, new Random());
|
|
|
|
totalGrowths++;
|
|
|
|
}
|
2015-12-30 15:34:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (totalGrowths >= maxGrowths)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-10 17:24:36 -04:00
|
|
|
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(ModPotions.plantLeech) || !entityLiving.isPotionApplicable(new PotionEffect(ModPotions.plantLeech)))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entityLiving.addPotionEffect(new PotionEffect(ModPotions.plantLeech, 200, 0));
|
|
|
|
|
|
|
|
corrosiveWill -= corrosiveWillDrain;
|
|
|
|
corrosiveDrain += corrosiveWillDrain;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (corrosiveWillDrain > 0)
|
|
|
|
{
|
|
|
|
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, corrosiveDrain, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-30 15:34:40 -05:00
|
|
|
network.syphon(totalGrowths * getRefreshCost());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRefreshTime()
|
|
|
|
{
|
|
|
|
return 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRefreshCost()
|
|
|
|
{
|
2016-02-16 11:46:47 -05:00
|
|
|
return 5; //TODO: Need to find a way to balance this
|
2015-12-30 15:34:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ArrayList<RitualComponent> getComponents()
|
|
|
|
{
|
|
|
|
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
|
|
|
|
|
|
|
|
this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH);
|
|
|
|
this.addParallelRunes(components, 1, 0, EnumRuneType.WATER);
|
|
|
|
|
|
|
|
return components;
|
|
|
|
}
|
2015-12-31 13:50:38 -05:00
|
|
|
|
2016-08-10 17:24:36 -04:00
|
|
|
@Override
|
|
|
|
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player)
|
|
|
|
{
|
|
|
|
return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info"), new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info") };
|
|
|
|
}
|
|
|
|
|
2015-12-31 08:01:39 -05:00
|
|
|
@Override
|
|
|
|
public Ritual getNewCopy()
|
|
|
|
{
|
|
|
|
return new RitualGreenGrove();
|
|
|
|
}
|
2015-12-30 15:24:25 -05:00
|
|
|
}
|