diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java index 7289c491..2d96a753 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/omega/OmegaStructureHandler.java @@ -1,6 +1,9 @@ package WayofTime.alchemicalWizardry.common.omega; 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 WayofTime.alchemicalWizardry.ModBlocks; import WayofTime.alchemicalWizardry.api.Int3; @@ -14,7 +17,7 @@ public class OmegaStructureHandler 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; @@ -46,107 +49,33 @@ public class OmegaStructureHandler { if (boolList[i][j][k] == 1) { - if (i - 1 >= 0 && !(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 == 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)) - { - 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 == 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)) - { - 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 == 0) - { - return emptyParam; - } - boolList[i][j][k - 1] = 1; - isReady = false; - }else - { - boolList[i][j][k - 1] = -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; - } - } + BlockPos position = pos.add(i - range, j - range, k - range); + + for(EnumFacing face : EnumFacing.VALUES) + { + int iP = i + face.getFrontOffsetX(); + int jP = j + face.getFrontOffsetY(); + int kP = k + face.getFrontOffsetZ(); + + 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)) + { + BlockPos newPos = position.add(face.getDirectionVec()); + IBlockState state = world.getBlockState(newPos); + Block block = state.getBlock(); + if (world.isAirBlock(newPos) || block == ModBlocks.blockSpectralContainer) + { + if(iP == 0 && iP == 2 * range && jP == 0 && jP == 2 * range && kP == 0 && kP == 2 * range) + { + return emptyParam; + } + boolList[iP][jP][kP] = 1; + isReady = false; + }else + { + boolList[iP][jP][kP] = -1; + } + } + } } } } diff --git a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java index 47b6bc16..d2460140 100644 --- a/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java +++ b/src/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectOmegaTest.java @@ -11,6 +11,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; +import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import WayofTime.alchemicalWizardry.api.Int3; import WayofTime.alchemicalWizardry.api.alchemy.energy.IReagentHandler; @@ -48,7 +49,7 @@ public class RitualEffectOmegaTest extends RitualEffect 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 enchantability = param.enchantability; int enchantmentLevel = param.enchantmentLevel; @@ -62,7 +63,7 @@ public class RitualEffectOmegaTest extends RitualEffect double range = 0.5; - List playerList = SpellHelper.getPlayersInRange(world, x + 0.5, y + 1.5, z + 0.5, range, range); + List playerList = SpellHelper.getPlayersInRange(world, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5, range, range); Reagent reagent = null; @@ -70,11 +71,12 @@ public class RitualEffectOmegaTest extends RitualEffect for(int i=0; i<4; 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) { IReagentHandler container = (IReagentHandler)tile; - ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(ForgeDirection.UP); + ReagentContainerInfo[] containerInfoArray = container.getContainerInfo(EnumFacing.UP); if(containerInfoArray == null) { continue; @@ -121,7 +123,7 @@ public class RitualEffectOmegaTest extends RitualEffect for(EntityPlayer player : playerList) { 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.setPlayerMaxReagentAmount(player, tickDuration); @@ -139,16 +141,17 @@ public class RitualEffectOmegaTest extends RitualEffect break; } 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) { 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) { drainLeft -= drained.amount; - world.markBlockForUpdate(x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord); - world.addWeatherEffect(new EntityLightningBolt(world, x + jarLoc.xCoord, y + jarLoc.yCoord, z + jarLoc.zCoord)); + world.markBlockForUpdate(newPos); + world.addWeatherEffect(new EntityLightningBolt(world, newPos.getX(), newPos.getY(), newPos.getZ())); } } }