Merge pull request #511 from thatsIch/b-361-assembler

Try to catch assemblers being build too high or low for ChunkCache
This commit is contained in:
thatsIch 2014-12-02 22:38:39 +01:00
commit 9fae9d1ec0

View file

@ -18,6 +18,7 @@
package appeng.client.render.blocks; package appeng.client.render.blocks;
import java.util.EnumSet; import java.util.EnumSet;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
@ -28,6 +29,7 @@ import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.IItemRenderer.ItemRenderType; import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.networking.IGridHost; import appeng.api.networking.IGridHost;
import appeng.api.parts.IBoxProvider; import appeng.api.parts.IBoxProvider;
import appeng.api.parts.IPart; import appeng.api.parts.IPart;
@ -48,21 +50,25 @@ import appeng.util.Platform;
public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvider public class RenderBlockAssembler extends BaseBlockRender implements IBoxProvider
{ {
IIcon getConnectedCable(IBlockAccess world, int x, int y, int z, ForgeDirection d, boolean covered) IIcon getConnectedCable(IBlockAccess world, int x, int y, int z, ForgeDirection side, boolean covered)
{ {
TileEntity ne = world.getTileEntity( x + d.offsetX, y + d.offsetY, z + d.offsetZ ); final int tileYPos = y + side.offsetY;
if ( ne instanceof IGridHost && ne instanceof IPartHost ) if ( -1 < tileYPos && tileYPos < 256 )
{ {
IPartHost ph = (IPartHost) ne; TileEntity ne = world.getTileEntity( x + side.offsetX, tileYPos, z + side.offsetZ );
IPart pcx = ph.getPart( ForgeDirection.UNKNOWN ); if ( ne instanceof IGridHost && ne instanceof IPartHost )
if ( pcx instanceof PartCable )
{ {
PartCable pc = (PartCable) pcx; IPartHost ph = (IPartHost) ne;
if ( pc.isConnected( d.getOpposite() ) ) IPart pcx = ph.getPart( ForgeDirection.UNKNOWN );
if ( pcx instanceof PartCable )
{ {
if ( covered ) PartCable pc = (PartCable) pcx;
return pc.getCoveredTexture( pc.getCableColor() ); if ( pc.isConnected( side.getOpposite() ) )
return pc.getGlassTexture( pc.getCableColor() ); {
if ( covered )
return pc.getCoveredTexture( pc.getCableColor() );
return pc.getGlassTexture( pc.getCableColor() );
}
} }
} }
} }