From 415d3f1f4284bbd62a0239abbfa274dbbe16daca Mon Sep 17 00:00:00 2001 From: Tobias Gremeyer Date: Tue, 22 Jan 2019 00:06:38 +0100 Subject: [PATCH] Fixed RitualReader (RitualTinkerer) area setting ability. (#1505) * Fixed RitualReader (RitualTinkerer) area setting ability. Signed-off-by: tobias * Update TileMasterRitualStone.java * Interface tidied up --- .../bloodmagic/ritual/IMasterRitualStone.java | 10 +++ .../WayofTime/bloodmagic/ritual/Ritual.java | 16 +---- .../ritual/types/RitualAnimalGrowth.java | 4 +- .../ritual/types/RitualArmourEvolve.java | 2 +- .../ritual/types/RitualCobblestone.java | 2 +- .../bloodmagic/ritual/types/RitualCondor.java | 4 +- .../ritual/types/RitualContainment.java | 2 +- .../ritual/types/RitualCrushing.java | 4 +- .../ritual/types/RitualCrystalHarvest.java | 2 +- .../ritual/types/RitualEllipsoid.java | 4 +- .../ritual/types/RitualExpulsion.java | 2 +- .../ritual/types/RitualFeatheredKnife.java | 4 +- .../ritual/types/RitualFelling.java | 4 +- .../ritual/types/RitualForsakenSoul.java | 4 +- .../ritual/types/RitualFullStomach.java | 4 +- .../ritual/types/RitualGreenGrove.java | 6 +- .../ritual/types/RitualHarvest.java | 2 +- .../ritual/types/RitualInterdiction.java | 2 +- .../ritual/types/RitualJumping.java | 2 +- .../bloodmagic/ritual/types/RitualLava.java | 10 +-- .../types/RitualLivingArmourDowngrade.java | 2 +- .../ritual/types/RitualMagnetic.java | 2 +- .../bloodmagic/ritual/types/RitualMeteor.java | 2 +- .../bloodmagic/ritual/types/RitualPlacer.java | 4 +- .../bloodmagic/ritual/types/RitualPump.java | 2 +- .../ritual/types/RitualRegeneration.java | 4 +- .../bloodmagic/ritual/types/RitualSpeed.java | 2 +- .../ritual/types/RitualSuppression.java | 2 +- .../ritual/types/RitualUpgradeRemove.java | 2 +- .../bloodmagic/ritual/types/RitualWater.java | 2 +- .../ritual/types/RitualWellOfSuffering.java | 2 +- .../bloodmagic/ritual/types/RitualZephyr.java | 4 +- .../tile/TileMasterRitualStone.java | 64 ++++++++++++++----- 33 files changed, 106 insertions(+), 78 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java index eb61019c..2fec7fa8 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/IMasterRitualStone.java @@ -9,7 +9,9 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; /** @@ -22,6 +24,8 @@ public interface IMasterRitualStone { SoulNetwork getOwnerNetwork(); + Map modableRangeMap = new HashMap<>(); + boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual); void performRitual(World world, BlockPos pos); @@ -61,4 +65,10 @@ public interface IMasterRitualStone { default SoulTicket ticket(int amount) { return SoulTicket.block(getWorldObj(), getBlockPos(), amount); } + + AreaDescriptor getBlockRange(String range); + + void addBlockRanges(Map blockRanges); + + void addBlockRange(String range, AreaDescriptor defaultRange); } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/Ritual.java b/src/main/java/WayofTime/bloodmagic/ritual/Ritual.java index be545f56..7e642e6c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/Ritual.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/Ritual.java @@ -15,6 +15,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import java.util.*; import java.util.Map.Entry; +import java.util.function.BiFunction; import java.util.function.Consumer; /** @@ -185,20 +186,7 @@ public abstract class Ritual { return rangeList.get(0); } - public boolean setBlockRangeByBounds(String range, IMasterRitualStone master, BlockPos offset1, BlockPos offset2) { - AreaDescriptor descriptor = this.getBlockRange(range); - World world = master.getWorldObj(); - BlockPos masterPos = master.getBlockPos(); - DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, masterPos); - if (canBlockRangeBeModified(range, descriptor, master, offset1, offset2, holder)) { - descriptor.modifyAreaByBlockPositions(offset1, offset2); - return true; - } - - return false; - } - - protected boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) { + public boolean canBlockRangeBeModified(String range, AreaDescriptor descriptor, IMasterRitualStone master, BlockPos offset1, BlockPos offset2, DemonWillHolder holder) { List willConfig = master.getActiveWillConfig(); int maxVolume = getMaxVolumeForRange(range, willConfig, holder); int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java index 401398cc..f92b2db3 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualAnimalGrowth.java @@ -56,7 +56,7 @@ public class RitualAnimalGrowth extends Ritual { int totalGrowths = 0; BlockPos pos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity chest = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); IItemHandler itemHandler = null; if (chest != null) { @@ -83,7 +83,7 @@ public class RitualAnimalGrowth extends Ritual { boolean breedAnimals = steadfastWill >= steadfastWillDrain && itemHandler != null; boolean kamikaze = destructiveWill >= destructiveWillDrain; - AreaDescriptor growingRange = getBlockRange(GROWTH_RANGE); + AreaDescriptor growingRange = masterRitualStone.getBlockRange(GROWTH_RANGE); AxisAlignedBB axis = growingRange.getAABB(masterRitualStone.getBlockPos()); List animalList = world.getEntitiesWithinAABB(EntityAnimal.class, axis); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualArmourEvolve.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualArmourEvolve.java index 175069ea..77251191 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualArmourEvolve.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualArmourEvolve.java @@ -33,7 +33,7 @@ public class RitualArmourEvolve extends Ritual { BlockPos pos = masterRitualStone.getBlockPos(); - AreaDescriptor checkRange = getBlockRange(CHECK_RANGE); + AreaDescriptor checkRange = masterRitualStone.getBlockRange(CHECK_RANGE); List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java index f9d0d6e9..34321638 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCobblestone.java @@ -37,7 +37,7 @@ public class RitualCobblestone extends Ritual { int maxEffects = currentEssence / getRefreshCost(); int totalEffects = 0; - AreaDescriptor cobblestoneRange = getBlockRange(COBBLESTONE_RANGE); + AreaDescriptor cobblestoneRange = masterRitualStone.getBlockRange(COBBLESTONE_RANGE); if (tileEntity != null && tileEntity instanceof TileAlchemyArray) { TileAlchemyArray alchemyArray = (TileAlchemyArray) tileEntity; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCondor.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCondor.java index bc4232c0..a7f4b618 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCondor.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCondor.java @@ -24,7 +24,7 @@ public class RitualCondor extends Ritual { @Override public void performRitual(IMasterRitualStone masterRitualStone) { - AxisAlignedBB aabb = getBlockRange(FLIGHT_RANGE).getAABB(masterRitualStone.getBlockPos()).expand(-10, 0, -10); + AxisAlignedBB aabb = masterRitualStone.getBlockRange(FLIGHT_RANGE).getAABB(masterRitualStone.getBlockPos()).expand(-10, 0, -10); World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); @@ -52,7 +52,7 @@ public class RitualCondor extends Ritual { @Override public int getRefreshCost() { - return getBlockRange(FLIGHT_RANGE).getVolume() / 10000; // cost of 2 LP per second per player with default configuration + return 5; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualContainment.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualContainment.java index 51c8432e..a8224955 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualContainment.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualContainment.java @@ -29,7 +29,7 @@ public class RitualContainment extends Ritual { return; } - AreaDescriptor containmentRange = getBlockRange(CONTAINMENT_RANGE); + AreaDescriptor containmentRange = masterRitualStone.getBlockRange(CONTAINMENT_RANGE); for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, containmentRange.getAABB(masterRitualStone.getBlockPos()))) { if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || ((EntityPlayer) entity).getGameProfile().getId().equals(masterRitualStone.getOwner()))) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java index 49940c87..2d56e16f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrushing.java @@ -70,7 +70,7 @@ public class RitualCrushing extends Ritual { } BlockPos pos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); if (tile != null && Utils.getNumberOfFreeSlots(tile, EnumFacing.DOWN) < 1) { @@ -94,7 +94,7 @@ public class RitualCrushing extends Ritual { int fortune = destructiveWill > 0 ? 3 : 0; - AreaDescriptor crushingRange = getBlockRange(CRUSHING_RANGE); + AreaDescriptor crushingRange = masterRitualStone.getBlockRange(CRUSHING_RANGE); boolean hasOperated = false; double rawDrain = 0; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java index a28c8433..7382f09f 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualCrystalHarvest.java @@ -35,7 +35,7 @@ public class RitualCrystalHarvest extends Ritual { int maxEffects = 1; int totalEffects = 0; - AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE); + AreaDescriptor crystalRange = masterRitualStone.getBlockRange(CRYSTAL_RANGE); crystalRange.resetIterator(); while (crystalRange.hasNext()) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java index 636e5806..ad04ccfd 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEllipsoid.java @@ -42,7 +42,7 @@ public class RitualEllipsoid extends Ritual int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); BlockPos masterPos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); if (currentEssence < getRefreshCost()) @@ -51,7 +51,7 @@ public class RitualEllipsoid extends Ritual return; } - AreaDescriptor sphereRange = getBlockRange(SPHEROID_RANGE); + AreaDescriptor sphereRange = masterRitualStone.getBlockRange(SPHEROID_RANGE); AxisAlignedBB sphereBB = sphereRange.getAABB(masterPos); int minX = (int) (masterPos.getX() - sphereBB.minX); int maxX = (int) (sphereBB.maxX - masterPos.getX()) - 1; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java index 1294ea4f..358925b5 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualExpulsion.java @@ -48,7 +48,7 @@ public class RitualExpulsion extends Ritual { if (masterRitualStone.getWorldObj().isRemote) return; - AreaDescriptor expulsionRange = getBlockRange(EXPULSION_RANGE); + AreaDescriptor expulsionRange = masterRitualStone.getBlockRange(EXPULSION_RANGE); List whitelist = Lists.newArrayList(); BlockPos masterPos = masterRitualStone.getBlockPos(); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java index eae72593..7706e112 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFeatheredKnife.java @@ -80,7 +80,7 @@ public class RitualFeatheredKnife extends Ritual { TileEntity tile = world.getTileEntity(altarPos); - AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE); + AreaDescriptor altarRange = masterRitualStone.getBlockRange(ALTAR_RANGE); if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof IBloodAltar)) { for (BlockPos newPos : altarRange.getContainedPositions(pos)) { @@ -100,7 +100,7 @@ public class RitualFeatheredKnife extends Ritual { if (tile instanceof IBloodAltar) { IBloodAltar tileAltar = (IBloodAltar) tile; - AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE); + AreaDescriptor damageRange = masterRitualStone.getBlockRange(DAMAGE_RANGE); AxisAlignedBB range = damageRange.getAABB(pos); double destructiveDrain = 0; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java index 6e1f01e1..c116c0b5 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFelling.java @@ -46,7 +46,7 @@ public class RitualFelling extends Ritual { int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); BlockPos masterPos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); if (currentEssence < getRefreshCost()) { @@ -55,7 +55,7 @@ public class RitualFelling extends Ritual { } if (!cached || treePartsCache.isEmpty()) { - for (BlockPos blockPos : getBlockRange(FELLING_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { + for (BlockPos blockPos : masterRitualStone.getBlockRange(FELLING_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { if (!treePartsCache.contains(blockPos)) if (!world.isAirBlock(blockPos) && (world.getBlockState(blockPos).getBlock().isWood(world, blockPos) || world.getBlockState(blockPos).getBlock().isLeaves(world.getBlockState(blockPos), world, blockPos))) { treePartsCache.add(blockPos); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java index 7caf6c88..ea908c27 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualForsakenSoul.java @@ -86,7 +86,7 @@ public class RitualForsakenSoul extends Ritual { List crystalList = new ArrayList<>(); - AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE); + AreaDescriptor crystalRange = masterRitualStone.getBlockRange(CRYSTAL_RANGE); crystalRange.resetIterator(); while (crystalRange.hasNext()) { @@ -97,7 +97,7 @@ public class RitualForsakenSoul extends Ritual { } } - AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE); + AreaDescriptor damageRange = masterRitualStone.getBlockRange(DAMAGE_RANGE); AxisAlignedBB range = damageRange.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java index b803b810..0618d119 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualFullStomach.java @@ -39,14 +39,14 @@ public class RitualFullStomach extends Ritual { int maxEffects = currentEssence / getRefreshCost(); int totalEffects = 0; - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); if (tile == null || !tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) return; IItemHandler inventory = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); int lastSlot = 0; - AreaDescriptor fillingRange = getBlockRange(FILL_RANGE); + AreaDescriptor fillingRange = masterRitualStone.getBlockRange(FILL_RANGE); List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, fillingRange.getAABB(pos)); for (EntityPlayer player : playerList) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java index d8cdf397..19bd678b 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualGreenGrove.java @@ -80,7 +80,7 @@ public class RitualGreenGrove extends Ritual { double rawDrain = 0; double vengefulDrain = 0; - AreaDescriptor growingRange = getBlockRange(GROW_RANGE); + AreaDescriptor growingRange = masterRitualStone.getBlockRange(GROW_RANGE); int maxGrowthVolume = getMaxVolumeForRange(GROW_RANGE, willConfig, holder); if (!growingRange.isWithinRange(getMaxVerticalRadiusForRange(GROW_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(GROW_RANGE, willConfig, holder)) || (maxGrowthVolume != 0 && growingRange.getVolume() > maxGrowthVolume)) { @@ -126,7 +126,7 @@ public class RitualGreenGrove extends Ritual { WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.VENGEFUL, vengefulDrain, true); } - AreaDescriptor hydrateRange = getBlockRange(HYDRATE_RANGE); + AreaDescriptor hydrateRange = masterRitualStone.getBlockRange(HYDRATE_RANGE); double steadfastDrain = 0; if (steadfastWill > steadfastWillDrain) { @@ -167,7 +167,7 @@ public class RitualGreenGrove extends Ritual { double corrosiveDrain = 0; if (corrosiveWill > corrosiveWillDrain) { - AreaDescriptor leechRange = getBlockRange(LEECH_RANGE); + AreaDescriptor leechRange = masterRitualStone.getBlockRange(LEECH_RANGE); AxisAlignedBB mobArea = leechRange.getAABB(pos); List entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, mobArea); for (EntityLivingBase entityLiving : entityList) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java index fed3bb5b..78722805 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualHarvest.java @@ -52,7 +52,7 @@ public class RitualHarvest extends Ritual { int harvested = 0; - AreaDescriptor harvestArea = getBlockRange(HARVEST_RANGE); + AreaDescriptor harvestArea = masterRitualStone.getBlockRange(HARVEST_RANGE); harvestArea.resetIterator(); while (harvestArea.hasNext()) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualInterdiction.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualInterdiction.java index 861b2f32..a1a38ea0 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualInterdiction.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualInterdiction.java @@ -29,7 +29,7 @@ public class RitualInterdiction extends Ritual { return; } - AreaDescriptor interdictionRange = getBlockRange(INTERDICTION_RANGE); + AreaDescriptor interdictionRange = masterRitualStone.getBlockRange(INTERDICTION_RANGE); for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, interdictionRange.getAABB(masterRitualStone.getBlockPos()))) { if (entity instanceof EntityPlayer && (((EntityPlayer) entity).capabilities.isCreativeMode || ((EntityPlayer) entity).getGameProfile().getId().equals(masterRitualStone.getOwner()))) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java index 975f84d7..0321bd79 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualJumping.java @@ -34,7 +34,7 @@ public class RitualJumping extends Ritual { int maxEffects = currentEssence / getRefreshCost(); int totalEffects = 0; - AreaDescriptor jumpRange = getBlockRange(JUMP_RANGE); + AreaDescriptor jumpRange = masterRitualStone.getBlockRange(JUMP_RANGE); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos())); for (EntityLivingBase entity : entities) { if (totalEffects >= maxEffects) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java index e7e064a8..b247bcab 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLava.java @@ -76,7 +76,7 @@ public class RitualLava extends Ritual { double rawDrained = 0; DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos); - AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE); + AreaDescriptor lavaRange = masterRitualStone.getBlockRange(LAVA_RANGE); int maxLavaVolume = getMaxVolumeForRange(LAVA_RANGE, willConfig, holder); if (!lavaRange.isWithinRange(getMaxVerticalRadiusForRange(LAVA_RANGE, willConfig, holder), getMaxHorizontalRadiusForRange(LAVA_RANGE, willConfig, holder)) || (maxLavaVolume != 0 && lavaRange.getVolume() > maxLavaVolume)) { @@ -102,7 +102,7 @@ public class RitualLava extends Ritual { } if (rawWill > 0) { - AreaDescriptor chestRange = getBlockRange(LAVA_TANK_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(LAVA_TANK_RANGE); TileEntity tile = world.getTileEntity(chestRange.getContainedPositions(pos).get(0)); double drain = getWillCostForRawWill(rawWill); int lpCost = getLPCostForRawWill(rawWill); @@ -131,7 +131,7 @@ public class RitualLava extends Ritual { if (vengefulWill >= vengefulWillDrain) { double vengefulDrained = 0; - AreaDescriptor fuseRange = getBlockRange(FIRE_FUSE_RANGE); + AreaDescriptor fuseRange = masterRitualStone.getBlockRange(FIRE_FUSE_RANGE); AxisAlignedBB fuseArea = fuseRange.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, fuseArea); @@ -160,7 +160,7 @@ public class RitualLava extends Ritual { if (steadfastWill >= steadfastWillDrain) { double steadfastDrained = 0; - AreaDescriptor resistRange = getBlockRange(FIRE_RESIST_RANGE); + AreaDescriptor resistRange = masterRitualStone.getBlockRange(FIRE_RESIST_RANGE); int duration = getFireResistForWill(steadfastWill); @@ -186,7 +186,7 @@ public class RitualLava extends Ritual { if (timer % corrosiveRefreshTime == 0 && corrosiveWill >= corrosiveWillDrain) { double corrosiveDrained = 0; - AreaDescriptor resistRange = getBlockRange(FIRE_DAMAGE_RANGE); + AreaDescriptor resistRange = masterRitualStone.getBlockRange(FIRE_DAMAGE_RANGE); float damage = getCorrosiveDamageForWill(corrosiveWill); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLivingArmourDowngrade.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLivingArmourDowngrade.java index 35aa10ba..ea2da47c 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLivingArmourDowngrade.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualLivingArmourDowngrade.java @@ -49,7 +49,7 @@ public class RitualLivingArmourDowngrade extends Ritual { BlockPos masterPos = masterRitualStone.getBlockPos(); - AreaDescriptor downgradeRange = getBlockRange(DOWNGRADE_RANGE); + AreaDescriptor downgradeRange = masterRitualStone.getBlockRange(DOWNGRADE_RANGE); boolean isActivatorPresent = false; for (EntityPlayer player : world.getEntitiesWithinAABB(EntityPlayer.class, downgradeRange.getAABB(masterRitualStone.getBlockPos()))) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java index 1ad109a9..108b7c50 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMagnetic.java @@ -46,7 +46,7 @@ public class RitualMagnetic extends Ritual { BlockPos pos = masterRitualStone.getBlockPos(); - AreaDescriptor placementRange = getBlockRange(PLACEMENT_RANGE); + AreaDescriptor placementRange = masterRitualStone.getBlockRange(PLACEMENT_RANGE); BlockPos replacement = pos; boolean replace = false; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java index 1a5258d8..9cffa010 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualMeteor.java @@ -42,7 +42,7 @@ public class RitualMeteor extends Ritual { double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig); double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig); - AreaDescriptor itemDetectionRange = getBlockRange(ITEM_RANGE); + AreaDescriptor itemDetectionRange = masterRitualStone.getBlockRange(ITEM_RANGE); List itemList = world.getEntitiesWithinAABB(EntityItem.class, itemDetectionRange.getAABB(pos)); double radiusModifier = getRadiusModifier(rawWill); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java index 90469c94..5407b258 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPlacer.java @@ -33,7 +33,7 @@ public class RitualPlacer extends Ritual { public void performRitual(IMasterRitualStone masterRitualStone) { World world = masterRitualStone.getWorldObj(); BlockPos masterPos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tileEntity = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); @@ -43,7 +43,7 @@ public class RitualPlacer extends Ritual { return; } - AreaDescriptor areaDescriptor = getBlockRange(PLACER_RANGE); + AreaDescriptor areaDescriptor = masterRitualStone.getBlockRange(PLACER_RANGE); if (tileEntity != null) { if (tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.DOWN)) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java index c713721a..957145c0 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualPump.java @@ -56,7 +56,7 @@ public class RitualPump extends Ritual { if (fluidHandler.getTankProperties()[0].getContents() != null && fluidHandler.getTankProperties()[0].getContents().amount >= maxDrain) return; - for (BlockPos pos : getBlockRange(PUMP_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { + for (BlockPos pos : masterRitualStone.getBlockRange(PUMP_RANGE).getContainedPositions(masterRitualStone.getBlockPos())) { IBlockState state = world.getBlockState(pos); IFluidHandler blockHandler = null; if (state.getBlock() instanceof BlockLiquid) diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java index 1f431459..50db44a2 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualRegeneration.java @@ -71,10 +71,10 @@ public class RitualRegeneration extends Ritual { float absorptionRate = 1; int maxAbsorption = 20; - AreaDescriptor healArea = getBlockRange(HEAL_RANGE); + AreaDescriptor healArea = masterRitualStone.getBlockRange(HEAL_RANGE); AxisAlignedBB healRange = healArea.getAABB(pos); - AreaDescriptor damageArea = getBlockRange(VAMPIRE_RANGE); + AreaDescriptor damageArea = masterRitualStone.getBlockRange(VAMPIRE_RANGE); AxisAlignedBB damageRange = damageArea.getAABB(pos); List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, healRange); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSpeed.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSpeed.java index c40fb66a..5a1eb618 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSpeed.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSpeed.java @@ -50,7 +50,7 @@ public class RitualSpeed extends Ritual { double steadfastWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.STEADFAST, willConfig); double vengefulWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.VENGEFUL, willConfig); - AreaDescriptor speedRange = getBlockRange(SPEED_RANGE); + AreaDescriptor speedRange = masterRitualStone.getBlockRange(SPEED_RANGE); double vengefulDrain = 0; double destructiveDrain = 0; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSuppression.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSuppression.java index 5934ab9f..bbf02e04 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSuppression.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualSuppression.java @@ -31,7 +31,7 @@ public class RitualSuppression extends Ritual { } final int refresh = 100; - AreaDescriptor suppressionRange = getBlockRange(SUPPRESSION_RANGE); + AreaDescriptor suppressionRange = masterRitualStone.getBlockRange(SUPPRESSION_RANGE); for (BlockPos blockPos : suppressionRange.getContainedPositions(masterRitualStone.getBlockPos())) { IBlockState state = world.getBlockState(blockPos); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualUpgradeRemove.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualUpgradeRemove.java index ba9d5a04..c8e210ef 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualUpgradeRemove.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualUpgradeRemove.java @@ -40,7 +40,7 @@ public class RitualUpgradeRemove extends Ritual { BlockPos pos = masterRitualStone.getBlockPos(); - AreaDescriptor checkRange = getBlockRange(CHECK_RANGE); + AreaDescriptor checkRange = masterRitualStone.getBlockRange(CHECK_RANGE); List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos)); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java index c4f7d6b1..27a7b7fd 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWater.java @@ -31,7 +31,7 @@ public class RitualWater extends Ritual { int maxEffects = currentEssence / getRefreshCost(); int totalEffects = 0; - AreaDescriptor waterRange = getBlockRange(WATER_RANGE); + AreaDescriptor waterRange = masterRitualStone.getBlockRange(WATER_RANGE); for (BlockPos newPos : waterRange.getContainedPositions(masterRitualStone.getBlockPos())) { if (world.isAirBlock(newPos)) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java index 7a27fce3..302af3cd 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualWellOfSuffering.java @@ -53,7 +53,7 @@ public class RitualWellOfSuffering extends Ritual { TileEntity tile = world.getTileEntity(altarPos); - AreaDescriptor altarRange = getBlockRange(ALTAR_RANGE); + AreaDescriptor altarRange = masterRitualStone.getBlockRange(ALTAR_RANGE); if (!altarRange.isWithinArea(altarOffsetPos) || !(tile instanceof TileAltar)) { for (BlockPos newPos : altarRange.getContainedPositions(pos)) { diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java index 9935e162..1690ac88 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualZephyr.java @@ -32,7 +32,7 @@ public class RitualZephyr extends Ritual { World world = masterRitualStone.getWorldObj(); int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence(); BlockPos masterPos = masterRitualStone.getBlockPos(); - AreaDescriptor chestRange = getBlockRange(CHEST_RANGE); + AreaDescriptor chestRange = masterRitualStone.getBlockRange(CHEST_RANGE); TileEntity tileInventory = world.getTileEntity(chestRange.getContainedPositions(masterPos).get(0)); if (!masterRitualStone.getWorldObj().isRemote && tileInventory != null) { if (currentEssence < getRefreshCost()) { @@ -40,7 +40,7 @@ public class RitualZephyr extends Ritual { return; } - AreaDescriptor zephyrRange = getBlockRange(ZEPHYR_RANGE); + AreaDescriptor zephyrRange = masterRitualStone.getBlockRange(ZEPHYR_RANGE); List itemList = world.getEntitiesWithinAABB(EntityItem.class, zephyrRange.getAABB(masterRitualStone.getBlockPos())); int count = 0; diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index 510e8932..1383ae47 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -2,7 +2,10 @@ package WayofTime.bloodmagic.tile; import WayofTime.bloodmagic.BloodMagic; import WayofTime.bloodmagic.core.data.Binding; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import WayofTime.bloodmagic.iface.IBindable; +import WayofTime.bloodmagic.ritual.AreaDescriptor; +import WayofTime.bloodmagic.soul.DemonWillHolder; import WayofTime.bloodmagic.util.Constants; import WayofTime.bloodmagic.event.RitualEvent; import WayofTime.bloodmagic.ritual.IMasterRitualStone; @@ -25,9 +28,8 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import javax.annotation.Nullable; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; +import java.awt.geom.Area; +import java.util.*; public class TileMasterRitualStone extends TileTicking implements IMasterRitualStone { private UUID owner; @@ -40,6 +42,7 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS private EnumFacing direction = EnumFacing.NORTH; private boolean inverted; private List currentActiveWillConfig = new ArrayList<>(); + protected final Map modableRangeMap = new HashMap<>(); @Override public void onUpdate() { @@ -157,6 +160,9 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS this.cachedNetwork = network; this.currentRitual = ritual; + if(!checkBlockRanges(ritual.getModableRangeMap())) + addBlockRanges(ritual.getModableRangeMap()); + notifyUpdate(); return true; } @@ -298,22 +304,14 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS public void setActiveWillConfig(EntityPlayer player, List typeList) { this.currentActiveWillConfig = typeList; } - + @Override public boolean setBlockRangeByBounds(EntityPlayer player, String range, BlockPos offset1, BlockPos offset2) { - if (this.currentRitual != null) { - boolean allowed = this.currentRitual.setBlockRangeByBounds(range, this, offset1, offset2); - if (player != null && !allowed) { - ChatUtil.sendNoSpam(player, this.currentRitual.getErrorForBlockRangeOnFail(player, range, this, offset1, offset2)); - } else { - ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.success")); - } - - return allowed; - } - - if (player != null) { - ChatUtil.sendNoSpam(player, new TextComponentTranslation("ritual.bloodmagic.blockRange.inactive")); + AreaDescriptor descriptor = this.getBlockRange(range); + DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, getBlockPos()); + if (this.currentRitual.canBlockRangeBeModified(range, descriptor, this, offset1, offset2, holder)) { + descriptor.modifyAreaByBlockPositions(offset1, offset2); + return true; } return false; @@ -408,4 +406,36 @@ public class TileMasterRitualStone extends TileTicking implements IMasterRitualS public void setCurrentActiveWillConfig(List currentActiveWillConfig) { this.currentActiveWillConfig = currentActiveWillConfig; } + + /** + * Used to grab the range of a ritual for a given effect. + * + * @param range - Range that needs to be pulled. + * @return - + */ + public AreaDescriptor getBlockRange(String range) { + if (modableRangeMap.containsKey(range)) { + return modableRangeMap.get(range); + } + + return null; + } + + public void addBlockRange(String range, AreaDescriptor defaultRange) { + modableRangeMap.put(range, defaultRange); + } + + public void addBlockRanges(Map blockRanges){ + for (Map.Entry entry : blockRanges.entrySet()) { + modableRangeMap.put(entry.getKey(), entry.getValue()); + } + } + + public boolean checkBlockRanges(Map blockRanges){ + for (Map.Entry entry : blockRanges.entrySet()) { + if (modableRangeMap.get(entry.getKey()) == null) + return false; + } + return true; + } }