Fixed RitualReader (RitualTinkerer) area setting ability. (#1505)
* Fixed RitualReader (RitualTinkerer) area setting ability. Signed-off-by: tobias <angryaeon@icloud.com> * Update TileMasterRitualStone.java * Interface tidied up
This commit is contained in:
parent
399c2723d3
commit
415d3f1f42
|
@ -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<String, AreaDescriptor> 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<String, AreaDescriptor> blockRanges);
|
||||
|
||||
void addBlockRange(String range, AreaDescriptor defaultRange);
|
||||
}
|
||||
|
|
|
@ -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<EnumDemonWillType> willConfig = master.getActiveWillConfig();
|
||||
int maxVolume = getMaxVolumeForRange(range, willConfig, holder);
|
||||
int maxVertical = getMaxVerticalRadiusForRange(range, willConfig, holder);
|
||||
|
|
|
@ -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<EntityAnimal> animalList = world.getEntitiesWithinAABB(EntityAnimal.class, axis);
|
||||
|
||||
|
|
|
@ -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<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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())))
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<UUID> whitelist = Lists.newArrayList();
|
||||
BlockPos masterPos = masterRitualStone.getBlockPos();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -86,7 +86,7 @@ public class RitualForsakenSoul extends Ritual {
|
|||
|
||||
List<TileDemonCrystal> 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<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range);
|
||||
|
|
|
@ -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<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, fillingRange.getAABB(pos));
|
||||
|
||||
for (EntityPlayer player : playerList) {
|
||||
|
|
|
@ -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<EntityLivingBase> entityList = world.getEntitiesWithinAABB(EntityLivingBase.class, mobArea);
|
||||
for (EntityLivingBase entityLiving : entityList) {
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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())))
|
||||
|
|
|
@ -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<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, jumpRange.getAABB(masterRitualStone.getBlockPos()));
|
||||
for (EntityLivingBase entity : entities) {
|
||||
if (totalEffects >= maxEffects) {
|
||||
|
|
|
@ -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<EntityLivingBase> 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);
|
||||
|
||||
|
|
|
@ -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()))) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<EntityItem> itemList = world.getEntitiesWithinAABB(EntityItem.class, itemDetectionRange.getAABB(pos));
|
||||
|
||||
double radiusModifier = getRadiusModifier(rawWill);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<EntityLivingBase> entities = world.getEntitiesWithinAABB(EntityLivingBase.class, healRange);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<EntityPlayer> playerList = world.getEntitiesWithinAABB(EntityPlayer.class, checkRange.getAABB(pos));
|
||||
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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<EntityItem> itemList = world.getEntitiesWithinAABB(EntityItem.class, zephyrRange.getAABB(masterRitualStone.getBlockPos()));
|
||||
int count = 0;
|
||||
|
|
|
@ -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<EnumDemonWillType> currentActiveWillConfig = new ArrayList<>();
|
||||
protected final Map<String, AreaDescriptor> 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<EnumDemonWillType> 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<EnumDemonWillType> 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<String, AreaDescriptor> blockRanges){
|
||||
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet()) {
|
||||
modableRangeMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkBlockRanges(Map<String, AreaDescriptor> blockRanges){
|
||||
for (Map.Entry<String, AreaDescriptor> entry : blockRanges.entrySet()) {
|
||||
if (modableRangeMap.get(entry.getKey()) == null)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue