Added the Corrosive Green Grove augmentation
This commit is contained in:
parent
f431be3eb8
commit
d3c6a474de
8 changed files with 160 additions and 10 deletions
|
@ -1,13 +1,23 @@
|
|||
package WayofTime.bloodmagic.potion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.util.helper.NBTHelper;
|
||||
import WayofTime.bloodmagic.recipe.alchemyTable.AlchemyTablePotionAugmentRecipe;
|
||||
|
@ -16,6 +26,65 @@ import com.google.common.base.Objects;
|
|||
|
||||
public class BMPotionUtils
|
||||
{
|
||||
public static Random rand = new Random();
|
||||
|
||||
public static double damageMobAndGrowSurroundingPlants(EntityLivingBase entity, int horizontalRadius, int verticalRadius, double damageRatio, int maxPlantsGrown)
|
||||
{
|
||||
World world = entity.worldObj;
|
||||
if (world.isRemote)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (entity.isDead)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
double incurredDamage = 0;
|
||||
|
||||
List<BlockPos> growList = new ArrayList<BlockPos>();
|
||||
|
||||
for (int i = 0; i < maxPlantsGrown; i++)
|
||||
{
|
||||
BlockPos blockPos = entity.getPosition().add(rand.nextInt(horizontalRadius * 2 + 1) - horizontalRadius, rand.nextInt(verticalRadius * 2 + 1) - verticalRadius, rand.nextInt(horizontalRadius * 2 + 1) - horizontalRadius);
|
||||
Block block = world.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!BloodMagicAPI.getGreenGroveBlacklist().contains(block))
|
||||
{
|
||||
if (block instanceof IPlantable || block instanceof IGrowable)
|
||||
{
|
||||
growList.add(blockPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockPos blockPos : growList)
|
||||
{
|
||||
Block block = world.getBlockState(blockPos).getBlock();
|
||||
// if (world.rand.nextInt(50) == 0)
|
||||
{
|
||||
IBlockState preBlockState = world.getBlockState(blockPos);
|
||||
for (int n = 0; n < 10; n++)
|
||||
block.updateTick(world, blockPos, world.getBlockState(blockPos), world.rand);
|
||||
|
||||
IBlockState newState = world.getBlockState(blockPos);
|
||||
if (!newState.equals(preBlockState))
|
||||
{
|
||||
world.playEvent(2001, blockPos, Block.getIdFromBlock(newState.getBlock()) + (newState.getBlock().getMetaFromState(newState) << 12));
|
||||
incurredDamage += damageRatio;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (incurredDamage > 0)
|
||||
{
|
||||
entity.attackEntityFrom(BloodMagicAPI.getDamageSource(), (float) incurredDamage);
|
||||
}
|
||||
|
||||
return incurredDamage;
|
||||
}
|
||||
|
||||
public static double getLengthAugment(ItemStack flaskStack, Potion potion)
|
||||
{
|
||||
NBTHelper.checkNBT(flaskStack);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue