A lot more implementation work for custom areas for rituals.

This commit is contained in:
WayofTime 2016-04-11 15:36:27 -04:00
parent 51c79f15a9
commit 91ddb8b761
13 changed files with 127 additions and 26 deletions

View file

@ -43,6 +43,10 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
public abstract boolean isWithinRange(BlockPos offset1, BlockPos offset2, int verticalLimit, int horizontalLimit);
public abstract int getVolume();
public abstract boolean isWithinRange(int verticalLimit, int horizontalLimit);
/**
* This method changes the area descriptor so that its range matches the two
* blocks that are selected. When implementing this method, assume that
@ -243,6 +247,18 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
return minPos.getY() >= -verticalLimit && maxPos.getY() <= verticalLimit && minPos.getX() >= -horizontalLimit && maxPos.getX() <= horizontalLimit && minPos.getZ() >= -horizontalLimit && maxPos.getZ() <= horizontalLimit;
}
@Override
public int getVolume()
{
return (maximumOffset.getX() - minimumOffset.getX()) * (maximumOffset.getY() - minimumOffset.getY()) * (maximumOffset.getZ() - minimumOffset.getZ());
}
@Override
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
{
return minimumOffset.getY() >= -verticalLimit && maximumOffset.getY() < verticalLimit && minimumOffset.getX() >= -horizontalLimit && maximumOffset.getX() < horizontalLimit && minimumOffset.getZ() >= -horizontalLimit && maximumOffset.getZ() < horizontalLimit;
}
}
public static class HemiSphere extends AreaDescriptor
@ -386,6 +402,20 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
// TODO Auto-generated method stub
return false;
}
@Override
public int getVolume()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
{
// TODO Auto-generated method stub
return false;
}
}
public static class Cross extends AreaDescriptor
@ -493,5 +523,19 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
// TODO Auto-generated method stub
return false;
}
@Override
public int getVolume()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isWithinRange(int verticalLimit, int horizontalLimit)
{
// TODO Auto-generated method stub
return false;
}
}
}

View file

@ -46,7 +46,9 @@ public interface IMasterRitualStone
void provideInformationOfRangeToPlayer(EntityPlayer player, String range);
void setActiveWillDrain(EntityPlayer player, List<EnumDemonWillType> typeList);
void setActiveWillConfig(EntityPlayer player, List<EnumDemonWillType> typeList);
boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2);
List<EnumDemonWillType> getCurrentActiveWillConfig();
}

View file

@ -18,6 +18,7 @@ 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.soul.EnumDemonWillType;
/**
* Abstract class for creating new rituals. Rituals need be registered with
@ -230,9 +231,10 @@ public abstract class Ritual
protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
{
int maxVolume = volumeRangeMap.get(range);
int maxVertical = verticalRangeMap.get(range);
int maxHorizontal = horizontalRangeMap.get(range);
List<EnumDemonWillType> willConfig = master.getCurrentActiveWillConfig();
int maxVolume = getMaxVolumeForRange(range, willConfig);
int maxVertical = getMaxVerticalRadiusForRange(range, willConfig);
int maxHorizontal = getMaxHorizontalRadiusForRange(range, willConfig);
return (maxVolume <= 0 || descriptor.getVolumeForOffsets(offset1, offset2) <= maxVolume) && descriptor.isWithinRange(offset1, offset2, maxVertical, maxHorizontal);
}
@ -244,6 +246,26 @@ public abstract class Ritual
verticalRangeMap.put(range, verticalRadius);
}
protected boolean checkDescriptorIsWithinRange(AreaDescriptor descriptor, int maxVolume, int maxHorizontal, int maxVertical)
{
return descriptor.getVolume() <= maxVolume && descriptor.isWithinRange(maxVertical, maxHorizontal);
}
public int getMaxVolumeForRange(String range, List<EnumDemonWillType> activeTypes)
{
return volumeRangeMap.get(range);
}
public int getMaxVerticalRadiusForRange(String range, List<EnumDemonWillType> activeTypes)
{
return verticalRangeMap.get(range);
}
public int getMaxHorizontalRadiusForRange(String range, List<EnumDemonWillType> activeTypes)
{
return horizontalRangeMap.get(range);
}
public ITextComponent getErrorForBlockRangeOnFail(EntityPlayer player, String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2)
{
AreaDescriptor descriptor = this.getBlockRange(range);

View file

@ -29,6 +29,9 @@ public class RitualFeatheredKnife extends Ritual
super("ritualFeatheredKnife", 0, 25000, "ritual." + Constants.Mod.MODID + ".featheredKnifeRitual");
addBlockRange(ALTAR_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-5, -10, -5), 11, 21, 11));
addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -20, -15), 31, 41, 31));
setMaximumVolumeAndDistanceOfRange(ALTAR_RANGE, 0, 10, 15);
setMaximumVolumeAndDistanceOfRange(DAMAGE_RANGE, 0, 15, 15);
}
@Override

View file

@ -23,6 +23,7 @@ public class RitualGreenGrove extends Ritual
{
super("ritualGreenGrove", 0, 5000, "ritual." + Constants.Mod.MODID + ".greenGroveRitual");
addBlockRange(GROW_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 2, -1), 3, 1, 3));
setMaximumVolumeAndDistanceOfRange(GROW_RANGE, 81, 4, 4);
}
@Override

View file

@ -30,6 +30,8 @@ public class RitualHarvest extends Ritual
public RitualHarvest()
{
super("ritualHarvest", 0, 20000, "ritual." + Constants.Mod.MODID + ".harvestRitual");
addBlockRange(HARVEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-4, 1, -4), 9, 5, 9));
setMaximumVolumeAndDistanceOfRange(HARVEST_RANGE, 81, 15, 15);
}
@Override
@ -37,6 +39,7 @@ public class RitualHarvest extends Ritual
{
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
World world = masterRitualStone.getWorldObj();
BlockPos pos = masterRitualStone.getBlockPos();
if (network.getCurrentEssence() < getRefreshCost())
{
@ -44,22 +47,21 @@ public class RitualHarvest extends Ritual
return;
}
BlockStack amplifierStack = BlockStack.getStackFromPos(world, masterRitualStone.getBlockPos().up());
int range = 4;
if (amplifierStack != null)
if (HarvestRegistry.getAmplifierMap().containsKey(amplifierStack))
range = HarvestRegistry.getAmplifierMap().get(amplifierStack);
addBlockRange(HARVEST_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-range, 0, -range), new BlockPos(range + 1, 4, range + 1)));
int harvested = 0;
for (BlockPos pos : getBlockRange(HARVEST_RANGE).getContainedPositions(masterRitualStone.getBlockPos().up()))
if (harvestBlock(world, pos))
harvested++;
AreaDescriptor harvestArea = getBlockRange(HARVEST_RANGE);
network.syphon(getRefreshCost() * Math.min(100, harvested));
harvestArea.resetIterator();
while (harvestArea.hasNext())
{
BlockPos nextPos = harvestArea.next().add(pos);
if (harvestBlock(world, nextPos))
{
harvested++;
}
}
network.syphon(getRefreshCost() * harvested);
}
@Override

View file

@ -21,6 +21,7 @@ public class RitualJumping extends Ritual
{
super("ritualJump", 0, 5000, "ritual." + Constants.Mod.MODID + ".jumpRitual");
addBlockRange(JUMP_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3, 1, 3));
setMaximumVolumeAndDistanceOfRange(JUMP_RANGE, 0, 5, 5);
}
@Override

View file

@ -18,6 +18,7 @@ public class RitualLava extends Ritual
{
super("ritualLava", 0, 10000, "ritual." + Constants.Mod.MODID + ".lavaRitual");
addBlockRange(LAVA_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1));
setMaximumVolumeAndDistanceOfRange(LAVA_RANGE, 9, 3, 3);
}
@Override

View file

@ -34,6 +34,7 @@ public class RitualMagnetic extends Ritual
{
super("ritualMagnetic", 0, 5000, "ritual." + Constants.Mod.MODID + ".magneticRitual");
addBlockRange(PLACEMENT_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, 1, -1), 3));
setMaximumVolumeAndDistanceOfRange(PLACEMENT_RANGE, 50, 4, 4);
}
public static boolean isBlockOre(Block block, int meta)

View file

@ -1,20 +1,23 @@
package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
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 WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
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.util.helper.NetworkHelper;
public class RitualRegeneration extends Ritual
{
@ -26,6 +29,7 @@ public class RitualRegeneration extends Ritual
{
super("ritualRegeneration", 0, 25000, "ritual." + Constants.Mod.MODID + ".regenerationRitual");
addBlockRange(HEAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-15, -15, -15), 31));
setMaximumVolumeAndDistanceOfRange(HEAL_RANGE, 0, 20, 20);
}
@Override

View file

@ -31,6 +31,9 @@ public class RitualWellOfSuffering extends Ritual
super("ritualWellOfSuffering", 0, 40000, "ritual." + Constants.Mod.MODID + ".wellOfSufferingRitual");
addBlockRange(ALTAR_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-5, -10, -5), 11, 21, 11));
addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -10, -10), 21));
setMaximumVolumeAndDistanceOfRange(ALTAR_RANGE, 0, 10, 15);
setMaximumVolumeAndDistanceOfRange(DAMAGE_RANGE, 0, 15, 15);
}
@Override

View file

@ -1,5 +1,6 @@
package WayofTime.bloodmagic.tile;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
@ -330,7 +331,7 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
}
@Override
public void setActiveWillDrain(EntityPlayer player, List<EnumDemonWillType> typeList)
public void setActiveWillConfig(EntityPlayer player, List<EnumDemonWillType> typeList)
{
// TODO Auto-generated method stub
@ -360,4 +361,10 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
return false;
}
@Override
public List<EnumDemonWillType> getCurrentActiveWillConfig()
{
return new ArrayList<EnumDemonWillType>();
}
}

View file

@ -429,8 +429,18 @@ ritual.BloodMagic.armourEvolveRitual.info=Undocumented.
ritual.BloodMagic.animalGrowthRitual.info=Increases the maturity rate of baby animals within its range.
ritual.BloodMagic.forsakenSoulRitual.info=Damages mobs within its damage range and when the mob dies a demon crystal within its crystal range will be grown.
ritual.BloodMagic.waterRitual.waterRange.info=(Water) The area that the ritual will place water source blocks.
ritual.BloodMagic.lavaRitual.lavaRange.info=(Lava) The area that the ritual will place lava source blocks.
ritual.BloodMagic.greenGroveRitual.growing.info=(Growth) The area that the ritual will grow plants in.
ritual.BloodMagic.jumpRitual.jumpRange.info=(Jumping) Entities in this range will be launched in the air.
ritual.BloodMagic.wellOfSufferingRitual.altar.info=(Altar) This range defines the area that the ritual searches for the blood altar. Changing this will either expand or limit the range to a certain region.
ritual.BloodMagic.wellOfSufferingRitual.damage.info=(Damage) This defines where the ritual will damage a mob. All mobs inside of this range (except for players) will receive damage over time.
ritual.BloodMagic.featheredKnifeRitual.altar.info=(Altar) This range defines the area that the ritual searches for the blood altar. Changing this will either expand or limit the range to a certain region.
ritual.BloodMagic.featheredKnifeRitual.damage.info=(Damage) This defines where the ritual will damage a player. Players inside of this range will receive damage over time up to the specified limit.
ritual.BloodMagic.regenerationRitual.heal.info=(Healing) Mobs within this range will receive a regeneration buff.
ritual.BloodMagic.harvestRitual.harvestRange.info=(Harvesting) Plants within this range will be harvested.
ritual.BloodMagic.magneticRitual.placementRange.info=
# Chat
chat.BloodMagic.altarMaker.setTier=Set Tier to: %d
chat.BloodMagic.altarMaker.building=Building a Tier %d Altar