Added some effects for the Crushing Ritual when affected by different types of Demon Will (balancing pending)

Also added the LP costs for the Crystal Harvest and Forsaken Souls rituals. You are welcome!
This commit is contained in:
WayofTime 2016-07-11 19:47:19 -04:00
parent c09ad83e53
commit 3dd574b1f7
7 changed files with 158 additions and 11 deletions

View file

@ -19,6 +19,7 @@ import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
/**
* Abstract class for creating new rituals. Rituals need be registered with
@ -286,9 +287,9 @@ public abstract class Ritual
}
}
public ITextComponent provideInformationOfRitualToPlayer(EntityPlayer player)
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player)
{
return new TextComponentTranslation(this.getUnlocalizedName() + ".info");
return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info") };
}
public ITextComponent provideInformationOfRangeToPlayer(EntityPlayer player, String range)
@ -350,5 +351,10 @@ public abstract class Ritual
EXPLOSION,
}
public double getWillRespectingConfig(World world, BlockPos pos, EnumDemonWillType type, List<EnumDemonWillType> willConfig)
{
return willConfig.contains(type) ? WorldDemonWillHandler.getCurrentWill(world, pos, type) : 0;
}
public abstract Ritual getNewCopy();
}

View file

@ -7,6 +7,7 @@ import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.api.registry.RitualRegistry;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import WayofTime.bloodmagic.item.alchemy.ItemCuttingFluid;
import WayofTime.bloodmagic.ritual.*;
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerPlantable;
import WayofTime.bloodmagic.ritual.harvest.HarvestHandlerStem;
@ -114,6 +115,9 @@ public class ModRituals
RitualRegistry.registerRitual(altarBuilderRitual, ConfigHandler.altarBuilderRitual);
portalRitual = new RitualPortal();
RitualRegistry.registerRitual(portalRitual, ConfigHandler.portalRitual);
RitualCrushing.registerCuttingFluid(ItemCuttingFluid.getStack(ItemCuttingFluid.BASIC), 250, 0.5);
RitualCrushing.registerCuttingFluid(ItemCuttingFluid.getStack(ItemCuttingFluid.EXPLOSIVE), 25, 0.05);
}
public static void initImperfectRituals()

View file

@ -1,16 +1,24 @@
package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentTranslation;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.recipe.AlchemyTableRecipe;
import WayofTime.bloodmagic.api.registry.AlchemyTableRecipeRegistry;
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
@ -20,6 +28,7 @@ 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.item.alchemy.ItemCuttingFluid;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.util.Utils;
@ -29,7 +38,11 @@ public class RitualCrushing extends Ritual
public static final String CHEST_RANGE = "chest";
public static double rawWillDrain = 0.5;
public static double steadfastWillDrain = 0.5;
public static double steadfastWillDrain = 0.2;
public static double destructiveWillDrain = 0.2;
public static Map<ItemStack, Integer> cuttingFluidLPMap = new HashMap<ItemStack, Integer>();
public static Map<ItemStack, Double> cuttingFluidWillMap = new HashMap<ItemStack, Double>();
public RitualCrushing()
{
@ -41,6 +54,12 @@ public class RitualCrushing extends Ritual
setMaximumVolumeAndDistanceOfRange(CHEST_RANGE, 1, 3, 3);
}
public static void registerCuttingFluid(ItemStack stack, int lpDrain, double willDrain)
{
cuttingFluidLPMap.put(stack, lpDrain);
cuttingFluidWillMap.put(stack, willDrain);
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
@ -55,15 +74,24 @@ public class RitualCrushing extends Ritual
}
BlockPos pos = masterRitualStone.getBlockPos();
TileEntity tile = world.getTileEntity(pos.up());
AreaDescriptor chestRange = getBlockRange(CHEST_RANGE);
TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0));
if (tile != null && Utils.getNumberOfFreeSlots(tile, EnumFacing.DOWN) < 1)
{
return;
}
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
double steadfastWill = willConfig.contains(EnumDemonWillType.STEADFAST) ? WorldDemonWillHandler.getCurrentWill(world, pos, EnumDemonWillType.STEADFAST) : 0;
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);
boolean isSilkTouch = steadfastWill >= steadfastWillDrain;
boolean useCuttingFluid = corrosiveWill > 0;
int fortune = 0;
int fortune = destructiveWill > 0 ? 3 : 0;
AreaDescriptor crushingRange = getBlockRange(CRUSHING_RANGE);
@ -81,7 +109,66 @@ public class RitualCrushing extends Ritual
continue;
}
if (isSilkTouch && block.canSilkHarvest(world, newPos, state, null))
boolean isBlockClaimed = false;
if (useCuttingFluid)
{
ItemStack checkStack = block.getItem(world, newPos, state);
if (checkStack == null)
{
continue;
}
ItemStack copyStack = checkStack.copy();
for (Entry<ItemStack, Integer> entry : cuttingFluidLPMap.entrySet())
{
ItemStack cuttingStack = entry.getKey();
int lpDrain = entry.getValue();
double willDrain = cuttingFluidWillMap.containsKey(cuttingStack) ? cuttingFluidWillMap.get(cuttingStack) : 0;
if (corrosiveWill < willDrain || currentEssence < lpDrain + getRefreshCost())
{
continue;
}
cuttingStack = cuttingStack.copy();
List<ItemStack> input = new ArrayList<ItemStack>();
input.add(cuttingStack);
input.add(copyStack);
AlchemyTableRecipe recipe = AlchemyTableRecipeRegistry.getMatchingRecipe(input, world, pos);
if (recipe == null)
{
continue;
}
ItemStack result = recipe.getRecipeOutput(input);
if (result == null)
{
continue;
}
if (tile != null)
result = Utils.insertStackIntoTile(result, tile, EnumFacing.DOWN);
else
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, result);
if (result != null && result.stackSize > 0)
{
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, result);
}
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.CORROSIVE, willDrain, true);
corrosiveWill -= willDrain;
network.syphon(lpDrain);
currentEssence -= lpDrain;
isBlockClaimed = true;
}
}
if (!isBlockClaimed && isSilkTouch && block.canSilkHarvest(world, newPos, state, null))
{
ItemStack checkStack = block.getItem(world, newPos, state);
if (checkStack == null)
@ -109,8 +196,13 @@ public class RitualCrushing extends Ritual
{
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
}
} else
} else if (!isBlockClaimed)
{
if (fortune > 0 && destructiveWill < destructiveWillDrain)
{
fortune = 0;
}
List<ItemStack> stackList = block.getDrops(world, newPos, state, fortune);
if (stackList != null && !stackList.isEmpty())
@ -132,6 +224,12 @@ public class RitualCrushing extends Ritual
Utils.spawnStackAtBlock(world, pos, EnumFacing.UP, copyStack);
}
}
if (fortune > 0)
{
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DESTRUCTIVE, destructiveWillDrain, true);
destructiveWill -= destructiveWillDrain;
}
}
}
@ -167,6 +265,12 @@ public class RitualCrushing extends Ritual
return components;
}
@Override
public ITextComponent[] provideInformationOfRitualToPlayer(EntityPlayer player)
{
return new ITextComponent[] { new TextComponentTranslation(this.getUnlocalizedName() + ".info"), new TextComponentTranslation(this.getUnlocalizedName() + ".destructive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".corrosive.info"), new TextComponentTranslation(this.getUnlocalizedName() + ".steadfast.info") };
}
@Override
public Ritual getNewCopy()
{

View file

@ -80,7 +80,7 @@ public class RitualCrystalHarvest extends Ritual
@Override
public int getRefreshCost()
{
return 0;
return 50;
}
@Override

View file

@ -197,7 +197,7 @@ public class RitualForsakenSoul extends Ritual
@Override
public int getRefreshCost()
{
return 0;
return 2;
}
@Override

View file

@ -470,6 +470,35 @@ public class Utils
return stack;
}
public static int getNumberOfFreeSlots(TileEntity tile, EnumFacing dir)
{
int slots = 0;
if (tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir))
{
IItemHandler handler = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir);
for (int i = 0; i < handler.getSlots(); i++)
{
if (handler.getStackInSlot(i) == null)
{
slots++;
}
}
} else if (tile instanceof IInventory)
{
for (int i = 0; i < ((IInventory) tile).getSizeInventory(); i++)
{
if (((IInventory) tile).getStackInSlot(i) == null)
{
slots++;
}
}
}
return slots;
}
public static ItemStack insertStackIntoTile(ItemStack stack, IItemHandler handler)
{
int numberOfSlots = handler.getSlots();

View file

@ -474,6 +474,10 @@ ritual.BloodMagic.regenerationRitual.info=Casts regeneration on entities within
ritual.BloodMagic.harvestRitual.info=Harvests plants within its range, dropping the results on the ground.
ritual.BloodMagic.magneticRitual.info=Pulls up ores from the ground and puts them into its placement range.
ritual.BloodMagic.crushingRitual.info=Breaks blocks within its crushing range and places the items into the linked chest.
ritual.BloodMagic.crushingRitual.destructive.info=(Destructive) Blocks are broken down forcefuly: all blocks broken are affected by Fortune III.
ritual.BloodMagic.crushingRitual.steadfast.info=(Steadfast) Causes all blocks that are broken to be picked up with silk touch. Overrides Fortune where applicable.
ritual.BloodMagic.crushingRitual.corrosive.info=(Corrosive) All blocks are broken to be processed with a form of cutting fluid. Overrides Silk Touch where applicable.
ritual.BloodMagic.fullStomachRitual.info=Takes food from the linked chest and fills the player's saturation with it.
ritual.BloodMagic.interdictionRitual.info=Pushes all mobs within its area away from the master ritual stone.
ritual.BloodMagic.containmentRitual.info=Pulls all mobs within its area towards the master ritual stone.