Finished most of the Augments for the Ritual of the Shepherd.

This commit is contained in:
WayofTime 2016-11-06 17:03:10 -05:00
parent d1e6076cca
commit 0419800a86
7 changed files with 245 additions and 21 deletions

View file

@ -9,7 +9,9 @@ import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.oredict.OreDictionary;
import WayofTime.bloodmagic.util.Utils;
@Getter
@Setter
@ -21,6 +23,24 @@ public class MeteorComponent
public IBlockState getStateFromOre()
{
if (oreName.contains(":"))
{
String[] stringList = oreName.split(":");
String domain = stringList[0];
String block = stringList[1];
int meta = 0;
if (stringList.length > 2 && Utils.isInteger(stringList[2]))
{
meta = Integer.parseInt(stringList[2]);
}
Block ore = Block.REGISTRY.getObject(new ResourceLocation(domain, block));
if (ore != null)
{
return ore.getStateFromMeta(meta);
}
}
List<ItemStack> list = OreDictionary.getOres(oreName);
if (list != null && !list.isEmpty())
{

View file

@ -128,7 +128,7 @@ public class MeteorConfigHandler
diamondMeteorList.add(new MeteorComponent(250, "oreDiamond"));
diamondMeteorList.add(new MeteorComponent(180, "oreEmerald"));
diamondMeteorList.add(new MeteorComponent(50, "oreRedstone"));
diamondMeteorList.add(new MeteorComponent(400, "oreCoal"));
diamondMeteorList.add(new MeteorComponent(400, "minecraft:diamond_block"));
Meteor diamondMeteor = new Meteor(new ItemStack(Blocks.DIAMOND_BLOCK), diamondMeteorList, 10, 3, 1000);
goldMeteor.setVersion(3);

View file

@ -23,6 +23,7 @@ public class ModPotions
public static Potion bounce;
public static Potion cling;
public static Potion sacrificialLamb;
public static void init()
{
@ -52,6 +53,7 @@ public class ModPotions
deafness = registerPotion("Deaf", new ResourceLocation("deafness"), true, 0x000000, 0, 1);
bounce = registerPotion("Bounce", new ResourceLocation("bounce"), false, 0x000000, 1, 1);
cling = registerPotion("Cling", new ResourceLocation("cling"), false, 0x000000, 2, 1);
sacrificialLamb = registerPotion("S. Lamb", new ResourceLocation("lamb"), false, 0x000000, 3, 1);
// heavyHeart = new PotionBloodMagic("Heavy Heart", new
// ResourceLocation(resourceLocation +
// heavyHeart.getName().toLowerCase()), true, 0, 0, 0);

View file

@ -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;
}
}

View file

@ -9,7 +9,12 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAITarget;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
@ -228,6 +233,9 @@ public class GenericHandler
}
}
private static Map<EntityAnimal, EntityAITarget> targetTaskMap = new HashMap<EntityAnimal, EntityAITarget>();
private static Map<EntityAnimal, EntityAIBase> attackTaskMap = new HashMap<EntityAnimal, EntityAIBase>();
// Handles sending the client the Demon Will Aura updates
@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event)
@ -239,6 +247,34 @@ public class GenericHandler
{
sendPlayerDemonWillAura((EntityPlayer) entity);
}
if (event.getEntityLiving() instanceof EntityAnimal)
{
EntityAnimal animal = (EntityAnimal) event.getEntityLiving();
if (animal.isPotionActive(ModPotions.sacrificialLamb))
{
if (!targetTaskMap.containsKey(animal))
{
EntityAITarget task = new EntityAINearestAttackableTarget<EntityMob>(animal, EntityMob.class, false);
EntityAIBase attackTask = new EntityAIAttackMelee(animal, 1.0D, false);
animal.targetTasks.addTask(1, task);
animal.tasks.addTask(1, attackTask);
targetTaskMap.put(animal, task);
attackTaskMap.put(animal, attackTask);
}
if (animal.getAttackTarget() != null && animal.getDistanceSqToEntity(animal.getAttackTarget()) < 4)
{
animal.worldObj.createExplosion(null, animal.posX, animal.posY + (double) (animal.height / 16.0F), animal.posZ, 2 + animal.getActivePotionEffect(ModPotions.sacrificialLamb).getAmplifier() * 1.5f, false);
targetTaskMap.remove(animal);
attackTaskMap.remove(animal);
}
} else if (targetTaskMap.containsKey(animal))
{
targetTaskMap.remove(animal);
attackTaskMap.remove(animal);
}
}
}
EntityLivingBase entity = event.getEntityLiving();