Finished the rituals

This commit is contained in:
WayofTime 2015-07-29 14:37:45 -04:00
parent 86b753d098
commit 1aa343624e
2 changed files with 43 additions and 111 deletions

View file

@ -1,6 +1,9 @@
package WayofTime.alchemicalWizardry.common.omega; package WayofTime.alchemicalWizardry.common.omega;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.ModBlocks; import WayofTime.alchemicalWizardry.ModBlocks;
import WayofTime.alchemicalWizardry.api.Int3; import WayofTime.alchemicalWizardry.api.Int3;
@ -14,7 +17,7 @@ public class OmegaStructureHandler
return true; return true;
} }
public static OmegaStructureParameters getStructureStabilityFactor(World world, int x, int y, int z, int expLim, Int3 offset) public static OmegaStructureParameters getStructureStabilityFactor(World world, BlockPos pos, int expLim, Int3 offset)
{ {
int range = expLim; int range = expLim;
@ -46,106 +49,32 @@ public class OmegaStructureHandler
{ {
if (boolList[i][j][k] == 1) if (boolList[i][j][k] == 1)
{ {
if (i - 1 >= 0 && !(boolList[i - 1][j][k] == 1 || boolList[i - 1][j][k] == -1)) BlockPos position = pos.add(i - range, j - range, k - range);
{
Block block = world.getBlock(x - range + i - 1, y - range + j, z - range + k);
if (world.isAirBlock(x - range + i - 1, y - range + j, z - range + k) || block == ModBlocks.blockSpectralContainer)
{
if(i - 1 == 0) //One of the found air blocks is at the range boundary, and thus the container is incomplete
{
return emptyParam;
}
boolList[i - 1][j][k] = 1;
isReady = false;
}else
{
boolList[i - 1][j][k] = -1;
}
}
if (j - 1 >= 0 && !(boolList[i][j - 1][k] == 1 || boolList[i][j - 1][k] == -1)) for(EnumFacing face : EnumFacing.VALUES)
{ {
Block block = world.getBlock(x - range + i, y - range + j - 1, z - range + k); int iP = i + face.getFrontOffsetX();
if (world.isAirBlock(x - range + i, y - range + j - 1, z - range + k) || block == ModBlocks.blockSpectralContainer) int jP = j + face.getFrontOffsetY();
{ int kP = k + face.getFrontOffsetZ();
if(j - 1 == 0)
{
return emptyParam;
}
boolList[i][j - 1][k] = 1;
isReady = false;
}else
{
boolList[i][j - 1][k] = -1;
}
}
if (k - 1 >= 0 && !(boolList[i][j][k - 1] == 1 || boolList[i][j][k - 1] == -1)) if(iP >= 0 && iP <= 2 * range && jP >= 0 && jP <= 2 * range && kP >= 0 && kP <= 2 * range && !(boolList[iP][jP][kP] == 1 || boolList[iP][jP][kP] == -1))
{ {
Block block = world.getBlock(x - range + i, y - range + j, z - range + k - 1); BlockPos newPos = position.add(face.getDirectionVec());
if (world.isAirBlock(x - range + i, y - range + j, z - range + k - 1) || block == ModBlocks.blockSpectralContainer) IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (world.isAirBlock(newPos) || block == ModBlocks.blockSpectralContainer)
{ {
if(k - 1 == 0) if(iP == 0 && iP == 2 * range && jP == 0 && jP == 2 * range && kP == 0 && kP == 2 * range)
{ {
return emptyParam; return emptyParam;
} }
boolList[i][j][k - 1] = 1; boolList[iP][jP][kP] = 1;
isReady = false; isReady = false;
}else }else
{ {
boolList[i][j][k - 1] = -1; boolList[iP][jP][kP] = -1;
} }
} }
if (i + 1 <= 2 * range && !(boolList[i + 1][j][k] == 1 || boolList[i + 1][j][k] == -1))
{
Block block = world.getBlock(x - range + i + 1, y - range + j, z - range + k);
if (world.isAirBlock(x - range + i + 1, y - range + j, z - range + k) || block == ModBlocks.blockSpectralContainer)
{
if(i + 1 == range * 2)
{
return emptyParam;
}
boolList[i + 1][j][k] = 1;
isReady = false;
}else
{
boolList[i + 1][j][k] = -1;
}
}
if (j + 1 <= 2 * range && !(boolList[i][j + 1][k] == 1 || boolList[i][j + 1][k] == -1))
{
Block block = world.getBlock(x - range + i, y - range + j + 1, z - range + k);
if (world.isAirBlock(x - range + i, y - range + j + 1, z - range + k) || block == ModBlocks.blockSpectralContainer)
{
if(j + 1 == range * 2)
{
return emptyParam;
}
boolList[i][j + 1][k] = 1;
isReady = false;
}else
{
boolList[i][j + 1][k] = -1;
}
}
if (k + 1 <= 2 * range && !(boolList[i][j][k + 1] == 1 || boolList[i][j][k + 1] == -1))
{
Block block = world.getBlock(x - range + i, y - range + j, z - range + k + 1);
if (world.isAirBlock(x - range + i, y - range + j, z - range + k + 1) || block == ModBlocks.blockSpectralContainer)
{
if(k + 1 == range * 2)
{
return emptyParam;
}
boolList[i][j][k + 1] = 1;
isReady = false;
}else
{
boolList[i][j][k + 1] = -1;
}
} }
} }
} }

View file

@ -11,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World; import net.minecraft.world.World;
import WayofTime.alchemicalWizardry.api.Int3; import WayofTime.alchemicalWizardry.api.Int3;
import WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler; import WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler;
@ -48,7 +49,7 @@ public class RitualEffectOmegaTest extends RitualEffect
return; return;
} }
OmegaStructureParameters param = OmegaStructureHandler.getStructureStabilityFactor(world, x, y, z, 5, new Int3(0,1,0)); OmegaStructureParameters param = OmegaStructureHandler.getStructureStabilityFactor(world, pos, 5, new Int3(0,1,0));
int stab = param.stability; int stab = param.stability;
int enchantability = param.enchantability; int enchantability = param.enchantability;
int enchantmentLevel = param.enchantmentLevel; int enchantmentLevel = param.enchantmentLevel;
@ -62,7 +63,7 @@ public class RitualEffectOmegaTest extends RitualEffect
double range = 0.5; double range = 0.5;
List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 1.5, z + 0.5, range, range); List<EntityPlayer> playerList = SpellHelper.getPlayersInRange(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, range, range);
Reagent reagent = null; Reagent reagent = null;
@ -70,11 +71,12 @@ public class RitualEffectOmegaTest extends RitualEffect
for(int i=0; i<4; i++) for(int i=0; i<4; i++)
{ {
Int3 jarLoc = this.getJarLocation(i); Int3 jarLoc = this.getJarLocation(i);
TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); BlockPos newPos = pos.add(jarLoc.xCoord, jarLoc.yCoord, jarLoc.zCoord);
TileEntity tile = world.getTileEntity(newPos);
if(tile instanceof IReagentHandler) if(tile instanceof IReagentHandler)
{ {
IReagentHandler container = (IReagentHandler)tile; IReagentHandler container = (IReagentHandler)tile;
ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP); ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(EnumFacing.UP);
if(containerInfoArray == null) if(containerInfoArray == null)
{ {
continue; continue;
@ -121,7 +123,7 @@ public class RitualEffectOmegaTest extends RitualEffect
for(EntityPlayer player : playerList) for(EntityPlayer player : playerList)
{ {
OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent); OmegaParadigm waterParadigm = OmegaRegistry.getParadigmForReagent(reagent);
if(waterParadigm != null && waterParadigm.convertPlayerArmour(player, x, y, z, stab, affinity, enchantability, enchantmentLevel)) if(waterParadigm != null && waterParadigm.convertPlayerArmour(player, pos.getX(), pos.getY(), pos.getZ(), stab, affinity, enchantability, enchantmentLevel))
{ {
APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration); APISpellHelper.setPlayerCurrentReagentAmount(player, tickDuration);
APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration); APISpellHelper.setPlayerMaxReagentAmount(player, tickDuration);
@ -139,16 +141,17 @@ public class RitualEffectOmegaTest extends RitualEffect
break; break;
} }
Int3 jarLoc = this.getJarLocation(i); Int3 jarLoc = this.getJarLocation(i);
TileEntity tile = world.getTileEntity(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); BlockPos newPos = pos.add(jarLoc.xCoord, jarLoc.yCoord, jarLoc.zCoord);
TileEntity tile = world.getTileEntity(newPos);
if(tile instanceof IReagentHandler) if(tile instanceof IReagentHandler)
{ {
IReagentHandler container = (IReagentHandler)tile; IReagentHandler container = (IReagentHandler)tile;
ReagentStack drained = container.drain(ForgeDirection.UP, new ReagentStack(reagent, drainLeft), true); ReagentStack drained = container.drain(EnumFacing.UP, new ReagentStack(reagent, drainLeft), true);
if(drained != null) if(drained != null)
{ {
drainLeft -= drained.amount; drainLeft -= drained.amount;
world.markBlockForUpdate(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); world.markBlockForUpdate(newPos);
world.addWeatherEffect(new EntityLightningBolt(world, x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord)); world.addWeatherEffect(new EntityLightningBolt(world, newPos.getX(), newPos.getY(), newPos.getZ()));
} }
} }
} }