Skip to content

Instantly share code, notes, and snippets.

@DenWav
Created February 8, 2017 17:59
Show Gist options
  • Save DenWav/6e78f34e87330c31b270aeaee7265d31 to your computer and use it in GitHub Desktop.
Save DenWav/6e78f34e87330c31b270aeaee7265d31 to your computer and use it in GitHub Desktop.
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
HttpUtil.DOWNLOADER_EXECUTOR.submit(new Runnable()
{
public void run()
{
Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);
for (int i = glassPos.getY() - 1; i >= 0; --i)
{
final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());
if (!chunk.canSeeSky(blockpos))
{
break;
}
IBlockState iblockstate = worldIn.getBlockState(blockpos);
if (iblockstate.getBlock() == Blocks.BEACON)
{
((WorldServer)worldIn).addScheduledTask(new Runnable()
{
public void run()
{
TileEntity tileentity = worldIn.getTileEntity(blockpos);
if (tileentity instanceof TileEntityBeacon)
{
((TileEntityBeacon)tileentity).updateBeacon();
worldIn.addBlockEvent(blockpos, Blocks.BEACON, 1, 0);
}
}
});
}
}
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment