Fixed redstone neighbor checks. Now works exactly as the Minecraft check does, simply without loading chunks.

This commit is contained in:
Aidan C. Brady 2015-03-26 09:30:55 -04:00
parent d88f8a4606
commit 8344ed25f7

View file

@ -82,7 +82,6 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import buildcraft.api.tools.IToolWrench;
import cofh.api.item.IToolHammer;
import cpw.mods.fml.common.ModAPIManager;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameData;
@ -658,24 +657,12 @@ public final class MekanismUtils
}
/**
* A better "isBlockIndirectlyGettingPowered()" that doesn't load chunks.
* Better version of the World.isBlockIndirectlyGettingPowered() method that doesn't load chunks.
* @param world - the world to perform the check in
* @param coord - the coordinate of the block performing the check
* @return if the block is indirectly getting powered by LOADED chunks
*/
public static boolean isGettingPowered(World world, Coord4D coord)
{
return isGettingPowered(world, coord, true);
}
/**
* Extension of preceding isGettingPowered() method, used to define expansions of the check.
* @param world - the world to perform the check in
* @param coord - the coordinate of the block performing the check
* @param expand - whether or not the check should be recursively called on the surrounding coordinates
* @return if the block is indirectly getting powered by LOADED chunks
*/
public static boolean isGettingPowered(World world, Coord4D coord, boolean expand)
{
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
@ -683,11 +670,38 @@ public final class MekanismUtils
if(sideCoord.exists(world) && sideCoord.getFromSide(side).exists(world))
{
if(world.isBlockProvidingPowerTo(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.getOpposite().ordinal()) > 0)
Block block = sideCoord.getBlock(world);
boolean weakPower = block.shouldCheckWeakPower(world, coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal());
if(weakPower && isDirectlyGettingPowered(world, sideCoord))
{
return true;
}
else if(expand && isGettingPowered(world, sideCoord, false))
else if(!weakPower && block.isProvidingWeakPower(world, sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.ordinal()) > 0)
{
return true;
}
}
}
return false;
}
/**
* Checks if a block is directly getting powered by any of its neighbors without loading any chunks.
* @param world - the world to perform the check in
* @param coord - the Coord4D of the block to check
* @return if the block is directly getting powered
*/
public static boolean isDirectlyGettingPowered(World world, Coord4D coord)
{
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
Coord4D sideCoord = coord.getFromSide(side);
if(sideCoord.exists(world))
{
if(world.isBlockProvidingPowerTo(coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal()) > 0)
{
return true;
}